From f295e6e044b0fa78742a9676901fd98c0230cb56 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mat=C3=A9=20Strysewske?= Date: Fri, 4 Nov 2022 09:13:43 +0100 Subject: [PATCH 1/5] [GITFLOW]updating poms for 1.76.3 branch with snapshot versions --- sormas-api/pom.xml | 2 +- sormas-app/pom.xml | 2 +- sormas-backend/pom.xml | 2 +- sormas-base/dependencies/serverlibs.pom | 2 +- sormas-base/pom.xml | 2 +- sormas-cargoserver/pom.xml | 2 +- sormas-ear/pom.xml | 2 +- sormas-keycloak-service-provider/pom.xml | 2 +- sormas-rest/pom.xml | 2 +- sormas-ui/pom.xml | 2 +- sormas-widgetset/pom.xml | 2 +- 11 files changed, 11 insertions(+), 11 deletions(-) diff --git a/sormas-api/pom.xml b/sormas-api/pom.xml index d7788c5d309..aae10be5ef9 100644 --- a/sormas-api/pom.xml +++ b/sormas-api/pom.xml @@ -2,7 +2,7 @@ de.symeda.sormas sormas-base - 1.76.2 + 1.76.3-SNAPSHOT ../sormas-base 4.0.0 diff --git a/sormas-app/pom.xml b/sormas-app/pom.xml index 04c93900427..0a3aacdf10d 100644 --- a/sormas-app/pom.xml +++ b/sormas-app/pom.xml @@ -3,7 +3,7 @@ sormas-base de.symeda.sormas - 1.76.2 + 1.76.3-SNAPSHOT ../sormas-base 4.0.0 diff --git a/sormas-backend/pom.xml b/sormas-backend/pom.xml index 26a7a434cc9..d59af33cc0d 100644 --- a/sormas-backend/pom.xml +++ b/sormas-backend/pom.xml @@ -3,7 +3,7 @@ sormas-base de.symeda.sormas - 1.76.2 + 1.76.3-SNAPSHOT ../sormas-base 4.0.0 diff --git a/sormas-base/dependencies/serverlibs.pom b/sormas-base/dependencies/serverlibs.pom index b2cc112f203..effab045ff8 100644 --- a/sormas-base/dependencies/serverlibs.pom +++ b/sormas-base/dependencies/serverlibs.pom @@ -8,7 +8,7 @@ sormas-base de.symeda.sormas - 1.76.2 + 1.76.3-SNAPSHOT ../ diff --git a/sormas-base/pom.xml b/sormas-base/pom.xml index 3b402e28d34..5b67d63a607 100644 --- a/sormas-base/pom.xml +++ b/sormas-base/pom.xml @@ -5,7 +5,7 @@ de.symeda.sormas sormas-base pom - 1.76.2 + 1.76.3-SNAPSHOT 1.8 diff --git a/sormas-cargoserver/pom.xml b/sormas-cargoserver/pom.xml index 101f5703873..bc4b0267a98 100644 --- a/sormas-cargoserver/pom.xml +++ b/sormas-cargoserver/pom.xml @@ -3,7 +3,7 @@ de.symeda.sormas sormas-base - 1.76.2 + 1.76.3-SNAPSHOT ../sormas-base diff --git a/sormas-ear/pom.xml b/sormas-ear/pom.xml index 2a23ba5bb7d..9cea87ff836 100644 --- a/sormas-ear/pom.xml +++ b/sormas-ear/pom.xml @@ -3,7 +3,7 @@ de.symeda.sormas sormas-base - 1.76.2 + 1.76.3-SNAPSHOT ../sormas-base diff --git a/sormas-keycloak-service-provider/pom.xml b/sormas-keycloak-service-provider/pom.xml index 1ed7b1c53db..2dc059b47a5 100644 --- a/sormas-keycloak-service-provider/pom.xml +++ b/sormas-keycloak-service-provider/pom.xml @@ -3,7 +3,7 @@ sormas-base de.symeda.sormas - 1.76.2 + 1.76.3-SNAPSHOT ../sormas-base 4.0.0 diff --git a/sormas-rest/pom.xml b/sormas-rest/pom.xml index 54dd80adcda..90075e628f6 100644 --- a/sormas-rest/pom.xml +++ b/sormas-rest/pom.xml @@ -3,7 +3,7 @@ de.symeda.sormas sormas-base - 1.76.2 + 1.76.3-SNAPSHOT ../sormas-base diff --git a/sormas-ui/pom.xml b/sormas-ui/pom.xml index 3db8813561d..dabc7e2e2e4 100644 --- a/sormas-ui/pom.xml +++ b/sormas-ui/pom.xml @@ -3,7 +3,7 @@ sormas-base de.symeda.sormas - 1.76.2 + 1.76.3-SNAPSHOT ../sormas-base 4.0.0 diff --git a/sormas-widgetset/pom.xml b/sormas-widgetset/pom.xml index 576662d6b6b..b207ee7031d 100644 --- a/sormas-widgetset/pom.xml +++ b/sormas-widgetset/pom.xml @@ -3,7 +3,7 @@ sormas-base de.symeda.sormas - 1.76.2 + 1.76.3-SNAPSHOT ../sormas-base 4.0.0 From 4a9cf28975146d4877db6d008d7c795bf4483c90 Mon Sep 17 00:00:00 2001 From: Jonas Cirotzki Date: Mon, 7 Nov 2022 17:17:23 +0100 Subject: [PATCH 2/5] [#10835] make sure that count computes correct amount of items in the index list --- .../share/outgoing/ShareRequestInfoFacadeEjb.java | 4 +++- .../src/main/java/de/symeda/sormas/ui/utils/AbstractView.java | 4 ---- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/sormas-backend/src/main/java/de/symeda/sormas/backend/sormastosormas/share/outgoing/ShareRequestInfoFacadeEjb.java b/sormas-backend/src/main/java/de/symeda/sormas/backend/sormastosormas/share/outgoing/ShareRequestInfoFacadeEjb.java index 5a5bac37169..a0194cf3490 100644 --- a/sormas-backend/src/main/java/de/symeda/sormas/backend/sormastosormas/share/outgoing/ShareRequestInfoFacadeEjb.java +++ b/sormas-backend/src/main/java/de/symeda/sormas/backend/sormastosormas/share/outgoing/ShareRequestInfoFacadeEjb.java @@ -176,8 +176,10 @@ public long count(ShareRequestCriteria criteria) { CriteriaBuilder cb = em.getCriteriaBuilder(); CriteriaQuery cq = cb.createQuery(Long.class); Root requestRoot = cq.from(ShareRequestInfo.class); + requestRoot.join(ShareRequestInfo.SHARES); Predicate filter = null; + if (criteria != null) { filter = shareRequestInfoService.buildCriteriaFilter(criteria, cb, requestRoot); } @@ -186,7 +188,7 @@ public long count(ShareRequestCriteria criteria) { cq.where(filter); } - cq.select(cb.count(requestRoot)); + cq.select(cb.countDistinct(requestRoot)); return em.createQuery(cq).getSingleResult(); } diff --git a/sormas-ui/src/main/java/de/symeda/sormas/ui/utils/AbstractView.java b/sormas-ui/src/main/java/de/symeda/sormas/ui/utils/AbstractView.java index 79d07efdf18..ff501aa3f3e 100644 --- a/sormas-ui/src/main/java/de/symeda/sormas/ui/utils/AbstractView.java +++ b/sormas-ui/src/main/java/de/symeda/sormas/ui/utils/AbstractView.java @@ -24,7 +24,6 @@ import com.vaadin.navigator.Navigator; import com.vaadin.navigator.View; -import com.vaadin.navigator.ViewChangeListener.ViewChangeEvent; import com.vaadin.server.FileDownloader; import com.vaadin.server.Resource; import com.vaadin.server.StreamResource; @@ -111,9 +110,6 @@ public void addComponent(Component c) { setExpandRatio(c, 1); } - @Override - public abstract void enter(ViewChangeEvent event); - public Label getViewTitleLabel() { return viewTitleLabel; } From 4fcf4bdcf86a994b97630a3b82e7fc8f472662ad Mon Sep 17 00:00:00 2001 From: Carina Paul <47103965+carina29@users.noreply.github.com> Date: Tue, 8 Nov 2022 14:49:33 +0200 Subject: [PATCH 3/5] =?UTF-8?q?#10830=20-=20Do=20not=20send=20the=20cases?= =?UTF-8?q?=20to=20the=20reporting=20tool=20if=20dontShareWith=E2=80=A6=20?= =?UTF-8?q?(#10850)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * #10830 - Do not send the cases to the reporting tool if dontShareWithReportingTool is true * #10830 - adjust testShareCase() unit test --- .../sormas/backend/caze/CaseService.java | 29 +++++++--- .../backend/caze/CaseFacadeEjbTest.java | 43 ++++++++++++-- .../sormas/backend/caze/CaseServiceTest.java | 57 +++++++++++++------ .../CoreEntityDeletionServiceTest.java | 25 +++++++- .../SormasToSormasCaseFacadeEjbTest.java | 26 ++++++++- 5 files changed, 150 insertions(+), 30 deletions(-) diff --git a/sormas-backend/src/main/java/de/symeda/sormas/backend/caze/CaseService.java b/sormas-backend/src/main/java/de/symeda/sormas/backend/caze/CaseService.java index 84fff640192..4a6be6bcf37 100644 --- a/sormas-backend/src/main/java/de/symeda/sormas/backend/caze/CaseService.java +++ b/sormas-backend/src/main/java/de/symeda/sormas/backend/caze/CaseService.java @@ -58,6 +58,7 @@ import de.symeda.sormas.api.RequestContextHolder; import de.symeda.sormas.api.caze.CaseClassification; import de.symeda.sormas.api.caze.CaseCriteria; +import de.symeda.sormas.api.caze.CaseDataDto; import de.symeda.sormas.api.caze.CaseIndexDto; import de.symeda.sormas.api.caze.CaseListEntryDto; import de.symeda.sormas.api.caze.CaseLogic; @@ -1083,18 +1084,28 @@ public void dearchive(List entityUuids, String dearchiveReason) { public void setArchiveInExternalSurveillanceToolForEntities(List entityUuids, boolean archived) { if (externalSurveillanceToolGatewayFacade.isFeatureEnabled()) { - List sharedCaseUuids = externalShareInfoService.getSharedCaseUuidsWithoutDeletedStatus(entityUuids); - - if (!sharedCaseUuids.isEmpty()) { - try { - externalSurveillanceToolGatewayFacade.sendCases(sharedCaseUuids, archived); - } catch (ExternalSurveillanceToolException e) { - throw new ExternalSurveillanceToolRuntimeException(e.getMessage(), e.getErrorCode()); + List uuidsAllowedToBeShared = getEntityUuidsAllowedToBeShared(entityUuids); + if (!uuidsAllowedToBeShared.isEmpty()) { + List sharedCaseUuids = externalShareInfoService.getSharedCaseUuidsWithoutDeletedStatus(uuidsAllowedToBeShared); + + if (!sharedCaseUuids.isEmpty()) { + try { + externalSurveillanceToolGatewayFacade.sendCases(sharedCaseUuids, archived); + } catch (ExternalSurveillanceToolException e) { + throw new ExternalSurveillanceToolRuntimeException(e.getMessage(), e.getErrorCode()); + } } } } } + public List getEntityUuidsAllowedToBeShared(List entityUuids) { + List casesAllowedToBeShare = + caseFacade.getByUuids(entityUuids).stream().filter(c -> !c.isDontShareWithReportingTool()).collect(Collectors.toList()); + + return casesAllowedToBeShare.stream().map(CaseDataDto::getUuid).collect(Collectors.toList()); + } + public void setArchiveInExternalSurveillanceToolForEntity(String entityUuid, boolean archived) { setArchiveInExternalSurveillanceToolForEntities(Collections.singletonList(entityUuid), archived); } @@ -1119,7 +1130,9 @@ public void delete(Case caze, DeletionDetails deletionDetails) { private void deleteCaseInExternalSurveillanceTool(Case caze) { try { - caseFacade.deleteCaseInExternalSurveillanceTool(caze); + if (!caze.isDontShareWithReportingTool()) { + caseFacade.deleteCaseInExternalSurveillanceTool(caze); + } } catch (ExternalSurveillanceToolException e) { throw new ExternalSurveillanceToolRuntimeException(e.getMessage(), e.getErrorCode()); } diff --git a/sormas-backend/src/test/java/de/symeda/sormas/backend/caze/CaseFacadeEjbTest.java b/sormas-backend/src/test/java/de/symeda/sormas/backend/caze/CaseFacadeEjbTest.java index cbe5a507ce1..1c8c1880e1d 100644 --- a/sormas-backend/src/test/java/de/symeda/sormas/backend/caze/CaseFacadeEjbTest.java +++ b/sormas-backend/src/test/java/de/symeda/sormas/backend/caze/CaseFacadeEjbTest.java @@ -17,7 +17,9 @@ import static com.github.tomakehurst.wiremock.client.WireMock.aResponse; import static com.github.tomakehurst.wiremock.client.WireMock.containing; +import static com.github.tomakehurst.wiremock.client.WireMock.exactly; import static com.github.tomakehurst.wiremock.client.WireMock.post; +import static com.github.tomakehurst.wiremock.client.WireMock.postRequestedFor; import static com.github.tomakehurst.wiremock.client.WireMock.stubFor; import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo; import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.options; @@ -178,6 +180,7 @@ import de.symeda.sormas.api.visit.VisitStatus; import de.symeda.sormas.backend.AbstractBeanTest; import de.symeda.sormas.backend.MockProducer; +import de.symeda.sormas.backend.TestDataCreator; import de.symeda.sormas.backend.TestDataCreator.RDCF; import de.symeda.sormas.backend.TestDataCreator.RDCFEntities; import de.symeda.sormas.backend.caze.CaseFacadeEjb.CaseFacadeEjbLocal; @@ -1313,7 +1316,7 @@ public void testGetExportListWithoutDeletedSamples() { public void testCaseDeletion() throws ExternalSurveillanceToolRuntimeException { Date since = new Date(); - RDCFEntities rdcf = creator.createRDCFEntities("Region", "District", "Community", "Facility"); + TestDataCreator.RDCF rdcf = creator.createRDCF(); UserDto user = creator.createUser( rdcf.region.getUuid(), rdcf.district.getUuid(), @@ -1331,7 +1334,9 @@ public void testCaseDeletion() throws ExternalSurveillanceToolRuntimeException { CaseClassification.PROBABLE, InvestigationStatus.PENDING, new Date(), - rdcf); + rdcf, + c -> c.setDontShareWithReportingTool(true)); + PersonDto contactPerson = creator.createPerson("Contact", "Person"); ContactDto contact = creator.createContact(user.toReference(), user.toReference(), contactPerson.toReference(), caze, new Date(), new Date(), null); @@ -1363,7 +1368,13 @@ public void testCaseDeletion() throws ExternalSurveillanceToolRuntimeException { assertNotNull(getAdditionalTestFacade().getByUuid(additionalTest.getUuid())); assertNotNull(getTaskFacade().getByUuid(task.getUuid())); + stubFor( + post(urlEqualTo("/export")).withRequestBody(containing(caze.getUuid())) + .withRequestBody(containing("caseUuids")) + .willReturn(aResponse().withStatus(HttpStatus.SC_OK))); + getCaseFacade().delete(caze.getUuid(), new DeletionDetails(DeletionReason.OTHER_REASON, "test reason")); + wireMockRule.verify(exactly(0), postRequestedFor(urlEqualTo("/export"))); // Deleted flag should be set for case, sample and pathogen test; Additional test should be deleted; Contact should not have the deleted flag; Task should not be deleted assertTrue(getCaseFacade().getDeletedUuidsSince(since).contains(caze.getUuid())); @@ -2189,7 +2200,7 @@ public void testDoesEpidNumberExistLargeNumbers() { @Test public void testArchiveAllArchivableCases() { - RDCFEntities rdcf = creator.createRDCFEntities(); + TestDataCreator.RDCF rdcf = creator.createRDCF(); UserReferenceDto user = creator.createUser(rdcf).toReference(); PersonReferenceDto person = creator.createPerson("Walter", "Schuster").toReference(); @@ -2207,7 +2218,7 @@ public void testArchiveAllArchivableCases() { assertTrue(cut.isArchived(case1.getUuid())); // One other case - CaseDataDto case2 = creator.createCase(user, person, rdcf); + CaseDataDto case2 = creator.createCase(user, person, rdcf, c -> c.setDontShareWithReportingTool(true)); Case caze2 = getCaseService().getByUuid(case2.getUuid()); getExternalShareInfoService().createAndPersistShareInfo(caze2, ExternalShareStatus.SHARED); assertFalse(cut.isArchived(case2.getUuid())); @@ -2228,6 +2239,30 @@ public void testArchiveAllArchivableCases() { assertTrue(cut.isArchived(case2.getUuid())); } + @Test + public void testArchiveAllArchivableCases_WithNotAllowedCaseToShareWithReportingTool() { + TestDataCreator.RDCF rdcf = creator.createRDCF(); + UserReferenceDto user = creator.createUser(rdcf).toReference(); + PersonReferenceDto person = creator.createPerson("Walter", "Schuster").toReference(); + + CaseFacadeEjbLocal cut = getBean(CaseFacadeEjbLocal.class); + + CaseDataDto case2 = creator.createCase(user, person, rdcf, c -> c.setDontShareWithReportingTool(true)); + Case caze2 = getCaseService().getByUuid(case2.getUuid()); + getExternalShareInfoService().createAndPersistShareInfo(caze2, ExternalShareStatus.SHARED); + assertFalse(cut.isArchived(case2.getUuid())); + + stubFor( + post(urlEqualTo("/export")).withRequestBody(containing(case2.getUuid())) + .withRequestBody(containing("caseUuids")) + .willReturn(aResponse().withStatus(HttpStatus.SC_OK))); + + // Case of "yesterday" should be archived but the case should not be shared with the Reporting Tool + cut.archiveAllArchivableCases(70, LocalDate.now().plusDays(71)); + assertTrue(cut.isArchived(case2.getUuid())); + wireMockRule.verify(exactly(0), postRequestedFor(urlEqualTo("/export"))); + } + @Test public void testCreateInvestigationTask() { RDCF rdcf = creator.createRDCF(); diff --git a/sormas-backend/src/test/java/de/symeda/sormas/backend/caze/CaseServiceTest.java b/sormas-backend/src/test/java/de/symeda/sormas/backend/caze/CaseServiceTest.java index 8bcfc508e1a..dd8ee9b56a4 100644 --- a/sormas-backend/src/test/java/de/symeda/sormas/backend/caze/CaseServiceTest.java +++ b/sormas-backend/src/test/java/de/symeda/sormas/backend/caze/CaseServiceTest.java @@ -1,6 +1,22 @@ package de.symeda.sormas.backend.caze; +import static com.github.tomakehurst.wiremock.client.WireMock.aResponse; +import static com.github.tomakehurst.wiremock.client.WireMock.containing; +import static com.github.tomakehurst.wiremock.client.WireMock.exactly; +import static com.github.tomakehurst.wiremock.client.WireMock.post; +import static com.github.tomakehurst.wiremock.client.WireMock.postRequestedFor; +import static com.github.tomakehurst.wiremock.client.WireMock.stubFor; +import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo; +import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.options; + +import org.apache.http.HttpStatus; +import org.junit.After; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; + import com.github.tomakehurst.wiremock.junit.WireMockRule; + import de.symeda.sormas.api.caze.CaseDataDto; import de.symeda.sormas.api.externalsurveillancetool.ExternalSurveillanceToolException; import de.symeda.sormas.api.externalsurveillancetool.ExternalSurveillanceToolFacade; @@ -13,20 +29,6 @@ import de.symeda.sormas.backend.AbstractBeanTest; import de.symeda.sormas.backend.MockProducer; import de.symeda.sormas.backend.TestDataCreator; -import org.apache.http.HttpStatus; -import org.junit.After; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; - -import static com.github.tomakehurst.wiremock.client.WireMock.aResponse; -import static com.github.tomakehurst.wiremock.client.WireMock.containing; -import static com.github.tomakehurst.wiremock.client.WireMock.exactly; -import static com.github.tomakehurst.wiremock.client.WireMock.post; -import static com.github.tomakehurst.wiremock.client.WireMock.postRequestedFor; -import static com.github.tomakehurst.wiremock.client.WireMock.stubFor; -import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo; -import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.options; public class CaseServiceTest extends AbstractBeanTest { @@ -66,13 +68,14 @@ public void init() { } @Test - public void testSetArchiveInExternalSurveillanceToolForEntity_WithProperEntity() throws ExternalSurveillanceToolException { + public void testSetArchiveInExternalSurveillanceToolForEntity_WithProperEntity_WithCaseAllowedToShare() throws ExternalSurveillanceToolException { TestDataCreator.RDCF rdcf = creator.createRDCF(); UserReferenceDto user = creator.createUser(rdcf).toReference(); PersonReferenceDto person = creator.createPerson("Walter", "Schuster").toReference(); - CaseDataDto caze = creator.createCase(user, person, rdcf); + CaseDataDto caze = creator.createCase(user, person, rdcf, c -> c.setDontShareWithReportingTool(false)); Case case1 = getCaseService().getByUuid(caze.getUuid()); + case1.setDontShareWithReportingTool(false); getExternalShareInfoService().createAndPersistShareInfo(case1, ExternalShareStatus.SHARED); CaseService caseService = getBean(CaseService.class); @@ -85,6 +88,28 @@ public void testSetArchiveInExternalSurveillanceToolForEntity_WithProperEntity() wireMockRule.verify(exactly(1), postRequestedFor(urlEqualTo("/export"))); } + @Test + public void testSetArchiveInExternalSurveillanceToolForEntity_WithProperEntity_WithoutCaseAllowedToShare() + throws ExternalSurveillanceToolException { + TestDataCreator.RDCF rdcf = creator.createRDCF(); + UserReferenceDto user = creator.createUser(rdcf).toReference(); + PersonReferenceDto person = creator.createPerson("Walter", "Schuster").toReference(); + + CaseDataDto caze = creator.createCase(user, person, rdcf, c -> c.setDontShareWithReportingTool(true)); + + Case case1 = getCaseService().getByUuid(caze.getUuid()); + getExternalShareInfoService().createAndPersistShareInfo(case1, ExternalShareStatus.SHARED); + CaseService caseService = getBean(CaseService.class); + + stubFor( + post(urlEqualTo("/export")).withRequestBody(containing(caze.getUuid())) + .withRequestBody(containing("caseUuids")) + .willReturn(aResponse().withStatus(HttpStatus.SC_OK))); + + caseService.setArchiveInExternalSurveillanceToolForEntity(caze.getUuid(), true); + wireMockRule.verify(exactly(0), postRequestedFor(urlEqualTo("/export"))); + } + @Test public void testSetArchiveInExternalSurveillanceToolForEntity_WithoutProperEntity() throws ExternalSurveillanceToolException { TestDataCreator.RDCF rdcf = creator.createRDCF(); diff --git a/sormas-backend/src/test/java/de/symeda/sormas/backend/deletionconfiguration/CoreEntityDeletionServiceTest.java b/sormas-backend/src/test/java/de/symeda/sormas/backend/deletionconfiguration/CoreEntityDeletionServiceTest.java index c23fbdcb0f7..8c89b6e729e 100644 --- a/sormas-backend/src/test/java/de/symeda/sormas/backend/deletionconfiguration/CoreEntityDeletionServiceTest.java +++ b/sormas-backend/src/test/java/de/symeda/sormas/backend/deletionconfiguration/CoreEntityDeletionServiceTest.java @@ -1,5 +1,13 @@ package de.symeda.sormas.backend.deletionconfiguration; +import static com.github.tomakehurst.wiremock.client.WireMock.aResponse; +import static com.github.tomakehurst.wiremock.client.WireMock.containing; +import static com.github.tomakehurst.wiremock.client.WireMock.exactly; +import static com.github.tomakehurst.wiremock.client.WireMock.post; +import static com.github.tomakehurst.wiremock.client.WireMock.postRequestedFor; +import static com.github.tomakehurst.wiremock.client.WireMock.stubFor; +import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo; +import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.options; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; @@ -14,11 +22,15 @@ import javax.validation.ConstraintViolationException; import org.apache.commons.lang3.time.DateUtils; +import org.apache.http.HttpStatus; import org.hibernate.internal.SessionImpl; import org.hibernate.query.spi.QueryImplementor; import org.junit.Before; +import org.junit.Rule; import org.junit.Test; +import com.github.tomakehurst.wiremock.junit.WireMockRule; + import de.symeda.sormas.api.Disease; import de.symeda.sormas.api.caze.CaseDataDto; import de.symeda.sormas.api.common.CoreEntityType; @@ -66,6 +78,11 @@ public class CoreEntityDeletionServiceTest extends SormasToSormasTest { + private static final int WIREMOCK_TESTING_PORT = 8888; + + @Rule + public WireMockRule wireMockRule = new WireMockRule(options().port(WIREMOCK_TESTING_PORT), false); + @Before public void setupConfig() { MockProducer.getProperties().setProperty(ConfigFacadeEjb.INTERFACE_PATIENT_DIARY_URL, "url"); @@ -81,7 +98,7 @@ public void testCaseAutomaticDeletion() throws IOException { UserDto user = creator .createUser(rdcf, creator.getUserRoleReference(DefaultUserRole.ADMIN), creator.getUserRoleReference(DefaultUserRole.NATIONAL_USER)); PersonDto person = creator.createPerson(); - CaseDataDto caze = creator.createCase(user.toReference(), person.toReference(), rdcf); + CaseDataDto caze = creator.createCase(user.toReference(), person.toReference(), rdcf, c -> c.setDontShareWithReportingTool(true)); creator.createClinicalVisit(caze); creator.createTreatment(caze); @@ -155,7 +172,13 @@ public void testCaseAutomaticDeletion() throws IOException { assertEquals(2, getCaseService().count()); useSystemUser(); + + stubFor( + post(urlEqualTo("/export")).withRequestBody(containing(caze.getUuid())) + .withRequestBody(containing("caseUuids")) + .willReturn(aResponse().withStatus(HttpStatus.SC_OK))); getCoreEntityDeletionService().executeAutomaticDeletion(); + wireMockRule.verify(exactly(0), postRequestedFor(urlEqualTo("/export"))); loginWith(user); ContactDto resultingContactUpdated = getContactFacade().getByUuid(resultingContact.getUuid()); diff --git a/sormas-backend/src/test/java/de/symeda/sormas/backend/sormastosormas/entities/SormasToSormasCaseFacadeEjbTest.java b/sormas-backend/src/test/java/de/symeda/sormas/backend/sormastosormas/entities/SormasToSormasCaseFacadeEjbTest.java index 76d413fda7a..8804b17255c 100644 --- a/sormas-backend/src/test/java/de/symeda/sormas/backend/sormastosormas/entities/SormasToSormasCaseFacadeEjbTest.java +++ b/sormas-backend/src/test/java/de/symeda/sormas/backend/sormastosormas/entities/SormasToSormasCaseFacadeEjbTest.java @@ -15,6 +15,14 @@ package de.symeda.sormas.backend.sormastosormas.entities; +import static com.github.tomakehurst.wiremock.client.WireMock.aResponse; +import static com.github.tomakehurst.wiremock.client.WireMock.containing; +import static com.github.tomakehurst.wiremock.client.WireMock.exactly; +import static com.github.tomakehurst.wiremock.client.WireMock.post; +import static com.github.tomakehurst.wiremock.client.WireMock.postRequestedFor; +import static com.github.tomakehurst.wiremock.client.WireMock.stubFor; +import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo; +import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.options; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.arrayWithSize; import static org.hamcrest.Matchers.hasSize; @@ -34,12 +42,16 @@ import javax.ws.rs.core.Response; +import org.apache.http.HttpStatus; +import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.ArgumentMatchers; import org.mockito.Mockito; import org.mockito.junit.MockitoJUnitRunner; +import com.github.tomakehurst.wiremock.junit.WireMockRule; + import de.symeda.sormas.api.Disease; import de.symeda.sormas.api.caze.CaseDataDto; import de.symeda.sormas.api.caze.CaseOrigin; @@ -98,8 +110,13 @@ @RunWith(MockitoJUnitRunner.class) public class SormasToSormasCaseFacadeEjbTest extends SormasToSormasTest { + private static final int WIREMOCK_TESTING_PORT = 8888; + + @Rule + public WireMockRule wireMockRule = new WireMockRule(options().port(WIREMOCK_TESTING_PORT), false); + @Test - public void testShareCase() throws SormasToSormasException { + public void testShareCase_WithCaseNotAllowedToBeSharedWithReportingTool() throws SormasToSormasException { UserReferenceDto officer = creator.createUser(rdcf, creator.getUserRoleReference(DefaultUserRole.SURVEILLANCE_OFFICER)).toReference(); useSurveillanceOfficerLogin(rdcf); @@ -109,6 +126,7 @@ public void testShareCase() throws SormasToSormasException { dto.setPerson(person.toReference()); dto.setSurveillanceOfficer(officer); dto.setClassificationUser(officer); + dto.setDontShareWithReportingTool(true); }); SormasToSormasOptionsDto options = new SormasToSormasOptionsDto(); @@ -144,7 +162,13 @@ public void testShareCase() throws SormasToSormasException { return encryptShareData(new ShareRequestAcceptData(null, null)); }); + stubFor( + post(urlEqualTo("/export")).withRequestBody(containing(caze.getUuid())) + .withRequestBody(containing("caseUuids")) + .willReturn(aResponse().withStatus(HttpStatus.SC_OK))); + getSormasToSormasCaseFacade().share(Collections.singletonList(caze.getUuid()), options); + wireMockRule.verify(exactly(0), postRequestedFor(urlEqualTo("/export"))); List shareInfoList = getSormasToSormasShareInfoFacade().getIndexList(new SormasToSormasShareInfoCriteria().caze(caze.toReference()), 0, 100); From b82900ac82c2a65addeb86fc92c99e16524eb019 Mon Sep 17 00:00:00 2001 From: Jonas Cirotzki Date: Tue, 8 Nov 2022 13:54:55 +0100 Subject: [PATCH 4/5] [#10820] avoid NPE in getByExternalId due to user and user path being null (#10857) --- .../java/de/symeda/sormas/backend/caze/CaseFacadeEjb.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/sormas-backend/src/main/java/de/symeda/sormas/backend/caze/CaseFacadeEjb.java b/sormas-backend/src/main/java/de/symeda/sormas/backend/caze/CaseFacadeEjb.java index 0e70059a594..8ddcf62a672 100644 --- a/sormas-backend/src/main/java/de/symeda/sormas/backend/caze/CaseFacadeEjb.java +++ b/sormas-backend/src/main/java/de/symeda/sormas/backend/caze/CaseFacadeEjb.java @@ -2598,7 +2598,9 @@ public void deleteCaseAsDuplicate(String caseUuid, String duplicateOfCaseUuid) { public void deleteCaseInExternalSurveillanceTool(Case caze) throws ExternalSurveillanceToolException { if (externalSurveillanceToolGatewayFacade.isFeatureEnabled() && caze.getExternalID() != null && !caze.getExternalID().isEmpty()) { - List casesWithSameExternalId = getByExternalId(caze.getExternalID()); + // getByExternalId(caze) throws NPE (see #10820) so we use the service directly. + // Can potentially be changed back once 10844 is done. + List casesWithSameExternalId = service.getByExternalId(caze.getExternalID()); if (casesWithSameExternalId != null && casesWithSameExternalId.size() == 1) { externalSurveillanceToolGatewayFacade.deleteCases(Collections.singletonList(toDto(caze))); } From 544920cad1d221ff07310a60cd12fcf91c9eafa6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mat=C3=A9=20Strysewske?= Date: Tue, 8 Nov 2022 14:11:50 +0100 Subject: [PATCH 5/5] [GITFLOW]updating poms for branch'hotfix-1.76.3' with non-snapshot versions --- sormas-api/pom.xml | 2 +- sormas-app/pom.xml | 2 +- sormas-backend/pom.xml | 2 +- sormas-base/dependencies/serverlibs.pom | 2 +- sormas-base/pom.xml | 2 +- sormas-cargoserver/pom.xml | 2 +- sormas-ear/pom.xml | 2 +- sormas-keycloak-service-provider/pom.xml | 2 +- sormas-rest/pom.xml | 2 +- sormas-ui/pom.xml | 2 +- sormas-widgetset/pom.xml | 2 +- 11 files changed, 11 insertions(+), 11 deletions(-) diff --git a/sormas-api/pom.xml b/sormas-api/pom.xml index aae10be5ef9..ab69a047906 100644 --- a/sormas-api/pom.xml +++ b/sormas-api/pom.xml @@ -2,7 +2,7 @@ de.symeda.sormas sormas-base - 1.76.3-SNAPSHOT + 1.76.3 ../sormas-base 4.0.0 diff --git a/sormas-app/pom.xml b/sormas-app/pom.xml index 0a3aacdf10d..dd05dd906fa 100644 --- a/sormas-app/pom.xml +++ b/sormas-app/pom.xml @@ -3,7 +3,7 @@ sormas-base de.symeda.sormas - 1.76.3-SNAPSHOT + 1.76.3 ../sormas-base 4.0.0 diff --git a/sormas-backend/pom.xml b/sormas-backend/pom.xml index d59af33cc0d..40f2a3495af 100644 --- a/sormas-backend/pom.xml +++ b/sormas-backend/pom.xml @@ -3,7 +3,7 @@ sormas-base de.symeda.sormas - 1.76.3-SNAPSHOT + 1.76.3 ../sormas-base 4.0.0 diff --git a/sormas-base/dependencies/serverlibs.pom b/sormas-base/dependencies/serverlibs.pom index effab045ff8..cd9a2cba1c2 100644 --- a/sormas-base/dependencies/serverlibs.pom +++ b/sormas-base/dependencies/serverlibs.pom @@ -8,7 +8,7 @@ sormas-base de.symeda.sormas - 1.76.3-SNAPSHOT + 1.76.3 ../ diff --git a/sormas-base/pom.xml b/sormas-base/pom.xml index 5b67d63a607..b9b52afd266 100644 --- a/sormas-base/pom.xml +++ b/sormas-base/pom.xml @@ -5,7 +5,7 @@ de.symeda.sormas sormas-base pom - 1.76.3-SNAPSHOT + 1.76.3 1.8 diff --git a/sormas-cargoserver/pom.xml b/sormas-cargoserver/pom.xml index bc4b0267a98..62312476c33 100644 --- a/sormas-cargoserver/pom.xml +++ b/sormas-cargoserver/pom.xml @@ -3,7 +3,7 @@ de.symeda.sormas sormas-base - 1.76.3-SNAPSHOT + 1.76.3 ../sormas-base diff --git a/sormas-ear/pom.xml b/sormas-ear/pom.xml index 9cea87ff836..adb0e975512 100644 --- a/sormas-ear/pom.xml +++ b/sormas-ear/pom.xml @@ -3,7 +3,7 @@ de.symeda.sormas sormas-base - 1.76.3-SNAPSHOT + 1.76.3 ../sormas-base diff --git a/sormas-keycloak-service-provider/pom.xml b/sormas-keycloak-service-provider/pom.xml index 2dc059b47a5..728aed9c8f4 100644 --- a/sormas-keycloak-service-provider/pom.xml +++ b/sormas-keycloak-service-provider/pom.xml @@ -3,7 +3,7 @@ sormas-base de.symeda.sormas - 1.76.3-SNAPSHOT + 1.76.3 ../sormas-base 4.0.0 diff --git a/sormas-rest/pom.xml b/sormas-rest/pom.xml index 90075e628f6..b363ed5b0c2 100644 --- a/sormas-rest/pom.xml +++ b/sormas-rest/pom.xml @@ -3,7 +3,7 @@ de.symeda.sormas sormas-base - 1.76.3-SNAPSHOT + 1.76.3 ../sormas-base diff --git a/sormas-ui/pom.xml b/sormas-ui/pom.xml index dabc7e2e2e4..961633d0531 100644 --- a/sormas-ui/pom.xml +++ b/sormas-ui/pom.xml @@ -3,7 +3,7 @@ sormas-base de.symeda.sormas - 1.76.3-SNAPSHOT + 1.76.3 ../sormas-base 4.0.0 diff --git a/sormas-widgetset/pom.xml b/sormas-widgetset/pom.xml index b207ee7031d..1f958c657b6 100644 --- a/sormas-widgetset/pom.xml +++ b/sormas-widgetset/pom.xml @@ -3,7 +3,7 @@ sormas-base de.symeda.sormas - 1.76.3-SNAPSHOT + 1.76.3 ../sormas-base 4.0.0