[(master)] Added check for sub-extensions.
This commit is contained in:
parent
b4032f4e8c
commit
1c1098a2b7
|
@ -734,6 +734,9 @@ public class JsonParser extends BaseParser implements IJsonLikeParser {
|
|||
beginArray(theEventWriter, arrayName);
|
||||
for (Map.Entry<ResourceMetadataKeyEnum<?>, Object> key : extensions) {
|
||||
ExtensionDt extension = (ExtensionDt) key.getValue();
|
||||
if (!extension.getAllUndeclaredExtensions().isEmpty()) {
|
||||
throw new IllegalArgumentException("Sub-extensions on metadata isn't supported");
|
||||
}
|
||||
theEventWriter.beginObject();
|
||||
writeOptionalTagWithTextNode(theEventWriter, "url", extension.getUrl());
|
||||
String extensionDatatype = myContext.getRuntimeChildUndeclaredExtensionDefinition().getChildNameByDatatype(extension.getValue().getClass());
|
||||
|
|
|
@ -1745,6 +1745,17 @@ public class JsonParserDstu2Test {
|
|||
// @formatter:on
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void testCannotEncodeSubextensionsOnMeta() {
|
||||
ProcedureRequest procedureRequest = new ProcedureRequest();
|
||||
procedureRequest.setStatus(ProcedureRequestStatusEnum.ACCEPTED);
|
||||
ExtensionDt parent = new ExtensionDt(false, "#parent");
|
||||
parent.addUndeclaredExtension(new ExtensionDt(false, "#child", new DurationDt().setValue(123)));
|
||||
procedureRequest.getResourceMetadata().put(new ResourceMetadataKeyEnum.ExtensionResourceMetadataKey(parent.getUrl()), parent);
|
||||
|
||||
String json = ourCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(procedureRequest);
|
||||
}
|
||||
|
||||
private void addExtensionResourceMetadataKeyToResource(BaseResource resource, boolean isModifier, String url, String value) {
|
||||
ExtensionDt extensionDt = new ExtensionDt(isModifier, url, new StringDt(value));
|
||||
resource.getResourceMetadata()
|
||||
|
|
Loading…
Reference in New Issue