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>
</pluginManagement>
<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>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>

View File

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

View File

@ -43,7 +43,6 @@ import static org.slf4j.LoggerFactory.getLogger;
@TestPropertySource(properties = {
"mdm.prevent_multiple_eids=false"
})
@DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_CLASS)
@ContextConfiguration(classes = {MdmHelperConfig.class})
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.slf4j.LoggerFactory.getLogger;
@DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_CLASS)
@ContextConfiguration(classes = {MdmHelperConfig.class})
public class MdmSearchExpandingInterceptorIT extends BaseMdmR4Test {
@ -177,18 +176,21 @@ public class MdmSearchExpandingInterceptorIT extends BaseMdmR4Test {
// test
myDaoConfig.setAllowMdmExpansion(true);
IFhirResourceDaoPatient<Patient> dao = (IFhirResourceDaoPatient<Patient>) myPatientDao;
IBundleProvider outcome = dao.patientInstanceEverything(
req,
new IdDt(id),
null,
null,
null,
null,
null,
null,
null,
theDetails
);
IBundleProvider outcome = runInTransaction(() -> {
IBundleProvider res = dao.patientInstanceEverything(
req,
new IdDt(id),
null,
null,
null,
null,
null,
null,
null,
theDetails
);
return res;
});
// verify return results
// 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.Patient;
import org.hl7.fhir.r4.model.SearchParameter;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
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.slf4j.LoggerFactory.getLogger;
@DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_CLASS)
@ContextConfiguration(classes = {MdmHelperConfig.class})
public class MdmStorageInterceptorIT extends BaseMdmR4Test {
@ -62,6 +62,12 @@ public class MdmStorageInterceptorIT extends BaseMdmR4Test {
@Autowired
private IJpaIdHelperService myIdHelperService;
@Override
public void beforeUnregisterAllSubscriptions() {
// noop
}
@Test
public void testCreatePractitioner() throws InterruptedException {
myMdmHelper.createWithLatch(buildPractitionerWithNameAndId("somename", "some_id"));
@ -98,7 +104,7 @@ public class MdmStorageInterceptorIT extends BaseMdmR4Test {
myMdmHelper.doCreateResource(patient, true);
fail();
} 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);
fail();
} 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);
fail();
} 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);
fail();
} 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);
fail();
} 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);
fail();
} 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);
fail();
} 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);
fail();
} 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);
}
@ -279,7 +285,7 @@ public class MdmStorageInterceptorIT extends BaseMdmR4Test {
myMdmHelper.doCreateResource(patient, true);
fail();
} 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);

View File

@ -145,7 +145,7 @@ public class MdmCandidateSearchSvcIT extends BaseMdmR4Test {
myMdmCandidateSearchSvc.findCandidates("Patient", newJane, RequestPartitionId.allPartitions());
fail();
} 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>
</configuration>
</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>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>

View File

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