Fix unit tests

This commit is contained in:
James Agnew 2016-08-30 18:27:57 -04:00
parent 98e0753b93
commit 6b9f8ec487
2 changed files with 124 additions and 120 deletions

View File

@ -95,12 +95,13 @@ public class ResourceReferenceInfo {
int colonIndex = theInclude.getValue().indexOf(':'); int colonIndex = theInclude.getValue().indexOf(':');
if (colonIndex != -1) { if (colonIndex != -1) {
// DSTU2+ style // DSTU2+ style
String resourceName = theInclude.getValue().substring(0, colonIndex);
String paramName = theInclude.getValue().substring(colonIndex + 1); String paramName = theInclude.getValue().substring(colonIndex + 1);
RuntimeResourceDefinition resourceDef = myContext.getResourceDefinition(myOwningResource); RuntimeResourceDefinition resourceDef = myContext.getResourceDefinition(resourceName);
if (resourceDef != null) { if (resourceDef != null) {
RuntimeSearchParam searchParamDef = resourceDef.getSearchParam(paramName); RuntimeSearchParam searchParamDef = resourceDef.getSearchParam(paramName);
if (searchParamDef!=null) { if (searchParamDef!=null) {
if (searchParamDef.getPathsSplit().contains(resourceDef.getName() + "." + myName)) { if (searchParamDef.getPathsSplit().contains(myOwningResource + "." + myName)) {
return true; return true;
} }
} }

View File

@ -28,6 +28,8 @@ import ca.uhn.fhir.rest.server.BundleInclusionRule;
import ca.uhn.fhir.util.TestUtil; import ca.uhn.fhir.util.TestUtil;
public class Dstu2BundleFactoryTest { public class Dstu2BundleFactoryTest {
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(Dstu2BundleFactoryTest.class);
private static FhirContext ourCtx; private static FhirContext ourCtx;
private List<IBaseResource> myResourceList; private List<IBaseResource> myResourceList;
private Dstu2BundleFactory myBundleFactory; private Dstu2BundleFactory myBundleFactory;
@ -42,7 +44,6 @@ public class Dstu2BundleFactoryTest {
TestUtil.clearAllStaticFieldsForUnitTest(); TestUtil.clearAllStaticFieldsForUnitTest();
} }
@Before @Before
public void setUp() throws Exception { public void setUp() throws Exception {
// DiagnosticReport // DiagnosticReport
@ -120,6 +121,8 @@ public class Dstu2BundleFactoryTest {
public void whenAChainedResourceIsIncludedAndItsParentIsAlsoIncluded_bundle_shouldContainTheChainedResource() throws Exception { public void whenAChainedResourceIsIncludedAndItsParentIsAlsoIncluded_bundle_shouldContainTheChainedResource() throws Exception {
Bundle bundle = makeBundle(BundleInclusionRule.BASED_ON_INCLUDES, includes(DiagnosticReport.INCLUDE_RESULT.getValue(), Observation.INCLUDE_SPECIMEN.getValue())); Bundle bundle = makeBundle(BundleInclusionRule.BASED_ON_INCLUDES, includes(DiagnosticReport.INCLUDE_RESULT.getValue(), Observation.INCLUDE_SPECIMEN.getValue()));
ourLog.info(ourCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(bundle));
assertEquals(3, bundle.getEntry().size()); assertEquals(3, bundle.getEntry().size());
assertEquals(1, numberOfEntriesOfType(bundle, DiagnosticReport.class)); assertEquals(1, numberOfEntriesOfType(bundle, DiagnosticReport.class));
assertEquals(1, numberOfEntriesOfType(bundle, Observation.class)); assertEquals(1, numberOfEntriesOfType(bundle, Observation.class));