issue-2901 cleaning up test contexts
This commit is contained in:
parent
cbfcc02a92
commit
ff7433edd7
|
@ -233,6 +233,7 @@ public abstract class BaseStorageDao {
|
||||||
// resource not found
|
// resource not found
|
||||||
// and no autocreateplaceholders set...
|
// and no autocreateplaceholders set...
|
||||||
// we throw
|
// we throw
|
||||||
|
System.out.println("FINDME");
|
||||||
throw new ResourceNotFoundException(referenceElement);
|
throw new ResourceNotFoundException(referenceElement);
|
||||||
}
|
}
|
||||||
String newTargetReference = referenceElement.withVersion(version.toString()).getValue();
|
String newTargetReference = referenceElement.withVersion(version.toString()).getValue();
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package ca.uhn.fhir.jpa.dao.r4;
|
package ca.uhn.fhir.jpa.dao.r4;
|
||||||
|
|
||||||
import ca.uhn.fhir.jpa.api.config.DaoConfig;
|
import ca.uhn.fhir.jpa.api.config.DaoConfig;
|
||||||
|
import ca.uhn.fhir.jpa.model.entity.ModelConfig;
|
||||||
import ca.uhn.fhir.jpa.partition.SystemRequestDetails;
|
import ca.uhn.fhir.jpa.partition.SystemRequestDetails;
|
||||||
import ca.uhn.fhir.jpa.searchparam.SearchParameterMap;
|
import ca.uhn.fhir.jpa.searchparam.SearchParameterMap;
|
||||||
import ca.uhn.fhir.rest.api.server.IBundleProvider;
|
import ca.uhn.fhir.rest.api.server.IBundleProvider;
|
||||||
|
@ -52,12 +53,11 @@ public class FhirResourceDaoCreatePlaceholdersR4Test extends BaseJpaR4Test {
|
||||||
myDaoConfig.setResourceClientIdStrategy(new DaoConfig().getResourceClientIdStrategy());
|
myDaoConfig.setResourceClientIdStrategy(new DaoConfig().getResourceClientIdStrategy());
|
||||||
myDaoConfig.setPopulateIdentifierInAutoCreatedPlaceholderReferenceTargets(new DaoConfig().isPopulateIdentifierInAutoCreatedPlaceholderReferenceTargets());
|
myDaoConfig.setPopulateIdentifierInAutoCreatedPlaceholderReferenceTargets(new DaoConfig().isPopulateIdentifierInAutoCreatedPlaceholderReferenceTargets());
|
||||||
myDaoConfig.setBundleTypesAllowedForStorage(new DaoConfig().getBundleTypesAllowedForStorage());
|
myDaoConfig.setBundleTypesAllowedForStorage(new DaoConfig().getBundleTypesAllowedForStorage());
|
||||||
|
myModelConfig.setAutoVersionReferenceAtPaths(new ModelConfig().getAutoVersionReferenceAtPaths());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testCreateWithBadReferenceFails() {
|
public void testCreateWithBadReferenceFails() {
|
||||||
|
|
||||||
Observation o = new Observation();
|
Observation o = new Observation();
|
||||||
o.setStatus(ObservationStatus.FINAL);
|
o.setStatus(ObservationStatus.FINAL);
|
||||||
o.getSubject().setReference("Patient/FOO");
|
o.getSubject().setReference("Patient/FOO");
|
||||||
|
@ -101,27 +101,28 @@ public class FhirResourceDaoCreatePlaceholdersR4Test extends BaseJpaR4Test {
|
||||||
params.add(Task.SP_PART_OF, new ReferenceParam("Task/AAA"));
|
params.add(Task.SP_PART_OF, new ReferenceParam("Task/AAA"));
|
||||||
List<String> found = toUnqualifiedVersionlessIdValues(myTaskDao.search(params));
|
List<String> found = toUnqualifiedVersionlessIdValues(myTaskDao.search(params));
|
||||||
assertThat(found, contains(id.getValue()));
|
assertThat(found, contains(id.getValue()));
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testUpdateWithBadReferenceFails() {
|
public void testUpdateWithBadReferenceFails() {
|
||||||
|
Observation o1 = new Observation();
|
||||||
|
o1.setStatus(ObservationStatus.FINAL);
|
||||||
|
IIdType id = myObservationDao.create(o1, mySrd).getId();
|
||||||
|
|
||||||
Observation o = new Observation();
|
Observation o = new Observation();
|
||||||
o.setStatus(ObservationStatus.FINAL);
|
|
||||||
IIdType id = myObservationDao.create(o, mySrd).getId();
|
|
||||||
|
|
||||||
o = new Observation();
|
|
||||||
o.setId(id);
|
o.setId(id);
|
||||||
o.setStatus(ObservationStatus.FINAL);
|
o.setStatus(ObservationStatus.FINAL);
|
||||||
o.getSubject().setReference("Patient/FOO");
|
o.getSubject().setReference("Patient/FOO");
|
||||||
try {
|
|
||||||
|
Assertions.assertThrows(InvalidRequestException.class, () -> {
|
||||||
myObservationDao.update(o, mySrd);
|
myObservationDao.update(o, mySrd);
|
||||||
fail();
|
});
|
||||||
} catch (InvalidRequestException e) {
|
// try {
|
||||||
assertThat(e.getMessage(), startsWith("Resource Patient/FOO not found, specified in path: Observation.subject"));
|
//
|
||||||
}
|
// fail();
|
||||||
|
// } catch (InvalidRequestException e) {
|
||||||
|
// assertThat(e.getMessage(), startsWith("Resource Patient/FOO not found, specified in path: Observation.subject"));
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -454,8 +455,6 @@ public class FhirResourceDaoCreatePlaceholdersR4Test extends BaseJpaR4Test {
|
||||||
ourLog.info("\nObservation read after Patient update:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(createdObs));
|
ourLog.info("\nObservation read after Patient update:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(createdObs));
|
||||||
assertEquals(createdObs.getSubject().getReference(), conditionalUpdatePatId.toUnqualifiedVersionless().getValueAsString());
|
assertEquals(createdObs.getSubject().getReference(), conditionalUpdatePatId.toUnqualifiedVersionless().getValueAsString());
|
||||||
assertEquals(placeholderPatId.toUnqualifiedVersionless().getValueAsString(), conditionalUpdatePatId.toUnqualifiedVersionless().getValueAsString());
|
assertEquals(placeholderPatId.toUnqualifiedVersionless().getValueAsString(), conditionalUpdatePatId.toUnqualifiedVersionless().getValueAsString());
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -566,7 +565,6 @@ public class FhirResourceDaoCreatePlaceholdersR4Test extends BaseJpaR4Test {
|
||||||
Observation createdObs = myObservationDao.read(id);
|
Observation createdObs = myObservationDao.read(id);
|
||||||
ourLog.info(myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(createdObs));
|
ourLog.info(myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(createdObs));
|
||||||
assertEquals("Patient/ABC", createdObs.getSubject().getReference());
|
assertEquals("Patient/ABC", createdObs.getSubject().getReference());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -590,7 +588,6 @@ public class FhirResourceDaoCreatePlaceholdersR4Test extends BaseJpaR4Test {
|
||||||
@Test
|
@Test
|
||||||
public void testAutocreatePlaceholderWithTargetExistingAlreadyTest() {
|
public void testAutocreatePlaceholderWithTargetExistingAlreadyTest() {
|
||||||
myDaoConfig.setAutoCreatePlaceholderReferenceTargets(true);
|
myDaoConfig.setAutoCreatePlaceholderReferenceTargets(true);
|
||||||
|
|
||||||
myModelConfig.setAutoVersionReferenceAtPaths("Observation.subject");
|
myModelConfig.setAutoVersionReferenceAtPaths("Observation.subject");
|
||||||
|
|
||||||
String patientId = "Patient/RED";
|
String patientId = "Patient/RED";
|
||||||
|
|
Loading…
Reference in New Issue