* Add test for #3890 * Remove unneeded import * Add changelog
This commit is contained in:
parent
60a879c842
commit
f4a0397b18
|
@ -123,7 +123,7 @@ public class JsonParser extends BaseParser implements IJsonLikeParser {
|
|||
}
|
||||
|
||||
private boolean addToHeldExtensions(int valueIdx, List<? extends IBaseExtension<?, ?>> ext, ArrayList<ArrayList<HeldExtension>> list, boolean theIsModifier, CompositeChildElement theChildElem,
|
||||
CompositeChildElement theParent, EncodeContext theEncodeContext, boolean theContainedResource, IBase theContainingElement) {
|
||||
CompositeChildElement theParent, EncodeContext theEncodeContext, boolean theContainedResource, IBase theContainingElement) {
|
||||
boolean retVal = false;
|
||||
if (ext.size() > 0) {
|
||||
Boolean encodeExtension = null;
|
||||
|
@ -1379,6 +1379,10 @@ public class JsonParser extends BaseParser implements IJsonLikeParser {
|
|||
}
|
||||
}
|
||||
|
||||
private static void write(JsonLikeWriter theWriter, String theName, String theValue) throws IOException {
|
||||
theWriter.write(theName, theValue);
|
||||
}
|
||||
|
||||
private class HeldExtension implements Comparable<HeldExtension> {
|
||||
|
||||
private CompositeChildElement myChildElem;
|
||||
|
@ -1562,8 +1566,4 @@ public class JsonParser extends BaseParser implements IJsonLikeParser {
|
|||
theEventWriter.endObject();
|
||||
}
|
||||
}
|
||||
|
||||
private static void write(JsonLikeWriter theWriter, String theName, String theValue) throws IOException {
|
||||
theWriter.write(theName, theValue);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
---
|
||||
type: fix
|
||||
issue: 3890
|
||||
title: "When serializing references where the reference target has been instantiated using a resource object and
|
||||
not a reference string, the serialization was omitted when the reference appeared in the resource
|
||||
metadata section. This has been corrected."
|
|
@ -14,6 +14,7 @@ import org.apache.commons.io.IOUtils;
|
|||
import org.apache.commons.io.output.NullWriter;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||
import org.hl7.fhir.r4.model.Appointment;
|
||||
import org.hl7.fhir.r4.model.AuditEvent;
|
||||
import org.hl7.fhir.r4.model.Basic;
|
||||
import org.hl7.fhir.r4.model.Binary;
|
||||
|
@ -28,8 +29,10 @@ import org.hl7.fhir.r4.model.Medication;
|
|||
import org.hl7.fhir.r4.model.MedicationDispense;
|
||||
import org.hl7.fhir.r4.model.MedicationRequest;
|
||||
import org.hl7.fhir.r4.model.MessageHeader;
|
||||
import org.hl7.fhir.r4.model.Meta;
|
||||
import org.hl7.fhir.r4.model.Narrative;
|
||||
import org.hl7.fhir.r4.model.Observation;
|
||||
import org.hl7.fhir.r4.model.Organization;
|
||||
import org.hl7.fhir.r4.model.Patient;
|
||||
import org.hl7.fhir.r4.model.Practitioner;
|
||||
import org.hl7.fhir.r4.model.PrimitiveType;
|
||||
|
@ -67,6 +70,8 @@ import static org.hamcrest.Matchers.stringContainsInOrder;
|
|||
import static org.hamcrest.core.IsNot.not;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
import static org.junit.jupiter.api.Assertions.fail;
|
||||
|
||||
public class JsonParserR4Test extends BaseTest {
|
||||
|
@ -736,6 +741,31 @@ public class JsonParserR4Test extends BaseTest {
|
|||
|
||||
}
|
||||
|
||||
/**
|
||||
* See #3890
|
||||
*/
|
||||
@Test
|
||||
public void testEncodeExtensionWithReferenceObjectValue() {
|
||||
|
||||
Appointment appointment = new Appointment();
|
||||
appointment.setId("123");
|
||||
|
||||
Meta meta = new Meta();
|
||||
Extension extension = new Extension();
|
||||
extension.setUrl("http://example-source-team.com");
|
||||
extension.setValue(new Reference(new Organization().setId("546")));
|
||||
meta.addExtension(extension);
|
||||
appointment.setMeta(meta);
|
||||
|
||||
var parser = ourCtx.newJsonParser();
|
||||
String output = parser.encodeResourceToString(appointment);
|
||||
ourLog.info("Output: {}", output);
|
||||
|
||||
Appointment input = parser.parseResource(Appointment.class, output);
|
||||
|
||||
assertNotNull(input.getMeta().getExtensionByUrl("http://example-source-team.com"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testParseExtensionWithUriValue_BuiltInStructure() {
|
||||
String input = "{\n" +
|
||||
|
|
|
@ -5,19 +5,25 @@ import static org.hamcrest.Matchers.containsString;
|
|||
import static org.hamcrest.Matchers.stringContainsInOrder;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
|
||||
import org.hl7.fhir.r4.model.Appointment;
|
||||
import org.hl7.fhir.r4.model.AuditEvent;
|
||||
import org.hl7.fhir.r4.model.Bundle;
|
||||
import org.hl7.fhir.r4.model.Composition;
|
||||
import org.hl7.fhir.r4.model.DocumentReference;
|
||||
import org.hl7.fhir.r4.model.Extension;
|
||||
import org.hl7.fhir.r4.model.MessageHeader;
|
||||
import org.hl7.fhir.r4.model.Meta;
|
||||
import org.hl7.fhir.r4.model.Narrative;
|
||||
import org.hl7.fhir.r4.model.Observation;
|
||||
import org.hl7.fhir.r4.model.Organization;
|
||||
import org.hl7.fhir.r4.model.Parameters;
|
||||
import org.hl7.fhir.r4.model.Patient;
|
||||
import org.hl7.fhir.r4.model.Reference;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
@ -45,6 +51,32 @@ public class XmlParserR4Test extends BaseTest {
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* See #3890
|
||||
*/
|
||||
@Test
|
||||
public void testEncodeExtensionWithReferenceObjectValue() {
|
||||
|
||||
Appointment appointment = new Appointment();
|
||||
appointment.setId("123");
|
||||
|
||||
Meta meta = new Meta();
|
||||
Extension extension = new Extension();
|
||||
extension.setUrl("http://example-source-team.com");
|
||||
extension.setValue(new Reference(new Organization().setId("546")));
|
||||
meta.addExtension(extension);
|
||||
appointment.setMeta(meta);
|
||||
|
||||
var parser = ourCtx.newXmlParser();
|
||||
String output = parser.encodeResourceToString(appointment);
|
||||
ourLog.info("Output: {}", output);
|
||||
|
||||
Appointment input = parser.parseResource(Appointment.class, output);
|
||||
|
||||
assertNotNull(input.getMeta().getExtensionByUrl("http://example-source-team.com"));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Ensure that a contained bundle doesn't cause a crash
|
||||
*/
|
||||
|
|
Loading…
Reference in New Issue