mirror of
https://github.com/hapifhir/hapi-fhir.git
synced 2025-02-09 22:44:52 +00:00
Adds failing test for expunging and recreating a Patient with a profile in its meta field.
This commit is contained in:
parent
281596d5f2
commit
f04ff3fd0a
@ -10,6 +10,7 @@ import ca.uhn.fhir.jpa.dao.dstu3.BaseJpaDstu3Test;
|
|||||||
import ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException;
|
import ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException;
|
||||||
import ca.uhn.test.concurrency.PointcutLatch;
|
import ca.uhn.test.concurrency.PointcutLatch;
|
||||||
import org.hl7.fhir.dstu3.model.Patient;
|
import org.hl7.fhir.dstu3.model.Patient;
|
||||||
|
import org.hl7.fhir.dstu3.model.Meta;
|
||||||
import org.hl7.fhir.instance.model.api.IIdType;
|
import org.hl7.fhir.instance.model.api.IIdType;
|
||||||
import org.junit.jupiter.api.AfterEach;
|
import org.junit.jupiter.api.AfterEach;
|
||||||
import org.junit.jupiter.api.BeforeEach;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
@ -40,6 +41,8 @@ public class ExpungeHookTest extends BaseJpaDstu3Test {
|
|||||||
@BeforeEach
|
@BeforeEach
|
||||||
public void before() {
|
public void before() {
|
||||||
myDaoConfig.setExpungeEnabled(true);
|
myDaoConfig.setExpungeEnabled(true);
|
||||||
|
myDaoConfig.setResourceClientIdStrategy(DaoConfig.ClientIdStrategyEnum.ALPHANUMERIC);
|
||||||
|
myDaoConfig.setAutoCreatePlaceholderReferenceTargets(true);
|
||||||
myInterceptorService.registerAnonymousInterceptor(Pointcut.STORAGE_PRESTORAGE_EXPUNGE_EVERYTHING, myEverythingLatch);
|
myInterceptorService.registerAnonymousInterceptor(Pointcut.STORAGE_PRESTORAGE_EXPUNGE_EVERYTHING, myEverythingLatch);
|
||||||
myInterceptorService.registerAnonymousInterceptor(Pointcut.STORAGE_PRESTORAGE_EXPUNGE_RESOURCE, myExpungeResourceLatch);
|
myInterceptorService.registerAnonymousInterceptor(Pointcut.STORAGE_PRESTORAGE_EXPUNGE_RESOURCE, myExpungeResourceLatch);
|
||||||
}
|
}
|
||||||
@ -65,6 +68,43 @@ public class ExpungeHookTest extends BaseJpaDstu3Test {
|
|||||||
assertPatientGone(id);
|
assertPatientGone(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void expungeEverythingAndRecreate() throws InterruptedException {
|
||||||
|
// Create a patient.
|
||||||
|
Patient thePatient = new Patient();
|
||||||
|
thePatient.setId("ABC123");
|
||||||
|
Meta theMeta = new Meta();
|
||||||
|
theMeta.addProfile("http://hl7.org/fhir/us/core/StructureDefinition/us-core-patient");
|
||||||
|
thePatient.setMeta(theMeta);
|
||||||
|
myPatientDao.update(thePatient, mySrd);
|
||||||
|
|
||||||
|
IIdType id = myPatientDao.update(thePatient, mySrd).getId();
|
||||||
|
assertNotNull(myPatientDao.read(id));
|
||||||
|
|
||||||
|
// Expunge it directly.
|
||||||
|
myPatientDao.delete(id);
|
||||||
|
ExpungeOptions options = new ExpungeOptions();
|
||||||
|
options.setExpungeEverything(true);
|
||||||
|
options.setExpungeDeletedResources(true);
|
||||||
|
options.setExpungeOldVersions(true);
|
||||||
|
myPatientDao.expunge(id.toUnqualifiedVersionless(), options, mySrd);
|
||||||
|
assertPatientGone(id);
|
||||||
|
|
||||||
|
// Create it a second time.
|
||||||
|
myPatientDao.update(thePatient, mySrd);
|
||||||
|
assertNotNull(myPatientDao.read(id));
|
||||||
|
|
||||||
|
// Expunge everything with the service.
|
||||||
|
myEverythingLatch.setExpectedCount(1);
|
||||||
|
myExpungeService.expunge(null, null, null, options, mySrd);
|
||||||
|
myEverythingLatch.awaitExpected();
|
||||||
|
assertPatientGone(id);
|
||||||
|
|
||||||
|
// Create it a third time.
|
||||||
|
myPatientDao.update(thePatient, mySrd);
|
||||||
|
assertNotNull(myPatientDao.read(id));
|
||||||
|
}
|
||||||
|
|
||||||
private void assertPatientGone(IIdType theId) {
|
private void assertPatientGone(IIdType theId) {
|
||||||
try {
|
try {
|
||||||
myPatientDao.read(theId);
|
myPatientDao.read(theId);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user