Merge pull request #624 from CarthageKing/feature-make-bundle-fullurl-override-configurable
Feature make bundle fullurl override configurable
This commit is contained in:
commit
282e02801a
|
@ -41,6 +41,7 @@ public class ParserOptions {
|
||||||
|
|
||||||
private boolean myStripVersionsFromReferences = true;
|
private boolean myStripVersionsFromReferences = true;
|
||||||
private Set<String> myDontStripVersionsFromReferencesAtPaths = Collections.emptySet();
|
private Set<String> myDontStripVersionsFromReferencesAtPaths = Collections.emptySet();
|
||||||
|
private boolean myOverrideResourceIdWithBundleEntryFullUrl = true;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If supplied value(s), any resource references at the specified paths will have their
|
* If supplied value(s), any resource references at the specified paths will have their
|
||||||
|
@ -144,4 +145,33 @@ public class ParserOptions {
|
||||||
return myDontStripVersionsFromReferencesAtPaths;
|
return myDontStripVersionsFromReferencesAtPaths;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If set to <code>true</code> (which is the default), the Bundle.entry.fullUrl will override the Bundle.entry.resource's
|
||||||
|
* resource id if the fullUrl is defined. This behavior happens when parsing the source data into a Bundle object. Set this
|
||||||
|
* to <code>false</code> if this is not the desired behavior (e.g. the client code wishes to perform additional
|
||||||
|
* validation checks between the fullUrl and the resource id).
|
||||||
|
*
|
||||||
|
* @return Returns the parser instance's configuration setting for overriding resource ids with Bundle.entry.fullUrl when
|
||||||
|
* parsing the source data into a Bundle object. Default is <code>true</code>.
|
||||||
|
*/
|
||||||
|
public boolean isOverrideResourceIdWithBundleEntryFullUrl() {
|
||||||
|
return myOverrideResourceIdWithBundleEntryFullUrl;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If set to <code>true</code> (which is the default), the Bundle.entry.fullUrl will override the Bundle.entry.resource's
|
||||||
|
* resource id if the fullUrl is defined. This behavior happens when parsing the source data into a Bundle object. Set this
|
||||||
|
* to <code>false</code> if this is not the desired behavior (e.g. the client code wishes to perform additional
|
||||||
|
* validation checks between the fullUrl and the resource id).
|
||||||
|
*
|
||||||
|
* @param theOverrideResourceIdWithBundleEntryFullUrl
|
||||||
|
* Set this to <code>false</code> to prevent the parser from overriding resource ids with the
|
||||||
|
* Bundle.entry.fullUrl
|
||||||
|
*
|
||||||
|
* @return Returns a reference to <code>this</code> parser so that method calls can be chained together
|
||||||
|
*/
|
||||||
|
public ParserOptions setOverrideResourceIdWithBundleEntryFullUrl(boolean theOverrideResourceIdWithBundleEntryFullUrl) {
|
||||||
|
myOverrideResourceIdWithBundleEntryFullUrl = theOverrideResourceIdWithBundleEntryFullUrl;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -97,6 +97,7 @@ public abstract class BaseParser implements IParser {
|
||||||
private List<Class<? extends IBaseResource>> myPreferTypes;
|
private List<Class<? extends IBaseResource>> myPreferTypes;
|
||||||
private String myServerBaseUrl;
|
private String myServerBaseUrl;
|
||||||
private Boolean myStripVersionsFromReferences;
|
private Boolean myStripVersionsFromReferences;
|
||||||
|
private Boolean myOverrideResourceIdWithBundleEntryFullUrl;
|
||||||
private boolean mySummaryMode;
|
private boolean mySummaryMode;
|
||||||
private boolean mySuppressNarratives;
|
private boolean mySuppressNarratives;
|
||||||
private Set<String> myDontStripVersionsFromReferencesAtPaths;
|
private Set<String> myDontStripVersionsFromReferencesAtPaths;
|
||||||
|
@ -346,6 +347,15 @@ public abstract class BaseParser implements IParser {
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean isOverrideResourceIdWithBundleEntryFullUrl() {
|
||||||
|
Boolean overrideResourceIdWithBundleEntryFullUrl = myOverrideResourceIdWithBundleEntryFullUrl;
|
||||||
|
if (overrideResourceIdWithBundleEntryFullUrl != null) {
|
||||||
|
return overrideResourceIdWithBundleEntryFullUrl;
|
||||||
|
}
|
||||||
|
|
||||||
|
return myContext.getParserOptions().isOverrideResourceIdWithBundleEntryFullUrl();
|
||||||
|
}
|
||||||
|
|
||||||
protected abstract void doEncodeBundleToWriter(Bundle theBundle, Writer theWriter) throws IOException, DataFormatException;
|
protected abstract void doEncodeBundleToWriter(Bundle theBundle, Writer theWriter) throws IOException, DataFormatException;
|
||||||
|
|
||||||
|
@ -596,6 +606,11 @@ public abstract class BaseParser implements IParser {
|
||||||
public Boolean getStripVersionsFromReferences() {
|
public Boolean getStripVersionsFromReferences() {
|
||||||
return myStripVersionsFromReferences;
|
return myStripVersionsFromReferences;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Boolean getOverrideResourceIdWithBundleEntryFullUrl() {
|
||||||
|
return myOverrideResourceIdWithBundleEntryFullUrl;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isSummaryMode() {
|
public boolean isSummaryMode() {
|
||||||
|
@ -658,22 +673,23 @@ public abstract class BaseParser implements IParser {
|
||||||
if (fullUrlChild == null) {
|
if (fullUrlChild == null) {
|
||||||
continue; // TODO: remove this once the data model in tinder plugin catches up to 1.2
|
continue; // TODO: remove this once the data model in tinder plugin catches up to 1.2
|
||||||
}
|
}
|
||||||
List<IBase> fullUrl = fullUrlChild.getAccessor().getValues(nextEntry);
|
if (isOverrideResourceIdWithBundleEntryFullUrl()) {
|
||||||
if (fullUrl != null && !fullUrl.isEmpty()) {
|
List<IBase> fullUrl = fullUrlChild.getAccessor().getValues(nextEntry);
|
||||||
IPrimitiveType<?> value = (IPrimitiveType<?>) fullUrl.get(0);
|
if (fullUrl != null && !fullUrl.isEmpty()) {
|
||||||
if (value.isEmpty() == false) {
|
IPrimitiveType<?> value = (IPrimitiveType<?>) fullUrl.get(0);
|
||||||
List<IBase> entryResources = entryDef.getChildByName("resource").getAccessor().getValues(nextEntry);
|
if (value.isEmpty() == false) {
|
||||||
if (entryResources != null && entryResources.size() > 0) {
|
List<IBase> entryResources = entryDef.getChildByName("resource").getAccessor().getValues(nextEntry);
|
||||||
IBaseResource res = (IBaseResource) entryResources.get(0);
|
if (entryResources != null && entryResources.size() > 0) {
|
||||||
String versionId = res.getIdElement().getVersionIdPart();
|
IBaseResource res = (IBaseResource) entryResources.get(0);
|
||||||
res.setId(value.getValueAsString());
|
String versionId = res.getIdElement().getVersionIdPart();
|
||||||
if (isNotBlank(versionId) && res.getIdElement().hasVersionIdPart() == false) {
|
res.setId(value.getValueAsString());
|
||||||
res.setId(res.getIdElement().withVersion(versionId));
|
if (isNotBlank(versionId) && res.getIdElement().hasVersionIdPart() == false) {
|
||||||
|
res.setId(res.getIdElement().withVersion(versionId));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -876,6 +892,12 @@ public abstract class BaseParser implements IParser {
|
||||||
myStripVersionsFromReferences = theStripVersionsFromReferences;
|
myStripVersionsFromReferences = theStripVersionsFromReferences;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public IParser setOverrideResourceIdWithBundleEntryFullUrl(Boolean theOverrideResourceIdWithBundleEntryFullUrl) {
|
||||||
|
myOverrideResourceIdWithBundleEntryFullUrl = theOverrideResourceIdWithBundleEntryFullUrl;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IParser setDontStripVersionsFromReferencesAtPaths(String... thePaths) {
|
public IParser setDontStripVersionsFromReferencesAtPaths(String... thePaths) {
|
||||||
|
|
|
@ -128,6 +128,19 @@ public interface IParser {
|
||||||
* @see ParserOptions
|
* @see ParserOptions
|
||||||
*/
|
*/
|
||||||
Boolean getStripVersionsFromReferences();
|
Boolean getStripVersionsFromReferences();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If set to <code>true</code> (which is the default), the Bundle.entry.fullUrl will override the Bundle.entry.resource's
|
||||||
|
* resource id if the fullUrl is defined. This behavior happens when parsing the source data into a Bundle object. Set this
|
||||||
|
* to <code>false</code> if this is not the desired behavior (e.g. the client code wishes to perform additional
|
||||||
|
* validation checks between the fullUrl and the resource id).
|
||||||
|
*
|
||||||
|
* @return Returns the parser instance's configuration setting for overriding resource ids with Bundle.entry.fullUrl when
|
||||||
|
* parsing the source data into a Bundle object. This method will return <code>null</code> if no value is set, in
|
||||||
|
* which case the value from the {@link ParserOptions} will be used (default is <code>true</code>)
|
||||||
|
* @see ParserOptions
|
||||||
|
*/
|
||||||
|
Boolean getOverrideResourceIdWithBundleEntryFullUrl();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Is the parser in "summary mode"? See {@link #setSummaryMode(boolean)} for information
|
* Is the parser in "summary mode"? See {@link #setSummaryMode(boolean)} for information
|
||||||
|
@ -361,6 +374,22 @@ public interface IParser {
|
||||||
* @return Returns a reference to <code>this</code> parser so that method calls can be chained together
|
* @return Returns a reference to <code>this</code> parser so that method calls can be chained together
|
||||||
*/
|
*/
|
||||||
IParser setStripVersionsFromReferences(Boolean theStripVersionsFromReferences);
|
IParser setStripVersionsFromReferences(Boolean theStripVersionsFromReferences);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If set to <code>true</code> (which is the default), the Bundle.entry.fullUrl will override the Bundle.entry.resource's
|
||||||
|
* resource id if the fullUrl is defined. This behavior happens when parsing the source data into a Bundle object. Set this
|
||||||
|
* to <code>false</code> if this is not the desired behavior (e.g. the client code wishes to perform additional
|
||||||
|
* validation checks between the fullUrl and the resource id).
|
||||||
|
*
|
||||||
|
* @param theOverrideResourceIdWithBundleEntryFullUrl
|
||||||
|
* Set this to <code>false</code> to prevent the parser from overriding resource ids with the
|
||||||
|
* Bundle.entry.fullUrl (or <code>null</code> to apply the default setting from the {@link ParserOptions})
|
||||||
|
*
|
||||||
|
* @see ParserOptions
|
||||||
|
*
|
||||||
|
* @return Returns a reference to <code>this</code> parser so that method calls can be chained together
|
||||||
|
*/
|
||||||
|
IParser setOverrideResourceIdWithBundleEntryFullUrl(Boolean theOverrideResourceIdWithBundleEntryFullUrl);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If set to <code>true</code> (default is <code>false</code>) only elements marked by the FHIR specification as
|
* If set to <code>true</code> (default is <code>false</code>) only elements marked by the FHIR specification as
|
||||||
|
|
|
@ -6,6 +6,7 @@ import static org.hamcrest.Matchers.empty;
|
||||||
import static org.hamcrest.Matchers.not;
|
import static org.hamcrest.Matchers.not;
|
||||||
import static org.hamcrest.Matchers.stringContainsInOrder;
|
import static org.hamcrest.Matchers.stringContainsInOrder;
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
|
import static org.junit.Assert.assertFalse;
|
||||||
import static org.junit.Assert.assertNotNull;
|
import static org.junit.Assert.assertNotNull;
|
||||||
import static org.junit.Assert.assertNull;
|
import static org.junit.Assert.assertNull;
|
||||||
import static org.junit.Assert.assertSame;
|
import static org.junit.Assert.assertSame;
|
||||||
|
@ -36,6 +37,7 @@ import org.hl7.fhir.dstu2016may.model.Enumeration;
|
||||||
import org.hl7.fhir.dstu2016may.model.Enumerations.AdministrativeGender;
|
import org.hl7.fhir.dstu2016may.model.Enumerations.AdministrativeGender;
|
||||||
import org.hl7.fhir.dstu2016may.model.Identifier.IdentifierUse;
|
import org.hl7.fhir.dstu2016may.model.Identifier.IdentifierUse;
|
||||||
import org.hl7.fhir.dstu2016may.model.Observation.ObservationStatus;
|
import org.hl7.fhir.dstu2016may.model.Observation.ObservationStatus;
|
||||||
|
import org.hl7.fhir.instance.model.api.IIdType;
|
||||||
import org.hl7.fhir.utilities.xhtml.XhtmlNode;
|
import org.hl7.fhir.utilities.xhtml.XhtmlNode;
|
||||||
import org.junit.*;
|
import org.junit.*;
|
||||||
import org.mockito.ArgumentCaptor;
|
import org.mockito.ArgumentCaptor;
|
||||||
|
@ -62,7 +64,46 @@ public class JsonParserDstu2_1Test {
|
||||||
ourCtx.setNarrativeGenerator(null);
|
ourCtx.setNarrativeGenerator(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testOverrideResourceIdWithBundleEntryFullUrlDisabled_ConfiguredOnFhirContext() {
|
||||||
|
try {
|
||||||
|
String tmp = "{\"resourceType\":\"Bundle\",\"entry\":[{\"fullUrl\":\"http://lalaland.org/patient/pat1\",\"resource\":{\"resourceType\":\"Patient\",\"id\":\"patxuzos\"}}]}";
|
||||||
|
ourCtx.getParserOptions().setOverrideResourceIdWithBundleEntryFullUrl(false);
|
||||||
|
Bundle bundle = (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_1();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testOverrideResourceIdWithBundleEntryFullUrlDisabled_ConfiguredOnParser() {
|
||||||
|
try {
|
||||||
|
String tmp = "{\"resourceType\":\"Bundle\",\"entry\":[{\"fullUrl\":\"http://lalaland.org/patient/pat1\",\"resource\":{\"resourceType\":\"Patient\",\"id\":\"patxuzos\"}}]}";
|
||||||
|
Bundle bundle = (Bundle) ourCtx.newJsonParser().setOverrideResourceIdWithBundleEntryFullUrl(false).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_1();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* #480
|
* #480
|
||||||
|
|
|
@ -8,6 +8,7 @@ import static org.hamcrest.Matchers.startsWith;
|
||||||
import static org.hamcrest.Matchers.stringContainsInOrder;
|
import static org.hamcrest.Matchers.stringContainsInOrder;
|
||||||
import static org.junit.Assert.assertArrayEquals;
|
import static org.junit.Assert.assertArrayEquals;
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
|
import static org.junit.Assert.assertFalse;
|
||||||
import static org.junit.Assert.assertNotNull;
|
import static org.junit.Assert.assertNotNull;
|
||||||
import static org.junit.Assert.assertNull;
|
import static org.junit.Assert.assertNull;
|
||||||
import static org.junit.Assert.assertSame;
|
import static org.junit.Assert.assertSame;
|
||||||
|
@ -96,6 +97,7 @@ import org.hl7.fhir.dstu2016may.model.StringType;
|
||||||
import org.hl7.fhir.dstu2016may.model.UriType;
|
import org.hl7.fhir.dstu2016may.model.UriType;
|
||||||
import org.hl7.fhir.dstu2016may.model.ValueSet;
|
import org.hl7.fhir.dstu2016may.model.ValueSet;
|
||||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||||
|
import org.hl7.fhir.instance.model.api.IIdType;
|
||||||
import org.junit.After;
|
import org.junit.After;
|
||||||
import org.junit.AfterClass;
|
import org.junit.AfterClass;
|
||||||
import org.junit.BeforeClass;
|
import org.junit.BeforeClass;
|
||||||
|
@ -128,6 +130,47 @@ public class XmlParserDstu2_1Test {
|
||||||
}
|
}
|
||||||
ourCtx.setNarrativeGenerator(null);
|
ourCtx.setNarrativeGenerator(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testOverrideResourceIdWithBundleEntryFullUrlDisabled_ConfiguredOnFhirContext() {
|
||||||
|
try {
|
||||||
|
String tmp = "<Bundle xmlns=\"http://hl7.org/fhir\"><entry><fullUrl value=\"http://lalaland.org/patient/pat1\"/><resource><Patient xmlns=\"http://hl7.org/fhir\"><id value=\"patxuzos\"/></Patient></resource></entry></Bundle>";
|
||||||
|
ourCtx.getParserOptions().setOverrideResourceIdWithBundleEntryFullUrl(false);
|
||||||
|
Bundle bundle = (Bundle) ourCtx.newXmlParser().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 = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testOverrideResourceIdWithBundleEntryFullUrlDisabled_ConfiguredOnParser() {
|
||||||
|
try {
|
||||||
|
String tmp = "<Bundle xmlns=\"http://hl7.org/fhir\"><entry><fullUrl value=\"http://lalaland.org/patient/pat1\"/><resource><Patient xmlns=\"http://hl7.org/fhir\"><id value=\"patxuzos\"/></Patient></resource></entry></Bundle>";
|
||||||
|
Bundle bundle = (Bundle) ourCtx.newXmlParser().setOverrideResourceIdWithBundleEntryFullUrl(false).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 = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* See #414
|
* See #414
|
||||||
|
|
|
@ -5,6 +5,7 @@ import static org.hamcrest.Matchers.containsString;
|
||||||
import static org.hamcrest.Matchers.not;
|
import static org.hamcrest.Matchers.not;
|
||||||
import static org.hamcrest.Matchers.stringContainsInOrder;
|
import static org.hamcrest.Matchers.stringContainsInOrder;
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
|
import static org.junit.Assert.assertFalse;
|
||||||
import static org.junit.Assert.assertNotNull;
|
import static org.junit.Assert.assertNotNull;
|
||||||
import static org.junit.Assert.assertNull;
|
import static org.junit.Assert.assertNull;
|
||||||
import static org.junit.Assert.assertSame;
|
import static org.junit.Assert.assertSame;
|
||||||
|
@ -22,6 +23,7 @@ import java.util.*;
|
||||||
import org.apache.commons.io.IOUtils;
|
import org.apache.commons.io.IOUtils;
|
||||||
import org.hamcrest.Matchers;
|
import org.hamcrest.Matchers;
|
||||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||||
|
import org.hl7.fhir.instance.model.api.IIdType;
|
||||||
import org.junit.AfterClass;
|
import org.junit.AfterClass;
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
@ -70,6 +72,47 @@ public class JsonParserDstu2Test {
|
||||||
private static FhirContext ourCtx = FhirContext.forDstu2();
|
private static FhirContext ourCtx = FhirContext.forDstu2();
|
||||||
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(JsonParserDstu2Test.class);
|
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(JsonParserDstu2Test.class);
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testOverrideResourceIdWithBundleEntryFullUrlDisabled_ConfiguredOnFhirContext() {
|
||||||
|
try {
|
||||||
|
String tmp = "{\"resourceType\":\"Bundle\",\"entry\":[{\"fullUrl\":\"http://lalaland.org/patient/pat1\",\"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 {
|
||||||
|
String tmp = "{\"resourceType\":\"Bundle\",\"entry\":[{\"fullUrl\":\"http://lalaland.org/patient/pat1\",\"resource\":{\"resourceType\":\"Patient\",\"id\":\"patxuzos\"}}]}";
|
||||||
|
ca.uhn.fhir.model.dstu2.resource.Bundle bundle = (ca.uhn.fhir.model.dstu2.resource.Bundle) ourCtx.newJsonParser().setOverrideResourceIdWithBundleEntryFullUrl(false).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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* See #544
|
* See #544
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -12,6 +12,7 @@ import static org.junit.Assert.assertNull;
|
||||||
import static org.junit.Assert.assertSame;
|
import static org.junit.Assert.assertSame;
|
||||||
import static org.junit.Assert.assertThat;
|
import static org.junit.Assert.assertThat;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
|
import static org.junit.Assert.assertFalse;
|
||||||
import static org.junit.Assert.fail;
|
import static org.junit.Assert.fail;
|
||||||
import static org.mockito.Matchers.any;
|
import static org.mockito.Matchers.any;
|
||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
|
@ -30,6 +31,7 @@ import org.hamcrest.collection.IsEmptyCollection;
|
||||||
import org.hamcrest.core.StringContains;
|
import org.hamcrest.core.StringContains;
|
||||||
import org.hamcrest.text.StringContainsInOrder;
|
import org.hamcrest.text.StringContainsInOrder;
|
||||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||||
|
import org.hl7.fhir.instance.model.api.IIdType;
|
||||||
import org.junit.AfterClass;
|
import org.junit.AfterClass;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.BeforeClass;
|
import org.junit.BeforeClass;
|
||||||
|
@ -68,6 +70,47 @@ public class XmlParserDstu2Test {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testOverrideResourceIdWithBundleEntryFullUrlDisabled_ConfiguredOnFhirContext() {
|
||||||
|
try {
|
||||||
|
String tmp = "<Bundle xmlns=\"http://hl7.org/fhir\"><entry><fullUrl value=\"http://lalaland.org/patient/pat1\"/><resource><Patient xmlns=\"http://hl7.org/fhir\"><id value=\"patxuzos\"/></Patient></resource></entry></Bundle>";
|
||||||
|
ourCtx.getParserOptions().setOverrideResourceIdWithBundleEntryFullUrl(false);
|
||||||
|
ca.uhn.fhir.model.dstu2.resource.Bundle bundle = (ca.uhn.fhir.model.dstu2.resource.Bundle) ourCtx.newXmlParser().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 = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testOverrideResourceIdWithBundleEntryFullUrlDisabled_ConfiguredOnParser() {
|
||||||
|
try {
|
||||||
|
String tmp = "<Bundle xmlns=\"http://hl7.org/fhir\"><entry><fullUrl value=\"http://lalaland.org/patient/pat1\"/><resource><Patient xmlns=\"http://hl7.org/fhir\"><id value=\"patxuzos\"/></Patient></resource></entry></Bundle>";
|
||||||
|
ca.uhn.fhir.model.dstu2.resource.Bundle bundle = (ca.uhn.fhir.model.dstu2.resource.Bundle) ourCtx.newXmlParser().setOverrideResourceIdWithBundleEntryFullUrl(false).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 = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* See #414
|
* See #414
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -7,6 +7,7 @@ import static org.hamcrest.Matchers.empty;
|
||||||
import static org.hamcrest.Matchers.not;
|
import static org.hamcrest.Matchers.not;
|
||||||
import static org.hamcrest.Matchers.stringContainsInOrder;
|
import static org.hamcrest.Matchers.stringContainsInOrder;
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
|
import static org.junit.Assert.assertFalse;
|
||||||
import static org.junit.Assert.assertNotNull;
|
import static org.junit.Assert.assertNotNull;
|
||||||
import static org.junit.Assert.assertNull;
|
import static org.junit.Assert.assertNull;
|
||||||
import static org.junit.Assert.assertSame;
|
import static org.junit.Assert.assertSame;
|
||||||
|
@ -45,6 +46,7 @@ import org.hl7.fhir.dstu3.model.CapabilityStatement.UnknownContentCode;
|
||||||
import org.hl7.fhir.dstu3.model.Enumerations.AdministrativeGender;
|
import org.hl7.fhir.dstu3.model.Enumerations.AdministrativeGender;
|
||||||
import org.hl7.fhir.dstu3.model.Identifier.IdentifierUse;
|
import org.hl7.fhir.dstu3.model.Identifier.IdentifierUse;
|
||||||
import org.hl7.fhir.dstu3.model.Observation.ObservationStatus;
|
import org.hl7.fhir.dstu3.model.Observation.ObservationStatus;
|
||||||
|
import org.hl7.fhir.instance.model.api.IIdType;
|
||||||
import org.hl7.fhir.utilities.xhtml.XhtmlNode;
|
import org.hl7.fhir.utilities.xhtml.XhtmlNode;
|
||||||
import org.junit.After;
|
import org.junit.After;
|
||||||
import org.junit.AfterClass;
|
import org.junit.AfterClass;
|
||||||
|
@ -79,6 +81,47 @@ public class JsonParserDstu3Test {
|
||||||
public void after() {
|
public void after() {
|
||||||
ourCtx.setNarrativeGenerator(null);
|
ourCtx.setNarrativeGenerator(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testOverrideResourceIdWithBundleEntryFullUrlDisabled_ConfiguredOnFhirContext() {
|
||||||
|
try {
|
||||||
|
String tmp = "{\"resourceType\":\"Bundle\",\"entry\":[{\"fullUrl\":\"http://lalaland.org/patient/pat1\",\"resource\":{\"resourceType\":\"Patient\",\"id\":\"patxuzos\"}}]}";
|
||||||
|
ourCtx.getParserOptions().setOverrideResourceIdWithBundleEntryFullUrl(false);
|
||||||
|
Bundle bundle = (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.forDstu3();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testOverrideResourceIdWithBundleEntryFullUrlDisabled_ConfiguredOnParser() {
|
||||||
|
try {
|
||||||
|
String tmp = "{\"resourceType\":\"Bundle\",\"entry\":[{\"fullUrl\":\"http://lalaland.org/patient/pat1\",\"resource\":{\"resourceType\":\"Patient\",\"id\":\"patxuzos\"}}]}";
|
||||||
|
Bundle bundle = (Bundle) ourCtx.newJsonParser().setOverrideResourceIdWithBundleEntryFullUrl(false).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.forDstu3();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* See #544
|
* See #544
|
||||||
|
|
|
@ -8,6 +8,7 @@ import static org.hamcrest.Matchers.startsWith;
|
||||||
import static org.hamcrest.Matchers.stringContainsInOrder;
|
import static org.hamcrest.Matchers.stringContainsInOrder;
|
||||||
import static org.junit.Assert.assertArrayEquals;
|
import static org.junit.Assert.assertArrayEquals;
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
|
import static org.junit.Assert.assertFalse;
|
||||||
import static org.junit.Assert.assertNotNull;
|
import static org.junit.Assert.assertNotNull;
|
||||||
import static org.junit.Assert.assertNull;
|
import static org.junit.Assert.assertNull;
|
||||||
import static org.junit.Assert.assertSame;
|
import static org.junit.Assert.assertSame;
|
||||||
|
@ -50,6 +51,7 @@ import org.hl7.fhir.dstu3.model.Identifier.IdentifierUse;
|
||||||
import org.hl7.fhir.dstu3.model.Observation.ObservationRelationshipType;
|
import org.hl7.fhir.dstu3.model.Observation.ObservationRelationshipType;
|
||||||
import org.hl7.fhir.dstu3.model.Observation.ObservationStatus;
|
import org.hl7.fhir.dstu3.model.Observation.ObservationStatus;
|
||||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||||
|
import org.hl7.fhir.instance.model.api.IIdType;
|
||||||
import org.junit.*;
|
import org.junit.*;
|
||||||
import org.mockito.ArgumentCaptor;
|
import org.mockito.ArgumentCaptor;
|
||||||
|
|
||||||
|
@ -77,6 +79,47 @@ public class XmlParserDstu3Test {
|
||||||
}
|
}
|
||||||
ourCtx.setNarrativeGenerator(null);
|
ourCtx.setNarrativeGenerator(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testOverrideResourceIdWithBundleEntryFullUrlDisabled_ConfiguredOnFhirContext() {
|
||||||
|
try {
|
||||||
|
String tmp = "<Bundle xmlns=\"http://hl7.org/fhir\"><entry><fullUrl value=\"http://lalaland.org/patient/pat1\"/><resource><Patient xmlns=\"http://hl7.org/fhir\"><id value=\"patxuzos\"/></Patient></resource></entry></Bundle>";
|
||||||
|
ourCtx.getParserOptions().setOverrideResourceIdWithBundleEntryFullUrl(false);
|
||||||
|
Bundle bundle = (Bundle) ourCtx.newXmlParser().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 = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testOverrideResourceIdWithBundleEntryFullUrlDisabled_ConfiguredOnParser() {
|
||||||
|
try {
|
||||||
|
String tmp = "<Bundle xmlns=\"http://hl7.org/fhir\"><entry><fullUrl value=\"http://lalaland.org/patient/pat1\"/><resource><Patient xmlns=\"http://hl7.org/fhir\"><id value=\"patxuzos\"/></Patient></resource></entry></Bundle>";
|
||||||
|
Bundle bundle = (Bundle) ourCtx.newXmlParser().setOverrideResourceIdWithBundleEntryFullUrl(false).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 = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* See #551
|
* See #551
|
||||||
|
|
|
@ -5,6 +5,7 @@ import static org.hamcrest.Matchers.not;
|
||||||
import static org.hamcrest.Matchers.stringContainsInOrder;
|
import static org.hamcrest.Matchers.stringContainsInOrder;
|
||||||
import static org.junit.Assert.assertArrayEquals;
|
import static org.junit.Assert.assertArrayEquals;
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
|
import static org.junit.Assert.assertFalse;
|
||||||
import static org.junit.Assert.assertNotEquals;
|
import static org.junit.Assert.assertNotEquals;
|
||||||
import static org.junit.Assert.assertNotNull;
|
import static org.junit.Assert.assertNotNull;
|
||||||
import static org.junit.Assert.assertNull;
|
import static org.junit.Assert.assertNull;
|
||||||
|
@ -56,6 +57,7 @@ import org.hl7.fhir.instance.model.ValueSet;
|
||||||
import org.hl7.fhir.instance.model.ValueSet.ConceptDefinitionComponent;
|
import org.hl7.fhir.instance.model.ValueSet.ConceptDefinitionComponent;
|
||||||
import org.hl7.fhir.instance.model.ValueSet.ValueSetCodeSystemComponent;
|
import org.hl7.fhir.instance.model.ValueSet.ValueSetCodeSystemComponent;
|
||||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||||
|
import org.hl7.fhir.instance.model.api.IIdType;
|
||||||
import org.hl7.fhir.instance.model.api.INarrative;
|
import org.hl7.fhir.instance.model.api.INarrative;
|
||||||
import org.hl7.fhir.instance.model.api.IPrimitiveType;
|
import org.hl7.fhir.instance.model.api.IPrimitiveType;
|
||||||
import org.hl7.fhir.utilities.xhtml.XhtmlNode;
|
import org.hl7.fhir.utilities.xhtml.XhtmlNode;
|
||||||
|
@ -88,6 +90,67 @@ public class JsonParserHl7OrgDstu2Test {
|
||||||
public static void afterClassClearContext() {
|
public static void afterClassClearContext() {
|
||||||
TestUtil.clearAllStaticFieldsForUnitTest();
|
TestUtil.clearAllStaticFieldsForUnitTest();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testOverrideResourceIdWithBundleEntryFullUrlEnabled() {
|
||||||
|
try {
|
||||||
|
String tmp = "{\"resourceType\":\"Bundle\",\"entry\":[{\"fullUrl\":\"http://lalaland.org/patient/pat1\",\"resource\":{\"resourceType\":\"Patient\",\"id\":\"patxuzos\"}}]}";
|
||||||
|
Bundle bundle = (Bundle) ourCtx.newJsonParser().parseResource(tmp);
|
||||||
|
assertEquals(1, bundle.getEntry().size());
|
||||||
|
{
|
||||||
|
Patient o1 = (Patient) bundle.getEntry().get(0).getResource();
|
||||||
|
IIdType o1Id = o1.getIdElement();
|
||||||
|
assertEquals("http://lalaland.org", o1Id.getBaseUrl());
|
||||||
|
assertEquals("patient", o1Id.getResourceType());
|
||||||
|
assertEquals("pat1", o1Id.getIdPart());
|
||||||
|
assertFalse(o1Id.hasVersionIdPart());
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
// ensure we cleanup ourCtx so other tests continue to work
|
||||||
|
ourCtx = FhirContext.forDstu2Hl7Org();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testOverrideResourceIdWithBundleEntryFullUrlDisabled_ConfiguredOnFhirContext() {
|
||||||
|
try {
|
||||||
|
String tmp = "{\"resourceType\":\"Bundle\",\"entry\":[{\"fullUrl\":\"http://lalaland.org/patient/pat1\",\"resource\":{\"resourceType\":\"Patient\",\"id\":\"patxuzos\"}}]}";
|
||||||
|
ourCtx.getParserOptions().setOverrideResourceIdWithBundleEntryFullUrl(false);
|
||||||
|
Bundle bundle = (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.forDstu2Hl7Org();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testOverrideResourceIdWithBundleEntryFullUrlDisabled_ConfiguredOnParser() {
|
||||||
|
try {
|
||||||
|
String tmp = "{\"resourceType\":\"Bundle\",\"entry\":[{\"fullUrl\":\"http://lalaland.org/patient/pat1\",\"resource\":{\"resourceType\":\"Patient\",\"id\":\"patxuzos\"}}]}";
|
||||||
|
Bundle bundle = (Bundle) ourCtx.newJsonParser().setOverrideResourceIdWithBundleEntryFullUrl(false).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.forDstu2Hl7Org();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testEncodeUndeclaredExtensionWithEnumerationContent() {
|
public void testEncodeUndeclaredExtensionWithEnumerationContent() {
|
||||||
|
|
|
@ -5,6 +5,7 @@ import static org.hamcrest.Matchers.not;
|
||||||
import static org.hamcrest.Matchers.stringContainsInOrder;
|
import static org.hamcrest.Matchers.stringContainsInOrder;
|
||||||
import static org.junit.Assert.assertArrayEquals;
|
import static org.junit.Assert.assertArrayEquals;
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
|
import static org.junit.Assert.assertFalse;
|
||||||
import static org.junit.Assert.assertNotNull;
|
import static org.junit.Assert.assertNotNull;
|
||||||
import static org.junit.Assert.assertNull;
|
import static org.junit.Assert.assertNull;
|
||||||
import static org.junit.Assert.assertThat;
|
import static org.junit.Assert.assertThat;
|
||||||
|
@ -60,6 +61,7 @@ import org.hl7.fhir.instance.model.SimpleQuantity;
|
||||||
import org.hl7.fhir.instance.model.Specimen;
|
import org.hl7.fhir.instance.model.Specimen;
|
||||||
import org.hl7.fhir.instance.model.StringType;
|
import org.hl7.fhir.instance.model.StringType;
|
||||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||||
|
import org.hl7.fhir.instance.model.api.IIdType;
|
||||||
import org.hl7.fhir.instance.model.api.INarrative;
|
import org.hl7.fhir.instance.model.api.INarrative;
|
||||||
import org.hl7.fhir.instance.model.api.IPrimitiveType;
|
import org.hl7.fhir.instance.model.api.IPrimitiveType;
|
||||||
import org.junit.After;
|
import org.junit.After;
|
||||||
|
@ -97,6 +99,52 @@ public class XmlParserHl7OrgDstu2Test {
|
||||||
private String fixDivNodeTextJson(String htmlNoNs) {
|
private String fixDivNodeTextJson(String htmlNoNs) {
|
||||||
return htmlNoNs.replace("<div>", "<div xmlns=\\\"http://www.w3.org/1999/xhtml\\\">");
|
return htmlNoNs.replace("<div>", "<div xmlns=\\\"http://www.w3.org/1999/xhtml\\\">");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testOverrideResourceIdWithBundleEntryFullUrlEnabled() {
|
||||||
|
String tmp = "<Bundle xmlns=\"http://hl7.org/fhir\"><entry><fullUrl value=\"http://lalaland.org/patient/pat1\"/><resource><Patient xmlns=\"http://hl7.org/fhir\"><id value=\"patxuzos\"/></Patient></resource></entry></Bundle>";
|
||||||
|
Bundle bundle = (Bundle) ourCtx.newXmlParser().parseResource(tmp);
|
||||||
|
assertEquals(1, bundle.getEntry().size());
|
||||||
|
{
|
||||||
|
Patient o1 = (Patient) bundle.getEntry().get(0).getResource();
|
||||||
|
IIdType o1Id = o1.getIdElement();
|
||||||
|
assertEquals("http://lalaland.org", o1Id.getBaseUrl());
|
||||||
|
assertEquals("patient", o1Id.getResourceType());
|
||||||
|
assertEquals("pat1", o1Id.getIdPart());
|
||||||
|
assertFalse(o1Id.hasVersionIdPart());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testOverrideResourceIdWithBundleEntryFullUrlDisabled_ConfiguredOnFhirContext() {
|
||||||
|
String tmp = "<Bundle xmlns=\"http://hl7.org/fhir\"><entry><fullUrl value=\"http://lalaland.org/patient/pat1\"/><resource><Patient xmlns=\"http://hl7.org/fhir\"><id value=\"patxuzos\"/></Patient></resource></entry></Bundle>";
|
||||||
|
ourCtx.getParserOptions().setOverrideResourceIdWithBundleEntryFullUrl(false);
|
||||||
|
Bundle bundle = (Bundle) ourCtx.newXmlParser().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());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testOverrideResourceIdWithBundleEntryFullUrlDisabled_ConfiguredOnParser() {
|
||||||
|
String tmp = "<Bundle xmlns=\"http://hl7.org/fhir\"><entry><fullUrl value=\"http://lalaland.org/patient/pat1\"/><resource><Patient xmlns=\"http://hl7.org/fhir\"><id value=\"patxuzos\"/></Patient></resource></entry></Bundle>";
|
||||||
|
Bundle bundle = (Bundle) ourCtx.newXmlParser().setOverrideResourceIdWithBundleEntryFullUrl(false).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());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testComposition() {
|
public void testComposition() {
|
||||||
|
|
Loading…
Reference in New Issue