Merge pull request #104 from ahdis/oliveregger_fmltests

FML updates for tests and validator
This commit is contained in:
Grahame Grieve 2020-01-22 06:17:10 +11:00 committed by GitHub
commit 9b64f03a3e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 30 additions and 22 deletions

View File

@ -389,7 +389,9 @@ public class ExpressionNode {
b.append(")");
}
if (inner != null) {
if (!((ExpressionNode.Kind.Function == inner.getKind()) && (ExpressionNode.Function.Item == inner.getFunction()))) {
b.append(".");
}
b.append(inner.toString());
}
if (operation != null) {

View File

@ -248,6 +248,7 @@ public class FHIRPathEngine {
public FHIRPathEngine(IWorkerContext worker) {
super();
this.worker = worker;
if (this.worker!=null) {
for (StructureDefinition sd : worker.allStructures()) {
if (sd.getDerivation() == TypeDerivationRule.SPECIALIZATION && sd.getKind() != StructureDefinitionKind.LOGICAL)
allTypes.put(sd.getName(), sd);
@ -256,6 +257,7 @@ public class FHIRPathEngine {
}
}
}
}
// --- 3 methods to override in children -------------------------------------------------------
@ -1078,6 +1080,7 @@ public class FHIRPathEngine {
case Lower: return checkParamCount(lexer, location, exp, 0);
case Upper: return checkParamCount(lexer, location, exp, 0);
case ToChars: return checkParamCount(lexer, location, exp, 0);
case IndexOf : return checkParamCount(lexer, location, exp, 1);
case Substring: return checkParamCount(lexer, location, exp, 1, 2);
case StartsWith: return checkParamCount(lexer, location, exp, 1);
case EndsWith: return checkParamCount(lexer, location, exp, 1);

View File

@ -390,7 +390,9 @@ public class ExpressionNode {
b.append(")");
}
if (inner != null) {
if (!((ExpressionNode.Kind.Function == inner.getKind()) && (ExpressionNode.Function.Item == inner.getFunction()))) {
b.append(".");
}
b.append(inner.toString());
}
if (operation != null) {

View File

@ -82,7 +82,7 @@ public class FHIRMappingLanguageTests implements ITransformerServices {
static public void setUp() throws Exception {
if (context == null) {
PackageCacheManager pcm = new PackageCacheManager(true, ToolsVersion.TOOLS_VERSION);
context = SimpleWorkerContext.fromPackage(pcm.loadPackage("hl7.fhir.core", "4.0.0"));
context = SimpleWorkerContext.fromPackage(pcm.loadPackage("hl7.fhir.core", "4.0.1"));
jsonParser = new JsonParser();
jsonParser.setOutputStyle(OutputStyle.PRETTY);
}
@ -93,7 +93,7 @@ public class FHIRMappingLanguageTests implements ITransformerServices {
InputStream fileSource = TestingUtilities.loadTestResourceStream("r5", "fml", source);
InputStream fileMap = TestingUtilities.loadTestResourceStream("r5", "fml", map);
String fileOutput = TestingUtilities.tempFile("fml", output);
String outputJson = TestingUtilities.loadTestResource("r5","fml", output);
String fileOutputRes = TestingUtilities.tempFile("fml", output)+".out";
outputs.clear();
@ -117,9 +117,10 @@ public class FHIRMappingLanguageTests implements ITransformerServices {
if (ok) {
ByteArrayOutputStream boas = new ByteArrayOutputStream();
jsonParser.compose(boas, resource);
log(boas.toString());
String result = boas.toString();
log(result);
TextFile.bytesToFile(boas.toByteArray(), fileOutputRes);
msg = TestingUtilities.checkJsonIsSame(fileOutputRes,fileOutput);
msg = TestingUtilities.checkJsonSrcIsSame(result, outputJson);
assertTrue(msg, Utilities.noString(msg));
} else
assertTrue("Error, but proper output was expected (" + msg + ")", output.equals("$error"));