From 328541f53736304b2476ebd33599e4e7ba4645ac Mon Sep 17 00:00:00 2001 From: James Agnew Date: Sun, 1 Jul 2018 12:57:05 -0400 Subject: [PATCH] Test fix --- ...ourceDaoR4SearchCustomSearchParamTest.java | 91 ++++++++++--------- 1 file changed, 48 insertions(+), 43 deletions(-) diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4SearchCustomSearchParamTest.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4SearchCustomSearchParamTest.java index 12cf0b369de..df59b11e7f8 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4SearchCustomSearchParamTest.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4SearchCustomSearchParamTest.java @@ -175,48 +175,6 @@ public class FhirResourceDaoR4SearchCustomSearchParamTest extends BaseJpaR4Test assertThat(ids, contains(pid.getValue())); } - @Test - public void testSearchParameterDescendsIntoContainedResource() { - SearchParameter sp = new SearchParameter(); - sp.addBase("Observation"); - sp.setCode("specimencollectedtime"); - sp.setType(Enumerations.SearchParamType.DATE); - sp.setTitle("Observation Specimen Collected Time"); - sp.setExpression("Observation.specimen.resolve().receivedTime"); - sp.setXpathUsage(org.hl7.fhir.r4.model.SearchParameter.XPathUsageType.NORMAL); - sp.setStatus(org.hl7.fhir.r4.model.Enumerations.PublicationStatus.ACTIVE); - mySearchParameterDao.create(sp); - - mySearchParamRegsitry.forceRefresh(); - - Specimen specimen = new Specimen(); - specimen.setId("#FOO"); - specimen.setReceivedTimeElement(new DateTimeType("2011-01-01")); - Observation o = new Observation(); - o.setId("O1"); - o.getContained().add(specimen); - o.setStatus(Observation.ObservationStatus.FINAL); - o.setSpecimen(new Reference("#FOO")); - myObservationDao.update(o); - - specimen = new Specimen(); - specimen.setId("#FOO"); - specimen.setReceivedTimeElement(new DateTimeType("2011-01-03")); - o = new Observation(); - o.setId("O2"); - o.getContained().add(specimen); - o.setStatus(Observation.ObservationStatus.FINAL); - o.setSpecimen(new Reference("#FOO")); - myObservationDao.update(o); - - SearchParameterMap params = new SearchParameterMap(); - params.add("specimencollectedtime", new DateParam("2011-01-01")); - IBundleProvider outcome = myObservationDao.search(params); - List ids = toUnqualifiedVersionlessIdValues(outcome); - ourLog.info("IDS: " + ids); - assertThat(ids, contains("Observation/O1")); - } - @Test public void testExtensionWithNoValueIndexesWithoutFailure() { SearchParameter eyeColourSp = new SearchParameter(); @@ -397,7 +355,6 @@ public class FhirResourceDaoR4SearchCustomSearchParamTest extends BaseJpaR4Test assertThat(results, contains(mrId)); } - /** * See #863 */ @@ -751,6 +708,12 @@ public class FhirResourceDaoR4SearchCustomSearchParamTest extends BaseJpaR4Test @Override protected void doInTransactionWithoutResult(TransactionStatus theArg0) { mySearchParameterDao.create(siblingSp, mySrd); + } + }); + + txTemplate.execute(new TransactionCallbackWithoutResult() { + @Override + protected void doInTransactionWithoutResult(TransactionStatus theArg0) { mySearchParamRegsitry.forceRefresh(); } }); @@ -1074,6 +1037,48 @@ public class FhirResourceDaoR4SearchCustomSearchParamTest extends BaseJpaR4Test } + @Test + public void testSearchParameterDescendsIntoContainedResource() { + SearchParameter sp = new SearchParameter(); + sp.addBase("Observation"); + sp.setCode("specimencollectedtime"); + sp.setType(Enumerations.SearchParamType.DATE); + sp.setTitle("Observation Specimen Collected Time"); + sp.setExpression("Observation.specimen.resolve().receivedTime"); + sp.setXpathUsage(org.hl7.fhir.r4.model.SearchParameter.XPathUsageType.NORMAL); + sp.setStatus(org.hl7.fhir.r4.model.Enumerations.PublicationStatus.ACTIVE); + mySearchParameterDao.create(sp); + + mySearchParamRegsitry.forceRefresh(); + + Specimen specimen = new Specimen(); + specimen.setId("#FOO"); + specimen.setReceivedTimeElement(new DateTimeType("2011-01-01")); + Observation o = new Observation(); + o.setId("O1"); + o.getContained().add(specimen); + o.setStatus(Observation.ObservationStatus.FINAL); + o.setSpecimen(new Reference("#FOO")); + myObservationDao.update(o); + + specimen = new Specimen(); + specimen.setId("#FOO"); + specimen.setReceivedTimeElement(new DateTimeType("2011-01-03")); + o = new Observation(); + o.setId("O2"); + o.getContained().add(specimen); + o.setStatus(Observation.ObservationStatus.FINAL); + o.setSpecimen(new Reference("#FOO")); + myObservationDao.update(o); + + SearchParameterMap params = new SearchParameterMap(); + params.add("specimencollectedtime", new DateParam("2011-01-01")); + IBundleProvider outcome = myObservationDao.search(params); + List ids = toUnqualifiedVersionlessIdValues(outcome); + ourLog.info("IDS: " + ids); + assertThat(ids, contains("Observation/O1")); + } + @Test public void testSearchWithCustomParam() {