Add some tests

This commit is contained in:
James Agnew 2018-01-11 09:26:28 -05:00
parent d375977410
commit f58a03dacf
4 changed files with 28 additions and 0 deletions

View File

@ -373,6 +373,11 @@ public class DaoConfig {
* This feature may be enabled on servers where supporting the use of the :missing parameter is
* of higher importance than raw write performance
* </p>
* <p>
* Note that this setting also has an impact on sorting (i.e. using the
* <code>_sort</code> parameter on searches): If the server is configured
* to not index missing field.
* </p>
*/
public void setIndexMissingFields(IndexEnabledEnum theIndexMissingFields) {
Validate.notNull(theIndexMissingFields, "theIndexMissingFields must not be null");

View File

@ -67,6 +67,7 @@ public class TestDstu2Config extends BaseJavaConfigDstu2 {
retVal.getTreatBaseUrlsAsLocal().add("http://fhirtest.uhn.ca/baseDstu2");
retVal.getTreatBaseUrlsAsLocal().add("https://fhirtest.uhn.ca/baseDstu2");
retVal.setCountSearchResultsUpTo(TestR4Config.COUNT_SEARCH_RESULTS_UP_TO);
retVal.setIndexMissingFields(DaoConfig.IndexEnabledEnum.ENABLED);
return retVal;
}

View File

@ -56,6 +56,7 @@ public class TestDstu3Config extends BaseJavaConfigDstu3 {
retVal.getTreatBaseUrlsAsLocal().add("http://fhirtest.uhn.ca/baseDstu3");
retVal.getTreatBaseUrlsAsLocal().add("https://fhirtest.uhn.ca/baseDstu3");
retVal.setCountSearchResultsUpTo(TestR4Config.COUNT_SEARCH_RESULTS_UP_TO);
retVal.setIndexMissingFields(DaoConfig.IndexEnabledEnum.ENABLED);
return retVal;
}

View File

@ -74,6 +74,27 @@ public class JsonParserDstu2Test {
}
}
@Test
public void testParseEmptyString() {
try {
String tmp = "{\"resourceType\":\"Bundle\",\"entry\":[{\"fullUrl\":\"\",\"resource\":{\"resourceType\":\"Patient\",\"id\":\"patxuzos\"}}]}";
ourCtx.getParserOptions().setOverrideResourceIdWithBundleEntryFullUrl(false);
ca.uhn.fhir.model.dstu2.resource.Bundle bundle = (ca.uhn.fhir.model.dstu2.resource.Bundle) ourCtx.newJsonParser().parseResource(tmp);
assertEquals(1, bundle.getEntry().size());
{
Patient o1 = (Patient) bundle.getEntry().get(0).getResource();
IIdType o1Id = o1.getIdElement();
assertFalse(o1Id.hasBaseUrl());
assertEquals("Patient", o1Id.getResourceType());
assertEquals("patxuzos", o1Id.getIdPart());
assertFalse(o1Id.hasVersionIdPart());
}
} finally {
// ensure we cleanup ourCtx so other tests continue to work
ourCtx = FhirContext.forDstu2();
}
}
@Test
public void testOverrideResourceIdWithBundleEntryFullUrlDisabled_ConfiguredOnParser() {
try {