diff --git a/hapi-fhir-structures-dstu2/src/test/java/ca/uhn/fhir/parser/JsonParserDstu2Test.java b/hapi-fhir-structures-dstu2/src/test/java/ca/uhn/fhir/parser/JsonParserDstu2Test.java index 9a0b0bafd2a..2444b3c836d 100644 --- a/hapi-fhir-structures-dstu2/src/test/java/ca/uhn/fhir/parser/JsonParserDstu2Test.java +++ b/hapi-fhir-structures-dstu2/src/test/java/ca/uhn/fhir/parser/JsonParserDstu2Test.java @@ -8,9 +8,12 @@ import java.util.ArrayList; import java.util.List; import java.util.UUID; +import ca.uhn.fhir.model.dstu2.resource.*; +import ca.uhn.fhir.model.dstu2.valueset.*; import org.apache.commons.io.IOUtils; import org.hamcrest.Matchers; import org.junit.Assert; +import org.junit.Ignore; import org.junit.Test; import ca.uhn.fhir.context.ConfigurationException; @@ -26,20 +29,7 @@ import ca.uhn.fhir.model.base.composite.BaseCodingDt; import ca.uhn.fhir.model.dstu2.composite.CodingDt; import ca.uhn.fhir.model.dstu2.composite.HumanNameDt; import ca.uhn.fhir.model.dstu2.composite.ResourceReferenceDt; -import ca.uhn.fhir.model.dstu2.resource.Binary; import ca.uhn.fhir.model.dstu2.resource.Bundle.Entry; -import ca.uhn.fhir.model.dstu2.resource.Conformance; -import ca.uhn.fhir.model.dstu2.resource.DiagnosticReport; -import ca.uhn.fhir.model.dstu2.resource.Medication; -import ca.uhn.fhir.model.dstu2.resource.MedicationOrder; -import ca.uhn.fhir.model.dstu2.resource.Observation; -import ca.uhn.fhir.model.dstu2.resource.Patient; -import ca.uhn.fhir.model.dstu2.resource.QuestionnaireResponse; -import ca.uhn.fhir.model.dstu2.valueset.AdministrativeGenderEnum; -import ca.uhn.fhir.model.dstu2.valueset.BundleTypeEnum; -import ca.uhn.fhir.model.dstu2.valueset.IdentifierUseEnum; -import ca.uhn.fhir.model.dstu2.valueset.MaritalStatusCodesEnum; -import ca.uhn.fhir.model.dstu2.valueset.ObservationStatusEnum; import ca.uhn.fhir.model.primitive.DateDt; import ca.uhn.fhir.model.primitive.DateTimeDt; import ca.uhn.fhir.model.primitive.IdDt; @@ -1012,4 +1002,19 @@ public class JsonParserDstu2Test { Assert.assertThat(message, containsString("contained")); } + // see #241 + @Ignore + @Test + public void testEncodeThenParseShouldNotAddSpuriousId() throws Exception { + Condition condition = new Condition().setVerificationStatus(ConditionVerificationStatusEnum.CONFIRMED); + ca.uhn.fhir.model.dstu2.resource.Bundle bundle = new ca.uhn.fhir.model.dstu2.resource.Bundle(); + ca.uhn.fhir.model.dstu2.resource.Bundle.Entry entry = new ca.uhn.fhir.model.dstu2.resource.Bundle.Entry(); + entry.setFullUrl(IdDt.newRandomUuid()); + entry.setResource(condition); + bundle.getEntry().add(entry); + IParser parser = ourCtx.newJsonParser(); + String json = parser.encodeResourceToString(bundle); + bundle = (ca.uhn.fhir.model.dstu2.resource.Bundle) parser.parseResource(json); + assertTrue(bundle.getEntry().get(0).getResource().getIdElement().isEmpty()); + } }