added Test for #11 to Dstu3 and R4
This commit is contained in:
parent
72cf22e3a9
commit
a8f3c2efb6
|
@ -51,6 +51,8 @@ import java.util.*;
|
|||
import static org.hamcrest.Matchers.contains;
|
||||
import static org.hamcrest.Matchers.*;
|
||||
import static org.hamcrest.Matchers.startsWith;
|
||||
import static org.hamcrest.core.IsNot.not;
|
||||
import static org.hamcrest.text.StringContainsInOrder.stringContainsInOrder;
|
||||
import static org.junit.Assert.*;
|
||||
import static org.mockito.Matchers.any;
|
||||
import static org.mockito.Mockito.*;
|
||||
|
@ -3242,6 +3244,26 @@ public class XmlParserDstu3Test {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* See #11
|
||||
*/
|
||||
@Test
|
||||
public void testDuplicateContainedResources() {
|
||||
|
||||
Observation resA = new Observation();
|
||||
resA.setComment("A");
|
||||
|
||||
Observation resB = new Observation();
|
||||
resB.setComment("B");
|
||||
resB.addBasedOn(new Reference(resA));
|
||||
resB.addBasedOn(new Reference(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>", "<Observation", "</contained>"))));
|
||||
}
|
||||
/**
|
||||
* See #551
|
||||
*/
|
||||
|
|
|
@ -1,25 +0,0 @@
|
|||
package z;
|
||||
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
import ca.uhn.fhir.util.TestUtil;
|
||||
|
||||
public class TestTest {
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
public void testId() throws InterruptedException {
|
||||
Thread.sleep(1000000);
|
||||
}
|
||||
|
||||
|
||||
@AfterClass
|
||||
public static void afterClassClearContext() {
|
||||
TestUtil.clearAllStaticFieldsForUnitTest();
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -4,17 +4,21 @@ import ca.uhn.fhir.context.FhirContext;
|
|||
import ca.uhn.fhir.util.TestUtil;
|
||||
import com.google.common.collect.Sets;
|
||||
import org.hl7.fhir.r4.model.Bundle;
|
||||
import org.hl7.fhir.r4.model.Observation;
|
||||
import org.hl7.fhir.r4.model.Patient;
|
||||
import org.hl7.fhir.r4.model.Reference;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.Test;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import static org.hamcrest.Matchers.containsString;
|
||||
import static org.hamcrest.core.IsNot.not;
|
||||
import static org.hamcrest.text.StringContainsInOrder.stringContainsInOrder;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
public class XmlParserR4Test {
|
||||
|
@ -161,6 +165,26 @@ public class XmlParserR4Test {
|
|||
|
||||
}
|
||||
|
||||
/**
|
||||
* See #11
|
||||
*/
|
||||
@Test
|
||||
public void testDuplicateContainedResources() {
|
||||
|
||||
Observation resA = new Observation();
|
||||
resA.setComment("A");
|
||||
|
||||
Observation resB = new Observation();
|
||||
resB.setComment("B");
|
||||
resB.addHasMember(new Reference(resA));
|
||||
resB.addHasMember(new Reference(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>", "<Observation", "</contained>"))));
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static void afterClassClearContext() {
|
||||
|
|
Loading…
Reference in New Issue