Fix #401 - Don't clear fullUrl on stored bundles

This commit is contained in:
jamesagnew 2016-07-24 11:02:20 -04:00
parent 294e467811
commit ca97c0d000
3 changed files with 52 additions and 4 deletions

View File

@ -1,7 +1,6 @@
package ca.uhn.fhir.jpa.dao.dstu3; package ca.uhn.fhir.jpa.dao.dstu3;
import org.hl7.fhir.dstu3.model.Bundle; import org.hl7.fhir.dstu3.model.Bundle;
import org.hl7.fhir.dstu3.model.Bundle.BundleEntryComponent;
import org.hl7.fhir.dstu3.model.Bundle.BundleType; import org.hl7.fhir.dstu3.model.Bundle.BundleType;
/* /*
@ -37,9 +36,6 @@ public class FhirResourceDaoBundleDstu3 extends FhirResourceDaoDstu3<Bundle> {
throw new UnprocessableEntityException(message); throw new UnprocessableEntityException(message);
} }
for (BundleEntryComponent next : theResource.getEntry()) {
next.setFullUrl((String)null);
}
} }

View File

@ -0,0 +1,46 @@
package ca.uhn.fhir.jpa.provider.dstu3;
import static org.junit.Assert.*;
import org.hl7.fhir.dstu3.model.Bundle;
import org.hl7.fhir.dstu3.model.Bundle.BundleType;
import org.hl7.fhir.dstu3.model.Composition;
import org.hl7.fhir.instance.model.api.IIdType;
import org.junit.AfterClass;
import org.junit.Test;
import ca.uhn.fhir.util.TestUtil;
public class ResourceProviderDstu3BundleTest extends BaseResourceProviderDstu3Test {
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(ResourceProviderDstu3BundleTest.class);
@AfterClass
public static void afterClassClearContext() {
TestUtil.clearAllStaticFieldsForUnitTest();
}
/**
* See #401
*/
@Test
public void testBundlePreservesFullUrl() throws Exception {
Bundle bundle = new Bundle();
bundle.setType(BundleType.DOCUMENT);
Composition composition = new Composition();
composition.setTitle("Visit Summary");
bundle.addEntry().setFullUrl("http://foo").setResource(composition);
IIdType id = ourClient.create().resource(bundle).execute().getId();
Bundle retBundle = ourClient.read().resource(Bundle.class).withId(id).execute();
ourLog.info(myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(retBundle));
assertEquals("http://foo", bundle.getEntry().get(0).getFullUrl());
}
}

View File

@ -94,6 +94,12 @@
<![CDATA[<code>Tag#setCode(String)</code>]]> did not actually set the code it was supposed to <![CDATA[<code>Tag#setCode(String)</code>]]> did not actually set the code it was supposed to
set. Thanks to Tim Tschampel for reporting! set. Thanks to Tim Tschampel for reporting!
</action> </action>
<action type="fix" issue="401">
JPA server's <![CDATA[<code>/Bundle</code>]]> endpoint cleared
the <![CDATA[<code>Bundle.entry.fullUrl</code>]]> field on stored
bundles, resulting in invalid content being saved. Thanks to Mirjam
Baltus for reporting!
</action>
</release> </release>
<release version="1.6" date="2016-07-07"> <release version="1.6" date="2016-07-07">
<action type="fix"> <action type="fix">