From b2e17dd746203c064d6f991ca9de7b05287ee067 Mon Sep 17 00:00:00 2001 From: jamesagnew Date: Sun, 26 Jul 2015 18:07:48 -0400 Subject: [PATCH] Add test --- .../java/ca/uhn/fhir/parser/JsonParserTest.java | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/parser/JsonParserTest.java b/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/parser/JsonParserTest.java index c30b4efeb4b..093316a9974 100644 --- a/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/parser/JsonParserTest.java +++ b/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/parser/JsonParserTest.java @@ -59,6 +59,7 @@ import ca.uhn.fhir.model.dstu.resource.Patient; import ca.uhn.fhir.model.dstu.resource.Profile; import ca.uhn.fhir.model.dstu.resource.Query; import ca.uhn.fhir.model.dstu.resource.Questionnaire; +import ca.uhn.fhir.model.dstu.resource.Remittance; import ca.uhn.fhir.model.dstu.resource.Specimen; import ca.uhn.fhir.model.dstu.resource.ValueSet; import ca.uhn.fhir.model.dstu.resource.ValueSet.Define; @@ -115,6 +116,21 @@ public class JsonParserTest { assertEquals(number, parsed.getPosition().getLatitude().getValueAsString()); } + + @Test + public void testDecimalPrecisionPreservedInResource() { + Remittance obs = new Remittance(); + obs.addService().setRate(new DecimalDt("0.10000")); + + String output = ourCtx.newJsonParser().encodeResourceToString(obs); + + ourLog.info(output); + assertEquals("{\"resourceType\":\"Remittance\",\"service\":[{\"rate\":0.10000}]}", output); + + obs = ourCtx.newJsonParser().parseResource(Remittance.class, output); + assertEquals("0.10000", obs.getService().get(0).getRate().getValueAsString()); + } + @Test public void testParseStringWithNewlineUnencoded() { Observation obs = new Observation();