Fix broken tests

This commit is contained in:
James Agnew 2017-05-24 15:50:53 -04:00
parent fcc04a8998
commit 32de48f392
5 changed files with 103 additions and 26 deletions

View File

@ -60,7 +60,7 @@ public class SearchParamExtractorDstu3 extends BaseSearchParamExtractor implemen
@Autowired @Autowired
private org.hl7.fhir.dstu3.hapi.validation.IValidationSupport myValidationSupport; private org.hl7.fhir.dstu3.hapi.validation.IValidationSupport myValidationSupport;
/** /**
* Constructor * Constructor
*/ */
@ -130,11 +130,6 @@ public class SearchParamExtractorDstu3 extends BaseSearchParamExtractor implemen
if (nextObject == null) { if (nextObject == null) {
continue; continue;
} }
if (nextObject instanceof Extension) {
Extension nextExtension = (Extension)nextObject;
nextObject = nextExtension.getValue();
}
ResourceIndexedSearchParamDate nextEntity; ResourceIndexedSearchParamDate nextEntity;
if (nextObject instanceof BaseDateTimeType) { if (nextObject instanceof BaseDateTimeType) {
@ -314,7 +309,7 @@ public class SearchParamExtractorDstu3 extends BaseSearchParamExtractor implemen
Quantity nextValue = (Quantity) nextObject; Quantity nextValue = (Quantity) nextObject;
addQuantity(theEntity, retVal, resourceName, nextValue); addQuantity(theEntity, retVal, resourceName, nextValue);
} else if (nextObject instanceof Range) { } else if (nextObject instanceof Range) {
Range nextValue = (Range)nextObject; Range nextValue = (Range) nextObject;
addQuantity(theEntity, retVal, resourceName, nextValue.getLow()); addQuantity(theEntity, retVal, resourceName, nextValue.getLow());
addQuantity(theEntity, retVal, resourceName, nextValue.getHigh()); addQuantity(theEntity, retVal, resourceName, nextValue.getHigh());
} else if (nextObject instanceof LocationPositionComponent) { } else if (nextObject instanceof LocationPositionComponent) {
@ -365,15 +360,15 @@ public class SearchParamExtractorDstu3 extends BaseSearchParamExtractor implemen
if (isBlank(nextPath)) { if (isBlank(nextPath)) {
// // TODO: implement phonetic, and any others that have no path // // TODO: implement phonetic, and any others that have no path
// //
// // TODO: do we still need this check? // // TODO: do we still need this check?
// if ("Questionnaire".equals(nextSpName) && nextSpDef.getName().equals("title")) { // if ("Questionnaire".equals(nextSpName) && nextSpDef.getName().equals("title")) {
// Questionnaire q = (Questionnaire) theResource; // Questionnaire q = (Questionnaire) theResource;
// String title = "";// q.getGroup().getTitle(); // String title = "";// q.getGroup().getTitle();
// addSearchTerm(theEntity, retVal, nextSpName, title); // addSearchTerm(theEntity, retVal, nextSpName, title);
// } // }
continue; continue;
} }
@ -487,18 +482,12 @@ public class SearchParamExtractorDstu3 extends BaseSearchParamExtractor implemen
// needContactPointSystem = "email"; // needContactPointSystem = "email";
// } // }
for (Object nextObject : extractValues(nextPath, theResource)) { for (Object nextObject : extractValues(nextPath, theResource)) {
if (nextObject instanceof Extension) {
Extension nextExtension = (Extension)nextObject;
nextObject = nextExtension.getValue();
}
if (nextObject == null) { if (nextObject == null) {
continue; continue;
} }
// Patient:language // Patient:language
if (nextObject instanceof PatientCommunicationComponent) { if (nextObject instanceof PatientCommunicationComponent) {
PatientCommunicationComponent nextValue = (PatientCommunicationComponent) nextObject; PatientCommunicationComponent nextValue = (PatientCommunicationComponent) nextObject;
@ -707,6 +696,16 @@ public class SearchParamExtractorDstu3 extends BaseSearchParamExtractor implemen
} catch (FHIRException e) { } catch (FHIRException e) {
throw new InternalErrorException(e); throw new InternalErrorException(e);
} }
for (int i = 0; i < values.size(); i++) {
Object nextObject = values.get(i);
if (nextObject instanceof Extension) {
Extension nextExtension = (Extension) nextObject;
nextObject = nextExtension.getValue();
values.set(i, nextObject);
}
}
return values; return values;
} }

View File

@ -451,6 +451,80 @@ public class FhirResourceDaoDstu3SearchCustomSearchParamTest extends BaseJpaDstu
assertThat(foundResources, contains(p2id.getValue())); assertThat(foundResources, contains(p2id.getValue()));
} }
@Test
public void testSearchForExtensionTwoDeepNumber() {
SearchParameter siblingSp = new SearchParameter();
siblingSp.addBase("Patient");
siblingSp.setCode("foobar");
siblingSp.setType(org.hl7.fhir.dstu3.model.Enumerations.SearchParamType.NUMBER);
siblingSp.setTitle("FooBar");
siblingSp.setExpression("Patient.extension('http://acme.org/foo').extension('http://acme.org/bar')");
siblingSp.setXpathUsage(org.hl7.fhir.dstu3.model.SearchParameter.XPathUsageType.NORMAL);
siblingSp.setStatus(org.hl7.fhir.dstu3.model.Enumerations.PublicationStatus.ACTIVE);
mySearchParameterDao.create(siblingSp, mySrd);
mySearchParamRegsitry.forceRefresh();
Patient patient = new Patient();
patient.addName().setFamily("P2");
Extension extParent = patient
.addExtension()
.setUrl("http://acme.org/foo");
extParent
.addExtension()
.setUrl("http://acme.org/bar")
.setValue(new IntegerType(5));
IIdType p2id = myPatientDao.create(patient).getId().toUnqualifiedVersionless();
SearchParameterMap map;
IBundleProvider results;
List<String> foundResources;
map = new SearchParameterMap();
map.add("foobar", new NumberParam("5"));
results = myPatientDao.search(map);
foundResources = toUnqualifiedVersionlessIdValues(results);
assertThat(foundResources, contains(p2id.getValue()));
}
@Test
public void testSearchForExtensionTwoDeepString() {
SearchParameter siblingSp = new SearchParameter();
siblingSp.addBase("Patient");
siblingSp.setCode("foobar");
siblingSp.setType(org.hl7.fhir.dstu3.model.Enumerations.SearchParamType.STRING);
siblingSp.setTitle("FooBar");
siblingSp.setExpression("Patient.extension('http://acme.org/foo').extension('http://acme.org/bar')");
siblingSp.setXpathUsage(org.hl7.fhir.dstu3.model.SearchParameter.XPathUsageType.NORMAL);
siblingSp.setStatus(org.hl7.fhir.dstu3.model.Enumerations.PublicationStatus.ACTIVE);
mySearchParameterDao.create(siblingSp, mySrd);
mySearchParamRegsitry.forceRefresh();
Patient patient = new Patient();
patient.addName().setFamily("P2");
Extension extParent = patient
.addExtension()
.setUrl("http://acme.org/foo");
extParent
.addExtension()
.setUrl("http://acme.org/bar")
.setValue(new StringType("HELLOHELLO"));
IIdType p2id = myPatientDao.create(patient).getId().toUnqualifiedVersionless();
SearchParameterMap map;
IBundleProvider results;
List<String> foundResources;
map = new SearchParameterMap();
map.add("foobar", new StringParam("hello"));
results = myPatientDao.search(map);
foundResources = toUnqualifiedVersionlessIdValues(results);
assertThat(foundResources, contains(p2id.getValue()));
}
@Test @Test
public void testSearchForExtensionReferenceWithNonMatchingTarget() { public void testSearchForExtensionReferenceWithNonMatchingTarget() {
SearchParameter siblingSp = new SearchParameter(); SearchParameter siblingSp = new SearchParameter();

View File

@ -1280,7 +1280,7 @@ public class ResourceProviderDstu2Test extends BaseResourceProviderDstu2Test {
ourLog.info(output); ourLog.info(output);
List<IdDt> ids = toIdListUnqualifiedVersionless(myFhirCtx.newXmlParser().parseBundle(output)); List<IdDt> ids = toIdListUnqualifiedVersionless(myFhirCtx.newXmlParser().parseBundle(output));
ourLog.info(ids.toString()); ourLog.info(ids.toString());
assertThat(ids, containsInAnyOrder(cId)); assertThat(ids, containsInAnyOrder(pId, cId));
} finally { } finally {
response.close(); response.close();
} }

View File

@ -1520,7 +1520,7 @@ public class ResourceProviderDstu3Test extends BaseResourceProviderDstu3Test {
ourLog.info(output); ourLog.info(output);
List<IIdType> ids = toUnqualifiedVersionlessIds(myFhirCtx.newXmlParser().parseResource(Bundle.class, output)); List<IIdType> ids = toUnqualifiedVersionlessIds(myFhirCtx.newXmlParser().parseResource(Bundle.class, output));
ourLog.info(ids.toString()); ourLog.info(ids.toString());
assertThat(ids, containsInAnyOrder(cId)); assertThat(ids, containsInAnyOrder(pId, cId));
} finally { } finally {
response.close(); response.close();
} }
@ -1594,7 +1594,7 @@ public class ResourceProviderDstu3Test extends BaseResourceProviderDstu3Test {
ourLog.info(myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(responseBundle)); ourLog.info(myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(responseBundle));
assertEquals(23, responseBundle.getEntry().size()); assertEquals(22, responseBundle.getEntry().size());
TreeSet<String> ids = new TreeSet<String>(); TreeSet<String> ids = new TreeSet<String>();
for (int i = 0; i < responseBundle.getEntry().size(); i++) { for (int i = 0; i < responseBundle.getEntry().size(); i++) {

View File

@ -133,6 +133,10 @@
<![CDATA[<br/><br/>]]> <![CDATA[<br/><br/>]]>
A corresponding flag has been added to the CLI tool as well. A corresponding flag has been added to the CLI tool as well.
</action> </action>
<action type="fix">
JPA server did not correctly support searching on a custom search parameter whose
path pointed to an extension, where the client used a chained value.
</action>
</release> </release>
<release version="2.4" date="2017-04-19"> <release version="2.4" date="2017-04-19">
<action type="add"> <action type="add">