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

View File

@ -451,6 +451,80 @@ public class FhirResourceDaoDstu3SearchCustomSearchParamTest extends BaseJpaDstu
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
public void testSearchForExtensionReferenceWithNonMatchingTarget() {
SearchParameter siblingSp = new SearchParameter();

View File

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

View File

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

View File

@ -133,6 +133,10 @@
<![CDATA[<br/><br/>]]>
A corresponding flag has been added to the CLI tool as well.
</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 version="2.4" date="2017-04-19">
<action type="add">