diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/BaseHapiFhirDao.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/BaseHapiFhirDao.java index 6c40ea27aa8..9285b207d59 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/BaseHapiFhirDao.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/BaseHapiFhirDao.java @@ -796,6 +796,7 @@ public abstract class BaseHapiFhirDao implements IDao { } + @SuppressWarnings("unchecked") private R populateResourceMetadataHapi(Class theResourceType, BaseHasResource theEntity, boolean theForHistoryOperation, IResource res) { R retVal = (R) res; if (theEntity.getDeleted() != null) { @@ -866,6 +867,7 @@ public abstract class BaseHapiFhirDao implements IDao { return retVal; } + @SuppressWarnings("unchecked") private R populateResourceMetadataRi(Class theResourceType, BaseHasResource theEntity, boolean theForHistoryOperation, IAnyResource res) { R retVal = (R) res; if (theEntity.getDeleted() != null) { @@ -936,6 +938,7 @@ public abstract class BaseHapiFhirDao implements IDao { * @return Returns true if the tag should be removed * @see Updates to Tags, Profiles, and Security Labels for a description of the logic that the default behaviour folows. */ + @SuppressWarnings("unused") protected void postPersist(ResourceTable theEntity, T theResource) { // nothing } @@ -968,6 +971,8 @@ public abstract class BaseHapiFhirDao implements IDao { return ids; } + @SuppressWarnings("unused") + @CoverageIgnore public BaseHasResource readEntity(IIdType theValueId) { throw new NotImplementedException(""); } @@ -1194,7 +1199,6 @@ public abstract class BaseHapiFhirDao implements IDao { } @Override - @SuppressWarnings("unchecked") public R toResource(Class theResourceType, BaseHasResource theEntity, boolean theForHistoryOperation) { String resourceText = null; switch (theEntity.getEncoding()) { @@ -1563,10 +1567,6 @@ public abstract class BaseHapiFhirDao implements IDao { return theEntity; } - protected ResourceTable updateEntity(final IResource theResource, ResourceTable entity, boolean theUpdateHistory, Date theDeletedTimestampOrNull, Date theUpdateTime) { - return updateEntity(theResource, entity, theUpdateHistory, theDeletedTimestampOrNull, true, true, theUpdateTime); - } - protected void validateDeleteConflictsEmptyOrThrowException(List theDeleteConflicts) { if (theDeleteConflicts.isEmpty()) { return; diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/BaseJpaTest.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/BaseJpaTest.java index 14261c933a2..c4e36e56d99 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/BaseJpaTest.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/BaseJpaTest.java @@ -1,8 +1,9 @@ package ca.uhn.fhir.jpa.dao; +import static org.mockito.Mockito.mock; + import java.io.IOException; import java.io.InputStream; -import java.sql.DriverManager; import java.sql.SQLException; import java.util.ArrayList; import java.util.List; @@ -12,21 +13,29 @@ import org.hl7.fhir.dstu3.model.Bundle.BundleEntryComponent; import org.hl7.fhir.instance.model.api.IBaseResource; import org.hl7.fhir.instance.model.api.IIdType; import org.junit.AfterClass; +import org.junit.Before; import ca.uhn.fhir.jpa.provider.SystemProviderDstu2Test; import ca.uhn.fhir.model.dstu2.resource.Bundle; import ca.uhn.fhir.model.dstu2.resource.Bundle.Entry; import ca.uhn.fhir.rest.server.IBundleProvider; +import ca.uhn.fhir.rest.server.servlet.ServletRequestDetails; public class BaseJpaTest { private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(BaseJpaTest.class); + protected ServletRequestDetails mySrd; @SuppressWarnings({ "rawtypes" }) protected List toList(IBundleProvider theSearch) { return theSearch.getResources(0, theSearch.size()); } + @Before + public void beforeCreateSrd() { + mySrd = mock(ServletRequestDetails.class); + } + protected List toUnqualifiedVersionlessIds(Bundle theFound) { List retVal = new ArrayList(); for (Entry next : theFound.getEntry()) { diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu3/FhirResourceDaoDstu3ContainedTest.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu3/FhirResourceDaoDstu3ContainedTest.java index 9fceb615e08..bc8cd77dd02 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu3/FhirResourceDaoDstu3ContainedTest.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu3/FhirResourceDaoDstu3ContainedTest.java @@ -12,6 +12,7 @@ import org.junit.Test; import ca.uhn.fhir.jpa.dao.SearchParameterMap; import ca.uhn.fhir.rest.param.TokenParam; import ca.uhn.fhir.rest.param.TokenParamModifier; +import ca.uhn.fhir.rest.server.servlet.ServletRequestDetails; public class FhirResourceDaoDstu3ContainedTest extends BaseJpaDstu3Test { private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(FhirResourceDaoDstu3ContainedTest.class); @@ -30,16 +31,16 @@ public class FhirResourceDaoDstu3ContainedTest extends BaseJpaDstu3Test { Observation o1 = new Observation(); o1.getCode().setText("Some Observation"); o1.setSubject(new Reference(p)); - IIdType oid1 = myObservationDao.create(o1).getId().toUnqualifiedVersionless(); + IIdType oid1 = myObservationDao.create(o1, new ServletRequestDetails()).getId().toUnqualifiedVersionless(); Observation o2 = new Observation(); o2.getCode().setText("Some Observation"); o2.setSubject(new Reference(p)); - IIdType oid2 = myObservationDao.create(o2).getId().toUnqualifiedVersionless(); + IIdType oid2 = myObservationDao.create(o2, new ServletRequestDetails()).getId().toUnqualifiedVersionless(); Patient p2 = new Patient(); p2.addName().addFamily("MYFAMILY").addGiven("MYGIVEN"); - IIdType pid2 = myPatientDao.create(p2).getId().toUnqualifiedVersionless(); + IIdType pid2 = myPatientDao.create(p2, new ServletRequestDetails()).getId().toUnqualifiedVersionless(); ourLog.info(myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(o2)); diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu3/FhirResourceDaoDstu3SearchFtTest.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu3/FhirResourceDaoDstu3SearchFtTest.java index c6cc058627d..33eff79c03c 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu3/FhirResourceDaoDstu3SearchFtTest.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu3/FhirResourceDaoDstu3SearchFtTest.java @@ -47,13 +47,13 @@ public class FhirResourceDaoDstu3SearchFtTest extends BaseJpaDstu3Test { obs1.setStatus(ObservationStatus.FINAL); obs1.setValue(new Quantity(123)); obs1.setComments("obs1"); - IIdType id1 = myObservationDao.create(obs1, new ServletRequestDetails()).getId().toUnqualifiedVersionless(); + IIdType id1 = myObservationDao.create(obs1, mySrd).getId().toUnqualifiedVersionless(); Observation obs2 = new Observation(); obs2.getCode().setText("Diastolic Blood Pressure"); obs2.setStatus(ObservationStatus.FINAL); obs2.setValue(new Quantity(81)); - IIdType id2 = myObservationDao.create(obs2, new ServletRequestDetails()).getId().toUnqualifiedVersionless(); + IIdType id2 = myObservationDao.create(obs2, mySrd).getId().toUnqualifiedVersionless(); SearchParameterMap map; @@ -72,6 +72,10 @@ public class FhirResourceDaoDstu3SearchFtTest extends BaseJpaDstu3Test { } + private ServletRequestDetails mockSrd() { + return new ServletRequestDetails(); + } + @Test @Ignore public void testStringTextSearch() { @@ -79,13 +83,13 @@ public class FhirResourceDaoDstu3SearchFtTest extends BaseJpaDstu3Test { obs1.getCode().setText("AAAAA"); obs1.setValue(new StringType("Systolic Blood Pressure")); obs1.setStatus(ObservationStatus.FINAL); - IIdType id1 = myObservationDao.create(obs1, new ServletRequestDetails()).getId().toUnqualifiedVersionless(); + IIdType id1 = myObservationDao.create(obs1, mockSrd()).getId().toUnqualifiedVersionless(); Observation obs2 = new Observation(); obs1.getCode().setText("AAAAA"); obs1.setValue(new StringType("Diastolic Blood Pressure")); obs2.setStatus(ObservationStatus.FINAL); - IIdType id2 = myObservationDao.create(obs2, new ServletRequestDetails()).getId().toUnqualifiedVersionless(); + IIdType id2 = myObservationDao.create(obs2, mockSrd()).getId().toUnqualifiedVersionless(); SearchParameterMap map; @@ -100,7 +104,7 @@ public class FhirResourceDaoDstu3SearchFtTest extends BaseJpaDstu3Test { public void testSuggestIgnoresBase64Content() { Patient patient = new Patient(); patient.addName().addFamily("testSuggest"); - IIdType ptId = myPatientDao.create(patient, new ServletRequestDetails()).getId().toUnqualifiedVersionless(); + IIdType ptId = myPatientDao.create(patient, mockSrd()).getId().toUnqualifiedVersionless(); Media med = new Media(); med.getSubject().setReferenceElement(ptId); @@ -108,7 +112,7 @@ public class FhirResourceDaoDstu3SearchFtTest extends BaseJpaDstu3Test { med.getContent().setContentType("LCws"); med.getContent().setDataElement(new Base64BinaryType(new byte[] {44,44,44,44,44,44,44,44})); med.getContent().setTitle("bbbb syst"); - myMediaDao.create(med, new ServletRequestDetails()); + myMediaDao.create(med, mockSrd()); ourLog.info(myFhirCtx.newJsonParser().encodeResourceToString(med)); List output = mySearchDao.suggestKeywords("Patient/" + ptId.getIdPart() + "/$everything", "_content", "press"); @@ -140,35 +144,35 @@ public class FhirResourceDaoDstu3SearchFtTest extends BaseJpaDstu3Test { public void testSuggest() { Patient patient = new Patient(); patient.addName().addFamily("testSuggest"); - IIdType ptId = myPatientDao.create(patient, new ServletRequestDetails()).getId().toUnqualifiedVersionless(); + IIdType ptId = myPatientDao.create(patient, mockSrd()).getId().toUnqualifiedVersionless(); Observation obs = new Observation(); obs.getSubject().setReferenceElement(ptId); obs.getCode().setText("ZXCVBNM ASDFGHJKL QWERTYUIOPASDFGHJKL"); - myObservationDao.create(obs, new ServletRequestDetails()); + myObservationDao.create(obs, mockSrd()); obs = new Observation(); obs.getSubject().setReferenceElement(ptId); obs.getCode().setText("MNBVCXZ"); - myObservationDao.create(obs, new ServletRequestDetails()); + myObservationDao.create(obs, mockSrd()); obs = new Observation(); obs.getSubject().setReferenceElement(ptId); obs.getCode().setText("ZXC HELLO"); obs.addComponent().getCode().setText("HHHHHHHHHH"); - myObservationDao.create(obs, new ServletRequestDetails()); + myObservationDao.create(obs, mockSrd()); /* * These shouldn't match since they're for another patient */ patient = new Patient(); patient.addName().addFamily("testSuggest2"); - IIdType ptId2 = myPatientDao.create(patient, new ServletRequestDetails()).getId().toUnqualifiedVersionless(); + IIdType ptId2 = myPatientDao.create(patient, mockSrd()).getId().toUnqualifiedVersionless(); Observation obs2 = new Observation(); obs2.getSubject().setReferenceElement(ptId2); obs2.getCode().setText("ZXCVBNMZZ"); - myObservationDao.create(obs2, new ServletRequestDetails()); + myObservationDao.create(obs2, mockSrd()); List output = mySearchDao.suggestKeywords("Patient/" + ptId.getIdPart() + "/$everything", "_content", "ZXCVBNM"); ourLog.info("Found: " + output); @@ -213,7 +217,7 @@ public class FhirResourceDaoDstu3SearchFtTest extends BaseJpaDstu3Test { patient = new Patient(); patient.getText().setDivAsString("
DIVAAA
"); patient.addName().addGiven("NAMEAAA"); - IIdType pId1 = myPatientDao.create(patient, new ServletRequestDetails()).getId().toUnqualifiedVersionless(); + IIdType pId1 = myPatientDao.create(patient, mockSrd()).getId().toUnqualifiedVersionless(); map = new SearchParameterMap(); map.add(Constants.PARAM_CONTENT, new StringParam("NAMEAAA")); @@ -231,7 +235,7 @@ public class FhirResourceDaoDstu3SearchFtTest extends BaseJpaDstu3Test { patient.setId(pId1); patient.getText().setDivAsString("
DIVBBB
"); patient.addName().addGiven("NAMEBBB"); - myPatientDao.update(patient, new ServletRequestDetails()); + myPatientDao.update(patient, mockSrd()); map = new SearchParameterMap(); map.add(Constants.PARAM_CONTENT, new StringParam("NAMEAAA")); @@ -255,19 +259,19 @@ public class FhirResourceDaoDstu3SearchFtTest extends BaseJpaDstu3Test { public void testEverythingInstanceWithContentFilter() { Patient pt1 = new Patient(); pt1.addName().addFamily("Everything").addGiven("Arthur"); - IIdType ptId1 = myPatientDao.create(pt1, new ServletRequestDetails()).getId().toUnqualifiedVersionless(); + IIdType ptId1 = myPatientDao.create(pt1, mockSrd()).getId().toUnqualifiedVersionless(); Patient pt2 = new Patient(); pt2.addName().addFamily("Everything").addGiven("Arthur"); - IIdType ptId2 = myPatientDao.create(pt2, new ServletRequestDetails()).getId().toUnqualifiedVersionless(); + IIdType ptId2 = myPatientDao.create(pt2, mockSrd()).getId().toUnqualifiedVersionless(); Device dev1 = new Device(); dev1.setManufacturer("Some Manufacturer"); - IIdType devId1 = myDeviceDao.create(dev1, new ServletRequestDetails()).getId().toUnqualifiedVersionless(); + IIdType devId1 = myDeviceDao.create(dev1, mockSrd()).getId().toUnqualifiedVersionless(); Device dev2 = new Device(); dev2.setManufacturer("Some Manufacturer 2"); - myDeviceDao.create(dev2, new ServletRequestDetails()).getId().toUnqualifiedVersionless(); + myDeviceDao.create(dev2, mockSrd()).getId().toUnqualifiedVersionless(); Observation obs1 = new Observation(); obs1.getText().setDivAsString("
OBSTEXT1
"); @@ -275,19 +279,19 @@ public class FhirResourceDaoDstu3SearchFtTest extends BaseJpaDstu3Test { obs1.getCode().addCoding().setCode("CODE1"); obs1.setValue(new StringType("obsvalue1")); obs1.getDevice().setReferenceElement(devId1); - IIdType obsId1 = myObservationDao.create(obs1, new ServletRequestDetails()).getId().toUnqualifiedVersionless(); + IIdType obsId1 = myObservationDao.create(obs1, mockSrd()).getId().toUnqualifiedVersionless(); Observation obs2 = new Observation(); obs2.getSubject().setReferenceElement(ptId1); obs2.getCode().addCoding().setCode("CODE2"); obs2.setValue(new StringType("obsvalue2")); - IIdType obsId2 = myObservationDao.create(obs2, new ServletRequestDetails()).getId().toUnqualifiedVersionless(); + IIdType obsId2 = myObservationDao.create(obs2, mockSrd()).getId().toUnqualifiedVersionless(); Observation obs3 = new Observation(); obs3.getSubject().setReferenceElement(ptId2); obs3.getCode().addCoding().setCode("CODE3"); obs3.setValue(new StringType("obsvalue3")); - IIdType obsId3 = myObservationDao.create(obs3, new ServletRequestDetails()).getId().toUnqualifiedVersionless(); + IIdType obsId3 = myObservationDao.create(obs3, mockSrd()).getId().toUnqualifiedVersionless(); HttpServletRequest request; List actual; @@ -298,16 +302,16 @@ public class FhirResourceDaoDstu3SearchFtTest extends BaseJpaDstu3Test { param = new StringAndListParam(); param.addAnd(new StringOrListParam().addOr(new StringParam("obsvalue1"))); - actual = toUnqualifiedVersionlessIdValues(myPatientDao.patientInstanceEverything(request, ptId1, null, null, null, param, null, new ServletRequestDetails())); + actual = toUnqualifiedVersionlessIdValues(myPatientDao.patientInstanceEverything(request, ptId1, null, null, null, param, null, mockSrd())); assertThat(actual, containsInAnyOrder(toValues(ptId1, obsId1, devId1))); param = new StringAndListParam(); param.addAnd(new StringOrListParam().addOr(new StringParam("obstext1"))); - actual = toUnqualifiedVersionlessIdValues(myPatientDao.patientInstanceEverything(request, ptId1, null, null, null, null, param, new ServletRequestDetails())); + actual = toUnqualifiedVersionlessIdValues(myPatientDao.patientInstanceEverything(request, ptId1, null, null, null, null, param, mockSrd())); assertThat(actual, containsInAnyOrder(toValues(ptId1, obsId1, devId1))); request = mock(HttpServletRequest.class); - actual = toUnqualifiedVersionlessIdValues(myPatientDao.patientInstanceEverything(request, ptId1, null, null, null, null, null, new ServletRequestDetails())); + actual = toUnqualifiedVersionlessIdValues(myPatientDao.patientInstanceEverything(request, ptId1, null, null, null, null, null, mockSrd())); assertThat(actual, containsInAnyOrder(toValues(ptId1, obsId1, obsId2, devId1))); /* @@ -318,12 +322,12 @@ public class FhirResourceDaoDstu3SearchFtTest extends BaseJpaDstu3Test { obs4.getSubject().setReferenceElement(ptId1); obs4.getCode().addCoding().setCode("CODE1"); obs4.setValue(new StringType("obsvalue1")); - IIdType obsId4 = myObservationDao.create(obs4, new ServletRequestDetails()).getId().toUnqualifiedVersionless(); + IIdType obsId4 = myObservationDao.create(obs4, mockSrd()).getId().toUnqualifiedVersionless(); assertNotEquals(obsId1.getIdPart(), obsId4.getIdPart(), devId1); param = new StringAndListParam(); param.addAnd(new StringOrListParam().addOr(new StringParam("obsvalue1"))); - actual = toUnqualifiedVersionlessIdValues(myPatientDao.patientInstanceEverything(request, ptId1, null, null, null, param, null, new ServletRequestDetails())); + actual = toUnqualifiedVersionlessIdValues(myPatientDao.patientInstanceEverything(request, ptId1, null, null, null, param, null, mockSrd())); assertThat(actual, containsInAnyOrder(toValues(ptId1, obsId1, obsId4, devId1))); /* @@ -335,11 +339,11 @@ public class FhirResourceDaoDstu3SearchFtTest extends BaseJpaDstu3Test { obs1.getSubject().setReferenceElement(ptId1); obs1.getCode().addCoding().setCode("CODE2"); obs1.setValue(new StringType("obsvalue2")); - myObservationDao.update(obs1, new ServletRequestDetails()); + myObservationDao.update(obs1, mockSrd()); param = new StringAndListParam(); param.addAnd(new StringOrListParam().addOr(new StringParam("obsvalue1"))); - actual = toUnqualifiedVersionlessIdValues(myPatientDao.patientInstanceEverything(request, ptId1, null, null, null, param, null, new ServletRequestDetails())); + actual = toUnqualifiedVersionlessIdValues(myPatientDao.patientInstanceEverything(request, ptId1, null, null, null, param, null, mockSrd())); assertThat(actual, containsInAnyOrder(toValues(ptId1, obsId4))); } @@ -348,38 +352,38 @@ public class FhirResourceDaoDstu3SearchFtTest extends BaseJpaDstu3Test { public void testEverythingTypeWithContentFilter() { Patient pt1 = new Patient(); pt1.addName().addFamily("Everything").addGiven("Arthur"); - IIdType ptId1 = myPatientDao.create(pt1, new ServletRequestDetails()).getId().toUnqualifiedVersionless(); + IIdType ptId1 = myPatientDao.create(pt1, mockSrd()).getId().toUnqualifiedVersionless(); Patient pt2 = new Patient(); pt2.addName().addFamily("Everything").addGiven("Arthur"); - IIdType ptId2 = myPatientDao.create(pt2, new ServletRequestDetails()).getId().toUnqualifiedVersionless(); + IIdType ptId2 = myPatientDao.create(pt2, mockSrd()).getId().toUnqualifiedVersionless(); Device dev1 = new Device(); dev1.setManufacturer("Some Manufacturer"); - IIdType devId1 = myDeviceDao.create(dev1, new ServletRequestDetails()).getId().toUnqualifiedVersionless(); + IIdType devId1 = myDeviceDao.create(dev1, mockSrd()).getId().toUnqualifiedVersionless(); Device dev2 = new Device(); dev2.setManufacturer("Some Manufacturer 2"); - IIdType devId2 = myDeviceDao.create(dev2, new ServletRequestDetails()).getId().toUnqualifiedVersionless(); + myDeviceDao.create(dev2, mockSrd()).getId().toUnqualifiedVersionless(); Observation obs1 = new Observation(); obs1.getSubject().setReferenceElement(ptId1); obs1.getCode().addCoding().setCode("CODE1"); obs1.setValue(new StringType("obsvalue1")); obs1.getDevice().setReferenceElement(devId1); - IIdType obsId1 = myObservationDao.create(obs1, new ServletRequestDetails()).getId().toUnqualifiedVersionless(); + IIdType obsId1 = myObservationDao.create(obs1, mockSrd()).getId().toUnqualifiedVersionless(); Observation obs2 = new Observation(); obs2.getSubject().setReferenceElement(ptId1); obs2.getCode().addCoding().setCode("CODE2"); obs2.setValue(new StringType("obsvalue2")); - IIdType obsId2 = myObservationDao.create(obs2, new ServletRequestDetails()).getId().toUnqualifiedVersionless(); + IIdType obsId2 = myObservationDao.create(obs2, mockSrd()).getId().toUnqualifiedVersionless(); Observation obs3 = new Observation(); obs3.getSubject().setReferenceElement(ptId2); obs3.getCode().addCoding().setCode("CODE3"); obs3.setValue(new StringType("obsvalue3")); - IIdType obsId3 = myObservationDao.create(obs3, new ServletRequestDetails()).getId().toUnqualifiedVersionless(); + IIdType obsId3 = myObservationDao.create(obs3, mockSrd()).getId().toUnqualifiedVersionless(); HttpServletRequest request; List actual; @@ -390,11 +394,11 @@ public class FhirResourceDaoDstu3SearchFtTest extends BaseJpaDstu3Test { param = new StringAndListParam(); param.addAnd(new StringOrListParam().addOr(new StringParam("obsvalue1"))); - actual = toUnqualifiedVersionlessIdValues(myPatientDao.patientTypeEverything(request, null, null, null, param, null, new ServletRequestDetails())); + actual = toUnqualifiedVersionlessIdValues(myPatientDao.patientTypeEverything(request, null, null, null, param, null, mockSrd())); assertThat(actual, containsInAnyOrder(toValues(ptId1, obsId1, devId1))); request = mock(HttpServletRequest.class); - actual = toUnqualifiedVersionlessIdValues(myPatientDao.patientTypeEverything(request, null, null, null, null, null, new ServletRequestDetails())); + actual = toUnqualifiedVersionlessIdValues(myPatientDao.patientTypeEverything(request, null, null, null, null, null, mockSrd())); assertThat(actual, containsInAnyOrder(toValues(ptId1, obsId1, obsId2, devId1, ptId2, obsId3))); /* @@ -405,12 +409,12 @@ public class FhirResourceDaoDstu3SearchFtTest extends BaseJpaDstu3Test { obs4.getSubject().setReferenceElement(ptId1); obs4.getCode().addCoding().setCode("CODE1"); obs4.setValue(new StringType("obsvalue1")); - IIdType obsId4 = myObservationDao.create(obs4, new ServletRequestDetails()).getId().toUnqualifiedVersionless(); + IIdType obsId4 = myObservationDao.create(obs4, mockSrd()).getId().toUnqualifiedVersionless(); assertNotEquals(obsId1.getIdPart(), obsId4.getIdPart(), devId1); param = new StringAndListParam(); param.addAnd(new StringOrListParam().addOr(new StringParam("obsvalue1"))); - actual = toUnqualifiedVersionlessIdValues(myPatientDao.patientTypeEverything(request, null, null, null, param, null, new ServletRequestDetails())); + actual = toUnqualifiedVersionlessIdValues(myPatientDao.patientTypeEverything(request, null, null, null, param, null, mockSrd())); assertThat(actual, containsInAnyOrder(toValues(ptId1, obsId1, obsId4, devId1))); /* @@ -422,11 +426,11 @@ public class FhirResourceDaoDstu3SearchFtTest extends BaseJpaDstu3Test { obs1.getSubject().setReferenceElement(ptId1); obs1.getCode().addCoding().setCode("CODE2"); obs1.setValue(new StringType("obsvalue2")); - myObservationDao.update(obs1, new ServletRequestDetails()); + myObservationDao.update(obs1, mockSrd()); param = new StringAndListParam(); param.addAnd(new StringOrListParam().addOr(new StringParam("obsvalue1"))); - actual = toUnqualifiedVersionlessIdValues(myPatientDao.patientTypeEverything(request, null, null, null, param, null, new ServletRequestDetails())); + actual = toUnqualifiedVersionlessIdValues(myPatientDao.patientTypeEverything(request, null, null, null, param, null, mockSrd())); assertThat(actual, containsInAnyOrder(toValues(ptId1, obsId4))); } @@ -444,7 +448,7 @@ public class FhirResourceDaoDstu3SearchFtTest extends BaseJpaDstu3Test { patient = new Patient(); patient.getText().setDivAsString("
DIVAAA
"); patient.addName().addGiven("NAMEAAA"); - IIdType pId1 = myPatientDao.create(patient, new ServletRequestDetails()).getId().toUnqualifiedVersionless(); + IIdType pId1 = myPatientDao.create(patient, mockSrd()).getId().toUnqualifiedVersionless(); map = new SearchParameterMap(); map.add(Constants.PARAM_CONTENT, new StringParam("NAMEAAA")); @@ -462,7 +466,7 @@ public class FhirResourceDaoDstu3SearchFtTest extends BaseJpaDstu3Test { patient.setId(pId1); patient.getText().setDivAsString("
DIVBBB
"); patient.addName().addGiven("NAMEBBB"); - myPatientDao.update(patient, null, false, new ServletRequestDetails()); + myPatientDao.update(patient, null, false, mockSrd()); map = new SearchParameterMap(); map.add(Constants.PARAM_CONTENT, new StringParam("NAMEAAA")); @@ -471,7 +475,7 @@ public class FhirResourceDaoDstu3SearchFtTest extends BaseJpaDstu3Test { map.add(Constants.PARAM_CONTENT, new StringParam("NAMEBBB")); assertThat(toUnqualifiedVersionlessIdValues(myPatientDao.search(map)), not(contains(toValues(pId1)))); - myPatientDao.update(patient, null, true, new ServletRequestDetails()); + myPatientDao.update(patient, null, true, mockSrd()); map = new SearchParameterMap(); map.add(Constants.PARAM_CONTENT, new StringParam("NAMEAAA")); @@ -499,18 +503,18 @@ public class FhirResourceDaoDstu3SearchFtTest extends BaseJpaDstu3Test { Patient patient = new Patient(); patient.addName().addGiven(methodName); patient.addAddress().addLine("My fulltext address"); - pId1 = myPatientDao.create(patient, new ServletRequestDetails()).getId().toUnqualifiedVersionless(); + pId1 = myPatientDao.create(patient, mockSrd()).getId().toUnqualifiedVersionless(); } Observation obs = new Observation(); obs.getSubject().setReferenceElement(pId1); obs.setValue(new StringType("This is the FULLtext of the observation")); - IIdType oId1 = myObservationDao.create(obs, new ServletRequestDetails()).getId().toUnqualifiedVersionless(); + IIdType oId1 = myObservationDao.create(obs, mockSrd()).getId().toUnqualifiedVersionless(); obs = new Observation(); obs.getSubject().setReferenceElement(pId1); obs.setValue(new StringType("Another fullText")); - IIdType oId2 = myObservationDao.create(obs, new ServletRequestDetails()).getId().toUnqualifiedVersionless(); + IIdType oId2 = myObservationDao.create(obs, mockSrd()).getId().toUnqualifiedVersionless(); List patients; SearchParameterMap params; diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu3/FhirResourceDaoDstu3SearchNoFtTest.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu3/FhirResourceDaoDstu3SearchNoFtTest.java index cfad4424cb2..1c3df054e74 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu3/FhirResourceDaoDstu3SearchNoFtTest.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu3/FhirResourceDaoDstu3SearchNoFtTest.java @@ -51,6 +51,7 @@ import org.hl7.fhir.dstu3.model.Subscription.SubscriptionStatus; import org.hl7.fhir.dstu3.model.Substance; import org.hl7.fhir.dstu3.model.TemporalPrecisionEnum; import org.hl7.fhir.dstu3.model.ValueSet; +import org.hl7.fhir.instance.model.api.IAnyResource; import org.hl7.fhir.instance.model.api.IBaseResource; import org.hl7.fhir.instance.model.api.IIdType; import org.junit.Ignore; @@ -67,6 +68,7 @@ import ca.uhn.fhir.jpa.entity.ResourceIndexedSearchParamUri; import ca.uhn.fhir.jpa.entity.ResourceLink; import ca.uhn.fhir.model.api.IQueryParameterType; import ca.uhn.fhir.model.api.Include; +import ca.uhn.fhir.model.dstu.valueset.QuantityCompararatorEnum; import ca.uhn.fhir.rest.api.SortOrderEnum; import ca.uhn.fhir.rest.api.SortSpec; import ca.uhn.fhir.rest.param.CompositeParam; diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu3/FhirSystemDaoDstu3Test.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu3/FhirSystemDaoDstu3Test.java index eb39585b3f3..f79375cd079 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu3/FhirSystemDaoDstu3Test.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu3/FhirSystemDaoDstu3Test.java @@ -322,7 +322,7 @@ public class FhirSystemDaoDstu3Test extends BaseJpaDstu3SystemTest { Patient p = new Patient(); p.addIdentifier().setSystem("urn:system").setValue(methodName); p.setId("Patient/" + methodName); - IIdType id = myPatientDao.update(p).getId(); + IIdType id = myPatientDao.update(p, mySrd).getId(); ourLog.info("Created patient, got it: {}", id); Observation o = new Observation(); @@ -339,7 +339,7 @@ public class FhirSystemDaoDstu3Test extends BaseJpaDstu3SystemTest { assertThat(respEntry.getResponse().getLocation(), endsWith("/_history/1")); assertEquals("1", respEntry.getResponse().getEtag()); - o = myObservationDao.read(new IdType(respEntry.getResponse().getLocationElement())); + o = myObservationDao.read(new IdType(respEntry.getResponse().getLocationElement()), mySrd); assertEquals(id.toVersionless().getValue(), o.getSubject().getReference()); assertEquals("1", o.getIdElement().getVersionIdPart()); @@ -354,11 +354,11 @@ public class FhirSystemDaoDstu3Test extends BaseJpaDstu3SystemTest { Patient p = new Patient(); p.addIdentifier().setSystem("urn:system").setValue(methodName); - myPatientDao.create(p).getId(); + myPatientDao.create(p, mySrd).getId(); p = new Patient(); p.addIdentifier().setSystem("urn:system").setValue(methodName); - myPatientDao.create(p).getId(); + myPatientDao.create(p, mySrd).getId(); Observation o = new Observation(); o.getCode().setText("Some Observation"); @@ -382,11 +382,11 @@ public class FhirSystemDaoDstu3Test extends BaseJpaDstu3SystemTest { Patient p = new Patient(); p.addIdentifier().setSystem("urn:system").setValue(methodName); - myPatientDao.create(p).getId(); + myPatientDao.create(p, mySrd).getId(); p = new Patient(); p.addIdentifier().setSystem("urn:system").setValue(methodName); - myPatientDao.create(p).getId(); + myPatientDao.create(p, mySrd).getId(); Observation o = new Observation(); o.getCode().setText("Some Observation"); diff --git a/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/server/DynamicSearchTest.java b/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/server/DynamicSearchTest.java index 63d06a264b1..a72e55159d0 100644 --- a/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/server/DynamicSearchTest.java +++ b/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/server/DynamicSearchTest.java @@ -173,8 +173,8 @@ public class DynamicSearchTest { @Override public List getSearchParameters() { ArrayList retVal = new ArrayList(); - retVal.add(new RuntimeSearchParam("param1", "This is the first parameter", "Patient.param1", RestSearchParameterTypeEnum.STRING)); - retVal.add(new RuntimeSearchParam("param2", "This is the second parameter", "Patient.param2", RestSearchParameterTypeEnum.DATE)); + retVal.add(new RuntimeSearchParam("param1", "This is the first parameter", "Patient.param1", RestSearchParameterTypeEnum.STRING, null)); + retVal.add(new RuntimeSearchParam("param2", "This is the second parameter", "Patient.param2", RestSearchParameterTypeEnum.DATE, null)); return retVal; }