diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4ReferentialIntegrityTest.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4ReferentialIntegrityTest.java index 3c3de290a30..53b44b63fd0 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4ReferentialIntegrityTest.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4ReferentialIntegrityTest.java @@ -21,6 +21,7 @@ public class FhirResourceDaoR4ReferentialIntegrityTest extends BaseJpaR4Test { public void afterResetConfig() { myDaoConfig.setEnforceReferentialIntegrityOnWrite(new DaoConfig().isEnforceReferentialIntegrityOnWrite()); myDaoConfig.setEnforceReferentialIntegrityOnDelete(new DaoConfig().isEnforceReferentialIntegrityOnDelete()); + myDaoConfig.setEnforceReferenceTargetTypes(new DaoConfig().isEnforceReferenceTargetTypes()); } @Test @@ -38,7 +39,7 @@ public class FhirResourceDaoR4ReferentialIntegrityTest extends BaseJpaR4Test { } @Test - public void testCreateUnknownReferenceAllow() throws Exception { + public void testCreateUnknownReferenceAllowed() { myDaoConfig.setEnforceReferentialIntegrityOnWrite(false); Patient p = new Patient(); @@ -50,6 +51,20 @@ public class FhirResourceDaoR4ReferentialIntegrityTest extends BaseJpaR4Test { } + @Test + public void testCreateUnknownReferenceAllowed_NumericId() { + myDaoConfig.setEnforceReferentialIntegrityOnWrite(false); + myDaoConfig.setEnforceReferenceTargetTypes(false); + + Patient p = new Patient(); + p.setManagingOrganization(new Reference("Organization/123")); + IIdType id = myPatientDao.create(p).getId().toUnqualifiedVersionless(); + + p = myPatientDao.read(id); + assertEquals("Organization/123", p.getManagingOrganization().getReference()); + + } + @Test public void testDeleteFail() throws Exception { Organization o = new Organization();