From 16df4566bfc0f3aec85ee7a4adf68fa8a7fc5c4c Mon Sep 17 00:00:00 2001 From: jamesagnew Date: Fri, 24 Jun 2016 06:10:03 -0400 Subject: [PATCH] Add test for #390 --- .../uhn/fhir/parser/JsonParserDstu2Test.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) 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 a3dd22d3f33..b764ba5be39 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 @@ -92,6 +92,24 @@ public class JsonParserDstu2Test { assertThat(output, containsString("\"div\":\"
VALUE
\"")); } + /** + * See #390 + */ + @Test + public void testEncodeAndParseBundleWithNoEntries() { + ca.uhn.fhir.model.dstu2.resource.Bundle b = new ca.uhn.fhir.model.dstu2.resource.Bundle(); + b.setId("123"); + String encoded = ourCtx.newJsonParser().encodeResourceToString(b); + ourLog.info(encoded); + + assertThat(encoded, containsString("123")); + assertThat(encoded, not(containsString("entry"))); + + b = ourCtx.newJsonParser().parseResource(ca.uhn.fhir.model.dstu2.resource.Bundle.class, encoded); + assertEquals("123", b.getId().getIdPart()); + assertEquals(0, b.getEntry().size()); + } + @Test public void testEncodeNarrativeShouldIncludeNamespaceWithProcessingInstruction() {