Fix #308 - Remove unneded warning on parsing declared extension
This commit is contained in:
parent
970bc3ed89
commit
b147083f5a
|
@ -1480,6 +1480,15 @@ class ParserState<T> {
|
|||
myParentInstance = theParentInstance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void attributeValue(String theName, String theValue) throws DataFormatException {
|
||||
if (theName.equals("url")) {
|
||||
// This can be ignored
|
||||
return;
|
||||
}
|
||||
super.attributeValue(theName, theValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void endingElement() throws DataFormatException {
|
||||
pop();
|
||||
|
|
|
@ -25,6 +25,7 @@ import org.junit.Assert;
|
|||
import org.junit.Test;
|
||||
import org.mockito.ArgumentCaptor;
|
||||
import org.mockito.Mockito;
|
||||
import org.mockito.internal.stubbing.answers.ThrowsException;
|
||||
|
||||
import ca.uhn.fhir.context.ConfigurationException;
|
||||
import ca.uhn.fhir.context.FhirContext;
|
||||
|
@ -70,6 +71,24 @@ public class JsonParserDstu2Test {
|
|||
private static final FhirContext ourCtx = FhirContext.forDstu2();
|
||||
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(JsonParserDstu2Test.class);
|
||||
|
||||
/**
|
||||
* See #308
|
||||
*/
|
||||
@Test
|
||||
public void testDeclaredExtensionsDontProduceWarning() {
|
||||
ReportObservation obs = new ReportObservation();
|
||||
obs.setReadOnly(true);
|
||||
|
||||
IParser p = ourCtx.newJsonParser();
|
||||
p.setParserErrorHandler(mock(IParserErrorHandler.class, new ThrowsException(new IllegalStateException())));
|
||||
|
||||
String encoded = p.encodeResourceToString(obs);
|
||||
ourLog.info(encoded);
|
||||
|
||||
obs = p.parseResource(ReportObservation.class, encoded);
|
||||
assertEquals(true, obs.getReadOnly().getValue().booleanValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEncodeAndParseExtensions() throws Exception {
|
||||
|
||||
|
@ -1124,7 +1143,7 @@ public class JsonParserDstu2Test {
|
|||
ourLog.info(message);
|
||||
Assert.assertThat(message, containsString("contained"));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* See #144 and #146
|
||||
*/
|
||||
|
|
|
@ -12,6 +12,8 @@ import ca.uhn.fhir.util.ElementUtil;
|
|||
@ResourceDef(name = "Observation", id = "reportobservation")
|
||||
public class ReportObservation extends Observation {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* Each extension is defined in a field. Any valid HAPI Data Type can be used for the field type. Note that the
|
||||
* [name=""] attribute in the @Child annotation needs to match the name for the bean accessor and mutator methods.
|
||||
|
|
|
@ -36,6 +36,7 @@ import org.hl7.fhir.instance.model.api.IBaseResource;
|
|||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.mockito.ArgumentCaptor;
|
||||
import org.mockito.internal.stubbing.answers.ThrowsException;
|
||||
|
||||
import ca.uhn.fhir.context.FhirContext;
|
||||
import ca.uhn.fhir.model.api.Bundle;
|
||||
|
@ -97,7 +98,6 @@ public class XmlParserDstu2Test {
|
|||
private static final FhirContext ourCtx = FhirContext.forDstu2();
|
||||
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(XmlParserDstu2Test.class);
|
||||
|
||||
|
||||
@Test
|
||||
public void testBundleWithBinary() {
|
||||
//@formatter:off
|
||||
|
@ -130,6 +130,7 @@ public class XmlParserDstu2Test {
|
|||
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testChoiceTypeWithProfiledType() {
|
||||
//@formatter:off
|
||||
|
@ -150,7 +151,6 @@ public class XmlParserDstu2Test {
|
|||
assertThat(encoded, containsString("<valueMarkdown value=\"THIS IS MARKDOWN\"/>"));
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testChoiceTypeWithProfiledType2() {
|
||||
Parameters par = new Parameters();
|
||||
|
@ -168,6 +168,7 @@ public class XmlParserDstu2Test {
|
|||
assertEquals(MarkdownDt.class, par.getParameter().get(1).getValue().getClass());
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testContainedResourceInExtensionUndeclared() {
|
||||
Patient p = new Patient();
|
||||
|
@ -190,6 +191,24 @@ public class XmlParserDstu2Test {
|
|||
assertEquals("ORG", o.getName());
|
||||
}
|
||||
|
||||
/**
|
||||
* See #308
|
||||
*/
|
||||
@Test
|
||||
public void testDeclaredExtensionsDontProduceWarning() {
|
||||
ReportObservation obs = new ReportObservation();
|
||||
obs.setReadOnly(true);
|
||||
|
||||
IParser p = ourCtx.newJsonParser();
|
||||
p.setParserErrorHandler(mock(IParserErrorHandler.class, new ThrowsException(new IllegalStateException())));
|
||||
|
||||
String encoded = p.encodeResourceToString(obs);
|
||||
ourLog.info(encoded);
|
||||
|
||||
obs = p.parseResource(ReportObservation.class, encoded);
|
||||
assertEquals(true, obs.getReadOnly().getValue().booleanValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDuration() {
|
||||
Encounter enc = new Encounter();
|
||||
|
|
|
@ -170,6 +170,10 @@
|
|||
generics this helps improve the error message at runtime. Thanks to Hugo Soares for
|
||||
suggesting.
|
||||
</action>
|
||||
<action type="fix" issue="308">
|
||||
Prevent an unneeded warning when parsing a resource containing
|
||||
a declared extension. Thanks to Matt Blanchette for reporting!
|
||||
</action>
|
||||
</release>
|
||||
<release version="1.4" date="2016-02-04">
|
||||
<action type="add">
|
||||
|
|
Loading…
Reference in New Issue