more tests fixes

This commit is contained in:
Grahame Grieve 2023-05-03 17:16:16 +10:00
parent 0b71add74c
commit 94fd0ae795
3 changed files with 24 additions and 5 deletions

View File

@ -260,7 +260,10 @@ public class ValueSetCheckerSimple extends ValueSetWorker implements ValueSetChe
if (!c.hasSystem()) {
info.addIssue(makeIssue(IssueSeverity.WARNING, IssueType.UNKNOWN, path, context.formatMessage(I18nConstants.CODING_HAS_NO_SYSTEM__CANNOT_VALIDATE)));
}
CodeSystem cs = resolveCodeSystem(c.getSystem(), c.getVersion());
VersionInfo vi = new VersionInfo();
checkExpansion(c, vi);
checkInclude(c, vi);
CodeSystem cs = resolveCodeSystem(c.getSystem(), vi.getVersion(c.getSystem(), c.getVersion()));
ValidationResult res = null;
if (cs == null || cs.getContent() != CodeSystemContentMode.COMPLETE) {
if (context.isNoTerminologyServer()) {

View File

@ -614,7 +614,11 @@ public class ValueSetExpanderSimple extends ValueSetWorker implements ValueSetEx
if (!requiredSupplements.isEmpty()) {
return new ValueSetExpansionOutcome("Required supplements not found: "+requiredSupplements.toString(), TerminologyServiceErrorClass.BUSINESS_RULE, allErrors);
}
if (!expParams.hasParameter("includeDefinition") || !expParams.getParameterBool("includeDefinition")) {
focus.setCompose(null);
focus.getExtension().clear();
focus.setPublisher(null);
}
return new ValueSetExpansionOutcome(focus);
}

View File

@ -3,7 +3,7 @@ package org.hl7.fhir.r5.test.utils;
import org.apache.commons.codec.binary.Base64;
import org.apache.commons.lang3.StringUtils;
import org.hl7.fhir.utilities.*;
import org.hl7.fhir.utilities.json.JsonUtilities;
import org.hl7.fhir.utilities.settings.FhirSettings;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
@ -245,9 +245,10 @@ public class CompareUtilities extends BaseTestingUtilities {
}
private static String compareObjects(String path, JsonObject expectedJsonObject, JsonObject actualJsonObject) {
List<String> optionals = listOptionals(expectedJsonObject);
for (Map.Entry<String, JsonElement> en : actualJsonObject.entrySet()) {
String n = en.getKey();
if (!n.equals("fhir_comments") && !n.equals("$optional$")) {
if (!n.equals("fhir_comments")) {
if (expectedJsonObject.has(n)) {
String s = compareNodes(path + '.' + n, expectedJsonObject.get(n), en.getValue());
if (!Utilities.noString(s))
@ -258,7 +259,7 @@ public class CompareUtilities extends BaseTestingUtilities {
}
for (Map.Entry<String, JsonElement> en : expectedJsonObject.entrySet()) {
String n = en.getKey();
if (!n.equals("fhir_comments") && !n.equals("$optional$")) {
if (!n.equals("fhir_comments") && !n.equals("$optional$") && !optionals.contains(n)) {
if (!actualJsonObject.has(n))
return "properties differ at " + path + ": missing property " + n;
}
@ -266,6 +267,17 @@ public class CompareUtilities extends BaseTestingUtilities {
return null;
}
private static List<String> listOptionals(JsonObject expectedJsonObject) {
List<String> res = new ArrayList<>();
if (expectedJsonObject.has("$optional-properties$")) {
res.add("$optional-properties$");
for (String s : JsonUtilities.strings(expectedJsonObject.getAsJsonArray("$optional-properties$"))) {
res.add(s);
}
}
return res;
}
private static String compareNodes(String path, JsonElement expectedJsonElement, JsonElement actualJsonElement) {
if (actualJsonElement.getClass() != expectedJsonElement.getClass())
return createNotEqualMessage("properties differ at " + path, expectedJsonElement.getClass().getName(), actualJsonElement.getClass().getName());