Add test for #11

This commit is contained in:
James Agnew 2014-08-26 10:13:35 -04:00
parent faa28cb825
commit 84c479927e
1 changed files with 19 additions and 0 deletions

View File

@ -729,6 +729,25 @@ public class XmlParserTest {
assertThat(str, StringContains.containsString("<Patient xmlns=\"http://hl7.org/fhir\">"));
}
@Test
public void testDuplicateContainedResources() {
Observation resA = new Observation();
resA.getName().setText("A");
Observation resB = new Observation();
resB.getName().setText("B");
resB.addRelated().setTarget(new ResourceReferenceDt(resA));
resB.addRelated().setTarget(new ResourceReferenceDt(resA));
String encoded = ourCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(resB);
ourLog.info(encoded);
assertThat(encoded, stringContainsInOrder(Arrays.asList("<contained>", "<Observation", "</Observation>", "</contained>")));
assertThat(encoded, not(stringContainsInOrder(Arrays.asList("<contained>", "<Observation", "</Observation>", "<Obser", "</contained>"))));
}
@Test
public void testNestedContainedResources() {