#274 - test illustrating bug

This commit is contained in:
Bill de Beaubien 2015-12-20 21:09:58 -05:00
parent 9e110506f7
commit c66429ef3c
1 changed files with 28 additions and 0 deletions

View File

@ -0,0 +1,28 @@
package ca.uhn.fhir.parser;
import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.model.dstu2.composite.CodingDt;
import ca.uhn.fhir.model.dstu2.resource.Observation;
import ca.uhn.fhir.model.primitive.StringDt;
import org.junit.Ignore;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
/**
* Created by Bill de Beaubien on 12/20/2015.
*/
public class EmptyElementWithExtensionTest {
@Ignore
@Test
public void testNullFlavor() throws Exception {
Observation observation = new Observation();
observation.getCode().getCoding().add(new CodingDt().setSystem("http://loinc.org").setCode("3141-9"));
observation.getStatusElement().addUndeclaredExtension(false, "http://hl7.org/fhir/StructureDefinition/iso21090-nullFlavor", new StringDt("UNK"));
FhirContext ctx = FhirContext.forDstu2();
IParser parser = ctx.newXmlParser().setPrettyPrint(true);
String xml = parser.encodeResourceToString(observation);
observation = (Observation) parser.parseResource(xml);
assertEquals(1, observation.getStatusElement().getUndeclaredExtensions().size());
}
}