Add tests for #814
This commit is contained in:
parent
18e4d85625
commit
84dcd51091
|
@ -5,10 +5,7 @@ import ca.uhn.fhir.util.TestUtil;
|
||||||
import com.google.common.collect.Sets;
|
import com.google.common.collect.Sets;
|
||||||
import org.apache.commons.io.IOUtils;
|
import org.apache.commons.io.IOUtils;
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.hl7.fhir.r4.model.Bundle;
|
import org.hl7.fhir.r4.model.*;
|
||||||
import org.hl7.fhir.r4.model.Extension;
|
|
||||||
import org.hl7.fhir.r4.model.Patient;
|
|
||||||
import org.hl7.fhir.r4.model.StringType;
|
|
||||||
import org.junit.AfterClass;
|
import org.junit.AfterClass;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
|
@ -39,6 +36,58 @@ public class JsonParserR4Test {
|
||||||
return b;
|
return b;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* See #814
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testDuplicateContainedResourcesNotOutputtedTwice() {
|
||||||
|
MedicationDispense md = new MedicationDispense();
|
||||||
|
|
||||||
|
MedicationRequest mr = new MedicationRequest();
|
||||||
|
md.addAuthorizingPrescription().setResource(mr);
|
||||||
|
|
||||||
|
Medication med = new Medication();
|
||||||
|
md.setMedication(new Reference(med));
|
||||||
|
mr.setMedication(new Reference(med));
|
||||||
|
|
||||||
|
String encoded = ourCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(md);
|
||||||
|
ourLog.info(encoded);
|
||||||
|
|
||||||
|
int idx = encoded.indexOf("\"Medication\"");
|
||||||
|
assertNotEquals(-1, idx);
|
||||||
|
|
||||||
|
idx = encoded.indexOf("\"Medication\"", idx + 1);
|
||||||
|
assertEquals(-1, idx);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* See #814
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testDuplicateContainedResourcesNotOutputtedTwiceWithManualIds() {
|
||||||
|
MedicationDispense md = new MedicationDispense();
|
||||||
|
|
||||||
|
MedicationRequest mr = new MedicationRequest();
|
||||||
|
mr.setId("#MR");
|
||||||
|
md.addAuthorizingPrescription().setResource(mr);
|
||||||
|
|
||||||
|
Medication med = new Medication();
|
||||||
|
med.setId("#MED");
|
||||||
|
md.setMedication(new Reference(med));
|
||||||
|
mr.setMedication(new Reference(med));
|
||||||
|
|
||||||
|
String encoded = ourCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(md);
|
||||||
|
ourLog.info(encoded);
|
||||||
|
|
||||||
|
int idx = encoded.indexOf("\"Medication\"");
|
||||||
|
assertNotEquals(-1, idx);
|
||||||
|
|
||||||
|
idx = encoded.indexOf("\"Medication\"", idx + 1);
|
||||||
|
assertEquals(-1, idx);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testExcludeNothing() {
|
public void testExcludeNothing() {
|
||||||
IParser parser = ourCtx.newJsonParser().setPrettyPrint(true);
|
IParser parser = ourCtx.newJsonParser().setPrettyPrint(true);
|
||||||
|
|
Loading…
Reference in New Issue