From ea27689a4040b275627fb0c69e03422919aa3e66 Mon Sep 17 00:00:00 2001 From: James Agnew Date: Fri, 13 Jan 2017 11:24:35 -0500 Subject: [PATCH] Add test for #537 --- .../uhn/fhir/parser/JsonParserDstu2Test.java | 28 +++++++++++++++++++ 1 file changed, 28 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 0dc6bdfffab..567b6c4fc89 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 @@ -1811,6 +1811,34 @@ public class JsonParserDstu2Test { TestUtil.clearAllStaticFieldsForUnitTest(); } + /** + * See #537 + */ + @Test + public void testEncodeNestedContained() { + + Organization org04 = new Organization(); + org04.setName("LEVEL04"); + + Organization org03 = new Organization(); + org03.setName("LEVEL03"); + org03.getPartOf().setResource(org04); + + Organization org02 = new Organization(); + org02.setName("LEVEL02"); + org02.getPartOf().setResource(org03); + + Organization org01 = new Organization(); + org01.setName("LEVEL01"); + org01.getPartOf().setResource(org02); + + String encoded = ourCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(org01); + ourLog.info(encoded); + + assertThat(encoded, stringContainsInOrder("LEVEL02","LEVEL03","LEVEL04","LEVEL01" )); + } + + /** * See #505 */