From ee6d3d7a64772d86ba6e92af06398a57a0cdacd2 Mon Sep 17 00:00:00 2001 From: Anton Vasetenkov Date: Thu, 4 Jul 2024 06:22:45 +1200 Subject: [PATCH] Fix type conversion operator tests for malformed inputs. Enable tests for Boolean and null literals. (#1371) * Fix explicit conversion operator tests for malformed string inputs * Enable Boolean and null literal tests --------- Co-authored-by: JP --- .../org/hl7/fhirpath/CQLOperationsR4Test.java | 7 ------- .../test/java/org/hl7/fhirpath/TestFhirPath.java | 4 +++- .../hl7/fhirpath/cql/CqlTypeOperatorsTest.xml | 16 ++++++++-------- 3 files changed, 11 insertions(+), 16 deletions(-) diff --git a/Src/java/engine-fhir/src/test/java/org/hl7/fhirpath/CQLOperationsR4Test.java b/Src/java/engine-fhir/src/test/java/org/hl7/fhirpath/CQLOperationsR4Test.java index 136bf4000..5afe57d7d 100644 --- a/Src/java/engine-fhir/src/test/java/org/hl7/fhirpath/CQLOperationsR4Test.java +++ b/Src/java/engine-fhir/src/test/java/org/hl7/fhirpath/CQLOperationsR4Test.java @@ -121,26 +121,19 @@ public static Object[][] dataMethod() { "cql/CqlStringOperatorsTest/toString tests/DateTimeToString3", "cql/CqlTypeOperatorsTest/As/AsQuantity", "cql/CqlTypeOperatorsTest/As/CastAsQuantity", - "cql/CqlTypeOperatorsTest/Convert/StringToDateTimeMalformed", - "cql/CqlTypeOperatorsTest/Convert/StringToIntegerError", "cql/CqlTypeOperatorsTest/ToDateTime/ToDateTimeDate", - "cql/CqlTypeOperatorsTest/ToDateTime/ToDateTimeMalformed", "cql/CqlTypeOperatorsTest/ToDateTime/ToDateTimeTimeUnspecified", "cql/CqlTypeOperatorsTest/ToTime/ToTime2", "cql/CqlTypeOperatorsTest/ToTime/ToTime3", "cql/CqlTypeOperatorsTest/ToTime/ToTime4", - "cql/CqlTypeOperatorsTest/ToTime/ToTimeMalformed", "cql/CqlTypesTest/DateTime/DateTimeUncertain", "cql/CqlTypesTest/Time/TimeUpperBoundMillis", - "cql/ValueLiteralsAndSelectors/Boolean/BooleanFalse", - "cql/ValueLiteralsAndSelectors/Boolean/BooleanTrue", "cql/ValueLiteralsAndSelectors/Decimal/Decimal10Pow20", "cql/ValueLiteralsAndSelectors/Decimal/DecimalNeg10Pow20", "cql/ValueLiteralsAndSelectors/Decimal/DecimalNegTenthStep", "cql/ValueLiteralsAndSelectors/Decimal/DecimalPos10Pow20", "cql/ValueLiteralsAndSelectors/Decimal/DecimalPosTenthStep", "cql/ValueLiteralsAndSelectors/Decimal/DecimalTenthStep", - "cql/ValueLiteralsAndSelectors/Null/Null", "r4/tests-fhir-r4/from-Zulip/(true and 'foo').empty()", "r4/tests-fhir-r4/from-Zulip/(true | 'foo').allTrue()", "r4/tests-fhir-r4/testAggregate/testAggregate1", diff --git a/Src/java/engine-fhir/src/test/java/org/hl7/fhirpath/TestFhirPath.java b/Src/java/engine-fhir/src/test/java/org/hl7/fhirpath/TestFhirPath.java index 9e640dbd3..1da32c586 100644 --- a/Src/java/engine-fhir/src/test/java/org/hl7/fhirpath/TestFhirPath.java +++ b/Src/java/engine-fhir/src/test/java/org/hl7/fhirpath/TestFhirPath.java @@ -141,8 +141,10 @@ protected void runTest( String outputExpression = test.getOutput().get(0).getValue(); if ("null".equals(outputExpression)) { cql = String.format("%s (%s) is %s", cql, testExpression, outputExpression); + } else if ("null".equals(testExpression)) { + cql = String.format("%s (%s) is %s", cql, outputExpression, testExpression); } else { - cql = String.format("%s (%s) = %s", cql, testExpression, outputExpression); + cql = String.format("%s (%s) = (%s)", cql, testExpression, outputExpression); } } else { cql = String.format("%s %s", cql, testExpression); diff --git a/Src/java/engine-fhir/src/test/resources/org/hl7/fhirpath/cql/CqlTypeOperatorsTest.xml b/Src/java/engine-fhir/src/test/resources/org/hl7/fhirpath/cql/CqlTypeOperatorsTest.xml index 03c922e73..a6c06ad98 100644 --- a/Src/java/engine-fhir/src/test/resources/org/hl7/fhirpath/cql/CqlTypeOperatorsTest.xml +++ b/Src/java/engine-fhir/src/test/resources/org/hl7/fhirpath/cql/CqlTypeOperatorsTest.xml @@ -25,8 +25,8 @@ '5' - convert 'foo' to Integer - + convert 'foo' to Integer + null convert '2014-01-01' to DateTime @@ -37,8 +37,8 @@ @T14:30:00.000 - convert '2014/01/01' to DateTime - + convert '2014/01/01' to DateTime + null @@ -93,8 +93,8 @@ @2014-01-01T12:05:05.955+00:00 - ToDateTime('2014/01/01T12:05:05.955Z') - + ToDateTime('2014/01/01T12:05:05.955Z') + null ToDateTime(@2014-01-01) @@ -159,8 +159,8 @@ @T14:30:00.000 - ToTime('T14-30-00.0') - + ToTime('T14-30-00.0') + null