20220520 mdm test failure (#3629)

* wip fix test

* move to override in test class

* Test fixes

* Add failsafe to other projects which have ITs

* Fix test

* Fix test to use transaction

Co-authored-by: Ken Stevens <khstevens@gmail.com>
This commit is contained in:
Tadgh 2022-05-20 16:56:27 -07:00 committed by GitHub
parent e5df4be8da
commit bf6f763691
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 100 additions and 25 deletions

View File

@ -85,6 +85,34 @@
</plugins> </plugins>
</pluginManagement> </pluginManagement>
<plugins> <plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<configuration>
<forkCount>1</forkCount>
<reuseForks>false</reuseForks>
<runOrder>alphabetical</runOrder>
<includes>
<include>**/*IT.java</include>
</includes>
<useModulePath>false</useModulePath>
</configuration>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>${junit_version}</version>
</dependency>
</dependencies>
</plugin>
<plugin> <plugin>
<groupId>org.jacoco</groupId> <groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId> <artifactId>jacoco-maven-plugin</artifactId>

View File

@ -140,6 +140,11 @@ abstract public class BaseMdmR4Test extends BaseJpaR4Test {
myRequestDetails = new ServletRequestDetails(myInterceptorBroadcaster); myRequestDetails = new ServletRequestDetails(myInterceptorBroadcaster);
} }
@Override
public void beforeUnregisterAllSubscriptions() {
//no-op
}
@AfterEach @AfterEach
public void after() throws IOException { public void after() throws IOException {
myMdmLinkDao.deleteAll(); myMdmLinkDao.deleteAll();
@ -198,6 +203,11 @@ abstract public class BaseMdmR4Test extends BaseJpaR4Test {
return patient; return patient;
} }
@Override
public void afterResetInterceptors() {
//no-op
}
@Nonnull @Nonnull
protected Patient createPatientOnPartition(Patient thePatient, boolean theMdmManaged, boolean isRedirect, RequestPartitionId theRequestPartitionId) { protected Patient createPatientOnPartition(Patient thePatient, boolean theMdmManaged, boolean isRedirect, RequestPartitionId theRequestPartitionId) {
if (theMdmManaged) { if (theMdmManaged) {

View File

@ -43,7 +43,6 @@ import static org.slf4j.LoggerFactory.getLogger;
@TestPropertySource(properties = { @TestPropertySource(properties = {
"mdm.prevent_multiple_eids=false" "mdm.prevent_multiple_eids=false"
}) })
@DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_CLASS)
@ContextConfiguration(classes = {MdmHelperConfig.class}) @ContextConfiguration(classes = {MdmHelperConfig.class})
public class MdmEventIT extends BaseMdmR4Test { public class MdmEventIT extends BaseMdmR4Test {

View File

@ -41,7 +41,6 @@ import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.is; import static org.hamcrest.Matchers.is;
import static org.slf4j.LoggerFactory.getLogger; import static org.slf4j.LoggerFactory.getLogger;
@DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_CLASS)
@ContextConfiguration(classes = {MdmHelperConfig.class}) @ContextConfiguration(classes = {MdmHelperConfig.class})
public class MdmSearchExpandingInterceptorIT extends BaseMdmR4Test { public class MdmSearchExpandingInterceptorIT extends BaseMdmR4Test {
@ -177,7 +176,8 @@ public class MdmSearchExpandingInterceptorIT extends BaseMdmR4Test {
// test // test
myDaoConfig.setAllowMdmExpansion(true); myDaoConfig.setAllowMdmExpansion(true);
IFhirResourceDaoPatient<Patient> dao = (IFhirResourceDaoPatient<Patient>) myPatientDao; IFhirResourceDaoPatient<Patient> dao = (IFhirResourceDaoPatient<Patient>) myPatientDao;
IBundleProvider outcome = dao.patientInstanceEverything( IBundleProvider outcome = runInTransaction(() -> {
IBundleProvider res = dao.patientInstanceEverything(
req, req,
new IdDt(id), new IdDt(id),
null, null,
@ -189,6 +189,8 @@ public class MdmSearchExpandingInterceptorIT extends BaseMdmR4Test {
null, null,
theDetails theDetails
); );
return res;
});
// verify return results // verify return results
// we expect all the linked ids to be returned too // we expect all the linked ids to be returned too

View File

@ -22,6 +22,7 @@ import org.hl7.fhir.r4.model.Medication;
import org.hl7.fhir.r4.model.Organization; import org.hl7.fhir.r4.model.Organization;
import org.hl7.fhir.r4.model.Patient; import org.hl7.fhir.r4.model.Patient;
import org.hl7.fhir.r4.model.SearchParameter; import org.hl7.fhir.r4.model.SearchParameter;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.jupiter.api.extension.RegisterExtension;
import org.slf4j.Logger; import org.slf4j.Logger;
@ -50,7 +51,6 @@ import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.fail; import static org.junit.jupiter.api.Assertions.fail;
import static org.slf4j.LoggerFactory.getLogger; import static org.slf4j.LoggerFactory.getLogger;
@DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_CLASS)
@ContextConfiguration(classes = {MdmHelperConfig.class}) @ContextConfiguration(classes = {MdmHelperConfig.class})
public class MdmStorageInterceptorIT extends BaseMdmR4Test { public class MdmStorageInterceptorIT extends BaseMdmR4Test {
@ -62,6 +62,12 @@ public class MdmStorageInterceptorIT extends BaseMdmR4Test {
@Autowired @Autowired
private IJpaIdHelperService myIdHelperService; private IJpaIdHelperService myIdHelperService;
@Override
public void beforeUnregisterAllSubscriptions() {
// noop
}
@Test @Test
public void testCreatePractitioner() throws InterruptedException { public void testCreatePractitioner() throws InterruptedException {
myMdmHelper.createWithLatch(buildPractitionerWithNameAndId("somename", "some_id")); myMdmHelper.createWithLatch(buildPractitionerWithNameAndId("somename", "some_id"));
@ -98,7 +104,7 @@ public class MdmStorageInterceptorIT extends BaseMdmR4Test {
myMdmHelper.doCreateResource(patient, true); myMdmHelper.doCreateResource(patient, true);
fail(); fail();
} catch (ForbiddenOperationException e) { } catch (ForbiddenOperationException e) {
assertThat(e.getMessage(), startsWith("Cannot create or modify Resources that are managed by MDM.")); assertThat(e.getMessage(), startsWith("HAPI-0765: Cannot create or modify Resources that are managed by MDM."));
} }
} }
@ -110,7 +116,7 @@ public class MdmStorageInterceptorIT extends BaseMdmR4Test {
myMdmHelper.doCreateResource(patient, true); myMdmHelper.doCreateResource(patient, true);
fail(); fail();
} catch (ForbiddenOperationException e) { } catch (ForbiddenOperationException e) {
assertThat(e.getMessage(), startsWith("Cannot create or modify Resources that are managed by MDM.")); assertThat(e.getMessage(), startsWith("HAPI-0765: Cannot create or modify Resources that are managed by MDM."));
} }
} }
@ -122,7 +128,7 @@ public class MdmStorageInterceptorIT extends BaseMdmR4Test {
myMdmHelper.doCreateResource(medication, true); myMdmHelper.doCreateResource(medication, true);
fail(); fail();
} catch (ForbiddenOperationException e) { } catch (ForbiddenOperationException e) {
assertThat(e.getMessage(), startsWith("Cannot create or modify Resources that are managed by MDM.")); assertThat(e.getMessage(), startsWith("HAPI-0765: Cannot create or modify Resources that are managed by MDM."));
} }
} }
@ -150,7 +156,7 @@ public class MdmStorageInterceptorIT extends BaseMdmR4Test {
myMdmHelper.doCreateResource(organization, true); myMdmHelper.doCreateResource(organization, true);
fail(); fail();
} catch (ForbiddenOperationException e) { } catch (ForbiddenOperationException e) {
assertThat(e.getMessage(), startsWith("Cannot create or modify Resources that are managed by MDM.")); assertThat(e.getMessage(), startsWith("HAPI-0765: Cannot create or modify Resources that are managed by MDM."));
} }
} }
@ -164,7 +170,7 @@ public class MdmStorageInterceptorIT extends BaseMdmR4Test {
myMdmHelper.doUpdateResource(organization, true); myMdmHelper.doUpdateResource(organization, true);
fail(); fail();
} catch (ForbiddenOperationException e) { } catch (ForbiddenOperationException e) {
assertEquals("The HAPI-MDM tag on a resource may not be changed once created.", e.getMessage()); assertEquals("HAPI-0764: The HAPI-MDM tag on a resource may not be changed once created.", e.getMessage());
} }
} }
@ -195,7 +201,7 @@ public class MdmStorageInterceptorIT extends BaseMdmR4Test {
myMdmHelper.doUpdateResource(patient, true); myMdmHelper.doUpdateResource(patient, true);
fail(); fail();
} catch (ForbiddenOperationException e) { } catch (ForbiddenOperationException e) {
assertEquals("The HAPI-MDM tag on a resource may not be changed once created.", e.getMessage()); assertEquals("HAPI-0764: The HAPI-MDM tag on a resource may not be changed once created.", e.getMessage());
} }
} }
@ -216,7 +222,7 @@ public class MdmStorageInterceptorIT extends BaseMdmR4Test {
myMdmHelper.doUpdateResource(goldenResourcePatient, true); myMdmHelper.doUpdateResource(goldenResourcePatient, true);
fail(); fail();
} catch (ForbiddenOperationException e) { } catch (ForbiddenOperationException e) {
assertThat(e.getMessage(), startsWith("Cannot create or modify Resources that are managed by MDM.")); assertThat(e.getMessage(), startsWith("HAPI-0765: Cannot create or modify Resources that are managed by MDM."));
} }
} }
@ -264,7 +270,7 @@ public class MdmStorageInterceptorIT extends BaseMdmR4Test {
myMdmHelper.doUpdateResource(jane, true); myMdmHelper.doUpdateResource(jane, true);
fail(); fail();
} catch (ForbiddenOperationException e) { } catch (ForbiddenOperationException e) {
assertThat(e.getMessage(), is(equalTo("While running with EID updates disabled, EIDs may not be updated on source resources"))); assertThat(e.getMessage(), is(equalTo("HAPI-0763: While running with EID updates disabled, EIDs may not be updated on source resources")));
} }
setPreventEidUpdates(false); setPreventEidUpdates(false);
} }
@ -279,7 +285,7 @@ public class MdmStorageInterceptorIT extends BaseMdmR4Test {
myMdmHelper.doCreateResource(patient, true); myMdmHelper.doCreateResource(patient, true);
fail(); fail();
} catch (ForbiddenOperationException e) { } catch (ForbiddenOperationException e) {
assertThat(e.getMessage(), is(equalTo("While running with multiple EIDs disabled, source resources may have at most one EID."))); assertThat(e.getMessage(), is(equalTo("HAPI-0766: While running with multiple EIDs disabled, source resources may have at most one EID.")));
} }
setPreventMultipleEids(false); setPreventMultipleEids(false);

View File

@ -145,7 +145,7 @@ public class MdmCandidateSearchSvcIT extends BaseMdmR4Test {
myMdmCandidateSearchSvc.findCandidates("Patient", newJane, RequestPartitionId.allPartitions()); myMdmCandidateSearchSvc.findCandidates("Patient", newJane, RequestPartitionId.allPartitions());
fail(); fail();
} catch (TooManyCandidatesException e) { } catch (TooManyCandidatesException e) {
assertEquals("More than 3 candidate matches found for Patient?identifier=http%3A%2F%2Fa.tv%2F%7CID.JANE.123&active=true. Aborting mdm matching.", e.getMessage()); assertEquals("HAPI-0762: More than 3 candidate matches found for Patient?identifier=http%3A%2F%2Fa.tv%2F%7CID.JANE.123&active=true. Aborting mdm matching.", e.getMessage());
} }
} }

View File

@ -136,6 +136,34 @@
<argLine>@{argLine} ${surefire_jvm_args}</argLine> <argLine>@{argLine} ${surefire_jvm_args}</argLine>
</configuration> </configuration>
</plugin> </plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<configuration>
<forkCount>1</forkCount>
<reuseForks>false</reuseForks>
<runOrder>alphabetical</runOrder>
<includes>
<include>**/*IT.java</include>
</includes>
<useModulePath>false</useModulePath>
</configuration>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>${junit_version}</version>
</dependency>
</dependencies>
</plugin>
<plugin> <plugin>
<groupId>org.apache.felix</groupId> <groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId> <artifactId>maven-bundle-plugin</artifactId>

View File

@ -71,8 +71,10 @@ public class MailSvcIT {
public void testSendMailWithInvalidToAddress() { public void testSendMailWithInvalidToAddress() {
// setup // setup
final Email email = withEmail("xyz"); final Email email = withEmail("xyz");
// execute // execute
fixture.sendMail(email); fixture.sendMail(email);
// validate // validate
assertTrue(ourGreenMail.waitForIncomingEmail(1000, 0)); assertTrue(ourGreenMail.waitForIncomingEmail(1000, 0));
final MimeMessage[] receivedMessages = ourGreenMail.getReceivedMessages(); final MimeMessage[] receivedMessages = ourGreenMail.getReceivedMessages();