re-org validator tests
This commit is contained in:
parent
91cf756386
commit
8b25da3443
|
@ -0,0 +1,206 @@
|
|||
package org.hl7.fhir.r4.context;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.hl7.fhir.r4.model.CodeSystem;
|
||||
import org.hl7.fhir.r4.model.MetadataResource;
|
||||
import org.hl7.fhir.utilities.VersionUtilities;
|
||||
|
||||
/**
|
||||
* This manages a cached list of resources, and provides high speed access by URL / URL+version, and assumes that patch version doesn't matter for access
|
||||
* note, though, that not all resources have semver versions
|
||||
*
|
||||
* @author graha
|
||||
*
|
||||
*/
|
||||
|
||||
public class CanonicalResourceManager<T extends MetadataResource> {
|
||||
|
||||
public class MetadataResourceVersionComparator<T extends MetadataResource> implements Comparator<T> {
|
||||
@Override
|
||||
public int compare(T arg1, T arg2) {
|
||||
String v1 = arg1.getVersion();
|
||||
String v2 = arg2.getVersion();
|
||||
if (v1 == null && v2 == null) {
|
||||
return Integer.compare(list.indexOf(arg1), list.indexOf(arg2)); // retain original order
|
||||
} else if (v1 == null) {
|
||||
return -1;
|
||||
} else if (v2 == null) {
|
||||
return 1;
|
||||
} else {
|
||||
String mm1 = VersionUtilities.getMajMin(v1);
|
||||
String mm2 = VersionUtilities.getMajMin(v2);
|
||||
if (mm1 == null || mm2 == null) {
|
||||
return v1.compareTo(v2);
|
||||
} else {
|
||||
return mm1.compareTo(mm2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private boolean enforceUniqueId;
|
||||
private List<T> list = new ArrayList<>();
|
||||
private Map<String, T> map = new HashMap<>();
|
||||
|
||||
|
||||
public CanonicalResourceManager(boolean enforceUniqueId) {
|
||||
super();
|
||||
this.enforceUniqueId = enforceUniqueId;
|
||||
}
|
||||
|
||||
public void copy(CanonicalResourceManager<T> source) {
|
||||
list.clear();
|
||||
map.clear();
|
||||
list.addAll(source.list);
|
||||
map.putAll(source.map);
|
||||
}
|
||||
|
||||
public void see(T r) {
|
||||
if (!r.hasId()) {
|
||||
r.setId(UUID.randomUUID().toString());
|
||||
}
|
||||
if (enforceUniqueId && map.containsKey(r.getId())) {
|
||||
drop(r.getId());
|
||||
}
|
||||
list.add(r);
|
||||
map.put(r.getId(), r); // we do this so we can drop by id
|
||||
|
||||
if (r.hasUrl()) {
|
||||
// first, this is the correct reosurce for this version (if it has a version)
|
||||
if (r.hasVersion()) {
|
||||
map.put(r.getUrl()+"|"+r.getVersion(), r);
|
||||
}
|
||||
updateList(r.getUrl(), r.getVersion());
|
||||
}
|
||||
}
|
||||
|
||||
private void updateList(String url, String version) {
|
||||
List<T> rl = new ArrayList<T>();
|
||||
for (T t : list) {
|
||||
if (url.equals(t.getUrl()) && !rl.contains(t)) {
|
||||
rl.add(t);
|
||||
}
|
||||
}
|
||||
if (rl.size() > 0) {
|
||||
// sort by version as much as we are able
|
||||
Collections.sort(rl, new MetadataResourceVersionComparator<T>());
|
||||
// the current is the latest
|
||||
map.put(url, rl.get(rl.size()-1));
|
||||
// now, also, the latest for major/minor
|
||||
if (version != null) {
|
||||
T latest = null;
|
||||
for (T t : rl) {
|
||||
if (VersionUtilities.versionsCompatible(t.getVersion(), version)) {
|
||||
latest = t;
|
||||
}
|
||||
}
|
||||
if (latest != null) { // might be null if it's not using semver
|
||||
String lv = VersionUtilities.getMajMin(latest.getVersion());
|
||||
if (lv != null && !lv.equals(version))
|
||||
map.put(url+"|"+lv, rl.get(rl.size()-1));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public T get(String url) {
|
||||
return map.get(url);
|
||||
}
|
||||
|
||||
public boolean has(String url) {
|
||||
return map.containsKey(url);
|
||||
}
|
||||
|
||||
public T get(String system, String version) {
|
||||
if (map.containsKey(system+"|"+version))
|
||||
return map.get(system+"|"+version);
|
||||
String mm = VersionUtilities.getMajMin(version);
|
||||
if (mm != null)
|
||||
return map.get(system+"|"+mm);
|
||||
else
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean has(String system, String version) {
|
||||
if (map.containsKey(system+"|"+version))
|
||||
return true;
|
||||
String mm = VersionUtilities.getMajMin(version);
|
||||
if (mm != null)
|
||||
return map.containsKey(system+"|"+mm);
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
public int size() {
|
||||
return list.size();
|
||||
}
|
||||
|
||||
public void drop(String id) {
|
||||
T res = null;
|
||||
do {
|
||||
res = null;
|
||||
for (T t : list) {
|
||||
if (t.getId().equals(id)) {
|
||||
res = t;
|
||||
}
|
||||
}
|
||||
if (res != null) {
|
||||
list.remove(res);
|
||||
map.remove(id);
|
||||
map.remove(res.getUrl());
|
||||
if (res.hasVersion()) {
|
||||
map.remove(res.getUrl()+"|"+res.getVersion());
|
||||
String mm = VersionUtilities.getMajMin(res.getVersion());
|
||||
if (mm != null) {
|
||||
map.remove(res.getUrl()+"|"+mm);
|
||||
}
|
||||
}
|
||||
updateList(res.getUrl(), res.getVersion());
|
||||
}
|
||||
} while (res != null);
|
||||
}
|
||||
|
||||
|
||||
public void listAll(List<T> result) {
|
||||
result.addAll(list);
|
||||
}
|
||||
|
||||
public void listAllM(List<MetadataResource> result) {
|
||||
result.addAll(list);
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
list.clear();
|
||||
map.clear();
|
||||
|
||||
}
|
||||
|
||||
public List<T> getList() {
|
||||
List<T> res = new ArrayList<>();
|
||||
for (T t : list) {
|
||||
if (!res.contains(t)) {
|
||||
res.add(t);
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
public Set<String> keys() {
|
||||
return map.keySet();
|
||||
}
|
||||
|
||||
public boolean isEnforceUniqueId() {
|
||||
return enforceUniqueId;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,224 @@
|
|||
package org.hl7.fhir.r5.model;
|
||||
|
||||
|
||||
/*
|
||||
* #%L
|
||||
* org.hl7.fhir.r5
|
||||
* %%
|
||||
* Copyright (C) 2014 - 2019 Health Level 7
|
||||
* %%
|
||||
* Licensed under the Apache License, Version 2.0 (the \"License\");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an \"AS IS\" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* #L%
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright (c) 2011+, HL7, Inc.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification, \
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this \
|
||||
list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright notice, \
|
||||
this list of conditions and the following disclaimer in the documentation \
|
||||
and/or other materials provided with the distribution.
|
||||
* Neither the name of HL7 nor the names of its contributors may be used to
|
||||
endorse or promote products derived from this software without specific
|
||||
prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND \
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED \
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. \
|
||||
IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, \
|
||||
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT \
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR \
|
||||
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, \
|
||||
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) \
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE \
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
// Generated on Thu, Dec 13, 2018 14:07+1100 for FHIR v4.0.0
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import org.hl7.fhir.r5.model.Enumerations.*;
|
||||
import org.hl7.fhir.instance.model.api.IBaseBackboneElement;
|
||||
import org.hl7.fhir.exceptions.FHIRException;
|
||||
import org.hl7.fhir.instance.model.api.ICompositeType;
|
||||
import ca.uhn.fhir.model.api.annotation.ResourceDef;
|
||||
import ca.uhn.fhir.model.api.annotation.SearchParamDefinition;
|
||||
import org.hl7.fhir.instance.model.api.IBaseBackboneElement;
|
||||
import ca.uhn.fhir.model.api.annotation.Child;
|
||||
import ca.uhn.fhir.model.api.annotation.ChildOrder;
|
||||
import ca.uhn.fhir.model.api.annotation.Description;
|
||||
import ca.uhn.fhir.model.api.annotation.Block;
|
||||
|
||||
/**
|
||||
* Common Ancestor declaration for conformance and knowledge artifact resources.
|
||||
*/
|
||||
public abstract class MetadataResource extends CanonicalResource {
|
||||
|
||||
private static final long serialVersionUID = 0L;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public MetadataResource() {
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return {@link #approvalDate} (The date on which the resource content was approved by the publisher. Approval happens once when the content is officially approved for usage.). This is the underlying object with id, value and extensions. The accessor "getApprovalDate" gives direct access to the value
|
||||
*/
|
||||
public abstract DateType getApprovalDateElement();
|
||||
|
||||
public abstract boolean hasApprovalDateElement();
|
||||
public abstract boolean hasApprovalDate();
|
||||
|
||||
/**
|
||||
* @param value {@link #approvalDate} (The date on which the resource content was approved by the publisher. Approval happens once when the content is officially approved for usage.). This is the underlying object with id, value and extensions. The accessor "getApprovalDate" gives direct access to the value
|
||||
*/
|
||||
public abstract MetadataResource setApprovalDateElement(DateType value);
|
||||
/**
|
||||
* @return The date on which the resource content was approved by the publisher. Approval happens once when the content is officially approved for usage.
|
||||
*/
|
||||
public abstract Date getApprovalDate();
|
||||
/**
|
||||
* @param value The date on which the resource content was approved by the publisher. Approval happens once when the content is officially approved for usage.
|
||||
*/
|
||||
public abstract MetadataResource setApprovalDate(Date value);
|
||||
/**
|
||||
* @return {@link #lastReviewDate} (The date on which the resource content was last reviewed. Review happens periodically after approval but does not change the original approval date.). This is the underlying object with id, value and extensions. The accessor "getLastReviewDate" gives direct access to the value
|
||||
*/
|
||||
public abstract DateType getLastReviewDateElement();
|
||||
|
||||
public abstract boolean hasLastReviewDateElement();
|
||||
public abstract boolean hasLastReviewDate();
|
||||
|
||||
/**
|
||||
* @param value {@link #lastReviewDate} (The date on which the resource content was last reviewed. Review happens periodically after approval but does not change the original approval date.). This is the underlying object with id, value and extensions. The accessor "getLastReviewDate" gives direct access to the value
|
||||
*/
|
||||
public abstract MetadataResource setLastReviewDateElement(DateType value);
|
||||
/**
|
||||
* @return The date on which the resource content was last reviewed. Review happens periodically after approval but does not change the original approval date.
|
||||
*/
|
||||
public abstract Date getLastReviewDate();
|
||||
/**
|
||||
* @param value The date on which the resource content was last reviewed. Review happens periodically after approval but does not change the original approval date.
|
||||
*/
|
||||
public abstract MetadataResource setLastReviewDate(Date value);
|
||||
/**
|
||||
* @return {@link #effectivePeriod} (The period during which the metadata resource content was or is planned to be in active use.)
|
||||
*/
|
||||
public abstract Period getEffectivePeriod();
|
||||
public abstract boolean hasEffectivePeriod();
|
||||
/**
|
||||
* @param value {@link #effectivePeriod} (The period during which the metadata resource content was or is planned to be in active use.)
|
||||
*/
|
||||
public abstract MetadataResource setEffectivePeriod(Period value);
|
||||
|
||||
protected void listChildren(List<Property> children) {
|
||||
super.listChildren(children);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException {
|
||||
switch (_hash) {
|
||||
default: return super.getNamedProperty(_hash, _name, _checkValid);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
|
||||
switch (hash) {
|
||||
default: return super.getProperty(hash, name, checkValid);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Base setProperty(int hash, String name, Base value) throws FHIRException {
|
||||
switch (hash) {
|
||||
default: return super.setProperty(hash, name, value);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Base setProperty(String name, Base value) throws FHIRException {
|
||||
return super.setProperty(name, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Base makeProperty(int hash, String name) throws FHIRException {
|
||||
switch (hash) {
|
||||
default: return super.makeProperty(hash, name);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getTypesForProperty(int hash, String name) throws FHIRException {
|
||||
switch (hash) {
|
||||
default: return super.getTypesForProperty(hash, name);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Base addChild(String name) throws FHIRException {
|
||||
return super.addChild(name);
|
||||
}
|
||||
|
||||
public String fhirType() {
|
||||
return "MetadataResource";
|
||||
|
||||
}
|
||||
|
||||
public abstract MetadataResource copy();
|
||||
|
||||
public void copyValues(MetadataResource dst) {
|
||||
super.copyValues(dst);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equalsDeep(Base other_) {
|
||||
if (!super.equalsDeep(other_))
|
||||
return false;
|
||||
if (!(other_ instanceof MetadataResource))
|
||||
return false;
|
||||
MetadataResource o = (MetadataResource) other_;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equalsShallow(Base other_) {
|
||||
if (!super.equalsShallow(other_))
|
||||
return false;
|
||||
if (!(other_ instanceof MetadataResource))
|
||||
return false;
|
||||
MetadataResource o = (MetadataResource) other_;
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean isEmpty() {
|
||||
return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
<configuration scan="true" scanPeriod="30 seconds">
|
||||
|
||||
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
|
||||
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
|
||||
<level>INFO</level>
|
||||
</filter>
|
||||
<encoder>
|
||||
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{36} [%file:%line] %msg%n</pattern>
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
<root level="info">
|
||||
<appender-ref ref="STDOUT" />
|
||||
</root>
|
||||
|
||||
</configuration>
|
|
@ -1,6 +1,8 @@
|
|||
package org.hl7.fhir.validation.tests;
|
||||
|
||||
import com.google.common.base.Charsets;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
|
@ -29,11 +31,14 @@ import org.hl7.fhir.r5.utils.IResourceValidator.IValidatorResourceFetcher;
|
|||
import org.hl7.fhir.r5.utils.IResourceValidator.ReferenceValidationPolicy;
|
||||
import org.hl7.fhir.r5.validation.InstanceValidator;
|
||||
import org.hl7.fhir.r5.validation.ValidationEngine;
|
||||
import org.hl7.fhir.utilities.TextFile;
|
||||
import org.hl7.fhir.utilities.Utilities;
|
||||
import org.hl7.fhir.utilities.VersionUtilities;
|
||||
import org.hl7.fhir.utilities.json.JSONUtil;
|
||||
import org.hl7.fhir.utilities.validation.ValidationMessage;
|
||||
import org.hl7.fhir.utilities.validation.ValidationMessage.IssueSeverity;
|
||||
import org.hl7.fhir.validation.tests.utilities.TestUtilities;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
@ -53,13 +58,9 @@ public class ValidationTestSuite implements IEvaluationContext, IValidatorResour
|
|||
String contents = TestingUtilities.loadTestResource("validator", "manifest.json");
|
||||
|
||||
Map<String, JsonObject> examples = new HashMap<String, JsonObject>();
|
||||
JsonObject json = (JsonObject) new com.google.gson.JsonParser().parse(contents);
|
||||
json = json.getAsJsonObject("validator-tests");
|
||||
for (Entry<String, JsonElement> e : json.getAsJsonObject("Json").entrySet()) {
|
||||
examples.put("Json."+e.getKey(), e.getValue().getAsJsonObject());
|
||||
}
|
||||
for (Entry<String, JsonElement> e : json.getAsJsonObject("Xml").entrySet()) {
|
||||
examples.put("Xml."+e.getKey(), e.getValue().getAsJsonObject());
|
||||
manifest = (JsonObject) new com.google.gson.JsonParser().parse(contents);
|
||||
for (Entry<String, JsonElement> e : manifest.getAsJsonObject("test-cases").entrySet()) {
|
||||
examples.put(e.getKey(), e.getValue().getAsJsonObject());
|
||||
}
|
||||
|
||||
List<String> names = new ArrayList<String>(examples.size());
|
||||
|
@ -73,6 +74,8 @@ public class ValidationTestSuite implements IEvaluationContext, IValidatorResour
|
|||
return objects;
|
||||
}
|
||||
|
||||
private static JsonObject manifest;
|
||||
|
||||
private String name;
|
||||
private JsonObject content;
|
||||
|
||||
|
@ -105,6 +108,8 @@ public class ValidationTestSuite implements IEvaluationContext, IValidatorResour
|
|||
ve.put(v, new ValidationEngine("hl7.fhir.r4.core#4.0.1", DEF_TX, null, FhirPublication.R4, true));
|
||||
else if (v.startsWith("1.0"))
|
||||
ve.put(v, new ValidationEngine("hl7.fhir.r2.core#1.0.2", DEF_TX, null, FhirPublication.DSTU2, true));
|
||||
else if (v.startsWith("1.4"))
|
||||
ve.put(v, new ValidationEngine("hl7.fhir.r2b.core#1.4.0", DEF_TX, null, FhirPublication.DSTU2016May, true));
|
||||
else
|
||||
throw new Exception("unknown version "+v);
|
||||
}
|
||||
|
@ -114,7 +119,7 @@ public class ValidationTestSuite implements IEvaluationContext, IValidatorResour
|
|||
if (content.has("use-test") && !content.get("use-test").getAsBoolean())
|
||||
return;
|
||||
|
||||
String testCaseContent = TestingUtilities.loadTestResource("validator", name.substring(name.indexOf(".")+1));
|
||||
String testCaseContent = TestingUtilities.loadTestResource("validator", name);
|
||||
|
||||
InstanceValidator val = vCurr.getValidator();
|
||||
val.setDebug(false);
|
||||
|
@ -150,7 +155,7 @@ public class ValidationTestSuite implements IEvaluationContext, IValidatorResour
|
|||
}
|
||||
}
|
||||
List<ValidationMessage> errors = new ArrayList<ValidationMessage>();
|
||||
if (name.startsWith("Json."))
|
||||
if (name.endsWith(".json"))
|
||||
val.validate(null, errors, IOUtils.toInputStream(testCaseContent, Charsets.UTF_8), FhirFormat.JSON);
|
||||
else
|
||||
val.validate(null, errors, IOUtils.toInputStream(testCaseContent, Charsets.UTF_8), FhirFormat.XML);
|
||||
|
@ -171,7 +176,7 @@ public class ValidationTestSuite implements IEvaluationContext, IValidatorResour
|
|||
v = content.has("version") ? content.get("version").getAsString() : Constants.VERSION;
|
||||
StructureDefinition sd = loadProfile(filename, contents, v, messages);
|
||||
List<ValidationMessage> errorsProfile = new ArrayList<ValidationMessage>();
|
||||
if (name.startsWith("Json."))
|
||||
if (name.endsWith(".json"))
|
||||
val.validate(null, errorsProfile, IOUtils.toInputStream(testCaseContent, Charsets.UTF_8), FhirFormat.JSON, sd);
|
||||
else
|
||||
val.validate(null, errorsProfile, IOUtils.toInputStream(testCaseContent, Charsets.UTF_8), FhirFormat.XML, sd);
|
||||
|
@ -191,7 +196,7 @@ public class ValidationTestSuite implements IEvaluationContext, IValidatorResour
|
|||
}
|
||||
}
|
||||
List<ValidationMessage> errorsLogical = new ArrayList<ValidationMessage>();
|
||||
Element le = val.validate(null, errorsLogical, IOUtils.toInputStream(testCaseContent, Charsets.UTF_8), (name.startsWith("Json.")) ? FhirFormat.JSON : FhirFormat.XML);
|
||||
Element le = val.validate(null, errorsLogical, IOUtils.toInputStream(testCaseContent, Charsets.UTF_8), (name.endsWith(".json")) ? FhirFormat.JSON : FhirFormat.XML);
|
||||
if (logical.has("expressions")) {
|
||||
FHIRPathEngine fp = new FHIRPathEngine(val.getContext());
|
||||
for (JsonElement e : logical.getAsJsonArray("expressions")) {
|
||||
|
@ -203,6 +208,7 @@ public class ValidationTestSuite implements IEvaluationContext, IValidatorResour
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
public StructureDefinition loadProfile(String filename, String contents, String v, List<ValidationMessage> messages) throws IOException, FHIRFormatError, FileNotFoundException, FHIRException, DefinitionException {
|
||||
StructureDefinition sd = (StructureDefinition) loadResource(filename, contents, v);
|
||||
ProfileUtilities pu = new ProfileUtilities(TestingUtilities.context(), messages, null);
|
||||
|
@ -256,6 +262,7 @@ public class ValidationTestSuite implements IEvaluationContext, IValidatorResour
|
|||
}
|
||||
|
||||
private void checkOutcomes(List<ValidationMessage> errors, JsonObject focus) {
|
||||
JsonObject java = focus.getAsJsonObject("java");
|
||||
int ec = 0;
|
||||
int wc = 0;
|
||||
int hc = 0;
|
||||
|
@ -270,17 +277,25 @@ public class ValidationTestSuite implements IEvaluationContext, IValidatorResour
|
|||
}
|
||||
if (vm.getLevel() == IssueSeverity.INFORMATION) {
|
||||
hc++;
|
||||
if (focus.has("infoCount")) {
|
||||
if (java.has("infoCount")) {
|
||||
System.out.println("hint: "+vm.getDisplay());
|
||||
}
|
||||
}
|
||||
}
|
||||
if (TestingUtilities.context().isNoTerminologyServer() || !focus.has("tx-dependent")) {
|
||||
Assert.assertEquals("Expected "+Integer.toString(focus.get("errorCount").getAsInt())+" errors, but found "+Integer.toString(ec)+".", focus.get("errorCount").getAsInt(), ec);
|
||||
if (focus.has("warningCount"))
|
||||
Assert.assertEquals("Expected "+Integer.toString(focus.get("warningCount").getAsInt())+" warnings, but found "+Integer.toString(wc)+".", focus.get("warningCount").getAsInt(), wc);
|
||||
if (focus.has("infoCount"))
|
||||
Assert.assertEquals("Expected "+Integer.toString(focus.get("infoCount").getAsInt())+" hints, but found "+Integer.toString(hc)+".", focus.get("infoCount").getAsInt(), hc);
|
||||
Assert.assertEquals("Expected "+Integer.toString(java.get("errorCount").getAsInt())+" errors, but found "+Integer.toString(ec)+".", java.get("errorCount").getAsInt(), ec);
|
||||
if (java.has("warningCount"))
|
||||
Assert.assertEquals("Expected "+Integer.toString(java.get("warningCount").getAsInt())+" warnings, but found "+Integer.toString(wc)+".", java.get("warningCount").getAsInt(), wc);
|
||||
if (java.has("infoCount"))
|
||||
Assert.assertEquals("Expected "+Integer.toString(java.get("infoCount").getAsInt())+" hints, but found "+Integer.toString(hc)+".", java.get("infoCount").getAsInt(), hc);
|
||||
}
|
||||
if (focus.has("output")) {
|
||||
focus.remove("output");
|
||||
}
|
||||
JsonArray vr = new JsonArray();
|
||||
java.add("output", vr);
|
||||
for (ValidationMessage vm : errors) {
|
||||
vr.add(vm.getDisplay());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -373,4 +388,10 @@ public class ValidationTestSuite implements IEvaluationContext, IValidatorResour
|
|||
return vCurr.getContext().fetchResource(ValueSet.class, url);
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static void saveWhenDone() throws IOException {
|
||||
String content = new GsonBuilder().setPrettyPrinting().create().toJson(manifest);
|
||||
TextFile.stringToFile(content, Utilities.path("[tmp]", "validator-produced-manifest.json"));
|
||||
|
||||
}
|
||||
}
|
||||
|
|
2
pom.xml
2
pom.xml
|
@ -17,7 +17,7 @@
|
|||
|
||||
<properties>
|
||||
<hapi_fhir_version>4.1.0</hapi_fhir_version>
|
||||
<validator_test_case_version>1.0.25-SNAPSHOT</validator_test_case_version>
|
||||
<validator_test_case_version>1.0.26-SNAPSHOT</validator_test_case_version>
|
||||
</properties>
|
||||
|
||||
<artifactId>org.hl7.fhir.core</artifactId>
|
||||
|
|
Loading…
Reference in New Issue