From 2995994add671f3922f9e3ebe89914fbc1025413 Mon Sep 17 00:00:00 2001 From: Jonathan Percival Date: Wed, 24 Apr 2024 15:22:01 -0600 Subject: [PATCH] Migrate to JUnit 5, apply JUnit best practices --- Src/java/.vscode/settings.json | 41 +- .../main/groovy/cql.fhir-conventions.gradle | 3 +- .../main/groovy/cql.java-conventions.gradle | 14 +- .../fhir/npm/NpmPackageManagerTests.java | 26 +- .../cqframework/fhir/utilities/IGUtils.java | 9 +- .../fhir/utilities/TestIGContext.java | 11 +- .../cql2elm/preprocessor/CqlPreprocessor.java | 4 +- .../cql/cql2elm/ArchitectureTest.java | 6 +- .../cql/cql2elm/CMS146ElmTest.java | 44 +- .../cql/cql2elm/CMS146JsonTest.java | 12 +- .../cql/cql2elm/CMS146XmlTest.java | 18 +- .../cqframework/cql/cql2elm/CommentTests.java | 8 +- .../cql/cql2elm/Cql2ElmVisitorTest.java | 227 +++---- .../cql/cql2elm/ElmSupportTest.java | 28 +- .../cql/cql2elm/EscapeSequenceTests.java | 16 +- .../EscapeSequenceWithBacktickTests.java | 14 +- .../cql/cql2elm/GenericOverloadsTests.java | 18 +- .../cqframework/cql/cql2elm/HidingTests.java | 34 +- .../cql2elm/IncludedSignatureOutputTests.java | 14 +- ...IncludedSignatureWithAliasOutputTests.java | 14 +- .../cql/cql2elm/LibraryManagerTests.java | 24 +- .../cqframework/cql/cql2elm/LibraryTests.java | 114 ++-- .../cqframework/cql/cql2elm/LiteralTests.java | 24 +- .../cqframework/cql/cql2elm/ModelTests.java | 22 +- .../ModelWithoutDefaultLoadersTests.java | 22 +- .../cql/cql2elm/NamespaceTests.java | 54 +- .../cqframework/cql/cql2elm/OptionsTests.java | 15 +- .../cql/cql2elm/SemanticTests.java | 138 ++-- .../cql/cql2elm/SignatureOutputTests.java | 14 +- .../StringLibrarySourceProviderTest.java | 50 +- .../cqframework/cql/cql2elm/TestLocalId.java | 14 +- .../cql2elm/TestPointIntervalSignatures.java | 8 +- .../cql/cql2elm/TranslationTests.java | 119 ++-- .../cql/cql2elm/fhir/dstu2/BaseTest.java | 34 +- .../cql/cql2elm/fhir/r4/BaseTest.java | 36 +- .../cql/cql2elm/fhir/r401/BaseTest.java | 64 +- .../cql/cql2elm/fhir/stu3/BaseTest.java | 28 +- .../cql/cql2elm/fhir/stu301/BaseTest.java | 38 +- .../cql/cql2elm/fhir/v14/BaseTest.java | 6 +- .../cql/cql2elm/fhir/v16/BaseTest.java | 10 +- .../cql/cql2elm/fhir/v18/BaseTest.java | 10 +- .../cql/cql2elm/fhir/v18/PathTests.java | 18 +- .../cql/cql2elm/fhir/v32/BaseTest.java | 10 +- .../CqlTranslatorOptionsToJsonSchema.java | 11 +- .../cql/cql2elm/model/ModelImporterTest.java | 74 ++- .../cql/cql2elm/model/VersionTest.java | 53 +- .../cql2elm/operators/AgeOperatorsTest.java | 70 +- .../operators/AggregateOperatorsTest.java | 42 +- .../cql/cql2elm/operators/AggregateTest.java | 6 +- .../operators/ArithmeticOperatorsTest.java | 36 +- .../operators/CqlComparisonOperatorsTest.java | 10 +- .../operators/CqlIntervalOperatorsTest.java | 18 +- .../operators/CqlListOperatorsTest.java | 14 +- .../operators/DateTimeOperatorsTest.java | 28 +- .../cql2elm/operators/ListOperatorsTest.java | 30 +- .../operators/NullologicalOperatorsTest.java | 16 +- .../cql/cql2elm/operators/QueryTest.java | 34 +- .../cql/cql2elm/operators/SortingTest.java | 20 +- .../operators/StringOperatorsTest.java | 44 +- .../cql2elm/operators/TimeOperatorsTest.java | 16 +- .../cql2elm/operators/TypeOperatorsTest.java | 86 +-- .../cql/cql2elm/qdm/v54/BaseTest.java | 6 +- .../cql/cql2elm/qdm/v55/BaseTest.java | 6 +- .../cql/cql2elm/qdm/v56/BaseTest.java | 8 +- .../cql/cql2elm/qicore/v410/BaseTest.java | 10 +- .../cql/cql2elm/qicore/v411/BaseTest.java | 22 +- .../cql/cql2elm/qicore/v500/BaseTest.java | 24 +- .../cql/cql2elm/qicore/v600/BaseTest.java | 6 +- .../cql/cql2elm/quick/v330/BaseTest.java | 12 +- .../cql/cql2elm/uscore/v310/BaseTest.java | 6 +- .../cql/cql2elm/uscore/v311/BaseTest.java | 6 +- .../cql/cql2elm/uscore/v610/BaseTest.java | 6 +- .../cql/cql2elm/validation/LocalIdTests.java | 2 +- .../cqframework/cql/cql2elm/who/BaseTest.java | 6 +- .../cqframework/cql/grammar/GrammarTest.java | 8 +- .../fhir/DataRequirementsProcessorTest.java | 464 +++++++------- .../jaxb/ElmJsonLibraryReaderTest.java | 8 +- .../jaxb/ElmXmlLibraryReaderTest.java | 8 +- .../cql/elm/ElmDeserializeTests.java | 42 +- .../cql/elm/IdObjectFactoryTest.java | 6 +- .../cql/elm/utility/VisitorsTest.java | 12 +- .../cql/elm/visiting/BaseElmVisitorTest.java | 10 +- .../cql/elm/visiting/DesignTests.java | 6 +- .../visiting/FunctionalElmVisitorTest.java | 12 +- .../cql/elm/visiting/RandomElmGraphTest.java | 16 +- Src/java/engine-fhir/build.gradle | 2 +- .../fhir/retrieve/BaseFhirQueryGenerator.java | 6 +- .../hl7/fhirpath/CQLOperationsDstu3Test.java | 36 +- .../org/hl7/fhirpath/CQLOperationsR4Test.java | 37 +- .../java/org/hl7/fhirpath/DateTypeTest.java | 8 +- .../hl7/fhirpath/FhirHelpersDstu2Test.java | 4 +- .../hl7/fhirpath/FhirHelpersDstu3Test.java | 4 +- .../cqf/cql/engine/fhir/Dstu3FhirTest.java | 21 +- .../cqf/cql/engine/fhir/R4FhirTest.java | 15 +- .../fhir/converter/ConverterTestUtils.java | 5 - .../converter/Dstu2TypeConverterTests.java | 480 +++++++------- .../converter/Dstu3TypeConverterTests.java | 575 +++++++++-------- .../fhir/converter/R4TypeConverterTests.java | 599 ++++++++++-------- .../fhir/converter/R5TypeConverterTests.java | 577 +++++++++-------- .../fhir/data/EvaluatedResourcesTest.java | 8 +- .../fhir/data/FhirExecutionTestBase.java | 40 +- .../cqf/cql/engine/fhir/data/Issue1225.java | 8 +- .../cqf/cql/engine/fhir/data/Issue1226.java | 8 +- .../cqf/cql/engine/fhir/data/TestCodeRef.java | 2 +- .../TestCqlEngineRelatedContextSupport.java | 8 +- .../cql/engine/fhir/data/TestFHIRHelpers.java | 6 +- .../fhir/data/TestFhirDataProviderDstu2.java | 12 +- .../fhir/data/TestFhirDataProviderDstu3.java | 25 +- .../engine/fhir/data/TestFhirExecution.java | 12 +- .../cql/engine/fhir/data/TestFhirLibrary.java | 4 +- .../fhir/data/TestPrimitiveProfiles.java | 6 +- .../fhir/model/TestDstu2ModelResolver.java | 39 +- .../fhir/model/TestDstu3ModelResolver.java | 62 +- .../fhir/model/TestR4ModelResolver.java | 74 +-- .../fhir/model/TestR5ModelResolver.java | 61 +- .../retrieve/TestDstu3FhirQueryGenerator.java | 57 +- .../retrieve/TestR4FhirQueryGenerator.java | 71 ++- .../TestRestFhirRetrieveProvider.java | 38 +- .../TestSearchParameterResolver.java | 26 +- .../TestR4FhirTerminologyProvider.java | 99 ++- .../hl7/fhirpath/stu3/schema/fhir-single.xsd | 47 +- .../cql/engine/data/SystemDataProvider.java | 2 - .../elm/executing/RetrieveEvaluator.java | 26 +- .../data/CompositeDataProviderTest.java | 20 +- .../engine/data/SystemDataProviderTest.java | 10 +- .../execution/CqlAggregateFunctionsTest.java | 44 +- .../execution/CqlAggregateQueryTest.java | 6 +- .../execution/CqlArithmeticFunctionsTest.java | 167 +++-- .../execution/CqlClinicalOperatorsTest.java | 12 +- .../execution/CqlComparisonOperatorsTest.java | 14 +- .../cql/engine/execution/CqlConceptTest.java | 13 +- .../CqlConditionalOperatorsTest.java | 6 +- .../execution/CqlDateTimeOperatorsTest.java | 232 ++++--- .../cql/engine/execution/CqlEngineTest.java | 10 +- .../CqlErrorsAndMessagingOperatorsTest.java | 28 +- .../execution/CqlExternalFunctionsTest.java | 6 +- .../execution/CqlExternalFunctionsTest2.java | 6 +- .../execution/CqlFunctionOverloadTest.java | 6 +- .../cql/engine/execution/CqlFunctionTest.java | 6 +- ...qlInternalTypeRepresentationSuiteTest.java | 191 +++--- .../execution/CqlLibraryLoadingTest.java | 23 +- .../CqlListDistinguishedOverloadsTest.java | 14 +- .../execution/CqlLogicalOperatorsTest.java | 6 +- .../engine/execution/CqlMainSuiteTest.java | 18 +- .../execution/CqlNulLogicalOperatorsTest.java | 16 +- .../engine/execution/CqlPerformanceIT.java | 10 +- .../cql/engine/execution/CqlQueryTest.java | 44 +- .../execution/CqlStringOperatorsTest.java | 29 +- .../cqf/cql/engine/execution/CqlTestBase.java | 6 +- .../engine/execution/CqlTimezoneTests.java | 45 +- .../execution/CqlTypesOperatorsTest.java | 195 +++--- .../cql/engine/execution/CqlTypesTest.java | 89 ++- .../CqlValueLiteralsAndSelectorsTest.java | 10 +- .../engine/execution/DateComparatorTest.java | 6 +- .../engine/execution/EmptyStringsTest.java | 6 +- .../engine/execution/ExpandValueSetTest.java | 12 +- .../engine/execution/ExpressionCacheTest.java | 10 +- .../engine/execution/IncludedCodeRefTest.java | 8 +- .../execution/IncludedConceptRefTest.java | 6 +- .../execution/IncludedParameterTest.java | 28 +- .../IncludedSignatureOutputTests.java | 6 +- ...IncludedSignatureWithAliasOutputTests.java | 6 +- .../execution/IncludedValueSetRefTest.java | 12 +- .../execution/IntervalOperatorsTest.java | 166 +++-- .../cqf/cql/engine/execution/Issue208.java | 33 +- .../cqf/cql/engine/execution/Issue213.java | 16 +- .../cqf/cql/engine/execution/Issue223.java | 6 +- .../cqf/cql/engine/execution/Issue33.java | 13 +- .../cqf/cql/engine/execution/Issue39.java | 6 +- .../cqf/cql/engine/execution/Issue458.java | 10 +- .../LetClauseOutsideQueryContextTest.java | 13 +- .../engine/execution/ListOperatorsTest.java | 14 +- .../cql/engine/execution/RuntimeTests.java | 20 +- .../execution/SignatureOutputTests.java | 6 +- .../engine/execution/SortDescendingTest.java | 17 +- .../cqf/cql/engine/execution/TestUnion.java | 12 +- .../CachingModelResolverDecoratorTest.java | 31 +- .../cqf/cql/engine/runtime/DateTimeTest.java | 64 +- .../jackson/JacksonModelInfoLoadingTests.java | 62 +- .../jaxb/XmlModelInfoReaderTest.java | 8 +- .../org/hl7/cql/model/ChoiceTypeTests.java | 11 +- .../GenericClassSignatureParserTest.java | 20 +- .../hl7/cql/model/ModelInfoComparerTest.java | 8 +- .../fhir-modelinfo-4.0.1-with-metadata.xml | 12 +- Src/java/quick/schema/v1.4/fhir-single.xsd | 28 +- Src/java/quick/schema/v1.4/testscript.xsd | 2 +- Src/java/quick/schema/v1.6/fhir-single.xsd | 39 +- Src/java/quick/schema/v1.6/testscript.xsd | 2 +- Src/java/quick/schema/v1.8/fhir-single.xsd | 47 +- Src/java/quick/schema/v1.8/testscript.xsd | 4 +- .../org/hl7/fhir/fhir-modelinfo-4.0.1.xml | 12 +- .../formatter/CqlFormatterVisitorTest.java | 45 +- .../cql/tools/xsd2modelinfo/TestTypes.java | 6 +- 193 files changed, 4133 insertions(+), 3845 deletions(-) diff --git a/Src/java/.vscode/settings.json b/Src/java/.vscode/settings.json index d5ce5f70c..286f12b12 100644 --- a/Src/java/.vscode/settings.json +++ b/Src/java/.vscode/settings.json @@ -2,36 +2,71 @@ "java.configuration.updateBuildConfiguration": "automatic", "java.debug.settings.onBuildFailureProceed": true, "java.compile.nullAnalysis.mode": "automatic", - "java.jdt.ls.vmargs": "-noverify -Xmx8G -XX:+UseG1GC -XX:+UseStringDeduplication", + "java.jdt.ls.vmargs": "-noverify -Xmx64G -XX:+UseG1GC -XX:+UseStringDeduplication", "cSpell.words": [ "abstractclassname", + "Anded", + "antlr", "archunit", + "BACKBONEELEMENT", + "BACKBONETYPE", "bools", "Bryn", + "CANONICALRESOURCE", "checkstyle", "Codeable", "Codesystem", + "codesystems", "cqframework", "datumedge", + "DEPENDSON", + "DOMAINRESOURCE", + "DSTU", + "ecqi", + "ecqms", "fhir", "fhirpath", + "Gentest", + "GREATERTHAN", + "Greator", "hamcrest", + "healthit", "Inferencing", "Instancio", + "javac", "JAXB", + "Kolkata", + "LESSTHAN", + "loinc", + "MAXYEAR", + "Messageheader", + "METADATARESOURCE", "modelinfo", + "Multisource", + "mycontentig", + "myig", + "Nullological", "Objenesis", "opdef", "opencds", + "PRIMITIVETYPE", "qicore", + "QUOTEDIDENTIFIER", "Randomizer", "redeclaration", - "testng", + "searchparam", + "SEARCHSET", + "SNOMED", "tngtech", + "tomakehurst", "trackback", "Ucum", "unescaping", - "Unmarshaller" + "Unmarshaller", + "valueset", + "VALUESETS", + "wiremock", + "Zulip" ], "cSpell.enabledLanguageIds": [ "java", diff --git a/Src/java/buildSrc/src/main/groovy/cql.fhir-conventions.gradle b/Src/java/buildSrc/src/main/groovy/cql.fhir-conventions.gradle index 23f850cca..80622c10c 100644 --- a/Src/java/buildSrc/src/main/groovy/cql.fhir-conventions.gradle +++ b/Src/java/buildSrc/src/main/groovy/cql.fhir-conventions.gradle @@ -10,6 +10,7 @@ dependencies { api platform("ca.uhn.hapi.fhir:hapi-fhir-bom:${hapiVersion}") { exclude group: 'org.eclipse.jetty' exclude group: 'xpp3' + exclude group: 'org.junit' } implementation "ca.uhn.hapi.fhir:hapi-fhir-base" @@ -24,7 +25,7 @@ dependencies { // Note that this dependency hasn't been updated since 2013 // we probably need to standardize on a fork up the dependency chain implementation ('org.ogce:xpp3:1.1.6') { - exclude group: 'junit' + exclude group: 'org.junit' exclude group: 'org.hamcrest' } } \ No newline at end of file diff --git a/Src/java/buildSrc/src/main/groovy/cql.java-conventions.gradle b/Src/java/buildSrc/src/main/groovy/cql.java-conventions.gradle index 5ae2d3185..42614d30b 100644 --- a/Src/java/buildSrc/src/main/groovy/cql.java-conventions.gradle +++ b/Src/java/buildSrc/src/main/groovy/cql.java-conventions.gradle @@ -26,16 +26,17 @@ repositories { dependencies { implementation 'org.slf4j:slf4j-api:1.7.36' - testImplementation 'org.testng:testng:7.4.0' testImplementation 'org.hamcrest:hamcrest-all:1.3' testImplementation 'uk.co.datumedge:hamcrest-json:0.2' - testImplementation 'junit:junit:4.13.2' + testImplementation(platform('org.junit:junit-bom:5.10.2')) + testImplementation('org.junit.jupiter:junit-jupiter') testImplementation 'org.slf4j:slf4j-simple:1.7.36' // These are JAXB dependencies excluded because the libraries need to work // on Android. But for test purposes we use them pretty much everywhere. testRuntimeOnly 'org.eclipse.persistence:org.eclipse.persistence.moxy:4.0.2' testRuntimeOnly 'org.eclipse.parsson:parsson:1.1.5' + testRuntimeOnly('org.junit.platform:junit-platform-launcher') } jar { @@ -52,6 +53,10 @@ jacoco { } test { + useJUnitPlatform() + testLogging { + events "skipped", "failed" + } finalizedBy jacocoTestReport // report is always generated after tests run } @@ -71,11 +76,6 @@ tasks.withType(JavaCompile) { options.deprecation = true } - -tasks.named('test', Test) { - useTestNG() -} - spotless { java { targetExclude '**/generated/**' diff --git a/Src/java/cqf-fhir-npm/src/test/java/org/cqframework/fhir/npm/NpmPackageManagerTests.java b/Src/java/cqf-fhir-npm/src/test/java/org/cqframework/fhir/npm/NpmPackageManagerTests.java index cf2925ea0..69e106644 100644 --- a/Src/java/cqf-fhir-npm/src/test/java/org/cqframework/fhir/npm/NpmPackageManagerTests.java +++ b/Src/java/cqf-fhir-npm/src/test/java/org/cqframework/fhir/npm/NpmPackageManagerTests.java @@ -1,8 +1,8 @@ package org.cqframework.fhir.npm; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; import ca.uhn.fhir.context.FhirContext; import java.io.InputStream; @@ -15,10 +15,10 @@ import org.hl7.fhir.r5.context.IWorkerContext; import org.hl7.fhir.r5.model.ImplementationGuide; import org.hl7.fhir.utilities.npm.NpmPackage; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.testng.annotations.Ignore; -import org.testng.annotations.Test; public class NpmPackageManagerTests implements IWorkerContext.ILoggingService { @@ -26,17 +26,17 @@ public class NpmPackageManagerTests implements IWorkerContext.ILoggingService { private final VersionConvertor_40_50 convertor = new VersionConvertor_40_50(new BaseAdvisor_40_50()); @Test - public void testSampleIGLocalNoDependencies() { + void sampleIGLocalNoDependencies() { Resource igResource = (Resource) FhirContext.forR4Cached() .newXmlParser() .parseResource(NpmPackageManagerTests.class.getResourceAsStream("myig.xml")); ImplementationGuide ig = (ImplementationGuide) convertor.convertResource(igResource); NpmPackageManager pm = new NpmPackageManager(ig); - assertEquals(pm.getNpmList().size(), 1); + assertEquals(1, pm.getNpmList().size()); } @Test - public void testSampleContentIGLocalWithRecursiveDependencies() { + void sampleContentIGLocalWithRecursiveDependencies() { Resource igResource = (Resource) FhirContext.forR4Cached() .newXmlParser() .parseResource(NpmPackageManagerTests.class.getResourceAsStream("mycontentig.xml")); @@ -65,7 +65,7 @@ public void testSampleContentIGLocalWithRecursiveDependencies() { } @Test - public void testOpioidMMEIGLocalWithSingleFileDependency() { + void opioidMmeIGLocalWithSingleFileDependency() { Resource igResource = (Resource) FhirContext.forR4Cached() .newXmlParser() .parseResource(NpmPackageManagerTests.class.getResourceAsStream("opioid-mme-r4.xml")); @@ -89,8 +89,8 @@ public void testOpioidMMEIGLocalWithSingleFileDependency() { } @Test - @Ignore("This test depends on the example.fhir.uv.myig package, which is not currently published") - public void testLibrarySourceProviderLocal() { + @Disabled("This test depends on the example.fhir.uv.myig package, which is not currently published") + void librarySourceProviderLocal() { Resource igResource = (Resource) FhirContext.forR4Cached() .newXmlParser() .parseResource(NpmPackageManagerTests.class.getResourceAsStream("mycontentig.xml")); @@ -111,7 +111,7 @@ public void testLibrarySourceProviderLocal() { } @Test - public void testModelInfoProviderLocal() { + void modelInfoProviderLocal() { Resource igResource = (Resource) FhirContext.forR4Cached() .newXmlParser() .parseResource(NpmPackageManagerTests.class.getResourceAsStream("testig.xml")); @@ -125,7 +125,7 @@ public void testModelInfoProviderLocal() { .withSystem("http://hl7.org/fhir/us/qicore") .withId("QICore")); assertNotNull(mi); - assertEquals(mi.getName(), "QICore"); + assertEquals("QICore", mi.getName()); } @Override diff --git a/Src/java/cqf-fhir/src/main/java/org/cqframework/fhir/utilities/IGUtils.java b/Src/java/cqf-fhir/src/main/java/org/cqframework/fhir/utilities/IGUtils.java index 66a2d1707..2b4c012f7 100644 --- a/Src/java/cqf-fhir/src/main/java/org/cqframework/fhir/utilities/IGUtils.java +++ b/Src/java/cqf-fhir/src/main/java/org/cqframework/fhir/utilities/IGUtils.java @@ -9,6 +9,10 @@ public class IGUtils { + private IGUtils() { + // intentionally empty + } + public static String getImplementationGuideCanonicalBase(String url) { String canonicalBase = null; @@ -19,12 +23,11 @@ public static String getImplementationGuideCanonicalBase(String url) { return canonicalBase; } - public static ArrayList extractResourcePaths(String rootDir, ImplementationGuide sourceIg) - throws IOException { + public static List extractResourcePaths(String rootDir, ImplementationGuide sourceIg) throws IOException { ArrayList result = new ArrayList<>(); for (ImplementationGuide.ImplementationGuideDefinitionParameterComponent p : sourceIg.getDefinition().getParameter()) { - if (p.getCode().equals("path-resource")) { + if ("path-resource".equals(p.getCode().getCode())) { result.add(Utilities.path(rootDir, p.getValue())); } } diff --git a/Src/java/cqf-fhir/src/test/java/org/cqframework/fhir/utilities/TestIGContext.java b/Src/java/cqf-fhir/src/test/java/org/cqframework/fhir/utilities/TestIGContext.java index 3451cb599..f91782b36 100644 --- a/Src/java/cqf-fhir/src/test/java/org/cqframework/fhir/utilities/TestIGContext.java +++ b/Src/java/cqf-fhir/src/test/java/org/cqframework/fhir/utilities/TestIGContext.java @@ -1,17 +1,18 @@ package org.cqframework.fhir.utilities; -import static org.testng.Assert.*; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; import java.net.URI; import java.net.URISyntaxException; import java.net.URL; import org.hl7.fhir.r5.context.IWorkerContext; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Test; public class TestIGContext implements IWorkerContext.ILoggingService { @Test - public void testTypesAndValuesIG() throws URISyntaxException { + void typesAndValuesIG() throws URISyntaxException { URL url = TestIGContext.class.getResource("types-and-values/ig.ini"); assertNotNull(url); URI uri = Uris.parseOrNull(url.toURI().toString()); @@ -19,8 +20,8 @@ public void testTypesAndValuesIG() throws URISyntaxException { String path = uri.getSchemeSpecificPart(); IGContext igContext = new IGContext(this); igContext.initializeFromIni(path); - assertEquals(igContext.getPackageId(), "fhir.cqf.typesandvalues"); - assertEquals(igContext.getCanonicalBase(), "http://fhir.org/guides/cqf/typesandvalues"); + assertEquals("fhir.cqf.typesandvalues", igContext.getPackageId()); + assertEquals("http://fhir.org/guides/cqf/typesandvalues", igContext.getCanonicalBase()); } @Override diff --git a/Src/java/cql-to-elm/src/main/java/org/cqframework/cql/cql2elm/preprocessor/CqlPreprocessor.java b/Src/java/cql-to-elm/src/main/java/org/cqframework/cql/cql2elm/preprocessor/CqlPreprocessor.java index d6dc36b7b..7e5d6821b 100644 --- a/Src/java/cql-to-elm/src/main/java/org/cqframework/cql/cql2elm/preprocessor/CqlPreprocessor.java +++ b/Src/java/cql-to-elm/src/main/java/org/cqframework/cql/cql2elm/preprocessor/CqlPreprocessor.java @@ -2,6 +2,7 @@ import java.util.ArrayList; import java.util.List; +import org.antlr.v4.runtime.Recognizer; import org.antlr.v4.runtime.TokenStream; import org.antlr.v4.runtime.misc.Interval; import org.antlr.v4.runtime.tree.ParseTree; @@ -58,7 +59,7 @@ public Object visitLibrary(cqlParser.LibraryContext ctx) { for (int i = 0; i < ctx.getChildCount(); i++) { ParseTree tree = ctx.getChild(i); TerminalNode terminalNode = tree instanceof TerminalNode ? (TerminalNode) tree : null; - if (terminalNode != null && terminalNode.getSymbol().getType() == cqlLexer.EOF) { + if (terminalNode != null && terminalNode.getSymbol().getType() == Recognizer.EOF) { continue; } @@ -168,7 +169,6 @@ public Object visitUsingDefinition(cqlParser.UsingDefinitionContext ctx) { } @Override - @SuppressWarnings("unchecked") public Object visitCodesystemDefinition(cqlParser.CodesystemDefinitionContext ctx) { CodesystemDefinitionInfo codesystemDefinition = new CodesystemDefinitionInfo(); codesystemDefinition.setName(parseString(ctx.identifier())); diff --git a/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/ArchitectureTest.java b/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/ArchitectureTest.java index d0275b6d8..3671456e1 100644 --- a/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/ArchitectureTest.java +++ b/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/ArchitectureTest.java @@ -7,12 +7,12 @@ import org.cqframework.cql.cql2elm.model.LibraryRef; import org.cqframework.cql.elm.IdObjectFactory; import org.hl7.elm.r1.Element; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Test; -public class ArchitectureTest { +class ArchitectureTest { @Test - public void ensureNoDirectElmConstruction() { + void ensureNoDirectElmConstruction() { JavaClasses importedClasses = new ClassFileImporter().importPackages("org.cqframework.cql"); diff --git a/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/CMS146ElmTest.java b/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/CMS146ElmTest.java index 22aae1e4d..cac0cdaf3 100644 --- a/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/CMS146ElmTest.java +++ b/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/CMS146ElmTest.java @@ -2,7 +2,7 @@ import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.*; -import static org.testng.Assert.*; +import static org.junit.jupiter.api.Assertions.fail; import java.io.IOException; import java.util.ArrayList; @@ -17,18 +17,20 @@ import org.hl7.cql_annotations.r1.CqlToElmBase; import org.hl7.cql_annotations.r1.CqlToElmInfo; import org.hl7.elm.r1.*; -import org.testng.annotations.BeforeTest; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; public class CMS146ElmTest { - private CqlTranslator translator; - private Library library; - private ObjectFactory of; + private static CqlTranslator translator; + private static Library library; + private static ObjectFactory of; - @BeforeTest - public void setup() throws IOException { + @BeforeAll + static void setup() throws IOException { ModelManager modelManager = new ModelManager(); translator = CqlTranslator.fromStream( CMS146ElmTest.class.getResourceAsStream("CMS146v2_Test_CQM.cql"), @@ -38,15 +40,15 @@ public void setup() throws IOException { of = new ObjectFactory(); } - @DataProvider(name = "sigLevels") public static Object[][] primeNumbers() { return new Object[][] { {SignatureLevel.None}, {SignatureLevel.Differing}, {SignatureLevel.Overloads}, {SignatureLevel.All} }; } - @Test(dataProvider = "sigLevels") - public void testSignatureLevels(SignatureLevel signatureLevel) throws IOException { + @ParameterizedTest + @MethodSource("primeNumbers") + void signatureLevels(SignatureLevel signatureLevel) throws IOException { final ModelManager modelManager = new ModelManager(); final CqlTranslator translator = CqlTranslator.fromStream( CMS146ElmTest.class.getResourceAsStream("CMS146v2_Test_CQM.cql"), @@ -66,21 +68,21 @@ public void testSignatureLevels(SignatureLevel signatureLevel) throws IOExceptio } @Test - public void testLibraryAndVersion() { + void libraryAndVersion() { assertThat( library.getIdentifier(), is(of.createVersionedIdentifier().withId("CMS146").withVersion("2"))); } @Test - public void testUsingDataModel() { + void usingDataModel() { List models = library.getUsings().getDef(); assertThat(models, hasSize(2)); assertThat(models.get(1).getUri(), is("http://hl7.org/fhir")); } @Test - public void testClinicalRequests() { + void clinicalRequests() { Collection actualCR = translator.toRetrieves(); Collection expectedCR = Arrays.asList( @@ -130,8 +132,9 @@ public void testClinicalRequests() { // TODO: Disabled the test for now, valuesets have been moved to expression definitions. These are being checked in // the testVariables() test, but not as completely as this. - @Test(enabled = false) - public void testValueSets() { + @Test + @Disabled + void valueSets() { Collection actualVS = library.getValueSets().getDef(); Collection expectedVS = Arrays.asList( @@ -151,7 +154,7 @@ public void testValueSets() { } @Test - public void testVariables() { + void variables() { Collection actualVars = new ArrayList<>(); for (ExpressionDef def : library.getStatements().getDef()) { actualVars.add(def.getName()); @@ -175,8 +178,9 @@ public void testVariables() { } // TODO: Disabled the test for now, needs to be updated to use annotations, will update after all syntax changes. - @Test(enabled = false) - public void testTrackBacks() { + @Test + @Disabled + void trackBacks() { for (Retrieve dc : translator.toRetrieves()) { int expectedNumbers[] = new int[4]; switch (((ValueSetRef) dc.getCodes()).getName()) { diff --git a/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/CMS146JsonTest.java b/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/CMS146JsonTest.java index e61926a31..0fe2ed55f 100644 --- a/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/CMS146JsonTest.java +++ b/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/CMS146JsonTest.java @@ -9,13 +9,12 @@ import org.cqframework.cql.cql2elm.CqlCompilerException.ErrorSeverity; import org.cqframework.cql.cql2elm.LibraryBuilder.SignatureLevel; import org.json.JSONException; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import org.skyscreamer.jsonassert.JSONAssert; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; -public class CMS146JsonTest { +class CMS146JsonTest { - @DataProvider(name = "sigFileAndSigLevel") private static Object[][] sigFileAndSigLevel() { return new Object[][] { {"CMS146v2_Expected_SignatureLevel_None.json", SignatureLevel.None}, @@ -25,8 +24,9 @@ private static Object[][] sigFileAndSigLevel() { }; } - @Test(dataProvider = "sigFileAndSigLevel") - public void testCms146_SignatureLevels(String fileName, SignatureLevel expectedSignatureLevel) + @ParameterizedTest + @MethodSource("sigFileAndSigLevel") + void cms146SignatureLevels(String fileName, SignatureLevel expectedSignatureLevel) throws IOException, JSONException { final String expectedJson = getJson(fileName); diff --git a/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/CMS146XmlTest.java b/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/CMS146XmlTest.java index 22ff0d719..098a21bc9 100644 --- a/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/CMS146XmlTest.java +++ b/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/CMS146XmlTest.java @@ -11,12 +11,11 @@ import java.util.Scanner; import org.cqframework.cql.cql2elm.CqlCompilerException.ErrorSeverity; import org.cqframework.cql.cql2elm.LibraryBuilder.SignatureLevel; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; -public class CMS146XmlTest { +class CMS146XmlTest { - @DataProvider(name = "sigFileAndSigLevel") private static Object[][] sigFileAndSigLevel() { return new Object[][] { {"CMS146v2_Expected_SignatureLevel_None.xml", SignatureLevel.None}, @@ -26,8 +25,9 @@ private static Object[][] sigFileAndSigLevel() { }; } - @Test(dataProvider = "sigFileAndSigLevel") - public void testCms146_SignatureLevels(String fileName, SignatureLevel expectedSignatureLevel) throws IOException { + @ParameterizedTest + @MethodSource("sigFileAndSigLevel") + void cms146SignatureLevels(String fileName, SignatureLevel expectedSignatureLevel) throws IOException { final String expectedXml = getXml(fileName); final File cms146 = getFile("CMS146v2_Test_CQM.cql"); @@ -41,9 +41,9 @@ public void testCms146_SignatureLevels(String fileName, SignatureLevel expectedS } private static String getXml(String name) throws IOException { - return new Scanner(getFile(name), StandardCharsets.UTF_8) - .useDelimiter("\\Z") - .next(); + try (Scanner scanner = new Scanner(getFile(name), StandardCharsets.UTF_8).useDelimiter("\\Z")) { + return scanner.next(); + } } private static File getFile(String name) { diff --git a/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/CommentTests.java b/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/CommentTests.java index 0ad7fe313..9d8125989 100644 --- a/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/CommentTests.java +++ b/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/CommentTests.java @@ -14,12 +14,12 @@ import org.hl7.cql_annotations.r1.Tag; import org.hl7.elm.r1.ExpressionDef; import org.hl7.elm.r1.FunctionDef; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Test; -public class CommentTests { +class CommentTests { @Test - public void testComments() throws IOException { + void comments() throws IOException { CqlTranslator translator = TestUtils.runSemanticTest("TestComments.cql", 0, EnableAnnotations); CompiledLibrary library = translator.getTranslatedLibrary(); assertThat(library.getLibrary().getAnnotation(), notNullValue()); @@ -76,7 +76,7 @@ public void testComments() throws IOException { } @Test - public void testTags() throws IOException { + void tags() throws IOException { CqlTranslator translator = TestUtils.runSemanticTest("TestTags.cql", 0, EnableAnnotations); CompiledLibrary library = translator.getTranslatedLibrary(); assertThat(library.getLibrary().getAnnotation(), notNullValue()); diff --git a/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/Cql2ElmVisitorTest.java b/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/Cql2ElmVisitorTest.java index deb675b41..28bd2fb4b 100644 --- a/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/Cql2ElmVisitorTest.java +++ b/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/Cql2ElmVisitorTest.java @@ -6,8 +6,8 @@ import static org.cqframework.cql.cql2elm.matchers.QuickDataType.quickDataType; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.*; -import static org.testng.Assert.assertFalse; -import static org.testng.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; import java.io.IOException; import java.math.BigDecimal; @@ -16,18 +16,19 @@ import org.cqframework.cql.cql2elm.model.CompiledLibrary; import org.cqframework.cql.elm.tracking.Trackable; import org.hl7.elm.r1.*; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; -public class Cql2ElmVisitorTest { +class Cql2ElmVisitorTest { @Test - public void testLet() { + void let() { ExpressionDef def = (ExpressionDef) visitData("define b : true"); assertThat(def.getName(), is("b")); assertTrackable(def); } @Test - public void testBooleanLiteral() { + void booleanLiteral() { ExpressionDef def = (ExpressionDef) visitData("define b : true"); assertThat(def.getExpression(), literalFor(true)); assertTrackable(def.getExpression()); @@ -37,21 +38,21 @@ public void testBooleanLiteral() { } @Test - public void testStringLiteral() { + void stringLiteral() { ExpressionDef def = (ExpressionDef) visitData("define st : 'hey its a string'"); assertThat(def.getExpression(), literalFor("hey its a string")); assertTrackable(def.getExpression()); } @Test - public void testNullLiteral() { + void nullLiteral() { ExpressionDef def = (ExpressionDef) visitData("define st : null"); assertThat(def.getExpression(), instanceOf(Null.class)); assertTrackable(def.getExpression()); } @Test - public void testQuantityLiteral() { + void quantityLiteral() { ExpressionDef def = (ExpressionDef) visitData("define st : 1"); assertThat(def.getExpression(), literalFor(1)); assertTrackable(def.getExpression()); @@ -67,7 +68,7 @@ public void testQuantityLiteral() { } @Test - public void testAndExpressions() { + void andExpressions() { ExpressionDef def = (ExpressionDef) visitData("define st : true and false"); And and = (And) def.getExpression(); Expression left = and.getOperand().get(0); @@ -82,7 +83,7 @@ public void testAndExpressions() { } @Test - public void testOrExpressions() { + void orExpressions() { ExpressionDef def = (ExpressionDef) visitData("define st : true or false"); Or or = (Or) def.getExpression(); Expression left = or.getOperand().get(0); @@ -109,7 +110,7 @@ public void testOrExpressions() { } @Test - public void testComparisonExpressions() { + void comparisonExpressions() { Map comparisons = new HashMap() { { put("<", Less.class); @@ -137,7 +138,7 @@ public void testComparisonExpressions() { } @Test - public void testNotEqualExpression() { + void notEqualExpression() { ExpressionDef def = (ExpressionDef) visitData("define st : 1 != 2"); Not not = (Not) def.getExpression(); Equal equal = (Equal) not.getOperand(); @@ -154,7 +155,7 @@ public void testNotEqualExpression() { } @Test - public void testIsTrueExpressions() { + void isTrueExpressions() { ExpressionDef def = (ExpressionDef) visitData("define X : true\ndefine st : X is true"); IsTrue isTrue = (IsTrue) def.getExpression(); ExpressionRef left = (ExpressionRef) isTrue.getOperand(); @@ -166,7 +167,7 @@ public void testIsTrueExpressions() { } @Test - public void testIsNotTrueExpressions() { + void isNotTrueExpressions() { ExpressionDef def = (ExpressionDef) visitData("define X : true\ndefine st : X is not true"); Not not = (Not) def.getExpression(); IsTrue isTrue = (IsTrue) not.getOperand(); @@ -179,7 +180,7 @@ public void testIsNotTrueExpressions() { } @Test - public void testIsNullExpressions() { + void isNullExpressions() { ExpressionDef def = (ExpressionDef) visitData("define X : 1\ndefine st : X is null"); IsNull isNull = (IsNull) def.getExpression(); ExpressionRef id = (ExpressionRef) isNull.getOperand(); @@ -191,7 +192,7 @@ public void testIsNullExpressions() { } @Test - public void testIsNotNullExpressions() { + void isNotNullExpressions() { ExpressionDef def = (ExpressionDef) visitData("define X : 1\ndefine st : X is not null"); Not not = (Not) def.getExpression(); IsNull isNull = (IsNull) not.getOperand(); @@ -205,7 +206,7 @@ public void testIsNotNullExpressions() { } @Test - public void testExpressionReference() { + void expressionReference() { String cql = "using QUICK\n" + "define X : [Condition]\n" + "define st : X"; ExpressionDef def = (ExpressionDef) visitData(cql); ExpressionRef exp = (ExpressionRef) def.getExpression(); @@ -214,7 +215,7 @@ public void testExpressionReference() { } @Test - public void testPropertyReference() { + void propertyReference() { String cql = "using QUICK\n" + "define X : First([Condition])\n" + "define st : X.onsetDateTime"; ExpressionDef def = (ExpressionDef) visitData(cql); Property prop = (Property) def.getExpression(); @@ -226,7 +227,7 @@ public void testPropertyReference() { } @Test - public void testValueSetReference() { + void valueSetReference() { String cql = "valueset \"Acute Pharyngitis\" : '2.16.840.1.113883.3.464.1003.102.12.1011'\n" + "define st : \"Acute Pharyngitis\""; ExpressionDef def = (ExpressionDef) visitData(cql); @@ -236,7 +237,7 @@ public void testValueSetReference() { } @Test - public void testInValueSetExpression() { + void inValueSetExpression() { String cql = "valueset \"Acute Pharyngitis\" : '2.16.840.1.113883.3.464.1003.102.12.1011'\n" + "define m : 'Value' in \"Acute Pharyngitis\""; ExpressionDef def = (ExpressionDef) visitData(cql); @@ -246,9 +247,9 @@ public void testInValueSetExpression() { assertThat(vsr.getName(), is("Acute Pharyngitis")); } - // TODO: Fix when operator semantics are completed - @Test(enabled = false) - public void testFunctionReference() { + @Test + @Disabled("TODO: Fix when operator semantics are completed") + void functionReference() { String cql = "define function MyFunction() { return true }\n" + "define st : MyFunction()"; ExpressionDef def = (ExpressionDef) visitData(cql); FunctionRef fun = (FunctionRef) def.getExpression(); @@ -257,9 +258,9 @@ public void testFunctionReference() { assertThat(fun.getOperand(), is(empty())); } - // TODO: Need to add operand resolution to the type inference... - @Test(enabled = false) - public void testFunctionReferenceWithArguments() { + @Test + @Disabled("TODO: Need to add operand resolution to the type inference...") + void functionReferenceWithArguments() { String cql = "define function MyFunction(arg String) { return arg }\n" + "define st : MyFunction('hello there')"; ExpressionDef def = (ExpressionDef) visitData(cql); @@ -273,7 +274,7 @@ public void testFunctionReferenceWithArguments() { // TODO: Tests for accessors to expressions, valuesets, functions from included libraries @Test - public void testArithmeticExpressions() { + void arithmeticExpressions() { Map comparisons = new HashMap() { { put("+", Add.class); @@ -303,7 +304,7 @@ public void testArithmeticExpressions() { } @Test - public void testBasicValueSet() { + void basicValueSet() { String cql = "valueset \"Female Administrative Sex\" : '2.16.840.1.113883.3.560.100.2'\n" + "define X : 1"; Library l = visitLibrary(cql); ValueSetDef def = l.getValueSets().getDef().get(0); @@ -314,7 +315,7 @@ public void testBasicValueSet() { } @Test - public void testVersionedValueSet() { + void versionedValueSet() { String cql = "valueset \"Female Administrative Sex\" : '2.16.840.1.113883.3.560.100.2' version '1'\n" + "define X : 1"; Library l = visitLibrary(cql); @@ -326,7 +327,7 @@ public void testVersionedValueSet() { } @Test - public void testStaticallyBoundValueSet() { + void staticallyBoundValueSet() { String cql = "codesystem \"SNOMED-CT:2014\" : 'SNOMED-CT' version '2014'\n" + "codesystem \"ICD-9:2014\" : 'ICD-9' version '2014'\n" + "valueset \"Female Administrative Sex\" : '2.16.840.1.113883.3.560.100.2' version '1'\n" @@ -358,7 +359,7 @@ public void testStaticallyBoundValueSet() { } @Test - public void testRetrieveTopic() { + void retrieveTopic() { ExpressionDef def = (ExpressionDef) visitData("using QUICK define st : [Condition]"); Retrieve request = (Retrieve) def.getExpression(); assertThat(request.getDataType(), quickDataType("Condition")); @@ -371,7 +372,7 @@ public void testRetrieveTopic() { } @Test - public void testRetrieveTopicAndValueSet() { + void retrieveTopicAndValueSet() { String cql = "using QUICK\n" + "valueset \"Acute Pharyngitis\" : '2.16.840.1.113883.3.464.1003.102.12.1011'\n" + "define st : [Condition: \"Acute Pharyngitis\"]"; ExpressionDef def = (ExpressionDef) visitData(cql); @@ -388,7 +389,7 @@ public void testRetrieveTopicAndValueSet() { } @Test - public void testRetrieveTopicAndSpecifiedCodeAttribute() { + void retrieveTopicAndSpecifiedCodeAttribute() { String cql = "using QUICK\n" + "valueset \"Moderate or Severe\" : '2.16.840.1.113883.3.526.3.1092'\n" + "define st : [Condition: severity in \"Moderate or Severe\"]"; ExpressionDef def = (ExpressionDef) visitData(cql); @@ -405,7 +406,7 @@ public void testRetrieveTopicAndSpecifiedCodeAttribute() { } @Test - public void testDateRangeOptimizationForDateIntervalLiteral() { + void dateRangeOptimizationForDateIntervalLiteral() { String cql = "using QUICK\n" + "valueset \"Inpatient\" : '2.16.840.1.113883.3.666.5.307'\n" + "define st : [Encounter: \"Inpatient\"] E\n" + " where E.period during Interval[DateTime(2013, 1, 1), DateTime(2014, 1, 1))"; @@ -433,7 +434,7 @@ public void testDateRangeOptimizationForDateIntervalLiteral() { } @Test - public void testDateRangeOptimizationForDefaultedDateIntervalParameter() { + void dateRangeOptimizationForDefaultedDateIntervalParameter() { String cql = "using QUICK\n" + "valueset \"Inpatient\" : '2.16.840.1.113883.3.666.5.307'\n" + "parameter MeasurementPeriod default Interval[DateTime(2013, 1, 1), DateTime(2014, 1, 1))\n" + "define st : [Encounter: \"Inpatient\"] E\n" @@ -453,7 +454,7 @@ public void testDateRangeOptimizationForDefaultedDateIntervalParameter() { } @Test - public void testDateRangeOptimizationForTypedDateIntervalParameter() { + void dateRangeOptimizationForTypedDateIntervalParameter() { String cql = "using QUICK\n" + "valueset \"Inpatient\" : '2.16.840.1.113883.3.666.5.307'\n" + "parameter MeasurementPeriod Interval\n" + "define st : [Encounter: \"Inpatient\"] E\n" @@ -473,7 +474,7 @@ public void testDateRangeOptimizationForTypedDateIntervalParameter() { } @Test - public void testDateRangeOptimizationForDateIntervalExpressionReference() { + void dateRangeOptimizationForDateIntervalExpressionReference() { String cql = "using QUICK\n" + "valueset \"Inpatient\" : '2.16.840.1.113883.3.666.5.307'\n" + "define twentyThirteen : Interval[DateTime(2013, 1, 1), DateTime(2014, 1, 1))\n" + "define st : [Encounter: \"Inpatient\"] E\n" @@ -492,9 +493,9 @@ public void testDateRangeOptimizationForDateIntervalExpressionReference() { assertThat(query.getWhere(), is(nullValue())); } - // This test is semantically invalid, you cannot use "during" with a date - @Test(enabled = false) - public void testDateRangeOptimizationForDateTimeLiteral() { + @Test + @Disabled("TODO: This test is semantically invalid, you cannot use \"during\" with a date") + void dateRangeOptimizationForDateTimeLiteral() { String cql = "using QUICK\n" + "valueset \"Inpatient\" : '2.16.840.1.113883.3.666.5.307'\n" + "define st : [Encounter: \"Inpatient\"] E\n" + " where E.period during DateTime(2013, 6)"; @@ -514,9 +515,9 @@ public void testDateRangeOptimizationForDateTimeLiteral() { assertThat(query.getWhere(), is(nullValue())); } - // This test is semantically invalid, you cannot use "during" with a date - @Test(enabled = false) - public void testDateRangeOptimizationForDefaultedDateTimeParameter() { + @Test + @Disabled("TODO: test is semantically invalid, you cannot use \"during\" with a date") + void dateRangeOptimizationForDefaultedDateTimeParameter() { String cql = "using QUICK\n" + "valueset \"Inpatient\" : '2.16.840.1.113883.3.666.5.307'\n" + "parameter MyDate default DateTime(2013, 6)\n" + "define st : [Encounter: \"Inpatient\"] E\n" @@ -535,9 +536,9 @@ public void testDateRangeOptimizationForDefaultedDateTimeParameter() { assertThat(query.getWhere(), is(nullValue())); } - // This test is semantically invalid, you cannot use "during" with a date - @Test(enabled = false) - public void testDateRangeOptimizationForTypedDateTimeParameter() { + @Test + @Disabled("TODO: This test is semantically invalid, you cannot use \"during\" with a date") + void dateRangeOptimizationForTypedDateTimeParameter() { String cql = "using QUICK\n" + "valueset \"Inpatient\" : '2.16.840.1.113883.3.666.5.307'\n" + "parameter MyDate DateTime\n" + "define st : [Encounter: \"Inpatient\"] E\n" @@ -556,9 +557,9 @@ public void testDateRangeOptimizationForTypedDateTimeParameter() { assertThat(query.getWhere(), is(nullValue())); } - // This test is semantically invalid, you cannot use "during" with a date - @Test(enabled = false) - public void testDateRangeOptimizationForDateTimeExpressionReference() { + @Test + @Disabled("TODO: This test is semantically invalid, you cannot use \"during\" with a date") + void dateRangeOptimizationForDateTimeExpressionReference() { String cql = "using QUICK\n" + "valueset \"Inpatient\" : '2.16.840.1.113883.3.666.5.307'\n" + "define myDate : DateTime(2013, 6)\n" + "define st : [Encounter: \"Inpatient\"] E\n" @@ -578,7 +579,7 @@ public void testDateRangeOptimizationForDateTimeExpressionReference() { } @Test - public void testDateRangeOptimizationForAndedWhere() { + void dateRangeOptimizationForAndedWhere() { String cql = "using QUICK\n" + "valueset \"Inpatient\" : '2.16.840.1.113883.3.666.5.307'\n" + "parameter MeasurementPeriod default Interval[DateTime(2013, 1, 1), DateTime(2014, 1, 1))\n" + "define st : [Encounter: \"Inpatient\"] E\n" @@ -606,7 +607,7 @@ public void testDateRangeOptimizationForAndedWhere() { } @Test - public void testDateRangeOptimizationForDeeplyAndedWhere() { + void dateRangeOptimizationForDeeplyAndedWhere() { String cql = "using QUICK\n" + "valueset \"Inpatient\" : '2.16.840.1.113883.3.666.5.307'\n" + "parameter MeasurementPeriod default Interval[DateTime(2013, 1, 1), DateTime(2014, 1, 1))\n" + "define st : [Encounter: \"Inpatient\"] E\n" @@ -662,7 +663,7 @@ public void testDateRangeOptimizationForDeeplyAndedWhere() { } @Test - public void testDateRangeOptimizationForMultipleQualifyingClauses() { + void dateRangeOptimizationForMultipleQualifyingClauses() { String cql = "using QUICK\n" + "valueset \"Inpatient\" : '2.16.840.1.113883.3.666.5.307'\n" + "parameter MeasurementPeriod default Interval[DateTime(2013, 1, 1), DateTime(2014, 1, 1))\n" + "define st : [Encounter: \"Inpatient\"] E\n" @@ -690,7 +691,7 @@ public void testDateRangeOptimizationForMultipleQualifyingClauses() { } @Test - public void testDateRangeOptimizationNotDoneWhenDisabled() { + void dateRangeOptimizationNotDoneWhenDisabled() { String cql = "using QUICK\n" + "valueset \"Inpatient\" : '2.16.840.1.113883.3.666.5.307'\n" + "parameter MeasurementPeriod default Interval[DateTime(2013, 1, 1), DateTime(2014, 1, 1))\n" + "define st : [Encounter: \"Inpatient\"] E\n" @@ -714,9 +715,9 @@ public void testDateRangeOptimizationNotDoneWhenDisabled() { assertThat(rhs.getLibraryName(), is(nullValue())); } - // This test is semantically invalid, you cannot use "during" with a list - @Test(enabled = false) - public void testDateRangeOptimizationNotDoneOnUnsupportedExpressions() { + @Test + @Disabled("TODO: This test is semantically invalid, you cannot use \"during\" with a list") + void dateRangeOptimizationNotDoneOnUnsupportedExpressions() { // NOTE: I'm not sure that the below statement is even valid without a "with" clause String cql = "using QUICK\n" + "valueset \"Inpatient\" : '2.16.840.1.113883.3.666.5.307'\n" + "valueset \"Acute Pharyngitis\" : '2.16.840.1.113883.3.464.1003.102.12.1011'\n" @@ -727,7 +728,7 @@ public void testDateRangeOptimizationNotDoneOnUnsupportedExpressions() { Query query = testEncounterPerformanceInpatientForDateRangeOptimization(cql); Retrieve request = (Retrieve) query.getSource().get(0).getExpression(); - // First check the source and ensure the "during pharnyngitis" didn't migrate up! + // First check the source and ensure the "during pharyngitis" didn't migrate up! assertThat(request.getDateProperty(), is(nullValue())); assertThat(request.getDateRange(), is(nullValue())); @@ -766,7 +767,7 @@ private Query testEncounterPerformanceInpatientForDateRangeOptimization( } @Test - public void testComplexQuery() { + void complexQuery() { String cql = "using QUICK\n" + "valueset \"Inpatient\" : '2.16.840.1.113883.3.666.5.307'\n" + "valueset \"Acute Pharyngitis\" : '2.16.840.1.113883.3.464.1003.102.12.1011'\n" + "parameter MeasurementPeriod default Interval[DateTime(2013, 1, 1), DateTime(2014, 1, 1))\n" @@ -881,7 +882,7 @@ public void testComplexQuery() { } @Test - public void testQueryThatReturnsLet() { + void queryThatReturnsLet() { String cql = "using QUICK\n" + "valueset \"Inpatient\" : '2.16.840.1.113883.3.666.5.307'\n" + "define st : [Encounter: \"Inpatient\"] E\n" + " let a : 1\n" @@ -921,7 +922,7 @@ public void testQueryThatReturnsLet() { } @Test - public void testChoiceAssignment() throws IOException { + void choiceAssignment() throws IOException { ExpressionDef def = (ExpressionDef) visitFile("TestChoiceAssignment.cql"); Instance instance = (Instance) def.getExpression(); @@ -929,7 +930,7 @@ public void testChoiceAssignment() throws IOException { } @Test - public void testLocalFunctionResolution() throws IOException { + void localFunctionResolution() throws IOException { ExpressionDef def = (ExpressionDef) visitFile("LocalFunctionResolutionTest.cql"); assertThat(def.getExpression(), instanceOf(FunctionRef.class)); FunctionRef functionRef = (FunctionRef) def.getExpression(); @@ -937,7 +938,7 @@ public void testLocalFunctionResolution() throws IOException { } @Test - public void testUnion() throws IOException { + void union() throws IOException { ExpressionDef def = (ExpressionDef) visitFile("TestUnion.cql"); // Union(Union(Union(Union(A, B), Union(C,D)), Union(E,F)), Union(G,H)) @@ -968,7 +969,7 @@ public void testUnion() throws IOException { } @Test - public void testIncludedIn() throws IOException { + void includedIn() throws IOException { ExpressionDef def = (ExpressionDef) visitFile("TestIncludedIn.cql"); // Query-> // where-> @@ -983,9 +984,9 @@ public void testIncludedIn() throws IOException { assertThat(inExpression.getOperand().get(1), instanceOf(ParameterRef.class)); } - // TODO: This test needs to be repurposed, it won't work with the query as is. - @Test(enabled = false) - public void testSameAs() { + @Test + @Disabled("TODO: This test needs to be repurposed, it won't work with the query as is.") + void sameAs() { String where = "P same as E"; SameAs sameAs = (SameAs) testInpatientWithPharyngitisWhere(where); assertThat(sameAs.getOperand(), hasSize(2)); @@ -995,9 +996,9 @@ public void testSameAs() { assertThat(rhs.getName(), is("E")); } - // TODO: This test needs to be repurposed, it won't work with the query as is. - @Test(enabled = false) - public void testSameYearAs() { + @Test + @Disabled("TODO: This test needs to be repurposed, it won't work with the query as is.") + void sameYearAs() { String where = "P same year as E"; SameAs sameYear = (SameAs) testInpatientWithPharyngitisWhere(where); assertThat(sameYear.getPrecision(), is(DateTimePrecision.YEAR)); @@ -1008,9 +1009,9 @@ public void testSameYearAs() { assertThat(rhs.getName(), is("E")); } - // TODO: This test needs to be repurposed, it won't work with the query as is. - @Test(enabled = false) - public void testSameMonthAs() { + @Test + @Disabled("TODO: This test needs to be repurposed, it won't work with the query as is.") + void sameMonthAs() { String where = "P same month as E"; SameAs sameMonth = (SameAs) testInpatientWithPharyngitisWhere(where); assertThat(sameMonth.getPrecision(), is(DateTimePrecision.MONTH)); @@ -1021,9 +1022,9 @@ public void testSameMonthAs() { assertThat(rhs.getName(), is("E")); } - // TODO: This test needs to be repurposed, it won't work with the query as is. - @Test(enabled = false) - public void testSameDayAs() { + @Test + @Disabled("TODO: This test needs to be repurposed, it won't work with the query as is.") + void sameDayAs() { String where = "P same day as E"; SameAs sameDay = (SameAs) testInpatientWithPharyngitisWhere(where); assertThat(sameDay.getPrecision(), is(DateTimePrecision.DAY)); @@ -1034,9 +1035,9 @@ public void testSameDayAs() { assertThat(rhs.getName(), is("E")); } - // TODO: This test needs to be repurposed, it won't work with the query as is. - @Test(enabled = false) - public void testSameHourAs() { + @Test + @Disabled("TODO: This test needs to be repurposed, it won't work with the query as is.") + void sameHourAs() { String where = "P same hour as E"; SameAs sameHour = (SameAs) testInpatientWithPharyngitisWhere(where); assertThat(sameHour.getPrecision(), is(DateTimePrecision.HOUR)); @@ -1047,9 +1048,9 @@ public void testSameHourAs() { assertThat(rhs.getName(), is("E")); } - // TODO: This test needs to be repurposed, it won't work with the query as is. - @Test(enabled = false) - public void testSameMinuteAs() { + @Test + @Disabled("TODO: This test needs to be repurposed, it won't work with the query as is.") + void sameMinuteAs() { String where = "P same minute as E"; SameAs sameMin = (SameAs) testInpatientWithPharyngitisWhere(where); assertThat(sameMin.getPrecision(), is(DateTimePrecision.MINUTE)); @@ -1060,9 +1061,9 @@ public void testSameMinuteAs() { assertThat(rhs.getName(), is("E")); } - // TODO: This test needs to be repurposed, it won't work with the query as is. - @Test(enabled = false) - public void testSameSecondAs() { + @Test + @Disabled("TODO: This test needs to be repurposed, it won't work with the query as is.") + void sameSecondAs() { String where = "P same second as E"; SameAs sameSec = (SameAs) testInpatientWithPharyngitisWhere(where); assertThat(sameSec.getPrecision(), is(DateTimePrecision.SECOND)); @@ -1073,9 +1074,9 @@ public void testSameSecondAs() { assertThat(rhs.getName(), is("E")); } - // TODO: This test needs to be repurposed, it won't work with the query as is. - @Test(enabled = false) - public void testSameMillisecondAs() { + @Test + @Disabled("TODO: This test needs to be repurposed, it won't work with the query as is.") + void sameMillisecondAs() { String where = "P same millisecond as E"; SameAs sameMS = (SameAs) testInpatientWithPharyngitisWhere(where); assertThat(sameMS.getPrecision(), is(DateTimePrecision.MILLISECOND)); @@ -1086,9 +1087,9 @@ public void testSameMillisecondAs() { assertThat(rhs.getName(), is("E")); } - // TODO: This test needs to be repurposed, it won't work with the query as is. - @Test(enabled = false) - public void testStartsSameDayAs() { + @Test + @Disabled("TODO: This test needs to be repurposed, it won't work with the query as is.") + void startsSameDayAs() { String where = "P starts same day as E"; SameAs sameDay = (SameAs) testInpatientWithPharyngitisWhere(where); assertThat(sameDay.getPrecision(), is(DateTimePrecision.DAY)); @@ -1099,9 +1100,9 @@ public void testStartsSameDayAs() { assertThat(rhs.getName(), is("E")); } - // TODO: This test needs to be repurposed, it won't work with the query as is. - @Test(enabled = false) - public void testStartsSameDayAsStart() { + @Test + @Disabled("TODO: This test needs to be repurposed, it won't work with the query as is.") + void startsSameDayAsStart() { String where = "P starts same day as start E"; SameAs sameDay = (SameAs) testInpatientWithPharyngitisWhere(where); assertThat(sameDay.getPrecision(), is(DateTimePrecision.DAY)); @@ -1112,9 +1113,9 @@ public void testStartsSameDayAsStart() { assertThat(((AliasRef) rhs.getOperand()).getName(), is("E")); } - // TODO: This test needs to be repurposed, it won't work with the query as is. - @Test(enabled = false) - public void testStartsSameDayAsEnd() { + @Test + @Disabled("TODO: This test needs to be repurposed, it won't work with the query as is.") + void startsSameDayAsEnd() { String where = "P starts same day as end E"; SameAs sameDay = (SameAs) testInpatientWithPharyngitisWhere(where); assertThat(sameDay.getPrecision(), is(DateTimePrecision.DAY)); @@ -1125,9 +1126,9 @@ public void testStartsSameDayAsEnd() { assertThat(((AliasRef) rhs.getOperand()).getName(), is("E")); } - // TODO: This test needs to be repurposed, it won't work with the query as is. - @Test(enabled = false) - public void testStartsAtLeastSameDayAs() { + @Test + @Disabled("TODO: This test needs to be repurposed, it won't work with the query as is.") + void startsAtLeastSameDayAs() { String where = "P starts same day or after E"; SameOrAfter sameOrAfter = (SameOrAfter) testInpatientWithPharyngitisWhere(where); assertThat(sameOrAfter.getOperand(), hasSize(2)); @@ -1138,9 +1139,9 @@ public void testStartsAtLeastSameDayAs() { assertThat(rhs.getName(), is("E")); } - // TODO: This test needs to be repurposed, it won't work with the query as is. - @Test(enabled = false) - public void testStartsAtMostSameDayAs() { + @Test + @Disabled("TODO: This test needs to be repurposed, it won't work with the query as is.") + void startsAtMostSameDayAs() { String where = "P starts same day or before E"; SameOrBefore sameOrBefore = (SameOrBefore) testInpatientWithPharyngitisWhere(where); assertThat(sameOrBefore.getPrecision(), is(DateTimePrecision.DAY)); @@ -1150,9 +1151,9 @@ public void testStartsAtMostSameDayAs() { assertThat(rhs.getName(), is("E")); } - // TODO: This test needs to be repurposed, it won't work with the query as is. - @Test(enabled = false) - public void testEndsSameDayAs() { + @Test + @Disabled("TODO: This test needs to be repurposed, it won't work with the query as is.") + void endsSameDayAs() { String where = "P ends same day as E"; SameAs sameDay = (SameAs) testInpatientWithPharyngitisWhere(where); assertThat(sameDay.getPrecision(), is(DateTimePrecision.DAY)); @@ -1163,9 +1164,9 @@ public void testEndsSameDayAs() { assertThat(rhs.getName(), is("E")); } - // TODO: This test needs to be repurposed, it won't work with the query as is. - @Test(enabled = false) - public void testEndsSameDayAsEnd() { + @Test + @Disabled("TODO: This test needs to be repurposed, it won't work with the query as is.") + void endsSameDayAsEnd() { String where = "P ends same day as end E"; SameAs sameDay = (SameAs) testInpatientWithPharyngitisWhere(where); assertThat(sameDay.getPrecision(), is(DateTimePrecision.DAY)); @@ -1176,9 +1177,9 @@ public void testEndsSameDayAsEnd() { assertThat(((AliasRef) rhs.getOperand()).getName(), is("E")); } - // TODO: This test needs to be repurposed, it won't work with the query as is. - @Test(enabled = false) - public void testEndsSameDayAsStart() { + @Test + @Disabled("TODO: This test needs to be repurposed, it won't work with the query as is.") + void endsSameDayAsStart() { String where = "P ends same day as start E"; SameAs sameDay = (SameAs) testInpatientWithPharyngitisWhere(where); assertThat(sameDay.getPrecision(), is(DateTimePrecision.DAY)); @@ -1221,7 +1222,7 @@ private Expression testInpatientWithPharyngitisWhere(String withWhereClause) { } @Test - public void testPatientContext() throws IOException { + void patientContext() throws IOException { CompiledLibrary library = visitFileLibrary("TestPatientContext.cql"); ExpressionDef patient = library.resolveExpressionRef("Patient"); assertThat(patient.getExpression(), instanceOf(Literal.class)); diff --git a/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/ElmSupportTest.java b/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/ElmSupportTest.java index 81c41a831..623673180 100644 --- a/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/ElmSupportTest.java +++ b/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/ElmSupportTest.java @@ -1,32 +1,32 @@ package org.cqframework.cql.cql2elm; -import static org.testng.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertTrue; import java.io.IOException; import org.cqframework.cql.cql2elm.LibraryBuilder.SignatureLevel; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; -public class ElmSupportTest { +class ElmSupportTest { - ModelManager modelManager; - LibraryManager libraryManager; + static ModelManager modelManager; + static LibraryManager libraryManager; - @BeforeClass - public void setup() { + @BeforeAll + static void setup() { modelManager = new ModelManager(); libraryManager = new LibraryManager(modelManager); libraryManager.getLibrarySourceLoader().registerProvider(new TestLibrarySourceProvider()); } - @AfterClass - public void tearDown() { + @AfterAll + static void tearDown() { libraryManager.getLibrarySourceLoader().clearProviders(); } @Test - public void testIncludedLibraryWithJsonElm() { + void includedLibraryWithJsonElm() { CqlCompilerOptions options = new CqlCompilerOptions(CqlCompilerException.ErrorSeverity.Info, SignatureLevel.All); libraryManager = new LibraryManager(modelManager, options); @@ -46,7 +46,7 @@ public void testIncludedLibraryWithJsonElm() { } @Test - public void testIncludedLibraryWithXmlElm() { + void includedLibraryWithXmlElm() { CqlCompilerOptions options = new CqlCompilerOptions(CqlCompilerException.ErrorSeverity.Info, SignatureLevel.All); libraryManager = new LibraryManager(modelManager, options); @@ -65,7 +65,7 @@ public void testIncludedLibraryWithXmlElm() { } @Test - public void testIncludedLibraryWithJsonWithNullTypeSpecifierElm() { + void includedLibraryWithJsonWithNullTypeSpecifierElm() { CqlCompilerOptions options = new CqlCompilerOptions(CqlCompilerException.ErrorSeverity.Info, SignatureLevel.All); libraryManager = new LibraryManager(modelManager, options); diff --git a/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/EscapeSequenceTests.java b/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/EscapeSequenceTests.java index c91955fff..ace8c50cb 100644 --- a/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/EscapeSequenceTests.java +++ b/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/EscapeSequenceTests.java @@ -8,15 +8,15 @@ import java.util.HashMap; import java.util.Map; import org.hl7.elm.r1.*; -import org.testng.annotations.BeforeTest; -import org.testng.annotations.Test; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; -public class EscapeSequenceTests { +class EscapeSequenceTests { - private Map defs; + private static Map defs; - @BeforeTest - public void setup() throws IOException { + @BeforeAll + static void setup() throws IOException { ModelManager modelManager = new ModelManager(); LibraryManager libraryManager = new LibraryManager(modelManager); CqlTranslator translator = CqlTranslator.fromStream( @@ -31,7 +31,7 @@ public void setup() throws IOException { } @Test - public void testString() { + void string() { ExpressionDef def = defs.get("EmptyString"); assertThat(def, hasTypeAndResult(Literal.class, "System.String")); @@ -126,7 +126,7 @@ public void testString() { } @Test - public void testIdentifier() { + void identifier() { ExpressionDef def = defs.get(""); assertThat(def, hasTypeAndResult(Literal.class, "System.String")); diff --git a/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/EscapeSequenceWithBacktickTests.java b/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/EscapeSequenceWithBacktickTests.java index c540926b0..ee703b122 100644 --- a/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/EscapeSequenceWithBacktickTests.java +++ b/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/EscapeSequenceWithBacktickTests.java @@ -8,15 +8,15 @@ import java.util.HashMap; import java.util.Map; import org.hl7.elm.r1.*; -import org.testng.annotations.BeforeTest; -import org.testng.annotations.Test; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; -public class EscapeSequenceWithBacktickTests { +class EscapeSequenceWithBacktickTests { - private Map defs; + private static Map defs; - @BeforeTest - public void setup() throws IOException { + @BeforeAll + static void setup() throws IOException { ModelManager modelManager = new ModelManager(); LibraryManager libraryManager = new LibraryManager(modelManager); CqlTranslator translator = CqlTranslator.fromStream( @@ -32,7 +32,7 @@ public void setup() throws IOException { } @Test - public void testIdentifier() { + void identifier() { ExpressionDef def = defs.get(""); assertThat(def, hasTypeAndResult(Literal.class, "System.String")); diff --git a/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/GenericOverloadsTests.java b/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/GenericOverloadsTests.java index 2004b3ab6..ce630e8a6 100644 --- a/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/GenericOverloadsTests.java +++ b/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/GenericOverloadsTests.java @@ -3,8 +3,8 @@ import static java.util.stream.Collectors.toList; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.*; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; import java.io.IOException; import java.util.HashMap; @@ -16,12 +16,12 @@ import org.hl7.elm.r1.Library; import org.hl7.elm.r1.ListTypeSpecifier; import org.hl7.elm.r1.NamedTypeSpecifier; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Test; -public class GenericOverloadsTests { +class GenericOverloadsTests { private static final String CQL_TEST_FILE = "SignatureTests/GenericOverloadsTests.cql"; - private Map defs; + private static Map defs; private Library getLibrary(boolean enableResultTypes, SignatureLevel level) throws IOException { final CqlTranslator translator = getTranslator(enableResultTypes, level); @@ -76,7 +76,7 @@ private void validateResultTypes(FunctionDef functionDef) { } @Test - public void TestResultTypes() throws IOException { + void resultTypes() throws IOException { Library library = getLibrary(true, SignatureLevel.Overloads); var stringifies = stringifies(library); @@ -84,7 +84,7 @@ public void TestResultTypes() throws IOException { } @Test - public void TestNoResultTypes() throws IOException { + void noResultTypes() throws IOException { Library library = getLibrary(false, SignatureLevel.Overloads); var stringifies = stringifies(library); @@ -92,7 +92,7 @@ public void TestNoResultTypes() throws IOException { } @Test - public void TestResultTypesSignatureNone() throws IOException { + void resultTypesSignatureNone() throws IOException { Library library = getLibrary(true, SignatureLevel.None); var stringifies = stringifies(library); @@ -100,7 +100,7 @@ public void TestResultTypesSignatureNone() throws IOException { } @Test - public void TestNoResultTypesSignatureNone() throws IOException { + void noResultTypesSignatureNone() throws IOException { Library library = getLibrary(false, SignatureLevel.None); var stringifies = stringifies(library); diff --git a/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/HidingTests.java b/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/HidingTests.java index ddd92b385..3bae74f8b 100644 --- a/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/HidingTests.java +++ b/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/HidingTests.java @@ -7,12 +7,12 @@ import java.util.List; import java.util.Set; import java.util.stream.Collectors; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Test; -public class HidingTests { +class HidingTests { @Test - public void testCaseInsensitiveWarning() throws IOException { + void caseInsensitiveWarning() throws IOException { final CqlTranslator translator = TestUtils.runSemanticTest( "HidingTests/TestHidingCaseInsensitiveWarning.cql", 0, LibraryBuilder.SignatureLevel.All); final List warnings = translator.getWarnings(); @@ -20,7 +20,7 @@ public void testCaseInsensitiveWarning() throws IOException { } @Test - public void testHiddenIdentifierFromReturn() throws IOException { + void hiddenIdentifierFromReturn() throws IOException { final CqlTranslator translator = TestUtils.runSemanticTestNoErrors("HidingTests/TestHiddenIdentifierFromReturn.cql"); final List warnings = translator.getWarnings(); @@ -34,7 +34,7 @@ public void testHiddenIdentifierFromReturn() throws IOException { } @Test - public void testHidingUnionWithSameAlias() throws IOException { + void hidingUnionWithSameAlias() throws IOException { final CqlTranslator translator = TestUtils.runSemanticTestNoErrors("HidingTests/TestHidingUnionSameAlias.cql"); final List warnings = translator.getWarnings(); @@ -58,7 +58,7 @@ public void testHidingUnionWithSameAlias() throws IOException { } @Test - public void testHidingUnionWithSameAliasEachHides() throws IOException { + void hidingUnionWithSameAliasEachHides() throws IOException { final CqlTranslator translator = TestUtils.runSemanticTestNoErrors("HidingTests/TestHidingUnionSameAliasEachHides.cql"); final List warnings = translator.getWarnings(); @@ -85,7 +85,7 @@ public void testHidingUnionWithSameAliasEachHides() throws IOException { } @Test - public void testSoMuchNestingNormal() throws IOException { + void soMuchNestingNormal() throws IOException { final CqlTranslator translator = TestUtils.runSemanticTestNoErrors("HidingTests/TestHidingSoMuchNestingNormal.cql"); final List warnings = translator.getWarnings(); @@ -94,7 +94,7 @@ public void testSoMuchNestingNormal() throws IOException { } @Test - public void testSoMuchNestingHidingSimple() throws IOException { + void soMuchNestingHidingSimple() throws IOException { final CqlTranslator translator = TestUtils.runSemanticTestNoErrors("HidingTests/TestHidingSoMuchNestingHidingSimple.cql"); final List warnings = translator.getWarnings(); @@ -107,7 +107,7 @@ public void testSoMuchNestingHidingSimple() throws IOException { } @Test - public void testSoMuchNestingHidingComplex() throws IOException { + void soMuchNestingHidingComplex() throws IOException { final CqlTranslator translator = TestUtils.runSemanticTestNoErrors("HidingTests/TestHidingSoMuchNestingHidingComplex.cql"); final List warnings = translator.getWarnings(); @@ -132,7 +132,7 @@ public void testSoMuchNestingHidingComplex() throws IOException { } @Test - public void testHidingLetAlias() throws IOException { + void hidingLetAlias() throws IOException { final CqlTranslator translator = TestUtils.runSemanticTestNoErrors("HidingTests/TestHidingLetAlias.cql"); final List warnings = translator.getWarnings(); @@ -146,7 +146,7 @@ public void testHidingLetAlias() throws IOException { } @Test - public void testHiddenIdentifierArgumentToAlias() throws IOException { + void hiddenIdentifierArgumentToAlias() throws IOException { final CqlTranslator translator = TestUtils.runSemanticTestNoErrors("HidingTests/TestHiddenIdentifierArgumentToAlias.cql"); @@ -158,14 +158,14 @@ public void testHiddenIdentifierArgumentToAlias() throws IOException { } @Test - public void testReturnArgumentNotConsideredHiddenIdentifier() throws IOException { + void returnArgumentNotConsideredHiddenIdentifier() throws IOException { final CqlTranslator translator = TestUtils.runSemanticTestNoErrors( "HidingTests/TestHidingReturnArgumentNotConsideredHiddenIdentifier.cql"); assertThat(translator.getWarnings().size(), is(0)); } @Test - public void testHidingFunctionDefinitionWithOverloads() throws IOException { + void hidingFunctionDefinitionWithOverloads() throws IOException { final CqlTranslator translator = TestUtils.runSemanticTestNoErrors("HidingTests/TestHidingFunctionDefinitionWithOverloads.cql"); final List warnings = translator.getWarnings(); @@ -179,7 +179,7 @@ public void testHidingFunctionDefinitionWithOverloads() throws IOException { } @Test - public void testHidingParameterDefinition() throws IOException { + void hidingParameterDefinition() throws IOException { final CqlTranslator translator = TestUtils.runSemanticTestNoErrors("HidingTests/TestHidingParameterDefinition.cql"); final List warnings = translator.getWarnings(); @@ -193,7 +193,7 @@ public void testHidingParameterDefinition() throws IOException { } @Test - public void testHidingIncludeDefinition() throws IOException { + void hidingIncludeDefinition() throws IOException { final CqlTranslator translator = TestUtils.runSemanticTestNoErrors("HidingTests/TestHidingIncludeDefinition.cql"); final List warnings = translator.getWarnings(); @@ -207,7 +207,7 @@ public void testHidingIncludeDefinition() throws IOException { } @Test - public void testHidingCommaMissingInListConstruction() throws IOException { + void hidingCommaMissingInListConstruction() throws IOException { final CqlTranslator translator = TestUtils.runSemanticTestNoErrors("HidingTests/TestHidingCommaMissingInListConstruction.cql"); final List warnings = translator.getWarnings(); @@ -223,7 +223,7 @@ public void testHidingCommaMissingInListConstruction() throws IOException { } @Test - public void testHidingStringLiteral() throws IOException { + void hidingStringLiteral() throws IOException { final CqlTranslator translator = TestUtils.runSemanticTestNoErrors("HidingTests/TestHidingStringLiteral.cql"); final List warnings = translator.getWarnings(); final List warningMessages = diff --git a/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/IncludedSignatureOutputTests.java b/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/IncludedSignatureOutputTests.java index 2596f74f2..1cca1dd9a 100644 --- a/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/IncludedSignatureOutputTests.java +++ b/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/IncludedSignatureOutputTests.java @@ -7,16 +7,16 @@ import java.util.HashMap; import java.util.Map; import org.hl7.elm.r1.*; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Test; /** * Created by Bryn on 4/12/2018. */ -public class IncludedSignatureOutputTests { +class IncludedSignatureOutputTests { private static final String CQL_TEST_FILE = "SignatureTests/IncludedSignatureOutputTests.cql"; private static final String LIBRARY_SOURCE_PROVIDER = "SignatureTests"; - private Map defs; + private static Map defs; private Library getLibrary(LibraryBuilder.SignatureLevel signatureLevel) throws IOException { final CqlTranslator translator = getTranslator(signatureLevel); @@ -36,7 +36,7 @@ private static CqlTranslator getTranslator(LibraryBuilder.SignatureLevel signatu } @Test - public void TestNone() throws IOException { + void none() throws IOException { final CqlTranslator translator = getTranslator(LibraryBuilder.SignatureLevel.None); assertThat(translator.getWarnings().size(), greaterThan(1)); assertThat( @@ -46,7 +46,7 @@ public void TestNone() throws IOException { } @Test - public void TestDiffering() throws IOException { + void differing() throws IOException { Library library = getLibrary(LibraryBuilder.SignatureLevel.Differing); ExpressionDef def = defs.get("TestOverload"); @@ -72,7 +72,7 @@ public void TestDiffering() throws IOException { } @Test - public void TestOverloads() throws IOException { + void overloads() throws IOException { Library library = getLibrary(LibraryBuilder.SignatureLevel.Overloads); ExpressionDef def = defs.get("TestOverload"); @@ -98,7 +98,7 @@ public void TestOverloads() throws IOException { } @Test - public void TestAll() throws IOException { + void all() throws IOException { Library library = getLibrary(LibraryBuilder.SignatureLevel.All); ExpressionDef def = defs.get("TestOverload"); diff --git a/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/IncludedSignatureWithAliasOutputTests.java b/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/IncludedSignatureWithAliasOutputTests.java index 3134e7abe..1b6d7c0f5 100644 --- a/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/IncludedSignatureWithAliasOutputTests.java +++ b/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/IncludedSignatureWithAliasOutputTests.java @@ -7,13 +7,13 @@ import java.util.HashMap; import java.util.Map; import org.hl7.elm.r1.*; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Test; -public class IncludedSignatureWithAliasOutputTests { +class IncludedSignatureWithAliasOutputTests { private static final String CQL_TEST_FILE = "SignatureTests/IncludedSignatureWithAliasOutputTests.cql"; private static final String LIBRARY_SOURCE_PROVIDER = "SignatureTests"; - private Map defs; + private static Map defs; private Library getLibrary(LibraryBuilder.SignatureLevel signatureLevel) throws IOException { final CqlTranslator translator = getTranslator(signatureLevel); @@ -33,7 +33,7 @@ private static CqlTranslator getTranslator(LibraryBuilder.SignatureLevel signatu } @Test - public void TestNone() throws IOException { + void none() throws IOException { final CqlTranslator translator = getTranslator(LibraryBuilder.SignatureLevel.None); assertThat(translator.getWarnings().size(), greaterThan(1)); assertThat( @@ -43,7 +43,7 @@ public void TestNone() throws IOException { } @Test - public void TestDiffering() throws IOException { + void differing() throws IOException { Library library = getLibrary(LibraryBuilder.SignatureLevel.Differing); ExpressionDef def = defs.get("TestOverload"); @@ -69,7 +69,7 @@ public void TestDiffering() throws IOException { } @Test - public void TestOverloads() throws IOException { + void overloads() throws IOException { Library library = getLibrary(LibraryBuilder.SignatureLevel.Overloads); ExpressionDef def = defs.get("TestOverload"); @@ -95,7 +95,7 @@ public void TestOverloads() throws IOException { } @Test - public void TestAll() throws IOException { + void all() throws IOException { Library library = getLibrary(LibraryBuilder.SignatureLevel.All); ExpressionDef def = defs.get("TestOverload"); diff --git a/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/LibraryManagerTests.java b/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/LibraryManagerTests.java index 07ba56084..416cc657e 100644 --- a/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/LibraryManagerTests.java +++ b/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/LibraryManagerTests.java @@ -3,32 +3,32 @@ import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.greaterThan; import static org.hamcrest.Matchers.lessThanOrEqualTo; -import static org.testng.Assert.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNotNull; import org.hl7.elm.r1.VersionedIdentifier; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; -public class LibraryManagerTests { +class LibraryManagerTests { - ModelManager modelManager; - LibraryManager libraryManager; + private static ModelManager modelManager; + private static LibraryManager libraryManager; - @BeforeClass - public void setup() { + @BeforeAll + static void setup() { modelManager = new ModelManager(); libraryManager = new LibraryManager(modelManager); libraryManager.getLibrarySourceLoader().registerProvider(new TestLibrarySourceProvider("LibraryManagerTests")); } - @AfterClass - public void tearDown() { + @AfterAll + static void tearDown() { libraryManager.getLibrarySourceLoader().clearProviders(); } @Test - public void testLibraryStatementsAreSorted() { + void libraryStatementsAreSorted() { // Some optimizations depend on the Library statements being sorted in lexicographic order by name // This test validates that they are ordered var lib = libraryManager diff --git a/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/LibraryTests.java b/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/LibraryTests.java index 6a2245cd6..c51a1050e 100644 --- a/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/LibraryTests.java +++ b/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/LibraryTests.java @@ -2,7 +2,7 @@ import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.*; -import static org.testng.Assert.*; +import static org.junit.jupiter.api.Assertions.*; import java.io.File; import java.io.IOException; @@ -17,30 +17,31 @@ import org.cqframework.cql.cql2elm.LibraryBuilder.SignatureLevel; import org.hl7.cql_annotations.r1.CqlToElmError; import org.hl7.elm.r1.*; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; -public class LibraryTests { +class LibraryTests { - ModelManager modelManager; - LibraryManager libraryManager; + private static ModelManager modelManager; + private static LibraryManager libraryManager; - @BeforeClass - public void setup() { + @BeforeAll + static void setup() { modelManager = new ModelManager(); libraryManager = new LibraryManager(modelManager); libraryManager.getLibrarySourceLoader().registerProvider(new TestLibrarySourceProvider()); } - @AfterClass - public void tearDown() { + @AfterAll + static void tearDown() { libraryManager.getLibrarySourceLoader().clearProviders(); } @Test - public void testLibraryReferences() { + void libraryReferences() { CqlTranslator translator = null; try { translator = CqlTranslator.fromStream( @@ -65,7 +66,7 @@ public void testLibraryReferences() { // } @Test - public void testIncludedLibraryWithSignatures() { + void includedLibraryWithSignatures() { var compilerOptions = new CqlCompilerOptions(CqlCompilerException.ErrorSeverity.Info, SignatureLevel.All); libraryManager = new LibraryManager(modelManager, compilerOptions); libraryManager.getLibrarySourceLoader().registerProvider(new TestLibrarySourceProvider()); @@ -98,7 +99,7 @@ public void testIncludedLibraryWithSignatures() { } @Test - public void testAlphanumericVersionIssue641() { + void alphanumericVersionIssue641() { // the issue identified with using DefaultLibrarySourceLoader only; thus // creating a fresh set below ModelManager modelManager = new ModelManager(); @@ -142,7 +143,7 @@ public void testAlphanumericVersionIssue641() { } @Test - public void testInvalidLibraryReferences() { + void invalidLibraryReferences() { CqlTranslator translator = null; try { translator = CqlTranslator.fromStream( @@ -155,7 +156,7 @@ public void testInvalidLibraryReferences() { } @Test - public void testPrivateAccessModifierReferencing() throws IOException { + void privateAccessModifierReferencing() throws IOException { CqlTranslator translator = TestUtils.createTranslatorFromStream("LibraryTests/AccessModifierReferencing.cql"); assertThat(translator.getErrors().size(), is(not(0))); @@ -187,14 +188,14 @@ public void testPrivateAccessModifierReferencing() throws IOException { } @Test - public void testPrivateAccessModifierNonReferencing() throws IOException { + void privateAccessModifierNonReferencing() throws IOException { CqlTranslator translator = TestUtils.createTranslatorFromStream("LibraryTests/AccessModifierNonReferencing.cql"); assertThat(translator.getErrors().size(), is(0)); } @Test - public void testInvalidLibraryReference() { + void invalidLibraryReference() { CqlTranslator translator = null; try { translator = CqlTranslator.fromStream( @@ -206,7 +207,7 @@ public void testInvalidLibraryReference() { } @Test - public void testDuplicateExpressionLibrary() { + void duplicateExpressionLibrary() { CqlTranslator translator = null; try { translator = CqlTranslator.fromStream( @@ -219,7 +220,7 @@ public void testDuplicateExpressionLibrary() { } @Test - public void testMissingLibrary() { + void missingLibrary() { CqlTranslator translator = null; try { translator = CqlTranslator.fromStream( @@ -233,7 +234,7 @@ public void testMissingLibrary() { } @Test - public void testInvalidBaseLibrary() { + void invalidBaseLibrary() { CqlTranslator translator = null; try { translator = CqlTranslator.fromStream( @@ -265,7 +266,7 @@ public void testInvalidBaseLibrary() { // This test verifies that when a model load failure prevents proper creation of // the context expression, that doesn't lead to internal translator errors. @Test - public void testMixedVersionModelReferences() { + void mixedVersionModelReferences() { CqlTranslator translator = null; try { translator = CqlTranslator.fromStream( @@ -281,7 +282,7 @@ public void testMixedVersionModelReferences() { } @Test - public void testTranslatorOptionsFlowDownWithAnnotations() { + void translatorOptionsFlowDownWithAnnotations() { try { // Test Annotations are created for both libraries var options = new CqlCompilerOptions( @@ -308,7 +309,7 @@ public void testTranslatorOptionsFlowDownWithAnnotations() { } @Test - public void testTranslatorOptionsFlowDownWithoutAnnotations() { + void translatorOptionsFlowDownWithoutAnnotations() { try { // Test Annotations are created for both libraries CqlCompiler compiler = null; @@ -322,10 +323,11 @@ public void testTranslatorOptionsFlowDownWithoutAnnotations() { var includedLibraries = compiler.getLibraries(); includedLibraries.values().stream().forEach(includedLibrary -> { // Ensure that no annotations are present. - assertTrue(includedLibrary.getStatements().getDef().stream() + assertEquals( + 0, + includedLibrary.getStatements().getDef().stream() .filter(x -> x.getAnnotation().size() > 0) - .count() - == 0); + .count()); }); } catch (IOException e) { e.printStackTrace(); @@ -333,7 +335,7 @@ public void testTranslatorOptionsFlowDownWithoutAnnotations() { } @Test - public void testSyntaxErrorWithNoLibrary() throws IOException { + void syntaxErrorWithNoLibrary() throws IOException { // Syntax errors in anonymous libraries are reported with the name of the source // file as the library identifier CqlTranslator translator = TestUtils.createTranslator("LibraryTests/SyntaxErrorWithNoLibrary.cql"); @@ -343,7 +345,7 @@ public void testSyntaxErrorWithNoLibrary() throws IOException { } @Test - public void testSyntaxErrorWithNoLibraryFromStream() throws IOException { + void syntaxErrorWithNoLibraryFromStream() throws IOException { // Syntax errors in anonymous libraries are reported with the name of the source // file as the library identifier CqlTranslator translator = TestUtils.createTranslatorFromStream("LibraryTests/SyntaxErrorWithNoLibrary.cql"); @@ -352,21 +354,21 @@ public void testSyntaxErrorWithNoLibraryFromStream() throws IOException { } @Test - public void testSyntaxErrorWithLibrary() throws IOException { + void syntaxErrorWithLibrary() throws IOException { CqlTranslator translator = TestUtils.createTranslator("LibraryTests/SyntaxErrorWithLibrary.cql"); assertThat(translator.getErrors().size(), greaterThanOrEqualTo(1)); assertThat(translator.getErrors().get(0).getLocator().getLibrary().getId(), equalTo("SyntaxErrorWithLibrary")); } @Test - public void testSyntaxErrorWithLibraryFromStream() throws IOException { + void syntaxErrorWithLibraryFromStream() throws IOException { CqlTranslator translator = TestUtils.createTranslatorFromStream("LibraryTests/SyntaxErrorWithLibrary.cql"); assertThat(translator.getErrors().size(), greaterThanOrEqualTo(1)); assertThat(translator.getErrors().get(0).getLocator().getLibrary().getId(), equalTo("SyntaxErrorWithLibrary")); } @Test - public void testSyntaxErrorReferencingLibrary() throws IOException { + void syntaxErrorReferencingLibrary() throws IOException { CqlTranslator translator = TestUtils.createTranslator("LibraryTests/SyntaxErrorReferencingLibrary.cql"); assertThat(translator.getErrors().size(), greaterThanOrEqualTo(2)); assertThat( @@ -376,7 +378,7 @@ public void testSyntaxErrorReferencingLibrary() throws IOException { } @Test - public void testSyntaxErrorReferencingLibraryFromStream() throws IOException { + void syntaxErrorReferencingLibraryFromStream() throws IOException { CqlTranslator translator = TestUtils.createTranslatorFromStream("LibraryTests/SyntaxErrorReferencingLibrary.cql"); assertThat(translator.getErrors().size(), greaterThanOrEqualTo(2)); @@ -396,7 +398,7 @@ private ExpressionDef getExpressionDef(Library library, String name) { } @Test - public void testFluentFunctions1() throws IOException { + void fluentFunctions1() throws IOException { CqlTranslator translator = TestUtils.createTranslatorFromStream("LibraryTests/TestFluent3.cql"); assertThat(translator.getErrors().size(), equalTo(0)); Library library = translator.toELM(); @@ -413,7 +415,7 @@ public void testFluentFunctions1() throws IOException { } @Test - public void testFluentFunctions2() throws IOException { + void fluentFunctions2() throws IOException { CqlTranslator translator = TestUtils.createTranslatorFromStream("LibraryTests/TestFluent4.cql"); assertThat(translator.getErrors().size(), equalTo(0)); Library library = translator.toELM(); @@ -430,7 +432,7 @@ public void testFluentFunctions2() throws IOException { } @Test - public void testFluentFunctions5() throws IOException { + void fluentFunctions5() throws IOException { CqlTranslator translator = TestUtils.createTranslatorFromStream("LibraryTests/TestFluent5.cql"); assertThat(translator.getErrors().size(), equalTo(1)); // Expects invalid invocation assertThat( @@ -440,7 +442,7 @@ public void testFluentFunctions5() throws IOException { } @Test - public void testFluentFunctions6() throws IOException { + void fluentFunctions6() throws IOException { CqlTranslator translator = TestUtils.createTranslatorFromStream("LibraryTests/TestFluent6.cql"); assertThat(translator.getErrors().size(), equalTo(1)); // Expects invalid fluent invocation assertThat( @@ -450,7 +452,7 @@ public void testFluentFunctions6() throws IOException { } @Test - public void testFluentFunctions7() throws IOException { + void fluentFunctions7() throws IOException { CqlTranslator translator = TestUtils.createTranslatorFromStream("LibraryTests/TestFluent7.cql"); assertThat(translator.getErrors().size(), equalTo(0)); Library library = translator.toELM(); @@ -467,7 +469,7 @@ public void testFluentFunctions7() throws IOException { } @Test - public void testInvalidInvocation() throws IOException { + void invalidInvocation() throws IOException { CqlTranslator translator = TestUtils.createTranslatorFromStream("LibraryTests/TestInvalidFunction.cql"); assertThat(translator.getErrors().size(), equalTo(1)); assertThat( @@ -476,7 +478,7 @@ public void testInvalidInvocation() throws IOException { } @Test - public void testExpression() throws IOException { + void expression() throws IOException { // This test checks to the that the engine can compile short snippets of CQL CqlTranslator translator = TestUtils.createTranslatorFromStream("LibraryTests/expression.cql"); assertThat(translator.getErrors().size(), equalTo(0)); @@ -487,7 +489,7 @@ public void testExpression() throws IOException { } @Test - public void testExpression2() throws IOException { + void expression2() throws IOException { // This test checks to the that the engine can compile short snippets of CQL CqlTranslator translator = TestUtils.createTranslatorFromStream("LibraryTests/expression2.cql"); assertThat(translator.getErrors().size(), equalTo(0)); @@ -498,7 +500,7 @@ public void testExpression2() throws IOException { } @Test - public void TestForwardDeclaration() throws IOException { + void forwardDeclaration() throws IOException { final CqlTranslator translator = TestUtils.createTranslatorFromStream("LibraryTests/TestForwardDeclaration.cql"); assertThat("Errors: " + translator.getErrors(), translator.getErrors().size(), equalTo(0)); @@ -509,7 +511,7 @@ public void TestForwardDeclaration() throws IOException { } @Test - public void TestForwardDeclarationsNormalType() throws IOException { + void forwardDeclarationsNormalType() throws IOException { final CqlTranslator translator = TestUtils.createTranslatorFromStream("LibraryTests/TestForwardDeclarationNormalType.cql"); assertThat("Errors: " + translator.getErrors(), translator.getErrors().size(), equalTo(0)); @@ -520,7 +522,7 @@ public void TestForwardDeclarationsNormalType() throws IOException { } @Test - public void TestForwardDeclarationsGenericType() throws IOException { + void forwardDeclarationsGenericType() throws IOException { final CqlTranslator translator = TestUtils.createTranslatorFromStream("LibraryTests/TestForwardDeclarationGenericType.cql"); assertThat("Errors: " + translator.getErrors(), translator.getErrors().size(), equalTo(0)); @@ -531,7 +533,7 @@ public void TestForwardDeclarationsGenericType() throws IOException { } @Test - public void TestForwardDeclarationsImplicitConversion() throws IOException { + void forwardDeclarationsImplicitConversion() throws IOException { final CqlTranslator translator = TestUtils.createTranslatorFromStream("LibraryTests/TestForwardDeclarationImplicitConversion.cql"); assertThat(translator.getErrors().size(), equalTo(0)); @@ -542,7 +544,7 @@ public void TestForwardDeclarationsImplicitConversion() throws IOException { } @Test - public void TestForwardDeclarationsScoringImplicitConversion() throws IOException { + void forwardDeclarationsScoringImplicitConversion() throws IOException { CqlTranslator translator = TestUtils.createTranslatorFromStream( "LibraryTests/TestForwardDeclarationScoringImplicitConversion.cql"); assertThat("Errors: " + translator.getErrors(), translator.getErrors().size(), equalTo(0)); @@ -569,7 +571,7 @@ public void TestForwardDeclarationsScoringImplicitConversion() throws IOExceptio } @Test - public void TestForwardDeclarationsScoringImplicitConversionNonRelevantFunctionFirst() throws IOException { + void forwardDeclarationsScoringImplicitConversionNonRelevantFunctionFirst() throws IOException { final CqlTranslator translator = TestUtils.createTranslatorFromStream( "LibraryTests/TestForwardDeclarationScoringImplicitConversionNonRelevantFunctionFirst.cql"); assertThat("Errors: " + translator.getErrors(), translator.getErrors().size(), equalTo(0)); @@ -596,7 +598,7 @@ public void TestForwardDeclarationsScoringImplicitConversionNonRelevantFunctionF } @Test - public void TestForwardDeclarationsScoringImplicitConversionMultipleParams() throws IOException { + void forwardDeclarationsScoringImplicitConversionMultipleParams() throws IOException { final CqlTranslator translator = TestUtils.createTranslatorFromStream( "LibraryTests/TestForwardDeclarationScoringImplicitConversionMultipleParams.cql"); assertThat("Errors: " + translator.getErrors(), translator.getErrors().size(), equalTo(0)); @@ -626,14 +628,14 @@ public void TestForwardDeclarationsScoringImplicitConversionMultipleParams() thr } @Test - public void TestForwardDeclarationsScoringImplicitConversionMultipleParamsCannotResolve() throws IOException { + void forwardDeclarationsScoringImplicitConversionMultipleParamsCannotResolve() throws IOException { final CqlTranslator translator = TestUtils.createTranslatorFromStream( "LibraryTests/TestForwardDeclarationScoringImplicitConversionMultipleParamsCannotResolve.cql"); assertThat("Errors: " + translator.getErrors(), translator.getErrors().size(), equalTo(1)); } @Test - public void TestNonForwardDeclarationsScoringImplicitConversion() throws IOException { + void nonForwardDeclarationsScoringImplicitConversion() throws IOException { final CqlTranslator translator = TestUtils.createTranslatorFromStream( "LibraryTests/TestNonForwardDeclarationScoringImplicitConversion.cql"); assertThat("Errors: " + translator.getErrors(), translator.getErrors().size(), equalTo(0)); @@ -660,7 +662,7 @@ public void TestNonForwardDeclarationsScoringImplicitConversion() throws IOExcep } @Test - public void TestNonForwardDeclarationsScoringImplicitConversionMultipleParams() throws IOException { + void nonForwardDeclarationsScoringImplicitConversionMultipleParams() throws IOException { final CqlTranslator translator = TestUtils.createTranslatorFromStream( "LibraryTests/TestNonForwardDeclarationScoringImplicitConversionMultipleParams.cql"); assertThat("Errors: " + translator.getErrors(), translator.getErrors().size(), equalTo(0)); @@ -690,7 +692,7 @@ public void TestNonForwardDeclarationsScoringImplicitConversionMultipleParams() } @Test - public void TestNonForwardDeclarationsScoringImplicitConversionMultipleParamsCannotResolve() throws IOException { + void nonForwardDeclarationsScoringImplicitConversionMultipleParamsCannotResolve() throws IOException { final CqlTranslator translator = TestUtils.createTranslatorFromStream( "LibraryTests/TestNonForwardDeclarationScoringImplicitConversionMultipleParamsCannotResolve.cql"); assertThat("Errors: " + translator.getErrors(), translator.getErrors().size(), equalTo(1)); @@ -701,7 +703,6 @@ public void TestNonForwardDeclarationsScoringImplicitConversionMultipleParamsCan private static final String NON_FORWARD_AMBIGUOUS_FUNCTION_RESOLUTION_FILE = "LibraryTests/TestNonForwardAmbiguousFunctionResolutionWithoutTypeInformation.cql"; - @DataProvider private static Object[][] sigParams() { return new Object[][] { {FORWARD_AMBIGUOUS_FUNCTION_RESOLUTION_FILE, SignatureLevel.None}, @@ -715,8 +716,9 @@ private static Object[][] sigParams() { }; } - @Test(dataProvider = "sigParams") - public void testForwardAmbiguousFailOnAmbiguousFunctionResolutionWithoutTypeInformation_SignatureLevelNone( + @ParameterizedTest + @MethodSource("sigParams") + void forwardAmbiguousFailOnAmbiguousFunctionResolutionWithoutTypeInformationSignatureLevelNone( String testFileName, SignatureLevel signatureLevel) throws IOException { final CqlTranslator translator = TestUtils.createTranslatorFromStream(testFileName, signatureLevel); final int expectedWarningCount = diff --git a/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/LiteralTests.java b/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/LiteralTests.java index 501b7bc77..9b8bf5373 100644 --- a/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/LiteralTests.java +++ b/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/LiteralTests.java @@ -4,24 +4,24 @@ import static org.cqframework.cql.cql2elm.matchers.LiteralFor.literalFor; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.*; -import static org.testng.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import java.io.IOException; import java.math.BigDecimal; import java.util.HashMap; import java.util.Map; import org.hl7.elm.r1.*; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Test; /** * Created by Bryn on 11/21/2017. */ -public class LiteralTests { +class LiteralTests { - private Map defs; + private static Map defs; @Test - public void dateTimeLiteralTests() throws IOException { + void dateTimeLiteralTests() throws IOException { CqlTranslator translator = TestUtils.runSemanticTest("DateTimeLiteralTest.cql", 0); Library library = translator.toELM(); defs = new HashMap<>(); @@ -75,7 +75,7 @@ public void dateTimeLiteralTests() throws IOException { } @Test - public void quantityLiteralTests() throws IOException { + void quantityLiteralTests() throws IOException { CqlTranslator translator = TestUtils.runSemanticTest("QuantityLiteralTest.cql", 1); Library library = translator.toELM(); defs = new HashMap<>(); @@ -140,7 +140,7 @@ private Map getDefs(Library library) { } @Test - public void RatioLiteralTests() throws IOException { + void RatioLiteralTests() throws IOException { CqlTranslator translator = TestUtils.runSemanticTest("RatioLiteralTest.cql", 0); Library library = translator.toELM(); defs = getDefs(library); @@ -161,7 +161,7 @@ public void RatioLiteralTests() throws IOException { } @Test - public void testDecimal() throws IOException { + void decimal() throws IOException { CqlTranslator translator = TestUtils.createTranslatorFromText("define TestDecimal: 1.5"); Library library = translator.toELM(); defs = getDefs(library); @@ -174,7 +174,7 @@ public void testDecimal() throws IOException { } @Test - public void testString() throws IOException { + void string() throws IOException { CqlTranslator translator = TestUtils.createTranslatorFromText("define TestString: '12345''"); Library library = translator.toELM(); defs = getDefs(library); @@ -187,7 +187,7 @@ public void testString() throws IOException { } @Test - public void testInteger() throws IOException { + void integer() throws IOException { CqlTranslator translator = TestUtils.createTranslatorFromText("define TestInteger: 12345"); Library library = translator.toELM(); defs = getDefs(library); @@ -200,7 +200,7 @@ public void testInteger() throws IOException { } @Test - public void testLongInteger() throws IOException { + void longInteger() throws IOException { CqlTranslator translator = TestUtils.createTranslatorFromText("define TestLongInteger: 12345L"); Library library = translator.toELM(); defs = getDefs(library); @@ -213,7 +213,7 @@ public void testLongInteger() throws IOException { } @Test - public void TokenRecognitionErrorTest() throws IOException { + void TokenRecognitionErrorTest() throws IOException { CqlTranslator translator = TestUtils.runSemanticTest("TokenRecognitionError.cql", 1); assertThat(translator.getErrors().size(), equalTo(1)); } diff --git a/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/ModelTests.java b/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/ModelTests.java index f05e974d5..95ff2c7f7 100644 --- a/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/ModelTests.java +++ b/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/ModelTests.java @@ -6,28 +6,28 @@ import java.io.IOException; import org.hl7.cql.model.ModelInfoProvider; import org.hl7.elm.r1.Library; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; -public class ModelTests { - private ModelManager modelManager; - private ModelInfoProvider modelInfoProvider; +class ModelTests { + private static ModelManager modelManager; + private static ModelInfoProvider modelInfoProvider; - @BeforeClass - public void setup() { + @BeforeAll + static void setup() { modelManager = new ModelManager(); modelInfoProvider = new TestModelInfoProvider(); modelManager.getModelInfoLoader().registerModelInfoProvider(modelInfoProvider); } - @AfterClass - public void tearDown() { + @AfterAll + static void tearDown() { modelManager.getModelInfoLoader().unregisterModelInfoProvider(modelInfoProvider); } @Test - public void testModelInfo() { + void modelInfo() { CqlTranslator translator = null; try { translator = CqlTranslator.fromStream( diff --git a/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/ModelWithoutDefaultLoadersTests.java b/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/ModelWithoutDefaultLoadersTests.java index e155db7aa..3fd324c83 100644 --- a/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/ModelWithoutDefaultLoadersTests.java +++ b/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/ModelWithoutDefaultLoadersTests.java @@ -6,29 +6,29 @@ import java.io.IOException; import org.hl7.cql.model.ModelInfoProvider; import org.hl7.elm.r1.Library; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; -public class ModelWithoutDefaultLoadersTests { - private ModelManager modelManager; - private ModelInfoProvider modelInfoProvider; +class ModelWithoutDefaultLoadersTests { + private static ModelManager modelManager; + private static ModelInfoProvider modelInfoProvider; - @BeforeClass - public void setup() { + @BeforeAll + static void setup() { modelManager = new ModelManager(false); modelInfoProvider = new TestModelInfoProvider(); // modelManager.getModelInfoLoader().registerSystemModelInfoProvider(); modelManager.getModelInfoLoader().registerModelInfoProvider(modelInfoProvider); } - @AfterClass - public void tearDown() { + @AfterAll + static void tearDown() { modelManager.getModelInfoLoader().unregisterModelInfoProvider(modelInfoProvider); } @Test - public void testModelInfo() { + void modelInfo() { CqlTranslator translator = null; try { translator = CqlTranslator.fromStream( diff --git a/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/NamespaceTests.java b/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/NamespaceTests.java index 464bb74c5..ea3f54ab3 100644 --- a/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/NamespaceTests.java +++ b/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/NamespaceTests.java @@ -11,18 +11,18 @@ import org.hl7.cql_annotations.r1.CqlToElmError; import org.hl7.elm.r1.IncludeDef; import org.hl7.elm.r1.VersionedIdentifier; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; -public class NamespaceTests { - ModelManager modelManager; - LibraryManager libraryManager; - NamespaceInfo defaultNamespaceInfo; - NamespaceInfo coreNamespaceInfo; - NamespaceInfo sharedNamespaceInfo; - NamespaceInfo contentNamespaceInfo; +class NamespaceTests { + private static ModelManager modelManager; + private static LibraryManager libraryManager; + private static NamespaceInfo defaultNamespaceInfo; + private static NamespaceInfo coreNamespaceInfo; + private static NamespaceInfo sharedNamespaceInfo; + private static NamespaceInfo contentNamespaceInfo; - public class NamespaceTestsLibrarySourceProvider implements LibrarySourceProvider { + static class NamespaceTestsLibrarySourceProvider implements LibrarySourceProvider { @Override public InputStream getLibrarySource(VersionedIdentifier libraryIdentifier) { String namespacePath = "NamespaceTests/"; @@ -42,8 +42,8 @@ public InputStream getLibrarySource(VersionedIdentifier libraryIdentifier) { } } - @BeforeClass - public void setup() { + @BeforeAll + static void setup() { modelManager = new ModelManager(); libraryManager = new LibraryManager(modelManager); libraryManager.getLibrarySourceLoader().registerProvider(new NamespaceTestsLibrarySourceProvider()); @@ -60,25 +60,25 @@ public void setup() { /* Unit test namespace functionality */ @Test - public void testNamespacePath() { + void namespacePath() { assertThat( NamespaceManager.getPath(defaultNamespaceInfo.getUri(), "Main"), is("http://cql.hl7.org/public/Main")); } @Test - public void testNamespaceNamePart() { + void namespaceNamePart() { assertThat(NamespaceManager.getNamePart("http://cql.hl7.org/public/Main"), is("Main")); } @Test - public void testNamespaceUriPart() { + void namespaceUriPart() { assertThat(NamespaceManager.getUriPart("http://cql.hl7.org/public/Main"), is("http://cql.hl7.org/public")); } /* Ensure base functionality with a defaulted namespace uri */ @Test - public void testLibraryReferences() { + void libraryReferences() { CqlTranslator translator = null; try { translator = CqlTranslator.fromStream( @@ -93,7 +93,7 @@ public void testLibraryReferences() { } @Test - public void testInvalidLibraryReferences() { + void invalidLibraryReferences() { CqlTranslator translator = null; try { translator = CqlTranslator.fromStream( @@ -107,7 +107,7 @@ public void testInvalidLibraryReferences() { } @Test - public void testInvalidLibraryReference() { + void invalidLibraryReference() { CqlTranslator translator = null; try { translator = CqlTranslator.fromStream( @@ -121,7 +121,7 @@ public void testInvalidLibraryReference() { } @Test - public void testInvalidBaseLibrary() { + void invalidBaseLibrary() { CqlTranslator translator = null; try { translator = CqlTranslator.fromStream( @@ -156,7 +156,7 @@ public void testInvalidBaseLibrary() { } @Test - public void testMain() { + void main() { try { CqlTranslator translator = CqlTranslator.fromStream( defaultNamespaceInfo, @@ -171,7 +171,7 @@ public void testMain() { } @Test - public void testReferencingMain() { + void referencingMain() { try { CqlTranslator translator = CqlTranslator.fromStream( defaultNamespaceInfo, @@ -192,7 +192,7 @@ public void testReferencingMain() { } @Test - public void testCoreMain() { + void coreMain() { try { CqlTranslator translator = CqlTranslator.fromStream( coreNamespaceInfo, @@ -207,7 +207,7 @@ public void testCoreMain() { } @Test - public void testCoreReferencingMain() { + void coreReferencingMain() { try { CqlTranslator translator = CqlTranslator.fromStream( coreNamespaceInfo, @@ -228,7 +228,7 @@ public void testCoreReferencingMain() { } @Test - public void testSharedMain() { + void sharedMain() { try { CqlTranslator translator = CqlTranslator.fromStream( sharedNamespaceInfo, @@ -250,7 +250,7 @@ public void testSharedMain() { } @Test - public void testSharedReferencingMain() { + void sharedReferencingMain() { try { CqlTranslator translator = CqlTranslator.fromStream( sharedNamespaceInfo, @@ -271,7 +271,7 @@ public void testSharedReferencingMain() { } @Test - public void testContentMain() { + void contentMain() { try { CqlTranslator translator = CqlTranslator.fromStream( contentNamespaceInfo, @@ -297,7 +297,7 @@ public void testContentMain() { } @Test - public void testContentReferencingMain() { + void contentReferencingMain() { try { CqlTranslator translator = CqlTranslator.fromStream( contentNamespaceInfo, diff --git a/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/OptionsTests.java b/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/OptionsTests.java index 5a23db275..299c2aa7b 100644 --- a/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/OptionsTests.java +++ b/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/OptionsTests.java @@ -1,29 +1,30 @@ package org.cqframework.cql.cql2elm; +import static org.junit.jupiter.api.Assertions.*; + import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.StringWriter; -import org.testng.Assert; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Test; -public class OptionsTests { +class OptionsTests { @Test - public void testTranslatorOptions() throws IOException { + void translatorOptions() throws IOException { var options = CqlTranslatorOptions.defaultOptions(); StringWriter sw = new StringWriter(); CqlTranslatorOptionsMapper.toWriter(sw, options); String result = sw.toString(); - Assert.assertNotNull(result); + assertNotNull(result); InputStream input = OptionsTests.class.getResourceAsStream("options.json"); CqlTranslatorOptions readOptions = CqlTranslatorOptionsMapper.fromReader(new InputStreamReader(input)); - Assert.assertTrue(readOptions != null); + assertTrue(readOptions != null); StringWriter sw2 = new StringWriter(); CqlTranslatorOptionsMapper.toWriter(sw2, readOptions); String result2 = sw2.toString(); - Assert.assertTrue(result.equals(result2)); + assertEquals(result, result2); } } diff --git a/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/SemanticTests.java b/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/SemanticTests.java index 644917a1e..f950eda26 100644 --- a/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/SemanticTests.java +++ b/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/SemanticTests.java @@ -2,9 +2,9 @@ import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.*; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertThrows; -import static org.testng.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; import java.io.IOException; import java.util.HashMap; @@ -17,82 +17,82 @@ import org.hl7.cql.model.DataType; import org.hl7.cql.model.NamedType; import org.hl7.elm.r1.*; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Test; public class SemanticTests { @Test - public void testTranslations() throws IOException { + void translations() throws IOException { runSemanticTest("TranslationTests.cql"); } @Test - public void testIn() throws IOException { + void in() throws IOException { runSemanticTest("InTest.cql"); } @Test - public void testInValueSet() throws IOException { + void inValueSet() throws IOException { runSemanticTest("InValueSetTest.cql"); } @Test - public void testTerminologyReferences() throws IOException { + void terminologyReferences() throws IOException { runSemanticTest("OperatorTests/TerminologyReferences.cql", 0); } @Test - public void testProperties() throws IOException { + void properties() throws IOException { runSemanticTest("PropertyTest.cql"); } @Test - public void testParameters() throws IOException { + void parameters() throws IOException { runSemanticTest("ParameterTest.cql"); } @Test - public void testInvalidParameters() throws IOException { + void invalidParameters() throws IOException { runSemanticTest("ParameterTestInvalid.cql", 17); } @Test - public void testSignatureResolution() throws IOException { + void signatureResolution() throws IOException { runSemanticTest("SignatureResolutionTest.cql"); } @Test - public void testCMS146v2() throws IOException { + void cms146v2() throws IOException { runSemanticTest("CMS146v2_Test_CQM.cql"); } @Test - public void testAggregateOperators() throws IOException { + void aggregateOperators() throws IOException { runSemanticTest("OperatorTests/AggregateOperators.cql"); } @Test - public void testArithmeticOperators() throws IOException { + void arithmeticOperators() throws IOException { runSemanticTest("OperatorTests/ArithmeticOperators.cql"); } @Test - public void testComparisonOperators() throws IOException { + void comparisonOperators() throws IOException { runSemanticTest("OperatorTests/ComparisonOperators.cql"); } @Test - public void testDateTimeOperators() throws IOException { + void dateTimeOperators() throws IOException { runSemanticTest("OperatorTests/DateTimeOperators.cql"); } @Test - public void testIntervalOperators() throws IOException { + void intervalOperators() throws IOException { runSemanticTest("OperatorTests/IntervalOperators.cql"); } @Test - public void testIntervalOperatorPhrases() throws IOException { + void intervalOperatorPhrases() throws IOException { CqlTranslator translator = runSemanticTest("OperatorTests/IntervalOperatorPhrases.cql"); Library library = translator.toELM(); ExpressionDef pointWithin = getExpressionDef(library, "PointWithin"); @@ -111,32 +111,32 @@ private ExpressionDef getExpressionDef(Library library, String name) { } @Test - public void testListOperators() throws IOException { + void listOperators() throws IOException { runSemanticTest("OperatorTests/ListOperators.cql"); } @Test - public void testLogicalOperators() throws IOException { + void logicalOperators() throws IOException { runSemanticTest("OperatorTests/LogicalOperators.cql"); } @Test - public void testNullologicalOperators() throws IOException { + void nullologicalOperators() throws IOException { runSemanticTest("OperatorTests/NullologicalOperators.cql"); } @Test - public void testStringOperators() throws IOException { + void stringOperators() throws IOException { runSemanticTest("OperatorTests/StringOperators.cql"); } @Test - public void testTimeOperators() throws IOException { + void timeOperators() throws IOException { runSemanticTest("OperatorTests/TimeOperators.cql"); } @Test - public void testTypeOperators() throws IOException { + void typeOperators() throws IOException { CqlTranslator translator = runSemanticTest("OperatorTests/TypeOperators.cql"); org.hl7.elm.r1.Library library = translator.toELM(); Map defs = new HashMap<>(); @@ -179,82 +179,82 @@ public void testTypeOperators() throws IOException { } @Test - public void testImplicitConversions() throws IOException { + void implicitConversions() throws IOException { runSemanticTest("OperatorTests/ImplicitConversions.cql"); } @Test - public void testTupleAndClassConversions() throws IOException { + void tupleAndClassConversions() throws IOException { runSemanticTest("OperatorTests/TupleAndClassConversions.cql"); } @Test - public void testFunctions() throws IOException { + void functions() throws IOException { runSemanticTest("OperatorTests/Functions.cql"); } @Test - public void testDateTimeLiteral() throws IOException { + void dateTimeLiteral() throws IOException { runSemanticTest("DateTimeLiteralTest.cql"); } @Test - public void testCodeAndConcepts() throws IOException { + void codeAndConcepts() throws IOException { runSemanticTest("CodeAndConceptTest.cql"); } @Test - public void testInvalidCastExpression() throws IOException { + void invalidCastExpression() throws IOException { runSemanticTest("OperatorTests/InvalidCastExpression.cql", 1); } @Test - public void testForwardReferences() throws IOException { + void forwardReferences() throws IOException { runSemanticTest("OperatorTests/ForwardReferences.cql", 0); } @Test - public void testRecursiveFunctions() throws IOException { + void recursiveFunctions() throws IOException { runSemanticTest("OperatorTests/RecursiveFunctions.cql", 1); } @Test - public void testNameHiding() throws IOException { + void nameHiding() throws IOException { runSemanticTest("OperatorTests/NameHiding.cql", 1); } @Test - public void testSorting() throws IOException { + void sorting() throws IOException { runSemanticTest("OperatorTests/Sorting.cql", 1); } @Test - public void testInvalidSortClauses() throws IOException { + void invalidSortClauses() throws IOException { runSemanticTest("OperatorTests/InvalidSortClauses.cql", 3); } @Test - public void testUndeclaredForward() throws IOException { + void undeclaredForward() throws IOException { runSemanticTest("OperatorTests/UndeclaredForward.cql", 1); } @Test - public void testUndeclaredSignature() throws IOException { + void undeclaredSignature() throws IOException { runSemanticTest("OperatorTests/UndeclaredSignature.cql", 1); } @Test - public void testMessageOperators() throws IOException { + void messageOperators() throws IOException { runSemanticTest("OperatorTests/MessageOperators.cql", 0); } @Test - public void testMultiSourceQuery() throws IOException { + void multiSourceQuery() throws IOException { runSemanticTest("OperatorTests/MultiSourceQuery.cql", 0); } @Test - public void testQuery() throws IOException { + void query() throws IOException { runSemanticTest("OperatorTests/Query.cql", 0); } @@ -269,28 +269,28 @@ public void testQuery() throws IOException { // } @Test - public void tricksyParse() throws IOException { + void tricksyParse() throws IOException { runSemanticTest("TricksyParse.cql"); } @Test - public void shouldFail() throws IOException { + void shouldFail() throws IOException { runSemanticTest("ShouldFail.cql", 1); } @Test - public void testCompatibilityLevel3() throws IOException { + void compatibilityLevel3() throws IOException { runSemanticTest("TestCompatibilityLevel3.cql", 1); runSemanticTest("TestCompatibilityLevel3.cql", 0, new CqlCompilerOptions().withCompatibilityLevel("1.3")); } @Test - public void invalidEquality() throws IOException { + void invalidEquality() throws IOException { runSemanticTest("InvalidEquality.cql", 1, CqlCompilerOptions.Options.DisableListPromotion); } @Test - public void testRelatedContextRetrieve() throws IOException { + void relatedContextRetrieve() throws IOException { CqlTranslator translator = TestUtils.runSemanticTest("TestRelatedContextRetrieve.cql", 0); org.hl7.elm.r1.Library library = translator.toELM(); Map defs = new HashMap<>(); @@ -311,7 +311,7 @@ public void testRelatedContextRetrieve() throws IOException { } @Test - public void testIssue616() throws IOException { + void issue616() throws IOException { TestUtils.runSemanticTest("Issue616.cql", 1); } @@ -330,17 +330,17 @@ public void testIssue617() throws IOException { } @Test - public void testIssue547() throws IOException { + void issue547() throws IOException { TestUtils.runSemanticTest("Issue547.cql", 3); } @Test - public void testIssue558() throws IOException { + void issue558() throws IOException { TestUtils.runSemanticTest("Issue558.cql", 1); } @Test - public void testIssue581() throws IOException { + void issue581() throws IOException { CqlTranslator translator = TestUtils.runSemanticTest("Issue581.cql", 0); Library library = translator.toELM(); assertThat(library.getStatements(), notNullValue()); @@ -354,7 +354,7 @@ public void testIssue581() throws IOException { } @Test - public void testIssue405() throws IOException { + void issue405() throws IOException { CqlTranslator translator = TestUtils.runSemanticTest("Issue405.cql", 0, CqlCompilerOptions.Options.EnableAnnotations); Library library = translator.toELM(); @@ -366,7 +366,7 @@ public void testIssue405() throws IOException { } @Test - public void testIssue395() throws IOException { + void issue395() throws IOException { CqlTranslator translator = TestUtils.runSemanticTest("Issue395.cql", 0, CqlCompilerOptions.Options.EnableAnnotations); Library library = translator.toELM(); @@ -376,7 +376,7 @@ public void testIssue395() throws IOException { } @Test - public void testIssue587() throws IOException { + void issue587() throws IOException { CqlTranslator translator = TestUtils.runSemanticTest("Issue587.cql", 2); // This doesn't resolve correctly, collapse null should work, but it's related to this issue: // [#435](https://github.com/cqframework/clinical_quality_language/issues/435) @@ -385,12 +385,12 @@ public void testIssue587() throws IOException { } @Test - public void testIssue592() throws IOException { + void issue592() throws IOException { TestUtils.runSemanticTest("Issue592.cql", 0, new CqlCompilerOptions().withCompatibilityLevel("1.3")); } @Test - public void testIssue596() throws IOException { + void issue596() throws IOException { // NOTE: This test is susceptible to constant folding optimization... CqlTranslator translator = TestUtils.runSemanticTest("Issue596.cql", 0); ExpressionDef ed = translator.getTranslatedLibrary().resolveExpressionRef("NullBeforeInterval"); @@ -441,7 +441,7 @@ private FunctionDef resolveFunctionDef(Library library, String functionName) { } @Test - public void testIssue643() throws IOException { + void issue643() throws IOException { CqlTranslator translator = TestUtils.runSemanticTest("Issue643.cql", 0); /* define function EncountersWithCoding(encounters List, valueSet System.ValueSet): @@ -508,13 +508,13 @@ define function EncountersWithServiceType(encounters List, valueSet S } @Test - public void testIssue827() throws IOException { + void issue827() throws IOException { // https://github.com/cqframework/clinical_quality_language/issues/827 TestUtils.runSemanticTest("Issue827.cql", 0); } @Test - public void testIssueEmptySourceInterval() throws IOException { + void issueEmptySourceInterval() throws IOException { CqlTranslator translator = TestUtils.runSemanticTest( "IssueEmptySourceInterval.cql", 1, CqlCompilerOptions.Options.EnableAnnotations); @@ -524,7 +524,7 @@ public void testIssueEmptySourceInterval() throws IOException { } @Test - public void TestVSCastFunction14() throws IOException { + void vSCastFunction14() throws IOException { CqlCompilerOptions options = new CqlCompilerOptions() .withOptions( CqlCompilerOptions.Options.EnableAnnotations, @@ -585,7 +585,7 @@ public void TestVSCastFunction14() throws IOException { } @Test - public void TestVSCastFunction15() throws IOException { + void vSCastFunction15() throws IOException { // TODO: This test needs to pass, most likely by implicitly converting a ValueSet to a ValueSetRef? Or maybe a // new explicit ELM operation? CqlCompilerOptions options = new CqlCompilerOptions() @@ -654,12 +654,12 @@ public void TestVSCastFunction15() throws IOException { } @Test - public void TestQuotedForwards() throws IOException { + void quotedForwards() throws IOException { CqlTranslator translator = TestUtils.runSemanticTest("TestQuotedForwards.cql", 0); } @Test - public void testIncorrectParameterType1204() throws IOException { + void incorrectParameterType1204() throws IOException { final CqlTranslator translator = runSemanticTest("TestIncorrectParameterType1204.cql", 2); final List errors = translator.getErrors(); @@ -675,7 +675,7 @@ public void testIncorrectParameterType1204() throws IOException { } @Test - public void testIdentifierCaseMismatch() throws IOException { + void identifierCaseMismatch() throws IOException { final CqlTranslator translator = runSemanticTest("TestIdentifierCaseMismatch.cql", 2); final List errors = translator.getErrors(); @@ -692,12 +692,12 @@ public void testIdentifierCaseMismatch() throws IOException { } @Test - public void testNonExistentFileName() { + void nonExistentFileName() { assertThrows(IOException.class, () -> TestUtils.runSemanticTest("ThisFileDoesNotExist.cql", 0)); } @Test - public void testCaseConditionalReturnTypes() throws IOException { + void caseConditionalReturnTypes() throws IOException { CqlTranslator translator = runSemanticTest("Issue648.cql", 0); org.hl7.elm.r1.Library library = translator.toELM(); Map defs = new HashMap<>(); @@ -723,11 +723,11 @@ public void testCaseConditionalReturnTypes() throws IOException { for (DataType dt : choiceType.getTypes()) { actualChoiceTypes.add(((NamedType) dt).getName()); } - assertTrue(actualChoiceTypes.equals(expectedChoiceTypes), "Expected types are String, Boolean, and Integer: "); + assertEquals(actualChoiceTypes, expectedChoiceTypes, "Expected types are String, Boolean, and Integer: "); } @Test - public void testIfConditionalReturnTypes() throws IOException { + void ifConditionalReturnTypes() throws IOException { CqlTranslator translator = runSemanticTest("Issue648.cql", 0); org.hl7.elm.r1.Library library = translator.toELM(); Map defs = new HashMap<>(); @@ -751,11 +751,11 @@ public void testIfConditionalReturnTypes() throws IOException { for (DataType dt : choiceType.getTypes()) { actualChoiceTypes.add(((NamedType) dt).getName()); } - assertTrue(actualChoiceTypes.equals(expectedChoiceTypes), "Expected return types are String and Boolean: "); + assertEquals(actualChoiceTypes, expectedChoiceTypes, "Expected return types are String and Boolean: "); } @Test - public void testIssue863() throws IOException { + void issue863() throws IOException { TestUtils.runSemanticTest("Issue863.cql", 0); } diff --git a/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/SignatureOutputTests.java b/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/SignatureOutputTests.java index d4d63149d..f431a98c0 100644 --- a/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/SignatureOutputTests.java +++ b/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/SignatureOutputTests.java @@ -7,15 +7,15 @@ import java.util.HashMap; import java.util.Map; import org.hl7.elm.r1.*; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Test; /** * Created by Bryn on 4/12/2018. */ -public class SignatureOutputTests { +class SignatureOutputTests { private static final String CQL_TEST_FILE = "SignatureTests/SignatureOutputTests.cql"; - private Map defs; + private static Map defs; private Library getLibrary(LibraryBuilder.SignatureLevel signatureLevel) throws IOException { final CqlTranslator translator = getTranslator(signatureLevel); @@ -35,7 +35,7 @@ private static CqlTranslator getTranslator(LibraryBuilder.SignatureLevel signatu } @Test - public void TestNone() throws IOException { + void none() throws IOException { final CqlTranslator translator = getTranslator(LibraryBuilder.SignatureLevel.None); assertThat(translator.getWarnings().size(), greaterThan(1)); assertThat( @@ -45,7 +45,7 @@ public void TestNone() throws IOException { } @Test - public void TestDiffering() throws IOException { + void differing() throws IOException { Library library = getLibrary(LibraryBuilder.SignatureLevel.Differing); // TestAvg->Avg->signature(1) // TestDivide->Divide->signature(2) @@ -85,7 +85,7 @@ public void TestDiffering() throws IOException { } @Test - public void TestOverloads() throws IOException { + void overloads() throws IOException { Library library = getLibrary(LibraryBuilder.SignatureLevel.Overloads); // TestAdd->operand->signature(2) // TestDateAdd->operand->signature(2) @@ -128,7 +128,7 @@ public void TestOverloads() throws IOException { } @Test - public void TestAll() throws IOException { + void all() throws IOException { Library library = getLibrary(LibraryBuilder.SignatureLevel.All); // TestAdd->operand->signature(2) // TestDateAdd->operand->signature(2) diff --git a/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/StringLibrarySourceProviderTest.java b/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/StringLibrarySourceProviderTest.java index e9638910f..5394b0727 100644 --- a/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/StringLibrarySourceProviderTest.java +++ b/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/StringLibrarySourceProviderTest.java @@ -1,15 +1,16 @@ package org.cqframework.cql.cql2elm; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertNull; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertThrows; import java.io.IOException; import java.util.List; import org.hl7.elm.r1.VersionedIdentifier; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Test; -public class StringLibrarySourceProviderTest { +class StringLibrarySourceProviderTest { // CQL allows for Library identifiers to be quoted or unquoted, so we test both scenarios private static final String QUOTED = "library \"Test\"\n define \"Value\": 2 + 2"; @@ -19,33 +20,44 @@ public class StringLibrarySourceProviderTest { private static final String NOT_QUOTED_VERSION_2 = "library Test version '2.0.0'\n define \"Value\": 2 + 2"; private static final String GARBAGE = "NotALibrary"; - @Test(expectedExceptions = IllegalArgumentException.class) - public void ambiguous_id_throws_error() throws IOException { + @Test + void ambiguous_id_throws_error() throws IOException { var list = List.of(QUOTED, NOT_QUOTED); var provider = new StringLibrarySourceProvider(list); + var id = new VersionedIdentifier().withId("Test"); - provider.getLibrarySource(new VersionedIdentifier().withId("Test")); + assertThrows(IllegalArgumentException.class, () -> provider.getLibrarySource(id)); + ; } - @Test(expectedExceptions = IllegalArgumentException.class) - public void ambiguous_id_without_version_throws_error() throws IOException { + @Test + void ambiguous_id_without_version_throws_error() throws IOException { var list = List.of(QUOTED_VERSION_1, NOT_QUOTED_VERSION_1); var provider = new StringLibrarySourceProvider(list); - provider.getLibrarySource(new VersionedIdentifier().withId("Test")); + + var id = new VersionedIdentifier().withId("Test"); + + assertThrows(IllegalArgumentException.class, () -> { + provider.getLibrarySource(id); + }); } - @Test(expectedExceptions = IllegalArgumentException.class) - public void ambiguous_id_with_version_throws_error() throws IOException { + @Test + void ambiguous_id_with_version_throws_error() throws IOException { var list = List.of(QUOTED_VERSION_1, NOT_QUOTED_VERSION_1); var provider = new StringLibrarySourceProvider(list); - provider.getLibrarySource(new VersionedIdentifier().withId("Test").withVersion("1.0.0")); + var id = new VersionedIdentifier().withId("Test").withVersion("1.0.0"); + + assertThrows(IllegalArgumentException.class, () -> { + provider.getLibrarySource(id); + }); } @Test - public void quoted_match_returns_library() throws IOException { + void quoted_match_returns_library() throws IOException { var list = List.of(QUOTED); var provider = new StringLibrarySourceProvider(list); @@ -57,7 +69,7 @@ public void quoted_match_returns_library() throws IOException { } @Test - public void unquoted_match_returns_library() throws IOException { + void unquoted_match_returns_library() throws IOException { var list = List.of(NOT_QUOTED); var provider = new StringLibrarySourceProvider(list); @@ -69,7 +81,7 @@ public void unquoted_match_returns_library() throws IOException { } @Test - public void quoted_versioned_match_returns_library() throws IOException { + void quoted_versioned_match_returns_library() throws IOException { var list = List.of(QUOTED_VERSION_1); var provider = new StringLibrarySourceProvider(list); @@ -82,7 +94,7 @@ public void quoted_versioned_match_returns_library() throws IOException { } @Test - public void unquoted_versioned_match_returns_library() throws IOException { + void unquoted_versioned_match_returns_library() throws IOException { var list = List.of(NOT_QUOTED_VERSION_1, NOT_QUOTED_VERSION_2); var provider = new StringLibrarySourceProvider(list); @@ -95,7 +107,7 @@ public void unquoted_versioned_match_returns_library() throws IOException { } @Test - public void garbage_returns_nothing() throws IOException { + void garbage_returns_nothing() throws IOException { var list = List.of(GARBAGE); var provider = new StringLibrarySourceProvider(list); diff --git a/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/TestLocalId.java b/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/TestLocalId.java index 4359083d1..21889fab9 100644 --- a/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/TestLocalId.java +++ b/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/TestLocalId.java @@ -1,8 +1,8 @@ package org.cqframework.cql.cql2elm; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; import org.antlr.v4.runtime.CharStreams; import org.antlr.v4.runtime.CommonTokenStream; @@ -14,11 +14,11 @@ import org.cqframework.cql.gen.cqlLexer; import org.cqframework.cql.gen.cqlParser; import org.hl7.elm.r1.Element; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Test; // This test compiles a few example libraries and ensures // local ids are assigned for all elements in the resulting ELM -public class TestLocalId { +class TestLocalId { // This visitor checks that all nodes the graph have a localId static FunctionalElmVisitor idChecker = Visitors.from((node, libraryName) -> { @@ -37,7 +37,7 @@ public class TestLocalId { }); @Test - public void testLocalIds() throws Exception { + void localIds() throws Exception { runTest("OperatorTests/CqlListOperators.cql"); runTest("TranslationTests.cql"); runTest("LibraryTests/TestMeasure.cql"); @@ -51,7 +51,7 @@ private void runTest(String cqlFileName) throws Exception { } @Test - public void noLocalIdThrowsException() throws Exception { + void noLocalIdThrowsException() throws Exception { // This is an intentionally broken IdObjectFactory that will not assign localIds var brokenFactory = new IdObjectFactory() { diff --git a/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/TestPointIntervalSignatures.java b/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/TestPointIntervalSignatures.java index 56f81e4ba..6e5111384 100644 --- a/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/TestPointIntervalSignatures.java +++ b/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/TestPointIntervalSignatures.java @@ -8,17 +8,17 @@ import java.util.HashMap; import java.util.Map; import org.hl7.elm.r1.*; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Test; /** * Created by Bryn on 6/25/2018. */ -public class TestPointIntervalSignatures { +class TestPointIntervalSignatures { - private Map defs; + private static Map defs; @Test - public void TestResolvedSignatures() throws IOException { + void resolvedSignatures() throws IOException { CqlTranslator translator = TestUtils.runSemanticTest("TestPointIntervalSignatures.cql", 0); Library library = translator.toELM(); defs = new HashMap<>(); diff --git a/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/TranslationTests.java b/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/TranslationTests.java index fdb624f04..c996384fe 100644 --- a/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/TranslationTests.java +++ b/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/TranslationTests.java @@ -5,7 +5,7 @@ import static org.cqframework.cql.cql2elm.CqlCompilerOptions.Options.EnableResultTypes; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.*; -import static org.testng.Assert.*; +import static org.junit.jupiter.api.Assertions.*; import jakarta.xml.bind.JAXBException; import java.io.File; @@ -19,18 +19,21 @@ import org.hamcrest.Matchers; import org.hl7.cql_annotations.r1.CqlToElmInfo; import org.hl7.elm.r1.*; -import org.testng.annotations.Ignore; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; -public class TranslationTests { +class TranslationTests { // TODO: sameXMLAs? Couldn't find such a thing in hamcrest, but I don't want this to run on the JSON, I want it to // verify the actual XML. - @Test(enabled = false) - public void testPatientPropertyAccess() throws IOException, JAXBException { + @Test + @Disabled + void patientPropertyAccess() throws IOException, JAXBException { File expectedXmlFile = new File( Cql2ElmVisitorTest.class.getResource("PropertyTest_ELM.xml").getFile()); - String expectedXml = - new Scanner(expectedXmlFile, "UTF-8").useDelimiter("\\Z").next(); + String expectedXml = null; + try (var scanner = new Scanner(expectedXmlFile, "UTF-8").useDelimiter("\\Z")) { + expectedXml = scanner.next(); + } File propertyTestFile = new File( Cql2ElmVisitorTest.class.getResource("PropertyTest.cql").getFile()); @@ -40,8 +43,9 @@ public void testPatientPropertyAccess() throws IOException, JAXBException { assertThat(actualXml, is(expectedXml)); } - @Test(enabled = false) - public void testForPrintElm() throws IOException, JAXBException { + @Test + @Disabled + void forPrintElm() throws IOException, JAXBException { File propertyTestFile = new File(TranslationTests.class .getResource("LibraryTests/SupplementalDataElements_FHIR4-2.0.0.cql") .getFile()); @@ -63,8 +67,9 @@ public void testForPrintElm() throws IOException, JAXBException { System.out.println(translator.toJson()); } - @Test(enabled = false) - public void testCMS146v2XML() throws IOException { + @Test + @Disabled + void cms146v2XML() throws IOException { String expectedXml = ""; File cqlFile = new File( Cql2ElmVisitorTest.class.getResource("CMS146v2_Test_CQM.cql").getFile()); @@ -75,7 +80,7 @@ public void testCMS146v2XML() throws IOException { } @Test - public void testIdentifierLocation() throws IOException { + void identifierLocation() throws IOException { CqlTranslator translator = TestUtils.createTranslator("TranslatorTests/UnknownIdentifier.cql"); assertEquals(1, translator.getErrors().size()); @@ -90,7 +95,7 @@ public void testIdentifierLocation() throws IOException { } @Test - public void testAnnotationsPresent() throws IOException { + void annotationsPresent() throws IOException { CqlTranslator translator = TestUtils.createTranslator("CMS146v2_Test_CQM.cql", CqlCompilerOptions.Options.EnableAnnotations); assertEquals(0, translator.getErrors().size()); @@ -101,16 +106,16 @@ public void testAnnotationsPresent() throws IOException { } @Test - public void testAnnotationsAbsent() throws IOException { + void annotationsAbsent() throws IOException { CqlTranslator translator = TestUtils.createTranslator("CMS146v2_Test_CQM.cql"); assertEquals(0, translator.getErrors().size()); List defs = translator.getTranslatedLibrary().getLibrary().getStatements().getDef(); - assertTrue(defs.get(1).getAnnotation().size() == 0); + assertEquals(0, defs.get(1).getAnnotation().size()); } @Test - public void testTranslatorOptionsPresent() throws IOException { + void translatorOptionsPresent() throws IOException { CqlTranslator translator = TestUtils.createTranslator("CMS146v2_Test_CQM.cql", CqlCompilerOptions.Options.EnableAnnotations); assertEquals(0, translator.getErrors().size()); @@ -123,7 +128,7 @@ public void testTranslatorOptionsPresent() throws IOException { } @Test - public void testNoImplicitCasts() throws IOException { + void noImplicitCasts() throws IOException { CqlTranslator translator = TestUtils.createTranslator("TestNoImplicitCast.cql"); assertEquals(0, translator.getErrors().size()); // Gets the "TooManyCasts" define @@ -176,9 +181,9 @@ public void testNoImplicitCasts() throws IOException { assertThat(as.getAsTypeSpecifier(), is(instanceOf(ChoiceTypeSpecifier.class))); } - @Test // test for https://github.com/cqframework/clinical_quality_language/issues/1293 - public void defaultContextIsUnfiltered() throws IOException { + @Test + void defaultContextIsUnfiltered() throws IOException { CqlTranslator translator = TestUtils.createTranslator( "DefaultContext.cql", EnableAnnotations, EnableResultTypes, EnableDetailedErrors); assertEquals(0, translator.getErrors().size()); @@ -189,101 +194,101 @@ public void defaultContextIsUnfiltered() throws IOException { } @Test - public void tenDividedByTwo() throws IOException { + void tenDividedByTwo() throws IOException { final CqlTranslator translator = TestUtils.createTranslator("TenDividedByTwo.cql"); - assertEquals(translator.getErrors().size(), 0, "Errors: " + translator.getErrors()); + assertEquals(0, translator.getErrors().size(), "Errors: " + translator.getErrors()); } @Test - public void divideMultiple() throws IOException { + void divideMultiple() throws IOException { final CqlTranslator translator = TestUtils.createTranslator("DivideMultiple.cql"); - assertEquals(translator.getErrors().size(), 0, "Errors: " + translator.getErrors()); + assertEquals(0, translator.getErrors().size(), "Errors: " + translator.getErrors()); } @Test - public void divideVariables() throws IOException { + void divideVariables() throws IOException { final CqlTranslator translator = TestUtils.createTranslator("DivideVariables.cql"); - assertEquals(translator.getErrors().size(), 0, "Errors: " + translator.getErrors()); + assertEquals(0, translator.getErrors().size(), "Errors: " + translator.getErrors()); } @Test - public void arithmetic_Mixed() throws IOException { + void arithmetic_Mixed() throws IOException { final CqlTranslator translator = TestUtils.createTranslator("Arithmetic_Mixed.cql"); - assertEquals(translator.getErrors().size(), 0, "Errors: " + translator.getErrors()); + assertEquals(0, translator.getErrors().size(), "Errors: " + translator.getErrors()); } @Test - public void arithmetic_Parenthetical() throws IOException { + void arithmetic_Parenthetical() throws IOException { final CqlTranslator translator = TestUtils.createTranslator("Arithmetic_Parenthetical.cql"); - assertEquals(translator.getErrors().size(), 0, "Errors: " + translator.getErrors()); + assertEquals(0, translator.getErrors().size(), "Errors: " + translator.getErrors()); } @Test - public void roundUp() throws IOException { + void roundUp() throws IOException { final CqlTranslator translator = TestUtils.createTranslator("RoundUp.cql"); - assertEquals(translator.getErrors().size(), 0, "Errors: " + translator.getErrors()); + assertEquals(0, translator.getErrors().size(), "Errors: " + translator.getErrors()); } @Test - public void roundDown() throws IOException { + void roundDown() throws IOException { final CqlTranslator translator = TestUtils.createTranslator("RoundDown.cql"); - assertEquals(translator.getErrors().size(), 0, "Errors: " + translator.getErrors()); + assertEquals(0, translator.getErrors().size(), "Errors: " + translator.getErrors()); } @Test - public void log_BaseTen() throws IOException { + void log_BaseTen() throws IOException { final CqlTranslator translator = TestUtils.createTranslator("Log_BaseTen.cql"); - assertEquals(translator.getErrors().size(), 0, "Errors: " + translator.getErrors()); + assertEquals(0, translator.getErrors().size(), "Errors: " + translator.getErrors()); } @Test - public void median_odd() throws IOException { + void median_odd() throws IOException { final CqlTranslator translator = TestUtils.createTranslator("Median_odd.cql"); - assertEquals(translator.getErrors().size(), 0, "Errors: " + translator.getErrors()); + assertEquals(0, translator.getErrors().size(), "Errors: " + translator.getErrors()); } @Test - public void median_dup_vals_odd() throws IOException { + void median_dup_vals_odd() throws IOException { final CqlTranslator translator = TestUtils.createTranslator("Median_dup_vals_odd.cql"); - assertEquals(translator.getErrors().size(), 0, "Errors: " + translator.getErrors()); + assertEquals(0, translator.getErrors().size(), "Errors: " + translator.getErrors()); } @Test - public void geometricMean_Zero() throws IOException { + void geometricMean_Zero() throws IOException { final CqlTranslator translator = TestUtils.createTranslator("GeometricMean_Zero.cql"); - assertEquals(translator.getErrors().size(), 0, "Errors: " + translator.getErrors()); + assertEquals(0, translator.getErrors().size(), "Errors: " + translator.getErrors()); } @Test - @Ignore("Could not resolve call to operator Equal with signature (tuple{Foo:System.Any},tuple{Bar:System.Any}") - public void tupleDifferentKeys() throws IOException { + @Disabled("Could not resolve call to operator Equal with signature (tuple{Foo:System.Any},tuple{Bar:System.Any}") + void tupleDifferentKeys() throws IOException { final CqlTranslator translator = TestUtils.createTranslator("TupleDifferentKeys.cql"); - assertEquals(translator.getErrors().size(), 0, "Errors: " + translator.getErrors()); + assertEquals(0, translator.getErrors().size(), "Errors: " + translator.getErrors()); } @Test - @Ignore( + @Disabled( "Could not resolve call to operator Equal with signature (tuple{a:System.String,b:System.Any},tuple{a:System.String,c:System.Any})") - public void uncertTuplesWithDiffNullFields() throws IOException { + void uncertTuplesWithDiffNullFields() throws IOException { final CqlTranslator translator = TestUtils.createTranslator("UncertTuplesWithDiffNullFields.cql"); - assertEquals(translator.getErrors().size(), 0, "Errors: " + translator.getErrors()); + assertEquals(0, translator.getErrors().size(), "Errors: " + translator.getErrors()); } @Test - @Ignore("Could not resolve call to operator Collapse with signature (System.Any,System.Quantity)") - public void nullIvlCollapse_NullCollapse() throws IOException { + @Disabled("Could not resolve call to operator Collapse with signature (System.Any,System.Quantity)") + void nullIvlCollapse_NullCollapse() throws IOException { final CqlTranslator translator = TestUtils.createTranslator("NullIvlCollapse_NullCollapse.cql"); - assertEquals(translator.getErrors().size(), 0, "Errors: " + translator.getErrors()); + assertEquals(0, translator.getErrors().size(), "Errors: " + translator.getErrors()); } @Test - public void median_q_diff_units() throws IOException { + void median_q_diff_units() throws IOException { final CqlTranslator translator = TestUtils.createTranslator("Median_q_diff_units.cql"); - assertEquals(translator.getErrors().size(), 0, "Errors: " + translator.getErrors()); + assertEquals(0, translator.getErrors().size(), "Errors: " + translator.getErrors()); } @Test - public void testForwardDeclarationSameTypeDifferentNamespaceNormalTypes() throws IOException { + void forwardDeclarationSameTypeDifferentNamespaceNormalTypes() throws IOException { final CqlTranslator translator = TestUtils.createTranslator("TestForwardDeclarationSameTypeDifferentNamespaceNormalTypes.cql"); assertThat("Errors: " + translator.getErrors(), translator.getErrors().size(), Matchers.equalTo(0)); @@ -294,7 +299,7 @@ public void testForwardDeclarationSameTypeDifferentNamespaceNormalTypes() throws } @Test - public void testForwardDeclarationSameTypeDifferentNamespaceGenericTypes() throws IOException { + void forwardDeclarationSameTypeDifferentNamespaceGenericTypes() throws IOException { final CqlTranslator translator = TestUtils.createTranslator("TestForwardDeclarationSameTypeDifferentNamespaceGenericTypes.cql"); assertThat("Errors: " + translator.getErrors(), translator.getErrors().size(), Matchers.equalTo(0)); @@ -307,7 +312,7 @@ public void testForwardDeclarationSameTypeDifferentNamespaceGenericTypes() throw // This test creates a bunch of translators on the common pool to suss out any race conditions. // It's not fool-proof, but is reasonably consistent on my local machine. @Test - public void multiThreadedTranslation() throws IOException { + void multiThreadedTranslation() throws IOException { List> futures = new ArrayList<>(); for (int i = 0; i < 10; i++) { futures.add(CompletableFuture.runAsync(() -> { @@ -325,7 +330,7 @@ public void multiThreadedTranslation() throws IOException { } @Test - public void testHidingVariousUseCases() throws IOException { + void hidingVariousUseCases() throws IOException { final CqlTranslator translator = TestUtils.runSemanticTest("HidingTests/TestHidingVariousUseCases.cql", 0); final List warnings = translator.getWarnings(); final List warningMessages = diff --git a/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/fhir/dstu2/BaseTest.java b/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/fhir/dstu2/BaseTest.java index d1ce281de..d9a197fd4 100644 --- a/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/fhir/dstu2/BaseTest.java +++ b/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/fhir/dstu2/BaseTest.java @@ -14,11 +14,11 @@ import org.cqframework.cql.cql2elm.model.CompiledLibrary; import org.hl7.cql.model.NamespaceInfo; import org.hl7.elm.r1.*; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Test; -public class BaseTest { +class BaseTest { @Test - public void testEqualityWithConversions() throws IOException { + void equalityWithConversions() throws IOException { CompiledLibrary library = visitFileLibrary("fhir/dstu2/EqualityWithConversions.cql"); ExpressionDef getGender = library.resolveExpressionRef("GetGender"); assertThat(getGender.getExpression(), instanceOf(Equal.class)); @@ -30,7 +30,7 @@ public void testEqualityWithConversions() throws IOException { } @Test - public void testDoubleListPromotion() throws IOException { + void doubleListPromotion() throws IOException { CqlTranslator translator = TestUtils.runSemanticTest("fhir/dstu2/TestDoubleListPromotion.cql", 0); Library library = translator.toELM(); Map defs = new HashMap<>(); @@ -49,7 +49,7 @@ public void testDoubleListPromotion() throws IOException { } @Test - public void testChoiceDateRangeOptimization() throws IOException { + void choiceDateRangeOptimization() throws IOException { CqlTranslator translator = TestUtils.runSemanticTest( "fhir/dstu2/TestChoiceDateRangeOptimization.cql", 0, @@ -129,42 +129,42 @@ public void testChoiceDateRangeOptimization() throws IOException { } @Test - public void testIntervalImplicitConversion() throws IOException { + void intervalImplicitConversion() throws IOException { TestUtils.runSemanticTest("fhir/dstu2/TestIntervalImplicitConversion.cql", 0); } @Test - public void testFHIRHelpers() throws IOException { + void fhirHelpers() throws IOException { TestUtils.runSemanticTest("fhir/dstu2/TestFHIRHelpers.cql", 0); } @Test - public void testImplicitFHIRHelpers() throws IOException { + void implicitFHIRHelpers() throws IOException { TestUtils.runSemanticTest("fhir/dstu2/TestImplicitFHIRHelpers.cql", 0); } @Test - public void testParameterContext() throws IOException { + void parameterContext() throws IOException { TestUtils.runSemanticTest("fhir/dstu2/TestParameterContext.cql", 0); } @Test - public void testFHIR() throws IOException { + void fhir() throws IOException { TestUtils.runSemanticTest("fhir/dstu2/TestFHIR.cql", 0); } @Test - public void testFHIRWithHelpers() throws IOException { + void fhirWithHelpers() throws IOException { TestUtils.runSemanticTest("fhir/dstu2/TestFHIRWithHelpers.cql", 0); } @Test - public void testBundle() throws IOException { + void bundle() throws IOException { TestUtils.runSemanticTest("fhir/dstu2/TestBundle.cql", 0); } @Test - public void testConceptConversion() throws IOException { + void conceptConversion() throws IOException { CqlTranslator translator = TestUtils.runSemanticTest("fhir/dstu2/TestConceptConversion.cql", 0); Library library = translator.toELM(); Map defs = new HashMap<>(); @@ -251,7 +251,7 @@ public void testConceptConversion() throws IOException { } @Test - public void testRetrieveWithConcept() throws IOException { + void retrieveWithConcept() throws IOException { CqlTranslator translator = TestUtils.runSemanticTest("fhir/dstu2/TestRetrieveWithConcept.cql", 0); CompiledLibrary library = translator.getTranslatedLibrary(); ExpressionDef expressionDef = library.resolveExpressionRef("Test Tobacco Smoking Status"); @@ -264,7 +264,7 @@ public void testRetrieveWithConcept() throws IOException { } @Test - public void testFHIRNamespaces() throws IOException { + void fhirNamespaces() throws IOException { CqlTranslator translator = TestUtils.runSemanticTest( new NamespaceInfo("Public", "http://cql.hl7.org/public"), "fhir/dstu2/TestFHIRNamespaces.cql", 0); CompiledLibrary library = translator.getTranslatedLibrary(); @@ -275,7 +275,7 @@ public void testFHIRNamespaces() throws IOException { } @Test - public void testFHIRNamespacesSignatureLevelNone() throws IOException { + void fhirNamespacesSignatureLevelNone() throws IOException { TestUtils.runSemanticTest( new NamespaceInfo("Public", "http://cql.hl7.org/public"), "fhir/dstu2/TestFHIRNamespaces.cql", @@ -284,7 +284,7 @@ public void testFHIRNamespacesSignatureLevelNone() throws IOException { } @Test - public void testFHIRWithoutNamespaces() throws IOException { + void fhirWithoutNamespaces() throws IOException { CqlTranslator translator = TestUtils.runSemanticTest("fhir/dstu2/TestFHIRNamespaces.cql", 0); CompiledLibrary library = translator.getTranslatedLibrary(); IncludeDef includeDef = library.resolveIncludeRef("FHIRHelpers"); diff --git a/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/fhir/r4/BaseTest.java b/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/fhir/r4/BaseTest.java index 63e7d4aca..27abd12d5 100644 --- a/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/fhir/r4/BaseTest.java +++ b/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/fhir/r4/BaseTest.java @@ -5,7 +5,7 @@ import static org.cqframework.cql.cql2elm.matchers.QuickDataType.quickDataType; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.*; -import static org.testng.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import java.io.IOException; import java.util.HashMap; @@ -16,12 +16,12 @@ import org.cqframework.cql.cql2elm.TestUtils; import org.cqframework.cql.cql2elm.model.CompiledLibrary; import org.hl7.elm.r1.*; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Test; -public class BaseTest { +class BaseTest { @Test - public void testChoiceWithAlternativeConversion() throws IOException { + void choiceWithAlternativeConversion() throws IOException { ExpressionDef def = (ExpressionDef) visitFile("fhir/r4/TestChoiceTypes.cql"); Query query = (Query) def.getExpression(); @@ -45,13 +45,13 @@ public void testChoiceWithAlternativeConversion() throws IOException { } @Test - public void testURIConversion() throws IOException { + void uriConversion() throws IOException { // If this translates without errors, the test is successful ExpressionDef def = (ExpressionDef) visitFile("fhir/r4/TestURIConversion.cql"); } @Test - public void testFHIRTiming() throws IOException { + void fhirTiming() throws IOException { ExpressionDef def = (ExpressionDef) visitFile("fhir/r4/TestFHIRTiming.cql"); // Query-> // where-> @@ -86,7 +86,7 @@ public void testFHIRTiming() throws IOException { } @Test - public void testEqualityWithConversions() throws IOException { + void equalityWithConversions() throws IOException { CompiledLibrary library = visitFileLibrary("fhir/r4/EqualityWithConversions.cql"); ExpressionDef getGender = library.resolveExpressionRef("GetGender"); assertThat(getGender.getExpression(), instanceOf(Equal.class)); @@ -98,7 +98,7 @@ public void testEqualityWithConversions() throws IOException { } @Test - public void testDoubleListPromotion() throws IOException { + void doubleListPromotion() throws IOException { CqlTranslator translator = TestUtils.runSemanticTest("fhir/r4/TestDoubleListPromotion.cql", 0); Library library = translator.toELM(); Map defs = new HashMap<>(); @@ -117,7 +117,7 @@ public void testDoubleListPromotion() throws IOException { } @Test - public void testChoiceDateRangeOptimization() throws IOException { + void choiceDateRangeOptimization() throws IOException { CqlTranslator translator = TestUtils.runSemanticTest( "fhir/r4/TestChoiceDateRangeOptimization.cql", 0, @@ -197,37 +197,37 @@ public void testChoiceDateRangeOptimization() throws IOException { } @Test - public void testIntervalImplicitConversion() throws IOException { + void intervalImplicitConversion() throws IOException { TestUtils.runSemanticTest("fhir/r4/TestIntervalImplicitConversion.cql", 0); } @Test - public void testFHIRHelpers() throws IOException { + void fhirHelpers() throws IOException { TestUtils.runSemanticTest("fhir/r4/TestFHIRHelpers.cql", 0); } @Test - public void testImplicitFHIRHelpers() throws IOException { + void implicitFHIRHelpers() throws IOException { TestUtils.runSemanticTest("fhir/r4/TestImplicitFHIRHelpers.cql", 0); } @Test - public void testFHIR() throws IOException { + void fhir() throws IOException { TestUtils.runSemanticTest("fhir/r4/TestFHIR.cql", 0); } @Test - public void testFHIRWithHelpers() throws IOException { + void fhirWithHelpers() throws IOException { TestUtils.runSemanticTest("fhir/r4/TestFHIRWithHelpers.cql", 0); } @Test - public void testBundle() throws IOException { + void bundle() throws IOException { TestUtils.runSemanticTest("fhir/r4/TestBundle.cql", 0); } @Test - public void testConceptConversion() throws IOException { + void conceptConversion() throws IOException { CqlTranslator translator = TestUtils.runSemanticTest("fhir/r4/TestConceptConversion.cql", 0); Library library = translator.toELM(); Map defs = new HashMap<>(); @@ -314,7 +314,7 @@ public void testConceptConversion() throws IOException { } @Test - public void testRetrieveWithConcept() throws IOException { + void retrieveWithConcept() throws IOException { CqlTranslator translator = TestUtils.runSemanticTest("fhir/r4/TestRetrieveWithConcept.cql", 0); CompiledLibrary library = translator.getTranslatedLibrary(); ExpressionDef expressionDef = library.resolveExpressionRef("Test Tobacco Smoking Status"); @@ -327,7 +327,7 @@ public void testRetrieveWithConcept() throws IOException { } @Test - public void testExm108IdentifierHiding() throws IOException { + void exm108IdentifierHiding() throws IOException { var translator = TestUtils.runSemanticTest("fhir/r4/exm108/EXM108.cql", 0, SignatureLevel.All); // Should only be one identifier being hid after fixes, "Warafin" assertEquals(1, translator.getExceptions().size()); diff --git a/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/fhir/r401/BaseTest.java b/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/fhir/r401/BaseTest.java index 5f9f78169..37aea3a22 100644 --- a/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/fhir/r401/BaseTest.java +++ b/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/fhir/r401/BaseTest.java @@ -21,11 +21,11 @@ import org.hl7.cql.model.DataType; import org.hl7.cql.model.NamespaceInfo; import org.hl7.elm.r1.*; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Test; -public class BaseTest { +class BaseTest { @Test - public void testChoiceWithAlternativeConversion() throws IOException { + void choiceWithAlternativeConversion() throws IOException { ExpressionDef def = (ExpressionDef) visitFile("fhir/r401/TestChoiceTypes.cql"); Query query = (Query) def.getExpression(); @@ -49,13 +49,13 @@ public void testChoiceWithAlternativeConversion() throws IOException { } @Test - public void testURIConversion() throws IOException { + void uriConversion() throws IOException { // If this translates without errors, the test is successful ExpressionDef def = (ExpressionDef) visitFile("fhir/r401/TestURIConversion.cql"); } @Test - public void testFHIRTiming() throws IOException { + void fhirTiming() throws IOException { ExpressionDef def = (ExpressionDef) visitFile("fhir/r401/TestFHIRTiming.cql"); // Query-> // where-> @@ -90,7 +90,7 @@ public void testFHIRTiming() throws IOException { } @Test - public void testEqualityWithConversions() throws IOException { + void equalityWithConversions() throws IOException { CompiledLibrary library = visitFileLibrary("fhir/r401/EqualityWithConversions.cql"); ExpressionDef getGender = library.resolveExpressionRef("GetGender"); assertThat(getGender.getExpression(), instanceOf(Equal.class)); @@ -102,7 +102,7 @@ public void testEqualityWithConversions() throws IOException { } @Test - public void testDoubleListPromotion() throws IOException { + void doubleListPromotion() throws IOException { CqlTranslator translator = TestUtils.runSemanticTest("fhir/r401/TestDoubleListPromotion.cql", 0); Library library = translator.toELM(); Map defs = new HashMap<>(); @@ -121,7 +121,7 @@ public void testDoubleListPromotion() throws IOException { } @Test - public void testChoiceDateRangeOptimization() throws IOException { + void choiceDateRangeOptimization() throws IOException { CqlTranslator translator = TestUtils.runSemanticTest( "fhir/r401/TestChoiceDateRangeOptimization.cql", 0, @@ -201,7 +201,7 @@ public void testChoiceDateRangeOptimization() throws IOException { } @Test - public void testIntervalImplicitConversion() throws IOException { + void intervalImplicitConversion() throws IOException { TestUtils.runSemanticTest("fhir/r401/TestIntervalImplicitConversion.cql", 0); } @@ -216,7 +216,7 @@ private void assertResultType( } @Test - public void testFHIRHelpers() throws IOException { + void fhirHelpers() throws IOException { CqlTranslator translator = TestUtils.runSemanticTest("fhir/r401/TestFHIRHelpers.cql", 0); CompiledLibrary translatedLibrary = translator.getTranslatedLibrary(); assertResultType(translatedLibrary, "TestExtensions", "FHIR", "Extension"); @@ -234,57 +234,57 @@ public void testFHIRHelpers() throws IOException { } @Test - public void testImplicitFHIRHelpers() throws IOException { + void implicitFHIRHelpers() throws IOException { TestUtils.runSemanticTest("fhir/r401/TestImplicitFHIRHelpers.cql", 0); } @Test - public void testContext() throws IOException { + void context() throws IOException { TestUtils.runSemanticTest("fhir/r401/TestContext.cql", 0); } @Test - public void testImplicitContext() throws IOException { + void implicitContext() throws IOException { TestUtils.runSemanticTest("fhir/r401/TestImplicitContext.cql", 0); } @Test - public void testParameterContext() throws IOException { + void parameterContext() throws IOException { TestUtils.runSemanticTest("fhir/r401/TestParameterContext.cql", 0); } @Test - public void testEncounterParameterContext() throws IOException { + void encounterParameterContext() throws IOException { TestUtils.runSemanticTest("fhir/r401/TestEncounterParameterContext.cql", 0); } @Test - public void testMeasureParameterContext() throws IOException { + void measureParameterContext() throws IOException { TestUtils.runSemanticTest("fhir/r401/TestMeasureParameterContext.cql", 0); } @Test - public void testTrace() throws IOException { + void trace() throws IOException { TestUtils.runSemanticTest("fhir/r401/TestTrace.cql", 0); } @Test - public void testFHIR() throws IOException { + void fhir() throws IOException { TestUtils.runSemanticTest("fhir/r401/TestFHIR.cql", 0); } @Test - public void testFHIRWithHelpers() throws IOException { + void fhirWithHelpers() throws IOException { TestUtils.runSemanticTest("fhir/r401/TestFHIRWithHelpers.cql", 0); } @Test - public void testBundle() throws IOException { + void bundle() throws IOException { TestUtils.runSemanticTest("fhir/r401/TestBundle.cql", 0); } @Test - public void testConceptConversion() throws IOException { + void conceptConversion() throws IOException { CqlTranslator translator = TestUtils.runSemanticTest("fhir/r401/TestConceptConversion.cql", 0); Library library = translator.toELM(); Map defs = new HashMap<>(); @@ -371,7 +371,7 @@ public void testConceptConversion() throws IOException { } @Test - public void testRetrieveWithConcept() throws IOException { + void retrieveWithConcept() throws IOException { CqlTranslator translator = TestUtils.runSemanticTest("fhir/r401/TestRetrieveWithConcept.cql", 0); CompiledLibrary library = translator.getTranslatedLibrary(); ExpressionDef expressionDef = library.resolveExpressionRef("Test Tobacco Smoking Status"); @@ -384,7 +384,7 @@ public void testRetrieveWithConcept() throws IOException { } @Test - public void testFHIRNamespaces() throws IOException { + void fhirNamespaces() throws IOException { CqlTranslator translator = TestUtils.runSemanticTest( new NamespaceInfo("Public", "http://cql.hl7.org/public"), "fhir/r401/TestFHIRNamespaces.cql", 0); CompiledLibrary library = translator.getTranslatedLibrary(); @@ -400,7 +400,7 @@ public void testFHIRNamespaces() throws IOException { } @Test - public void testFHIRWithoutNamespaces() throws IOException { + void fhirWithoutNamespaces() throws IOException { CqlTranslator translator = TestUtils.runSemanticTest("fhir/r401/TestFHIRNamespaces.cql", 0); CompiledLibrary library = translator.getTranslatedLibrary(); UsingDef usingDef = library.resolveUsingRef("FHIR"); @@ -415,7 +415,7 @@ public void testFHIRWithoutNamespaces() throws IOException { } @Test - public void testFHIRPath() throws IOException { + void fhirPath() throws IOException { CqlTranslator translator = TestUtils.runSemanticTest("fhir/r401/TestFHIRPath.cql", 0); CompiledLibrary library = translator.getTranslatedLibrary(); ExpressionDef expressionDef = library.resolveExpressionRef("TestNow"); @@ -523,7 +523,7 @@ public void testFHIRPath() throws IOException { } @Test - public void testFHIRPathLiteralStringEscapes() throws IOException { + void fhirPathLiteralStringEscapes() throws IOException { CqlTranslator translator = TestUtils.runSemanticTest("fhir/r401/TestFHIRPathLiteralStringEscapes.cql", 0); CompiledLibrary library = translator.getTranslatedLibrary(); ExpressionDef expressionDef = library.resolveExpressionRef("Test"); @@ -561,7 +561,7 @@ public void testFHIRPathLiteralStringEscapes() throws IOException { } @Test - public void testSearchPath() throws IOException { + void searchPath() throws IOException { CqlTranslator translator = TestUtils.runSemanticTest("fhir/r401/TestInclude.cql", 0); CompiledLibrary library = translator.getTranslatedLibrary(); ExpressionDef expressionDef = library.resolveExpressionRef("TestPractitionerSearch1"); @@ -585,7 +585,7 @@ public void testSearchPath() throws IOException { } @Test - public void testInclude() throws IOException { + void include() throws IOException { CqlTranslator translator = TestUtils.runSemanticTest("fhir/r401/TestInclude.cql", 0); CompiledLibrary library = translator.getTranslatedLibrary(); @@ -843,7 +843,7 @@ public void testInclude() throws IOException { } @Test - public void testOverload() throws IOException { + void overload() throws IOException { CqlTranslator translator = TestUtils.runSemanticTest("fhir/r401/TestOverload.cql", 0); assertThat(translator.getWarnings().size(), is(2)); @@ -860,7 +860,7 @@ public void testOverload() throws IOException { } @Test - public void testOverloadOutput() throws IOException { + void overloadOutput() throws IOException { CqlTranslator translator = TestUtils.runSemanticTest("fhir/r401/TestOverload.cql", 0, LibraryBuilder.SignatureLevel.Overloads); assertThat(translator.getWarnings().size(), is(1)); @@ -876,7 +876,7 @@ public void testOverloadOutput() throws IOException { } @Test - public void testOverloadForward() throws IOException { + void overloadForward() throws IOException { CqlTranslator translator = TestUtils.runSemanticTest("fhir/r401/TestOverloadForward.cql", 0); assertThat(translator.getWarnings().size(), is(2)); @@ -893,7 +893,7 @@ public void testOverloadForward() throws IOException { } @Test - public void testOverloadForwardOutput() throws IOException { + void overloadForwardOutput() throws IOException { CqlTranslator translator = TestUtils.runSemanticTest( "fhir/r401/TestOverloadForward.cql", 0, LibraryBuilder.SignatureLevel.Overloads); assertThat(translator.getWarnings().size(), is(1)); diff --git a/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/fhir/stu3/BaseTest.java b/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/fhir/stu3/BaseTest.java index 1b1ba58f3..bfdaf1916 100644 --- a/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/fhir/stu3/BaseTest.java +++ b/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/fhir/stu3/BaseTest.java @@ -13,11 +13,11 @@ import org.cqframework.cql.cql2elm.TestUtils; import org.cqframework.cql.cql2elm.model.CompiledLibrary; import org.hl7.elm.r1.*; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Test; public class BaseTest { @Test - public void testChoiceWithAlternativeConversion() throws IOException { + void choiceWithAlternativeConversion() throws IOException { ExpressionDef def = (ExpressionDef) visitFile("fhir/stu3/TestChoiceTypes.cql"); Query query = (Query) def.getExpression(); @@ -41,13 +41,13 @@ public void testChoiceWithAlternativeConversion() throws IOException { } @Test - public void testURIConversion() throws IOException { + void uriConversion() throws IOException { // If this translates without errors, the test is successful ExpressionDef def = (ExpressionDef) visitFile("fhir/stu3/TestURIConversion.cql"); } @Test - public void testFHIRTiming() throws IOException { + void fhirTiming() throws IOException { ExpressionDef def = (ExpressionDef) visitFile("fhir/stu3/TestFHIRTiming.cql"); // Query-> // where-> @@ -82,7 +82,7 @@ public void testFHIRTiming() throws IOException { } @Test - public void testEqualityWithConversions() throws IOException { + void equalityWithConversions() throws IOException { CompiledLibrary library = visitFileLibrary("fhir/stu3/EqualityWithConversions.cql"); ExpressionDef getGender = library.resolveExpressionRef("GetGender"); assertThat(getGender.getExpression(), instanceOf(Equal.class)); @@ -94,7 +94,7 @@ public void testEqualityWithConversions() throws IOException { } @Test - public void testDoubleListPromotion() throws IOException { + void doubleListPromotion() throws IOException { CqlTranslator translator = TestUtils.runSemanticTest("fhir/stu3/TestDoubleListPromotion.cql", 0); Library library = translator.toELM(); Map defs = new HashMap<>(); @@ -113,7 +113,7 @@ public void testDoubleListPromotion() throws IOException { } @Test - public void testChoiceDateRangeOptimization() throws IOException { + void choiceDateRangeOptimization() throws IOException { CqlTranslator translator = TestUtils.runSemanticTest( "fhir/stu3/TestChoiceDateRangeOptimization.cql", 0, @@ -193,7 +193,7 @@ public void testChoiceDateRangeOptimization() throws IOException { } @Test - public void testIntervalImplicitConversion() throws IOException { + void intervalImplicitConversion() throws IOException { TestUtils.runSemanticTest("fhir/stu3/TestIntervalImplicitConversion.cql", 0); } @@ -204,27 +204,27 @@ public void testFHIRHelpers() throws IOException { } @Test - public void testImplicitFHIRHelpers() throws IOException { + void implicitFHIRHelpers() throws IOException { TestUtils.runSemanticTest("fhir/stu3/TestImplicitFHIRHelpers.cql", 0); } @Test - public void testFHIR() throws IOException { + void fhir() throws IOException { TestUtils.runSemanticTest("fhir/stu3/TestFHIR.cql", 0); } @Test - public void testFHIRWithHelpers() throws IOException { + void fhirWithHelpers() throws IOException { TestUtils.runSemanticTest("fhir/stu3/TestFHIRWithHelpers.cql", 0); } @Test - public void testBundle() throws IOException { + void bundle() throws IOException { TestUtils.runSemanticTest("fhir/stu3/TestBundle.cql", 0); } @Test - public void testConceptConversion() throws IOException { + void conceptConversion() throws IOException { CqlTranslator translator = TestUtils.runSemanticTest("fhir/stu3/TestConceptConversion.cql", 0); Library library = translator.toELM(); Map defs = new HashMap<>(); @@ -311,7 +311,7 @@ public void testConceptConversion() throws IOException { } @Test - public void testRetrieveWithConcept() throws IOException { + void retrieveWithConcept() throws IOException { CqlTranslator translator = TestUtils.runSemanticTest("fhir/stu3/TestRetrieveWithConcept.cql", 0); CompiledLibrary library = translator.getTranslatedLibrary(); ExpressionDef expressionDef = library.resolveExpressionRef("Test Tobacco Smoking Status"); diff --git a/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/fhir/stu301/BaseTest.java b/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/fhir/stu301/BaseTest.java index d1daa293f..ee06cb82f 100644 --- a/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/fhir/stu301/BaseTest.java +++ b/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/fhir/stu301/BaseTest.java @@ -15,11 +15,11 @@ import org.cqframework.cql.cql2elm.model.CompiledLibrary; import org.hl7.cql.model.NamespaceInfo; import org.hl7.elm.r1.*; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Test; -public class BaseTest { +class BaseTest { @Test - public void testChoiceWithAlternativeConversion() throws IOException { + void choiceWithAlternativeConversion() throws IOException { ExpressionDef def = (ExpressionDef) visitFile("fhir/stu301/TestChoiceTypes.cql"); Query query = (Query) def.getExpression(); @@ -43,13 +43,13 @@ public void testChoiceWithAlternativeConversion() throws IOException { } @Test - public void testURIConversion() throws IOException { + void uriConversion() throws IOException { // If this translates without errors, the test is successful ExpressionDef def = (ExpressionDef) visitFile("fhir/stu301/TestURIConversion.cql"); } @Test - public void testFHIRTiming() throws IOException { + void fhirTiming() throws IOException { ExpressionDef def = (ExpressionDef) visitFile("fhir/stu301/TestFHIRTiming.cql"); // Query-> // where-> @@ -84,7 +84,7 @@ public void testFHIRTiming() throws IOException { } @Test - public void testEqualityWithConversions() throws IOException { + void equalityWithConversions() throws IOException { CompiledLibrary library = visitFileLibrary("fhir/stu301/EqualityWithConversions.cql"); ExpressionDef getGender = library.resolveExpressionRef("GetGender"); assertThat(getGender.getExpression(), instanceOf(Equal.class)); @@ -96,7 +96,7 @@ public void testEqualityWithConversions() throws IOException { } @Test - public void testDoubleListPromotion() throws IOException { + void doubleListPromotion() throws IOException { CqlTranslator translator = TestUtils.runSemanticTest("fhir/stu301/TestDoubleListPromotion.cql", 0); Library library = translator.toELM(); Map defs = new HashMap<>(); @@ -115,7 +115,7 @@ public void testDoubleListPromotion() throws IOException { } @Test - public void testChoiceDateRangeOptimization() throws IOException { + void choiceDateRangeOptimization() throws IOException { CqlTranslator translator = TestUtils.runSemanticTest( "fhir/stu301/TestChoiceDateRangeOptimization.cql", 0, @@ -195,37 +195,37 @@ public void testChoiceDateRangeOptimization() throws IOException { } @Test - public void testIntervalImplicitConversion() throws IOException { + void intervalImplicitConversion() throws IOException { TestUtils.runSemanticTest("fhir/stu301/TestIntervalImplicitConversion.cql", 0); } @Test - public void testFHIRHelpers() throws IOException { + void fhirHelpers() throws IOException { TestUtils.runSemanticTest("fhir/stu301/TestFHIRHelpers.cql", 0); } @Test - public void testImplicitFHIRHelpers() throws IOException { + void implicitFHIRHelpers() throws IOException { TestUtils.runSemanticTest("fhir/stu301/TestImplicitFHIRHelpers.cql", 0); } @Test - public void testFHIR() throws IOException { + void fhir() throws IOException { TestUtils.runSemanticTest("fhir/stu301/TestFHIR.cql", 0); } @Test - public void testFHIRWithHelpers() throws IOException { + void fhirWithHelpers() throws IOException { TestUtils.runSemanticTest("fhir/stu301/TestFHIRWithHelpers.cql", 0); } @Test - public void testBundle() throws IOException { + void bundle() throws IOException { TestUtils.runSemanticTest("fhir/stu301/TestBundle.cql", 0); } @Test - public void testConceptConversion() throws IOException { + void conceptConversion() throws IOException { CqlTranslator translator = TestUtils.runSemanticTest("fhir/stu301/TestConceptConversion.cql", 0); Library library = translator.toELM(); Map defs = new HashMap<>(); @@ -312,7 +312,7 @@ public void testConceptConversion() throws IOException { } @Test - public void testRetrieveWithConcept() throws IOException { + void retrieveWithConcept() throws IOException { CqlTranslator translator = TestUtils.runSemanticTest("fhir/stu301/TestRetrieveWithConcept.cql", 0); CompiledLibrary library = translator.getTranslatedLibrary(); ExpressionDef expressionDef = library.resolveExpressionRef("Test Tobacco Smoking Status"); @@ -325,7 +325,7 @@ public void testRetrieveWithConcept() throws IOException { } @Test - public void testFHIRNamespaces() throws IOException { + void fhirNamespaces() throws IOException { CqlTranslator translator = TestUtils.runSemanticTest( new NamespaceInfo("Public", "http://cql.hl7.org/public"), "fhir/stu301/TestFHIRNamespaces.cql", 0); CompiledLibrary library = translator.getTranslatedLibrary(); @@ -336,7 +336,7 @@ public void testFHIRNamespaces() throws IOException { } @Test - public void testFHIRWithoutNamespaces() throws IOException { + void fhirWithoutNamespaces() throws IOException { CqlTranslator translator = TestUtils.runSemanticTest("fhir/stu301/TestFHIRNamespaces.cql", 0); CompiledLibrary library = translator.getTranslatedLibrary(); IncludeDef includeDef = library.resolveIncludeRef("FHIRHelpers"); @@ -346,7 +346,7 @@ public void testFHIRWithoutNamespaces() throws IOException { } @Test - public void testFHIRPathLiteralStringEscapes() throws IOException { + void fhirPathLiteralStringEscapes() throws IOException { CqlTranslator translator = TestUtils.runSemanticTest("fhir/stu301/TestFHIRPathLiteralStringEscapes.cql", 0); CompiledLibrary library = translator.getTranslatedLibrary(); ExpressionDef expressionDef = library.resolveExpressionRef("Test"); diff --git a/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/fhir/v14/BaseTest.java b/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/fhir/v14/BaseTest.java index ceb8159e2..9431f83cf 100644 --- a/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/fhir/v14/BaseTest.java +++ b/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/fhir/v14/BaseTest.java @@ -2,11 +2,11 @@ import java.io.IOException; import org.cqframework.cql.cql2elm.TestUtils; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Test; -public class BaseTest { +class BaseTest { @Test - public void testFHIR() throws IOException { + void fhir() throws IOException { TestUtils.runSemanticTest("fhir/v14/TestFHIR.cql", 0); } } diff --git a/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/fhir/v16/BaseTest.java b/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/fhir/v16/BaseTest.java index f6fb477ea..7f28202b5 100644 --- a/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/fhir/v16/BaseTest.java +++ b/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/fhir/v16/BaseTest.java @@ -2,21 +2,21 @@ import java.io.IOException; import org.cqframework.cql.cql2elm.TestUtils; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Test; -public class BaseTest { +class BaseTest { @Test - public void testFHIRHelpers() throws IOException { + void fhirHelpers() throws IOException { TestUtils.runSemanticTest("fhir/v16/TestFHIRHelpers.cql", 0); } @Test - public void testFHIR() throws IOException { + void fhir() throws IOException { TestUtils.runSemanticTest("fhir/v16/TestFHIR.cql", 0); } @Test - public void testFHIRWithHelpers() throws IOException { + void fhirWithHelpers() throws IOException { TestUtils.runSemanticTest("fhir/v16/TestFHIRWithHelpers.cql", 0); } } diff --git a/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/fhir/v18/BaseTest.java b/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/fhir/v18/BaseTest.java index 59c14db1a..0ca976f75 100644 --- a/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/fhir/v18/BaseTest.java +++ b/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/fhir/v18/BaseTest.java @@ -2,21 +2,21 @@ import java.io.IOException; import org.cqframework.cql.cql2elm.TestUtils; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Test; -public class BaseTest { +class BaseTest { @Test - public void testFHIRHelpers() throws IOException { + void fhirHelpers() throws IOException { TestUtils.runSemanticTest("fhir/v18/TestFHIRHelpers.cql", 0); } @Test - public void testFHIR() throws IOException { + void fhir() throws IOException { TestUtils.runSemanticTest("fhir/v18/TestFHIR.cql", 0); } @Test - public void testFHIRWithHelpers() throws IOException { + void fhirWithHelpers() throws IOException { TestUtils.runSemanticTest("fhir/v18/TestFHIRWithHelpers.cql", 0); } } diff --git a/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/fhir/v18/PathTests.java b/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/fhir/v18/PathTests.java index c0df223b9..d4a504283 100644 --- a/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/fhir/v18/PathTests.java +++ b/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/fhir/v18/PathTests.java @@ -8,21 +8,21 @@ import org.cqframework.cql.cql2elm.quick.FhirLibrarySourceProvider; import org.hl7.cql.model.ModelInfoProvider; import org.hl7.elm.r1.Library; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; /** * Created by Bryn on 12/11/2016. */ -public class PathTests { +class PathTests { private static LibraryManager libraryManager; private static ModelManager modelManager; private static ModelInfoProvider modelInfoProvider; - @BeforeClass - public void setup() { + @BeforeAll + static void setup() { modelManager = new ModelManager(); libraryManager = new LibraryManager(modelManager); libraryManager.getLibrarySourceLoader().clearProviders(); @@ -32,13 +32,13 @@ public void setup() { modelManager.getModelInfoLoader().registerModelInfoProvider(modelInfoProvider, true); } - @AfterClass - public void tearDown() { + @AfterAll + static void tearDown() { modelManager.getModelInfoLoader().unregisterModelInfoProvider(modelInfoProvider); } @Test - public void testPaths() { + void paths() { CqlTranslator translator = null; try { translator = CqlTranslator.fromStream(PathTests.class.getResourceAsStream("PathTests.cql"), libraryManager); diff --git a/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/fhir/v32/BaseTest.java b/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/fhir/v32/BaseTest.java index ee29f8512..a62d022e2 100644 --- a/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/fhir/v32/BaseTest.java +++ b/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/fhir/v32/BaseTest.java @@ -2,21 +2,21 @@ import java.io.IOException; import org.cqframework.cql.cql2elm.TestUtils; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Test; -public class BaseTest { +class BaseTest { @Test - public void testFHIRHelpers() throws IOException { + void fhirHelpers() throws IOException { TestUtils.runSemanticTest("fhir/v32/TestFHIRHelpers.cql", 0); } @Test - public void testFHIR() throws IOException { + void fhir() throws IOException { TestUtils.runSemanticTest("fhir/v32/TestFHIR.cql", 0); } @Test - public void testFHIRWithHelpers() throws IOException { + void fhirWithHelpers() throws IOException { TestUtils.runSemanticTest("fhir/v32/TestFHIRWithHelpers.cql", 0); } } diff --git a/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/json/CqlTranslatorOptionsToJsonSchema.java b/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/json/CqlTranslatorOptionsToJsonSchema.java index 91284a973..eb2fdc41a 100644 --- a/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/json/CqlTranslatorOptionsToJsonSchema.java +++ b/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/json/CqlTranslatorOptionsToJsonSchema.java @@ -1,5 +1,7 @@ package org.cqframework.cql.cql2elm.json; +import static org.junit.jupiter.api.Assertions.fail; + import com.fasterxml.jackson.databind.JsonNode; import com.github.reinert.jjschema.v1.JsonSchemaFactory; import com.github.reinert.jjschema.v1.JsonSchemaV4Factory; @@ -7,17 +9,16 @@ import java.io.File; import java.io.FileWriter; import org.cqframework.cql.cql2elm.CqlCompilerOptions; -import org.testng.Assert; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Test; -public class CqlTranslatorOptionsToJsonSchema { +class CqlTranslatorOptionsToJsonSchema { private static final String separator = System.getProperty("file.separator"); private static final String JSON_LOC = "src" + separator + "test" + separator + "resources" + separator + "org" + separator + "cqframework" + separator + "cql" + separator + "cql2elm" + separator + "json" + separator + "CqlTranslatorOptions.json"; @Test - public void BuildJsonSchemaFromCqlTranslatorOptions() { + void BuildJsonSchemaFromCqlTranslatorOptions() { // delete file if exists: try { File jsonFile = new File(JSON_LOC); @@ -37,7 +38,7 @@ public void BuildJsonSchemaFromCqlTranslatorOptions() { writer.close(); } catch (Exception e) { e.printStackTrace(); - Assert.fail(); + fail(); } } } diff --git a/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/model/ModelImporterTest.java b/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/model/ModelImporterTest.java index 9c2c8b9ad..ecb9ff422 100644 --- a/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/model/ModelImporterTest.java +++ b/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/model/ModelImporterTest.java @@ -1,16 +1,16 @@ package org.cqframework.cql.cql2elm.model; -import org.testng.SkipException; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; -public class ModelImporterTest { +class ModelImporterTest { @Test - // TODO: Re-enable generic support here - // Requires type resolution capability in the model classes - // Was being handled by pre-resolving and passing the entire map through to the GenericClassSignatureParser - public void handleModelInfoGenerics() { - throw new SkipException("Requires type resolution capability in the model classes"); + @Disabled("TODO: Requires type resolution capability in the model classes") + void handleModelInfoGenerics() { + // TODO: Re-enable generic support here + // Requires type resolution capability in the model classes + // Was being handled by pre-resolving and passing the entire map through to the GenericClassSignatureParser /* try { @@ -50,9 +50,9 @@ public void handleModelInfoGenerics() { //Checking that myGenericType has one element with type - parameter 'T' (an open type - one degree of freedom) assertThat(myQuantityType.getElements().size(), is(1)); - ClassTypeElement overridenField1 = myQuantityType.getElements().get(0); - assertThat(overridenField1.getName(), is("field1")); - assertThat(((ClassType)overridenField1.getType()).getName(), is("System.Quantity")); + ClassTypeElement overriddenField1 = myQuantityType.getElements().get(0); + assertThat(overriddenField1.getName(), is("field1")); + assertThat(((ClassType)overriddenField1.getType()).getName(), is("System.Quantity")); //Map @@ -75,9 +75,9 @@ public void handleModelInfoGenerics() { //Checking that myGenericType has one element with type - parameter 'T' (an open type - one degree of freedom) assertThat(myIntegerType.getElements().size(), is(1)); - overridenField1 = myIntegerType.getElements().get(0); - assertThat(overridenField1.getName(), is("field1")); - assertThat(((SimpleType)overridenField1.getType()).getName(), is("System.Integer")); + overriddenField1 = myIntegerType.getElements().get(0); + assertThat(overriddenField1.getName(), is("field1")); + assertThat(((SimpleType)overriddenField1.getType()).getName(), is("System.Integer")); // //List // GenericClassProfileInfo listOfIntegers = (GenericClassProfileInfo)gentestModel.getTypeInfo().get(2); @@ -123,29 +123,27 @@ public void handleModelInfoGenerics() { } @Test - // TODO: Re-enable, see message above - public void handleModelInfoGenericsSad1() { - throw new SkipException("Disabled until model classes support type resolution"); - /* - try { - - ModelManager modelManager = new ModelManager(); - GentestModelInfoProviderSad1 gentestModelInfoProvider = new GentestModelInfoProviderSad1(); - ModelImporter systemImporter = new ModelImporter(modelManager.getModelInfoLoader().getModelInfo(new VersionedIdentifier().withId("System").withVersion("1")), null); - ModelInfo gentestModel = gentestModelInfoProvider.load(new VersionedIdentifier().withId("GENTEST")); - try { - ModelImporter gentestImporter = new ModelImporter(gentestModel, modelManager); - fail(); - } catch(Exception e) { - assertThat(e.getMessage(), is("Unknown symbols [T]")); - } - - - - } catch (Exception e) { - e.printStackTrace(); - fail(); - } - */ + @Disabled("Disabled until model classes support type resolution") + void handleModelInfoGenericsSad1() { + // /* + // try { + + // ModelManager modelManager = new ModelManager(); + // GentestModelInfoProviderSad1 gentestModelInfoProvider = new GentestModelInfoProviderSad1(); + // ModelImporter systemImporter = new ModelImporter(modelManager.getModelInfoLoader().getModelInfo(new + // VersionedIdentifier().withId("System").withVersion("1")), null); + // ModelInfo gentestModel = gentestModelInfoProvider.load(new VersionedIdentifier().withId("GENTEST")); + // try { + // ModelImporter gentestImporter = new ModelImporter(gentestModel, modelManager); + // fail(); + // } catch(Exception e) { + // assertThat(e.getMessage(), is("Unknown symbols [T]")); + // } + + // } catch (Exception e) { + // e.printStackTrace(); + // fail(); + // } + // */ } } diff --git a/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/model/VersionTest.java b/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/model/VersionTest.java index 26b9c3fc5..cf53c5b1c 100644 --- a/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/model/VersionTest.java +++ b/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/model/VersionTest.java @@ -1,63 +1,66 @@ package org.cqframework.cql.cql2elm.model; -import org.testng.Assert; -import org.testng.annotations.Test; +import static org.junit.jupiter.api.Assertions.*; -public class VersionTest { +import org.junit.jupiter.api.Test; + +class VersionTest { @Test - public void testVersionComparable() { + void versionComparable() { Version versionComparable = new Version("0.0.1"); - Assert.assertTrue(versionComparable.isComparable()); + assertTrue(versionComparable.isComparable()); Version versionNonComparable = new Version("0.0a.0b1"); - Assert.assertFalse(versionNonComparable.isComparable()); + assertFalse(versionNonComparable.isComparable()); Version version = new Version("0.0&.1"); - Assert.assertFalse(version.isComparable()); + assertFalse(version.isComparable()); } - @Test(expectedExceptions = IllegalArgumentException.class) - public void testVersionValidateCompareToThrows() { + @Test + void versionValidateCompareToThrows() { Version version = new Version("0.0.1"); Version versionThat = new Version("0.0a.1"); - version.compareTo(versionThat); + assertThrows(IllegalArgumentException.class, () -> { + version.compareTo(versionThat); + }); } @Test - public void testVersionValidateCompareTo() { + void versionValidateCompareTo() { Version version = new Version("0.0.1"); Version versionThat = new Version("0.0.1"); - Assert.assertTrue(version.compareTo(versionThat) == 0); + assertEquals(0, version.compareTo(versionThat)); Version versionThatLater = new Version("0.0.2"); - Assert.assertTrue(version.compareTo(versionThatLater) < 0); - Assert.assertTrue(versionThatLater.compareTo(version) > 0); + assertTrue(version.compareTo(versionThatLater) < 0); + assertTrue(versionThatLater.compareTo(version) > 0); } @Test - public void testVersionValidateCompatibility() { + void versionValidateCompatibility() { Version version = new Version("0.0.1"); Version versionThat = new Version("0.0b.1"); Version versionThatSame = new Version("0.0b.1"); - Assert.assertFalse(version.compatibleWith(versionThat)); - Assert.assertFalse(versionThat.compatibleWith(version)); - Assert.assertTrue(versionThat.compatibleWith(versionThatSame)); + assertFalse(version.compatibleWith(versionThat)); + assertFalse(versionThat.compatibleWith(version)); + assertTrue(versionThat.compatibleWith(versionThatSame)); } @Test - public void testMATVersions() { + void matVersions() { Version version = new Version("v1-0-0-QDM-5-6"); - Assert.assertTrue(version.getMajorVersion() == 1); - Assert.assertTrue(version.getMinorVersion() == 0); - Assert.assertTrue(version.getPatchVersion() == 0); - Assert.assertTrue(version.getBuildVersion().equals("QDM-5-6")); + assertTrue(version.getMajorVersion() == 1); + assertTrue(version.getMinorVersion() == 0); + assertTrue(version.getPatchVersion() == 0); + assertEquals("QDM-5-6", version.getBuildVersion()); } @Test - public void testMATVersionsCompatible() { + void matVersionsCompatible() { Version version = new Version("7.0.0"); Version matVersion = new Version("v7-0-0-QDM-5-6"); - Assert.assertTrue(matVersion.compatibleWith(version)); + assertTrue(matVersion.compatibleWith(version)); } } diff --git a/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/operators/AgeOperatorsTest.java b/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/operators/AgeOperatorsTest.java index ffafc07f5..8c87b25d9 100644 --- a/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/operators/AgeOperatorsTest.java +++ b/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/operators/AgeOperatorsTest.java @@ -11,15 +11,15 @@ import org.cqframework.cql.cql2elm.LibraryManager; import org.cqframework.cql.cql2elm.ModelManager; import org.hl7.elm.r1.*; -import org.testng.annotations.BeforeTest; -import org.testng.annotations.Test; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; -public class AgeOperatorsTest { +class AgeOperatorsTest { - private Map defs; + private static Map defs; - @BeforeTest - public void setup() throws IOException { + @BeforeAll + static void setup() throws IOException { var modelManager = new ModelManager(); var translator = CqlTranslator.fromStream( AgeOperatorsTest.class.getResourceAsStream("../OperatorTests/AgeOperators.cql"), @@ -35,7 +35,7 @@ public void setup() throws IOException { } @Test - public void testAgeInYears() { + void ageInYears() { ExpressionDef def = defs.get("TestAgeInYears"); assertThat(def, hasTypeAndResult(CalculateAge.class, "System.Integer")); CalculateAge age = (CalculateAge) def.getExpression(); @@ -45,7 +45,7 @@ public void testAgeInYears() { } @Test - public void testAgeInMonths() { + void ageInMonths() { ExpressionDef def = defs.get("TestAgeInMonths"); assertThat(def, hasTypeAndResult(CalculateAge.class, "System.Integer")); CalculateAge age = (CalculateAge) def.getExpression(); @@ -55,7 +55,7 @@ public void testAgeInMonths() { } @Test - public void testAgeInWeeks() { + void ageInWeeks() { ExpressionDef def = defs.get("TestAgeInWeeks"); assertThat(def, hasTypeAndResult(CalculateAge.class, "System.Integer")); CalculateAge age = (CalculateAge) def.getExpression(); @@ -65,7 +65,7 @@ public void testAgeInWeeks() { } @Test - public void testAgeInDays() { + void ageInDays() { ExpressionDef def = defs.get("TestAgeInDays"); assertThat(def, hasTypeAndResult(CalculateAge.class, "System.Integer")); CalculateAge age = (CalculateAge) def.getExpression(); @@ -75,7 +75,7 @@ public void testAgeInDays() { } @Test - public void testAgeInHours() { + void ageInHours() { ExpressionDef def = defs.get("TestAgeInHours"); assertThat(def, hasTypeAndResult(CalculateAge.class, "System.Integer")); CalculateAge age = (CalculateAge) def.getExpression(); @@ -85,7 +85,7 @@ public void testAgeInHours() { } @Test - public void testAgeInMinutes() { + void ageInMinutes() { ExpressionDef def = defs.get("TestAgeInMinutes"); assertThat(def, hasTypeAndResult(CalculateAge.class, "System.Integer")); CalculateAge age = (CalculateAge) def.getExpression(); @@ -95,7 +95,7 @@ public void testAgeInMinutes() { } @Test - public void testAgeInSeconds() { + void ageInSeconds() { ExpressionDef def = defs.get("TestAgeInSeconds"); assertThat(def, hasTypeAndResult(CalculateAge.class, "System.Integer")); CalculateAge age = (CalculateAge) def.getExpression(); @@ -105,7 +105,7 @@ public void testAgeInSeconds() { } @Test - public void testAgeInYearsAtDateTime() { + void ageInYearsAtDateTime() { ExpressionDef def = defs.get("TestAgeInYearsAtDateTime"); assertThat(def, hasTypeAndResult(CalculateAgeAt.class, "System.Integer")); CalculateAgeAt age = (CalculateAgeAt) def.getExpression(); @@ -115,7 +115,7 @@ public void testAgeInYearsAtDateTime() { } @Test - public void testAgeInMonthsAtDateTime() { + void ageInMonthsAtDateTime() { ExpressionDef def = defs.get("TestAgeInMonthsAtDateTime"); assertThat(def, hasTypeAndResult(CalculateAgeAt.class, "System.Integer")); CalculateAgeAt age = (CalculateAgeAt) def.getExpression(); @@ -125,7 +125,7 @@ public void testAgeInMonthsAtDateTime() { } @Test - public void testAgeInWeeksAtDateTime() { + void ageInWeeksAtDateTime() { ExpressionDef def = defs.get("TestAgeInWeeksAtDateTime"); assertThat(def, hasTypeAndResult(CalculateAgeAt.class, "System.Integer")); CalculateAgeAt age = (CalculateAgeAt) def.getExpression(); @@ -135,7 +135,7 @@ public void testAgeInWeeksAtDateTime() { } @Test - public void testAgeInDaysAtDateTime() { + void ageInDaysAtDateTime() { ExpressionDef def = defs.get("TestAgeInDaysAtDateTime"); assertThat(def, hasTypeAndResult(CalculateAgeAt.class, "System.Integer")); CalculateAgeAt age = (CalculateAgeAt) def.getExpression(); @@ -145,7 +145,7 @@ public void testAgeInDaysAtDateTime() { } @Test - public void testAgeInYearsAtDate() { + void ageInYearsAtDate() { ExpressionDef def = defs.get("TestAgeInYearsAtDate"); assertThat(def, hasTypeAndResult(CalculateAgeAt.class, "System.Integer")); CalculateAgeAt age = (CalculateAgeAt) def.getExpression(); @@ -155,7 +155,7 @@ public void testAgeInYearsAtDate() { } @Test - public void testAgeInMonthsAtDate() { + void ageInMonthsAtDate() { ExpressionDef def = defs.get("TestAgeInMonthsAtDate"); assertThat(def, hasTypeAndResult(CalculateAgeAt.class, "System.Integer")); CalculateAgeAt age = (CalculateAgeAt) def.getExpression(); @@ -165,7 +165,7 @@ public void testAgeInMonthsAtDate() { } @Test - public void testAgeInWeeksAtDate() { + void ageInWeeksAtDate() { ExpressionDef def = defs.get("TestAgeInWeeksAtDate"); assertThat(def, hasTypeAndResult(CalculateAgeAt.class, "System.Integer")); CalculateAgeAt age = (CalculateAgeAt) def.getExpression(); @@ -175,7 +175,7 @@ public void testAgeInWeeksAtDate() { } @Test - public void testAgeInDaysAtDate() { + void ageInDaysAtDate() { ExpressionDef def = defs.get("TestAgeInDaysAtDate"); assertThat(def, hasTypeAndResult(CalculateAgeAt.class, "System.Integer")); CalculateAgeAt age = (CalculateAgeAt) def.getExpression(); @@ -185,7 +185,7 @@ public void testAgeInDaysAtDate() { } @Test - public void testAgeInHoursAtDateTime() { + void ageInHoursAtDateTime() { ExpressionDef def = defs.get("TestAgeInHoursAtDateTime"); assertThat(def, hasTypeAndResult(CalculateAgeAt.class, "System.Integer")); CalculateAgeAt age = (CalculateAgeAt) def.getExpression(); @@ -195,7 +195,7 @@ public void testAgeInHoursAtDateTime() { } @Test - public void testAgeInMinutesAtDateTime() { + void ageInMinutesAtDateTime() { ExpressionDef def = defs.get("TestAgeInMinutesAtDateTime"); assertThat(def, hasTypeAndResult(CalculateAgeAt.class, "System.Integer")); CalculateAgeAt age = (CalculateAgeAt) def.getExpression(); @@ -205,7 +205,7 @@ public void testAgeInMinutesAtDateTime() { } @Test - public void testAgeInSecondsAtDateTime() { + void ageInSecondsAtDateTime() { ExpressionDef def = defs.get("TestAgeInSecondsAtDateTime"); assertThat(def, hasTypeAndResult(CalculateAgeAt.class, "System.Integer")); CalculateAgeAt age = (CalculateAgeAt) def.getExpression(); @@ -215,7 +215,7 @@ public void testAgeInSecondsAtDateTime() { } @Test - public void testCalculateAgeInYearsAtDateTime() { + void calculateAgeInYearsAtDateTime() { ExpressionDef def = defs.get("TestCalculateAgeInYearsAtDateTime"); assertThat(def, hasTypeAndResult(CalculateAgeAt.class, "System.Integer")); CalculateAgeAt age = (CalculateAgeAt) def.getExpression(); @@ -225,7 +225,7 @@ public void testCalculateAgeInYearsAtDateTime() { } @Test - public void testCalculateAgeInMonthsAtDateTime() { + void calculateAgeInMonthsAtDateTime() { ExpressionDef def = defs.get("TestCalculateAgeInMonthsAtDateTime"); assertThat(def, hasTypeAndResult(CalculateAgeAt.class, "System.Integer")); CalculateAgeAt age = (CalculateAgeAt) def.getExpression(); @@ -235,7 +235,7 @@ public void testCalculateAgeInMonthsAtDateTime() { } @Test - public void testCalculateAgeInWeeksAtDateTime() { + void calculateAgeInWeeksAtDateTime() { ExpressionDef def = defs.get("TestCalculateAgeInWeeksAtDateTime"); assertThat(def, hasTypeAndResult(CalculateAgeAt.class, "System.Integer")); CalculateAgeAt age = (CalculateAgeAt) def.getExpression(); @@ -245,7 +245,7 @@ public void testCalculateAgeInWeeksAtDateTime() { } @Test - public void testCalculateAgeInDaysAtDateTime() { + void calculateAgeInDaysAtDateTime() { ExpressionDef def = defs.get("TestCalculateAgeInDaysAtDateTime"); assertThat(def, hasTypeAndResult(CalculateAgeAt.class, "System.Integer")); CalculateAgeAt age = (CalculateAgeAt) def.getExpression(); @@ -255,7 +255,7 @@ public void testCalculateAgeInDaysAtDateTime() { } @Test - public void testCalculateAgeInYearsAtDate() { + void calculateAgeInYearsAtDate() { ExpressionDef def = defs.get("TestCalculateAgeInYearsAtDate"); assertThat(def, hasTypeAndResult(CalculateAgeAt.class, "System.Integer")); CalculateAgeAt age = (CalculateAgeAt) def.getExpression(); @@ -265,7 +265,7 @@ public void testCalculateAgeInYearsAtDate() { } @Test - public void testCalculateAgeInMonthsAtDate() { + void calculateAgeInMonthsAtDate() { ExpressionDef def = defs.get("TestCalculateAgeInMonthsAtDate"); assertThat(def, hasTypeAndResult(CalculateAgeAt.class, "System.Integer")); CalculateAgeAt age = (CalculateAgeAt) def.getExpression(); @@ -275,7 +275,7 @@ public void testCalculateAgeInMonthsAtDate() { } @Test - public void testCalculateAgeInWeeksAtDate() { + void calculateAgeInWeeksAtDate() { ExpressionDef def = defs.get("TestCalculateAgeInWeeksAtDate"); assertThat(def, hasTypeAndResult(CalculateAgeAt.class, "System.Integer")); CalculateAgeAt age = (CalculateAgeAt) def.getExpression(); @@ -285,7 +285,7 @@ public void testCalculateAgeInWeeksAtDate() { } @Test - public void testCalculateAgeInDaysAtDate() { + void calculateAgeInDaysAtDate() { ExpressionDef def = defs.get("TestCalculateAgeInDaysAtDate"); assertThat(def, hasTypeAndResult(CalculateAgeAt.class, "System.Integer")); CalculateAgeAt age = (CalculateAgeAt) def.getExpression(); @@ -295,7 +295,7 @@ public void testCalculateAgeInDaysAtDate() { } @Test - public void testCalculateAgeInHoursAtDateTime() { + void calculateAgeInHoursAtDateTime() { ExpressionDef def = defs.get("TestCalculateAgeInHoursAtDateTime"); assertThat(def, hasTypeAndResult(CalculateAgeAt.class, "System.Integer")); CalculateAgeAt age = (CalculateAgeAt) def.getExpression(); @@ -305,7 +305,7 @@ public void testCalculateAgeInHoursAtDateTime() { } @Test - public void testCalculateAgeInMinutesAtDateTime() { + void calculateAgeInMinutesAtDateTime() { ExpressionDef def = defs.get("TestCalculateAgeInMinutesAtDateTime"); assertThat(def, hasTypeAndResult(CalculateAgeAt.class, "System.Integer")); CalculateAgeAt age = (CalculateAgeAt) def.getExpression(); @@ -315,7 +315,7 @@ public void testCalculateAgeInMinutesAtDateTime() { } @Test - public void testCalculateAgeInSecondsAtDateTime() { + void calculateAgeInSecondsAtDateTime() { ExpressionDef def = defs.get("TestCalculateAgeInSecondsAtDateTime"); assertThat(def, hasTypeAndResult(CalculateAgeAt.class, "System.Integer")); CalculateAgeAt age = (CalculateAgeAt) def.getExpression(); diff --git a/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/operators/AggregateOperatorsTest.java b/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/operators/AggregateOperatorsTest.java index 0574d7366..49e21019c 100644 --- a/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/operators/AggregateOperatorsTest.java +++ b/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/operators/AggregateOperatorsTest.java @@ -17,15 +17,15 @@ import org.cqframework.cql.cql2elm.LibraryManager; import org.cqframework.cql.cql2elm.ModelManager; import org.hl7.elm.r1.*; -import org.testng.annotations.BeforeTest; -import org.testng.annotations.Test; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; -public class AggregateOperatorsTest { +class AggregateOperatorsTest { - private Map defs; + private static Map defs; - @BeforeTest - public void setup() throws IOException { + @BeforeAll + static void setup() throws IOException { ModelManager modelManager = new ModelManager(); CqlTranslator translator = CqlTranslator.fromStream( AggregateOperatorsTest.class.getResourceAsStream("../OperatorTests/AggregateOperators.cql"), @@ -41,7 +41,7 @@ public void setup() throws IOException { } @Test - public void testAllTrue() { + void allTrue() { ExpressionDef def = defs.get("AllTrueExpression"); assertThat(def, hasTypeAndResult(AllTrue.class, "System.Boolean")); @@ -50,7 +50,7 @@ public void testAllTrue() { } @Test - public void testAnyTrue() { + void anyTrue() { ExpressionDef def = defs.get("AnyTrueExpression"); assertThat(def, hasTypeAndResult(AnyTrue.class, "System.Boolean")); @@ -59,7 +59,7 @@ public void testAnyTrue() { } @Test - public void testAverage() { + void average() { ExpressionDef def = defs.get("IntegerAvg"); assertThat(def, hasTypeAndResult(Avg.class, "System.Decimal")); assertDecimalConversionForIntegerListOneToFive(((Avg) def.getExpression()).getSource()); @@ -74,21 +74,21 @@ public void testAverage() { } @Test - public void testCount() { + void count() { ExpressionDef def = defs.get("CountExpression"); assertThat(def, hasTypeAndResult(Count.class, "System.Integer")); assertThat(((Count) def.getExpression()).getSource(), listOfLiterals(1, 2, 3, 4, 5)); } @Test - public void testGeometricMean() { + void geometricMean() { ExpressionDef def = defs.get("GeometricMeanExpression"); assertThat(def, hasTypeAndResult(GeometricMean.class, "System.Decimal")); assertThat(((GeometricMean) def.getExpression()).getSource(), listOfLiterals(1.0, 2.0, 3.0, 4.0, 5.0)); } @Test - public void testMax() { + void max() { ExpressionDef def = defs.get("IntegerMax"); assertThat(def, hasTypeAndResult(Max.class, "System.Integer")); assertThat(((Max) def.getExpression()).getSource(), listOfLiterals(1, 2, 3, 4, 5)); @@ -115,7 +115,7 @@ public void testMax() { } @Test - public void testMin() { + void min() { ExpressionDef def = defs.get("IntegerMin"); assertThat(def, hasTypeAndResult(Min.class, "System.Integer")); assertThat(((Min) def.getExpression()).getSource(), listOfLiterals(1, 2, 3, 4, 5)); @@ -142,7 +142,7 @@ public void testMin() { } @Test - public void testMedian() { + void median() { ExpressionDef def = defs.get("IntegerMedian"); assertThat(def, hasTypeAndResult(Median.class, "System.Decimal")); assertDecimalConversionForIntegerListOneToFive(((Median) def.getExpression()).getSource()); @@ -157,7 +157,7 @@ public void testMedian() { } @Test - public void testMode() { + void mode() { ExpressionDef def = defs.get("IntegerMode"); assertThat(def, hasTypeAndResult(Mode.class, "System.Integer")); assertThat(((Mode) def.getExpression()).getSource(), listOfLiterals(1, 2, 3, 4, 5)); @@ -168,7 +168,7 @@ public void testMode() { } @Test - public void testPopulationStdDev() { + void populationStdDev() { ExpressionDef def = defs.get("IntegerPopulationStdDev"); assertThat(def, hasTypeAndResult(PopulationStdDev.class, "System.Decimal")); assertDecimalConversionForIntegerListOneToFive(((PopulationStdDev) def.getExpression()).getSource()); @@ -183,7 +183,7 @@ public void testPopulationStdDev() { } @Test - public void testPopulationVariance() { + void populationVariance() { ExpressionDef def = defs.get("IntegerPopulationVariance"); assertThat(def, hasTypeAndResult(PopulationVariance.class, "System.Decimal")); assertDecimalConversionForIntegerListOneToFive(((PopulationVariance) def.getExpression()).getSource()); @@ -198,7 +198,7 @@ public void testPopulationVariance() { } @Test - public void testProduct() { + void product() { ExpressionDef def = defs.get("IntegerProduct"); assertThat(def, hasTypeAndResult(Product.class, "System.Integer")); assertThat(((Product) def.getExpression()).getSource(), listOfLiterals(1, 2, 3, 4, 5)); @@ -209,7 +209,7 @@ public void testProduct() { } @Test - public void testStdDev() { + void stdDev() { ExpressionDef def = defs.get("IntegerStdDev"); assertThat(def, hasTypeAndResult(StdDev.class, "System.Decimal")); assertDecimalConversionForIntegerListOneToFive(((StdDev) def.getExpression()).getSource()); @@ -224,7 +224,7 @@ public void testStdDev() { } @Test - public void testSum() { + void sum() { ExpressionDef def = defs.get("IntegerSum"); assertThat(def, hasTypeAndResult(Sum.class, "System.Integer")); assertThat(((Sum) def.getExpression()).getSource(), listOfLiterals(1, 2, 3, 4, 5)); @@ -239,7 +239,7 @@ public void testSum() { } @Test - public void testVariance() { + void variance() { ExpressionDef def = defs.get("IntegerVariance"); assertThat(def, hasTypeAndResult(Variance.class, "System.Decimal")); assertDecimalConversionForIntegerListOneToFive(((Variance) def.getExpression()).getSource()); diff --git a/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/operators/AggregateTest.java b/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/operators/AggregateTest.java index d68597ad6..b0acc8248 100644 --- a/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/operators/AggregateTest.java +++ b/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/operators/AggregateTest.java @@ -2,12 +2,12 @@ import java.io.IOException; import org.cqframework.cql.cql2elm.TestUtils; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Test; -public class AggregateTest { +class AggregateTest { @Test - public void testAggregate() throws IOException { + void aggregate() throws IOException { TestUtils.runSemanticTest("OperatorTests/Aggregate.cql", 0); } } diff --git a/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/operators/ArithmeticOperatorsTest.java b/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/operators/ArithmeticOperatorsTest.java index 8b5a034a9..0034caf5d 100644 --- a/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/operators/ArithmeticOperatorsTest.java +++ b/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/operators/ArithmeticOperatorsTest.java @@ -17,15 +17,15 @@ import org.cqframework.cql.cql2elm.LibraryManager; import org.cqframework.cql.cql2elm.ModelManager; import org.hl7.elm.r1.*; -import org.testng.annotations.BeforeTest; -import org.testng.annotations.Test; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; -public class ArithmeticOperatorsTest { +class ArithmeticOperatorsTest { - private Map defs; + private static Map defs; - @BeforeTest - public void setup() throws IOException { + @BeforeAll + static void setup() throws IOException { ModelManager modelManager = new ModelManager(); CqlTranslator translator = CqlTranslator.fromStream( ArithmeticOperatorsTest.class.getResourceAsStream("../OperatorTests/ArithmeticOperators.cql"), @@ -39,7 +39,7 @@ public void setup() throws IOException { } @Test - public void testDivide() { + void divide() { ExpressionDef def = defs.get("IntegerDivide"); assertThat(def, hasTypeAndResult(Divide.class, "System.Decimal")); @@ -57,7 +57,7 @@ public void testDivide() { } @Test - public void testCeiling() { + void ceiling() { ExpressionDef def = defs.get("IntegerCeiling"); assertThat(def, hasTypeAndResult(Ceiling.class, "System.Integer")); @@ -72,7 +72,7 @@ public void testCeiling() { } @Test - public void testFloor() { + void floor() { ExpressionDef def = defs.get("IntegerFloor"); assertThat(def, hasTypeAndResult(Floor.class, "System.Integer")); @@ -87,7 +87,7 @@ public void testFloor() { } @Test - public void testTruncate() { + void truncate() { ExpressionDef def = defs.get("IntegerTruncate"); assertThat(def, hasTypeAndResult(Truncate.class, "System.Integer")); @@ -102,7 +102,7 @@ public void testTruncate() { } @Test - public void testAbs() { + void abs() { ExpressionDef def = defs.get("IntegerAbs"); assertThat(def, hasTypeAndResult(Abs.class, "System.Integer")); @@ -130,7 +130,7 @@ public void testAbs() { } @Test - public void testLog() { + void log() { ExpressionDef def = defs.get("DecimalDecimalLog"); assertThat(def, hasTypeAndResult(Log.class, "System.Decimal")); @@ -165,7 +165,7 @@ public void testLog() { } @Test - public void testLn() { + void ln() { ExpressionDef def = defs.get("IntegerLn"); assertThat(def, hasTypeAndResult(Ln.class, "System.Decimal")); @@ -180,7 +180,7 @@ public void testLn() { } @Test - public void testExp() { + void exp() { ExpressionDef def = defs.get("IntegerExp"); assertThat(def, hasTypeAndResult(Exp.class, "System.Decimal")); @@ -195,7 +195,7 @@ public void testExp() { } @Test - public void testRound() { + void round() { ExpressionDef def = defs.get("DecimalRound"); assertThat(def, hasTypeAndResult(Round.class, "System.Decimal")); @@ -212,7 +212,7 @@ public void testRound() { } @Test - public void testPrecision() { + void precision() { ExpressionDef def = defs.get("DecimalPrecision"); assertThat(def, hasTypeAndResult(Precision.class, "System.Integer")); @@ -227,7 +227,7 @@ public void testPrecision() { } @Test - public void testLowBoundary() { + void lowBoundary() { ExpressionDef def = defs.get("DecimalLowBoundary"); assertThat(def, hasTypeAndResult(LowBoundary.class, "System.Decimal")); @@ -242,7 +242,7 @@ public void testLowBoundary() { } @Test - public void testHighBoundary() { + void highBoundary() { ExpressionDef def = defs.get("DecimalHighBoundary"); assertThat(def, hasTypeAndResult(HighBoundary.class, "System.Decimal")); diff --git a/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/operators/CqlComparisonOperatorsTest.java b/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/operators/CqlComparisonOperatorsTest.java index 7fbacd061..dbdda3e4f 100644 --- a/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/operators/CqlComparisonOperatorsTest.java +++ b/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/operators/CqlComparisonOperatorsTest.java @@ -11,21 +11,21 @@ import org.cqframework.cql.cql2elm.ModelManager; import org.hl7.elm.r1.ExpressionDef; import org.hl7.elm.r1.Library; -import org.testng.annotations.BeforeTest; +import org.junit.jupiter.api.BeforeAll; /** * Created by Bryn on 12/30/2016. */ -public class CqlComparisonOperatorsTest { +class CqlComparisonOperatorsTest { // NOTE: The CQL for this test is taken from an engine testing suite that produced a particular issue with the // operatorMap. This library will not translate successfully without the proper fix in place. // So this test only needs to validate that the library translates successfully. - private Map defs; + private static Map defs; - @BeforeTest - public void setup() throws IOException { + @BeforeAll + static void setup() throws IOException { ModelManager modelManager = new ModelManager(); CqlTranslator translator = CqlTranslator.fromStream( CqlComparisonOperatorsTest.class.getResourceAsStream("../OperatorTests/CqlComparisonOperators.cql"), diff --git a/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/operators/CqlIntervalOperatorsTest.java b/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/operators/CqlIntervalOperatorsTest.java index 35f439a13..ee1c799f6 100644 --- a/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/operators/CqlIntervalOperatorsTest.java +++ b/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/operators/CqlIntervalOperatorsTest.java @@ -11,23 +11,23 @@ import org.cqframework.cql.cql2elm.LibraryManager; import org.cqframework.cql.cql2elm.ModelManager; import org.hl7.elm.r1.*; -import org.testng.annotations.BeforeTest; -import org.testng.annotations.Test; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; /** * Created by Bryn on 12/30/2016. */ -public class CqlIntervalOperatorsTest { +class CqlIntervalOperatorsTest { // NOTE: The CQL for this test is taken from an engine testing suite that produced a particular issue with generic // instantiations. // This library will not translate successfully without the proper fix in place. // So this test only needs to validate that the library translates successfully. - private Map defs; + private static Map defs; - @BeforeTest - public void setup() throws IOException { + @BeforeAll + static void setup() throws IOException { ModelManager modelManager = new ModelManager(); CqlTranslator translator = CqlTranslator.fromStream( CqlIntervalOperatorsTest.class.getResourceAsStream("../OperatorTests/CqlIntervalOperators.cql"), @@ -50,19 +50,19 @@ public void setup() throws IOException { // } @Test - public void testOverlapsDay() { + void overlapsDay() { ExpressionDef def = defs.get("TestOverlapsDay"); assertThat(def, hasTypeAndResult(Overlaps.class, "System.Boolean")); } @Test - public void testOverlapsDayBefore() { + void overlapsDayBefore() { ExpressionDef def = defs.get("TestOverlapsDayBefore"); assertThat(def, hasTypeAndResult(OverlapsBefore.class, "System.Boolean")); } @Test - public void testOverlapsDayAfter() { + void overlapsDayAfter() { ExpressionDef def = defs.get("TestOverlapsDayAfter"); assertThat(def, hasTypeAndResult(OverlapsAfter.class, "System.Boolean")); } diff --git a/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/operators/CqlListOperatorsTest.java b/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/operators/CqlListOperatorsTest.java index cae842631..5d5ee1507 100644 --- a/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/operators/CqlListOperatorsTest.java +++ b/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/operators/CqlListOperatorsTest.java @@ -11,20 +11,20 @@ import org.cqframework.cql.cql2elm.LibraryManager; import org.cqframework.cql.cql2elm.ModelManager; import org.hl7.elm.r1.*; -import org.testng.annotations.BeforeTest; -import org.testng.annotations.Test; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; /** * Created by Bryn on 12/30/2016. */ -public class CqlListOperatorsTest { +class CqlListOperatorsTest { // NOTE: The CQL for this test is taken from an engine testing suite that produced a particular issue with ambiguous // conversions. - private Map defs; + private static Map defs; - @BeforeTest - public void setup() throws IOException { + @BeforeAll + static void setup() throws IOException { ModelManager modelManager = new ModelManager(); CqlTranslator translator = CqlTranslator.fromStream( CqlListOperatorsTest.class.getResourceAsStream("../OperatorTests/CqlListOperators.cql"), @@ -40,7 +40,7 @@ public void setup() throws IOException { } @Test - public void testUnion() { + void union() { ExpressionDef def = defs.get("Union123AndEmpty"); assertThat(def, hasTypeAndResult(Union.class, "list")); } diff --git a/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/operators/DateTimeOperatorsTest.java b/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/operators/DateTimeOperatorsTest.java index 8b4bc9628..d68cc23a9 100644 --- a/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/operators/DateTimeOperatorsTest.java +++ b/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/operators/DateTimeOperatorsTest.java @@ -15,15 +15,15 @@ import org.cqframework.cql.cql2elm.LibraryManager; import org.cqframework.cql.cql2elm.ModelManager; import org.hl7.elm.r1.*; -import org.testng.annotations.BeforeTest; -import org.testng.annotations.Test; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; -public class DateTimeOperatorsTest { +class DateTimeOperatorsTest { - private Map defs; + private static Map defs; - @BeforeTest - public void setup() throws IOException { + @BeforeAll + static void setup() throws IOException { ModelManager modelManager = new ModelManager(); CqlTranslator translator = CqlTranslator.fromStream( DateTimeOperatorsTest.class.getResourceAsStream("../OperatorTests/DateTimeOperators.cql"), @@ -37,7 +37,7 @@ public void setup() throws IOException { } @Test - public void testDateTime() { + void dateTime() { ExpressionDef def = defs.get("DateTimeYear"); assertThat(def, hasTypeAndResult(DateTime.class, "System.DateTime")); DateTime dt = (DateTime) def.getExpression(); @@ -136,7 +136,7 @@ public void testDateTime() { } @Test - public void testDate() { + void date() { ExpressionDef def = defs.get("DateYear"); assertThat(def, hasTypeAndResult(Date.class, "System.Date")); Date d = (Date) def.getExpression(); @@ -160,7 +160,7 @@ public void testDate() { } @Test - public void testTime() { + void time() { ExpressionDef def = defs.get("TimeHour"); assertThat(def, hasTypeAndResult(Time.class, "System.Time")); Time dt = (Time) def.getExpression(); @@ -195,31 +195,31 @@ public void testTime() { } @Test - public void testDateExtractor() { + void dateExtractor() { ExpressionDef def = defs.get("DateExtractor"); assertThat(def, hasTypeAndResult(DateFrom.class, "System.Date")); } @Test - public void testTimeExtractor() { + void timeExtractor() { ExpressionDef def = defs.get("TimeExtractor"); assertThat(def, hasTypeAndResult(TimeFrom.class, "System.Time")); } @Test - public void testNow() { + void now() { ExpressionDef def = defs.get("NowExpression"); assertThat(def, hasTypeAndResult(Now.class, "System.DateTime")); } @Test - public void testToday() { + void today() { ExpressionDef def = defs.get("TodayExpression"); assertThat(def, hasTypeAndResult(Today.class, "System.Date")); } @Test - public void testTimeOfDay() { + void timeOfDay() { ExpressionDef def = defs.get("TimeOfDayExpression"); assertThat(def, hasTypeAndResult(TimeOfDay.class, "System.Time")); } diff --git a/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/operators/ListOperatorsTest.java b/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/operators/ListOperatorsTest.java index 359316e98..b833249ac 100644 --- a/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/operators/ListOperatorsTest.java +++ b/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/operators/ListOperatorsTest.java @@ -15,15 +15,15 @@ import org.cqframework.cql.cql2elm.LibraryManager; import org.cqframework.cql.cql2elm.ModelManager; import org.hl7.elm.r1.*; -import org.testng.annotations.BeforeTest; -import org.testng.annotations.Test; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; -public class ListOperatorsTest { +class ListOperatorsTest { - private Map defs; + private static Map defs; - @BeforeTest - public void setup() throws IOException { + @BeforeAll + static void setup() throws IOException { ModelManager modelManager = new ModelManager(); CqlTranslator translator = CqlTranslator.fromStream( ListOperatorsTest.class.getResourceAsStream("../OperatorTests/ListOperators.cql"), @@ -37,7 +37,7 @@ public void setup() throws IOException { } @Test - public void testIndexOf() { + void indexOf() { ExpressionDef def = defs.get("ListIndexOf"); assertThat(def, hasTypeAndResult(IndexOf.class, "System.Integer")); @@ -47,7 +47,7 @@ public void testIndexOf() { } @Test - public void testFirst() { + void first() { ExpressionDef def = defs.get("ListFirst"); assertThat(def, hasTypeAndResult(First.class, "System.Integer")); @@ -56,7 +56,7 @@ public void testFirst() { } @Test - public void testLast() { + void last() { ExpressionDef def = defs.get("ListLast"); assertThat(def, hasTypeAndResult(Last.class, "System.Integer")); @@ -65,7 +65,7 @@ public void testLast() { } @Test - public void testSkip() { + void skip() { ExpressionDef def = defs.get("ListSkip"); assertThat(def, hasTypeAndResult(Slice.class, "list")); @@ -76,7 +76,7 @@ public void testSkip() { } @Test - public void testTail() { + void tail() { ExpressionDef def = defs.get("ListTail"); assertThat(def, hasTypeAndResult(Slice.class, "list")); @@ -87,7 +87,7 @@ public void testTail() { } @Test - public void testTake() { + void take() { ExpressionDef def = defs.get("ListTake"); assertThat(def, hasTypeAndResult(Slice.class, "list")); @@ -101,7 +101,7 @@ public void testTake() { } @Test - public void testFlatten() { + void flatten() { ExpressionDef def = defs.get("ListFlatten"); Flatten flatten = (Flatten) def.getExpression(); assertThat(flatten.getOperand() instanceof List, is(true)); @@ -112,7 +112,7 @@ public void testFlatten() { } @Test - public void testLength() { + void length() { ExpressionDef def = defs.get("ListLength"); assertThat(def, hasTypeAndResult(Length.class, "System.Integer")); @@ -121,7 +121,7 @@ public void testLength() { } @Test - public void testChoiceType() { + void choiceType() { ExpressionDef def = defs.get("ListUnionWithChoice"); assertThat( def, diff --git a/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/operators/NullologicalOperatorsTest.java b/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/operators/NullologicalOperatorsTest.java index 6ad9f2b4f..edb0e2514 100644 --- a/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/operators/NullologicalOperatorsTest.java +++ b/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/operators/NullologicalOperatorsTest.java @@ -18,15 +18,15 @@ import org.hl7.elm.r1.ExpressionDef; import org.hl7.elm.r1.IsNull; import org.hl7.elm.r1.Library; -import org.testng.annotations.BeforeTest; -import org.testng.annotations.Test; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; -public class NullologicalOperatorsTest { +class NullologicalOperatorsTest { - private Map defs; + private static Map defs; - @BeforeTest - public void setup() throws IOException { + @BeforeAll + static void setup() throws IOException { ModelManager modelManager = new ModelManager(); CqlTranslator translator = CqlTranslator.fromStream( NullologicalOperatorsTest.class.getResourceAsStream("../OperatorTests/NullologicalOperators.cql"), @@ -40,7 +40,7 @@ public void setup() throws IOException { } @Test - public void testIsNull() { + void isNull() { ExpressionDef def = defs.get("IsNullExpression"); assertThat(def, hasTypeAndResult(IsNull.class, "System.Boolean")); @@ -49,7 +49,7 @@ public void testIsNull() { } @Test - public void testCoalesce() { + void coalesce() { ExpressionDef def = defs.get("CoalesceList"); assertThat(def, hasTypeAndResult(Coalesce.class, "System.Integer")); diff --git a/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/operators/QueryTest.java b/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/operators/QueryTest.java index 7af87b221..348f50841 100644 --- a/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/operators/QueryTest.java +++ b/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/operators/QueryTest.java @@ -11,15 +11,15 @@ import org.cqframework.cql.cql2elm.LibraryManager; import org.cqframework.cql.cql2elm.ModelManager; import org.hl7.elm.r1.*; -import org.testng.annotations.BeforeTest; -import org.testng.annotations.Test; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; -public class QueryTest { +class QueryTest { - private Map defs; + private static Map defs; - @BeforeTest - public void setup() throws IOException { + @BeforeAll + static void setup() throws IOException { ModelManager modelManager = new ModelManager(); CqlTranslator translator = CqlTranslator.fromStream( QueryTest.class.getResourceAsStream("../OperatorTests/Query.cql"), new LibraryManager(modelManager)); @@ -32,25 +32,25 @@ public void setup() throws IOException { } @Test - public void testSingularSource() { + void singularSource() { ExpressionDef def = defs.get("Singular Source"); assertThat(def, hasTypeAndResult(Tuple.class, "tuple{id:System.Integer,name:System.String}")); } @Test - public void testPluralSource() { + void pluralSource() { ExpressionDef def = defs.get("Plural Source"); assertThat(def, hasTypeAndResult(List.class, "list")); } @Test - public void testSingularSourceQuery() { + void singularSourceQuery() { ExpressionDef def = defs.get("Singular Source Query"); assertThat(def, hasTypeAndResult(Query.class, "tuple{id:System.Integer,name:System.String}")); } @Test - public void testSingularMultipleSourceQuery() { + void singularMultipleSourceQuery() { ExpressionDef def = defs.get("Singular Multiple Source Query"); assertThat( def, @@ -60,7 +60,7 @@ public void testSingularMultipleSourceQuery() { } @Test - public void testPluralMultipleSourceQuery() { + void pluralMultipleSourceQuery() { ExpressionDef def = defs.get("Plural Multiple Source Query"); assertThat( def, @@ -70,7 +70,7 @@ public void testPluralMultipleSourceQuery() { } @Test - public void testMixedMultipleSourceQuery() { + void mixedMultipleSourceQuery() { ExpressionDef def = defs.get("Mixed Multiple Source Query"); assertThat( def, @@ -80,7 +80,7 @@ public void testMixedMultipleSourceQuery() { } @Test - public void testMixedMultipleSourceQuery2() { + void mixedMultipleSourceQuery2() { ExpressionDef def = defs.get("Mixed Multiple Source Query 2"); assertThat( def, @@ -90,25 +90,25 @@ public void testMixedMultipleSourceQuery2() { } @Test - public void testMixedMultipleSourceQueryWithReturn() { + void mixedMultipleSourceQueryWithReturn() { ExpressionDef def = defs.get("Mixed Multiple Source Query With Return"); assertThat(def, hasTypeAndResult(Query.class, "list")); } @Test - public void testSingularSourceWithPluralRelationship() { + void singularSourceWithPluralRelationship() { ExpressionDef def = defs.get("Singular Source With Plural Relationship"); assertThat(def, hasTypeAndResult(Query.class, "tuple{id:System.Integer,name:System.String}")); } @Test - public void testPluralSourceWithSingularRelationship() { + void pluralSourceWithSingularRelationship() { ExpressionDef def = defs.get("Plural Source With Singular Relationship"); assertThat(def, hasTypeAndResult(Query.class, "list")); } @Test - public void testSingularSourceWithPluralRelationshipAndReturn() { + void singularSourceWithPluralRelationshipAndReturn() { ExpressionDef def = defs.get("Singular Source With Plural Relationship And Return"); assertThat(def, hasTypeAndResult(Query.class, "tuple{id:System.Integer,name:System.String}")); } diff --git a/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/operators/SortingTest.java b/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/operators/SortingTest.java index 125d8cf3e..adf60b625 100644 --- a/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/operators/SortingTest.java +++ b/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/operators/SortingTest.java @@ -10,15 +10,15 @@ import org.cqframework.cql.cql2elm.LibraryManager; import org.cqframework.cql.cql2elm.ModelManager; import org.hl7.elm.r1.*; -import org.testng.annotations.BeforeTest; -import org.testng.annotations.Test; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; -public class SortingTest { +class SortingTest { - private Map defs; + private static Map defs; - @BeforeTest - public void setup() throws IOException { + @BeforeAll + static void setup() throws IOException { ModelManager modelManager = new ModelManager(); CqlTranslator translator = CqlTranslator.fromStream( QueryTest.class.getResourceAsStream("../OperatorTests/Sorting.cql"), new LibraryManager(modelManager)); @@ -34,7 +34,7 @@ public void setup() throws IOException { } @Test - public void testSimpleSort() { + void simpleSort() { Query query = (Query) defs.get("TestSimpleSort").getExpression(); SortClause sort = query.getSort(); assertThat(sort.getBy().size(), is(1)); @@ -42,7 +42,7 @@ public void testSimpleSort() { } @Test - public void testDescendingSort() { + void descendingSort() { Query query = (Query) defs.get("TestDescendingSort").getExpression(); SortClause sort = query.getSort(); assertThat(sort.getBy().size(), is(1)); @@ -50,7 +50,7 @@ public void testDescendingSort() { } @Test - public void testAscSort() { + void ascSort() { Query query = (Query) defs.get("TestAscSort").getExpression(); SortClause sort = query.getSort(); assertThat(sort.getBy().size(), is(1)); @@ -58,7 +58,7 @@ public void testAscSort() { } @Test - public void testAscendingSort() { + void ascendingSort() { Query query = (Query) defs.get("TestAscendingSort").getExpression(); SortClause sort = query.getSort(); assertThat(sort.getBy().size(), is(1)); diff --git a/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/operators/StringOperatorsTest.java b/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/operators/StringOperatorsTest.java index 90cbb2866..a3beb5bf0 100644 --- a/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/operators/StringOperatorsTest.java +++ b/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/operators/StringOperatorsTest.java @@ -17,15 +17,15 @@ import org.cqframework.cql.cql2elm.LibraryManager; import org.cqframework.cql.cql2elm.ModelManager; import org.hl7.elm.r1.*; -import org.testng.annotations.BeforeTest; -import org.testng.annotations.Test; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; -public class StringOperatorsTest { +class StringOperatorsTest { - private Map defs; + private static Map defs; - @BeforeTest - public void setup() throws IOException { + @BeforeAll + static void setup() throws IOException { ModelManager modelManager = new ModelManager(); CqlTranslator translator = CqlTranslator.fromStream( StringOperatorsTest.class.getResourceAsStream("../OperatorTests/StringOperators.cql"), @@ -39,19 +39,19 @@ public void setup() throws IOException { } @Test - public void testAdd() { + void add() { ExpressionDef def = defs.get("StringAdd"); assertThat(def, hasTypeAndResult(Concatenate.class, "System.String")); } @Test - public void testConcatenate() { + void concatenate() { ExpressionDef def = defs.get("StringConcatenate"); assertThat(def, hasTypeAndResult(Concatenate.class, "System.String")); } @Test - public void testConcatenateWithAmpersand() { + void concatenateWithAmpersand() { ExpressionDef def = defs.get("StringConcatenateWithAmpersand"); assertThat(def, hasTypeAndResult(Concatenate.class, "System.String")); @@ -62,7 +62,7 @@ public void testConcatenateWithAmpersand() { } @Test - public void testCombine() { + void combine() { ExpressionDef def = defs.get("StringCombine"); assertThat(def, hasTypeAndResult(Combine.class, "System.String")); Combine combine = (Combine) def.getExpression(); @@ -77,7 +77,7 @@ public void testCombine() { } @Test - public void testSplit() { + void split() { ExpressionDef def = defs.get("StringSplit"); assertThat(def, hasTypeAndResult(Split.class, "list")); Split split = (Split) def.getExpression(); @@ -86,7 +86,7 @@ public void testSplit() { } @Test - public void testSplitOnMatches() { + void splitOnMatches() { ExpressionDef def = defs.get("StringSplitOnMatches"); assertThat(def, hasTypeAndResult(SplitOnMatches.class, "list")); SplitOnMatches splitOnMatches = (SplitOnMatches) def.getExpression(); @@ -95,7 +95,7 @@ public void testSplitOnMatches() { } @Test - public void testUpper() { + void upper() { ExpressionDef def = defs.get("StringUpper"); assertThat(def, hasTypeAndResult(Upper.class, "System.String")); Upper upper = (Upper) def.getExpression(); @@ -103,7 +103,7 @@ public void testUpper() { } @Test - public void testLower() { + void lower() { ExpressionDef def = defs.get("StringLower"); assertThat(def, hasTypeAndResult(Lower.class, "System.String")); Lower lower = (Lower) def.getExpression(); @@ -111,7 +111,7 @@ public void testLower() { } @Test - public void testPositionOf() { + void positionOf() { ExpressionDef def = defs.get("StringPositionOf"); assertThat(def, hasTypeAndResult(PositionOf.class, "System.Integer")); PositionOf positionOf = (PositionOf) def.getExpression(); @@ -120,7 +120,7 @@ public void testPositionOf() { } @Test - public void testLastPositionOf() { + void lastPositionOf() { ExpressionDef def = defs.get("StringLastPositionOf"); assertThat(def, hasTypeAndResult(LastPositionOf.class, "System.Integer")); LastPositionOf lastPositionOf = (LastPositionOf) def.getExpression(); @@ -129,7 +129,7 @@ public void testLastPositionOf() { } @Test - public void testSubstring() { + void substring() { ExpressionDef def = defs.get("StringSubstring"); assertThat(def, hasTypeAndResult(Substring.class, "System.String")); Substring substring = (Substring) def.getExpression(); @@ -146,7 +146,7 @@ public void testSubstring() { } @Test - public void testLength() { + void length() { ExpressionDef def = defs.get("StringLength"); assertThat(def, hasTypeAndResult(Length.class, "System.Integer")); @@ -155,25 +155,25 @@ public void testLength() { } @Test - public void testStartsWith() { + void startsWith() { ExpressionDef def = defs.get("StringStartsWith"); assertThat(def, hasTypeAndResult(StartsWith.class, "System.Boolean")); } @Test - public void testEndsWith() { + void endsWith() { ExpressionDef def = defs.get("StringEndsWith"); assertThat(def, hasTypeAndResult(EndsWith.class, "System.Boolean")); } @Test - public void testMatches() { + void matches() { ExpressionDef def = defs.get("StringMatches"); assertThat(def, hasTypeAndResult(Matches.class, "System.Boolean")); } @Test - public void testReplaceMatches() { + void replaceMatches() { ExpressionDef def = defs.get("StringReplaceMatches"); assertThat(def, hasTypeAndResult(ReplaceMatches.class, "System.String")); } diff --git a/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/operators/TimeOperatorsTest.java b/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/operators/TimeOperatorsTest.java index ba374c394..c0870de22 100644 --- a/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/operators/TimeOperatorsTest.java +++ b/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/operators/TimeOperatorsTest.java @@ -12,15 +12,15 @@ import org.cqframework.cql.cql2elm.LibraryManager; import org.cqframework.cql.cql2elm.ModelManager; import org.hl7.elm.r1.*; -import org.testng.annotations.BeforeTest; -import org.testng.annotations.Test; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; -public class TimeOperatorsTest { +class TimeOperatorsTest { - private Map defs; + private static Map defs; - @BeforeTest - public void setup() throws IOException { + @BeforeAll + static void setup() throws IOException { ModelManager modelManager = new ModelManager(); CqlTranslator translator = CqlTranslator.fromStream( TimeOperatorsTest.class.getResourceAsStream("../OperatorTests/TimeOperators.cql"), @@ -34,7 +34,7 @@ public void setup() throws IOException { } @Test - public void testTime() { + void time() { ExpressionDef def = defs.get("TimeHour"); assertThat(def, hasTypeAndResult(Time.class, "System.Time")); Time t = (Time) def.getExpression(); @@ -63,7 +63,7 @@ public void testTime() { } @Test - public void testTimeOfDay() { + void timeOfDay() { ExpressionDef def = defs.get("TimeOfDayExpression"); assertThat(def, hasTypeAndResult(TimeOfDay.class, "System.Time")); } diff --git a/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/operators/TypeOperatorsTest.java b/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/operators/TypeOperatorsTest.java index 127782f61..9dee2e67c 100644 --- a/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/operators/TypeOperatorsTest.java +++ b/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/operators/TypeOperatorsTest.java @@ -6,7 +6,7 @@ import static org.hamcrest.Matchers.instanceOf; import static org.hamcrest.Matchers.is; import static org.hamcrest.Matchers.nullValue; -import static org.testng.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertTrue; import java.io.IOException; import java.util.HashMap; @@ -16,15 +16,15 @@ import org.cqframework.cql.cql2elm.LibraryManager; import org.cqframework.cql.cql2elm.ModelManager; import org.hl7.elm.r1.*; -import org.testng.annotations.BeforeTest; -import org.testng.annotations.Test; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; -public class TypeOperatorsTest { +class TypeOperatorsTest { - private Map defs; + private static Map defs; - @BeforeTest - public void setup() throws IOException { + @BeforeAll + static void setup() throws IOException { ModelManager modelManager = new ModelManager(); CqlTranslator translator = CqlTranslator.fromStream( TypeOperatorsTest.class.getResourceAsStream("../OperatorTests/TypeOperators.cql"), @@ -38,7 +38,7 @@ public void setup() throws IOException { } @Test - public void testAs() { + void as() { ExpressionDef def = defs.get("AsExpression"); assertThat(def, hasTypeAndResult(As.class, "System.Boolean")); As as = (As) def.getExpression(); @@ -51,7 +51,7 @@ public void testAs() { } @Test - public void testCast() { + void cast() { ExpressionDef def = defs.get("CastExpression"); assertThat(def, hasTypeAndResult(As.class, "System.Boolean")); As as = (As) def.getExpression(); @@ -64,7 +64,7 @@ public void testCast() { } @Test - public void testIs() { + void isExpression() { ExpressionDef def = defs.get("IsExpression"); assertThat(def, hasTypeAndResult(Is.class, "System.Boolean")); Is is = (Is) def.getExpression(); @@ -85,7 +85,7 @@ private static void validateTyping(Convert convert, QName typeName) { } @Test - public void testToString() { + void testToString() { ExpressionDef def = defs.get("BooleanToString"); assertThat(def, hasTypeAndResult(ToString.class, "System.String")); ToString convert = (ToString) def.getExpression(); @@ -161,7 +161,7 @@ public void testToString() { } @Test - public void testToStringFunction() { + void toStringFunction() { ExpressionDef def = defs.get("BooleanToStringFun"); assertThat(def, hasTypeAndResult(ToString.class, "System.String")); ToString convert = (ToString) def.getExpression(); @@ -246,7 +246,7 @@ public void testToStringFunction() { } @Test - public void testConvertsToString() { + void convertsToString() { ExpressionDef def = defs.get("BooleanConvertsToString"); assertThat(def, hasTypeAndResult(ConvertsToString.class, "System.Boolean")); ConvertsToString convert = (ConvertsToString) def.getExpression(); @@ -331,7 +331,7 @@ public void testConvertsToString() { } @Test - public void testToBoolean() { + void toBoolean() { ExpressionDef def = defs.get("StringToBoolean"); assertThat(def, hasTypeAndResult(ToBoolean.class, "System.Boolean")); ToBoolean convert = (ToBoolean) def.getExpression(); @@ -340,7 +340,7 @@ public void testToBoolean() { } @Test - public void testToBooleanFunction() { + void toBooleanFunction() { ExpressionDef def = defs.get("StringToBooleanFun"); assertThat(def, hasTypeAndResult(ToBoolean.class, "System.Boolean")); ToBoolean convert = (ToBoolean) def.getExpression(); @@ -350,7 +350,7 @@ public void testToBooleanFunction() { } @Test - public void testConvertsToBoolean() { + void convertsToBoolean() { ExpressionDef def = defs.get("StringConvertsToBoolean"); assertThat(def, hasTypeAndResult(ConvertsToBoolean.class, "System.Boolean")); ConvertsToBoolean convert = (ConvertsToBoolean) def.getExpression(); @@ -360,7 +360,7 @@ public void testConvertsToBoolean() { } @Test - public void testToInteger() { + void toInteger() { ExpressionDef def = defs.get("StringToInteger"); assertThat(def, hasTypeAndResult(ToInteger.class, "System.Integer")); ToInteger convert = (ToInteger) def.getExpression(); @@ -369,7 +369,7 @@ public void testToInteger() { } @Test - public void testToIntegerFunction() { + void toIntegerFunction() { ExpressionDef def = defs.get("StringToIntegerFun"); assertThat(def, hasTypeAndResult(ToInteger.class, "System.Integer")); ToInteger convert = (ToInteger) def.getExpression(); @@ -379,7 +379,7 @@ public void testToIntegerFunction() { } @Test - public void testConvertsToInteger() { + void convertsToInteger() { ExpressionDef def = defs.get("StringConvertsToInteger"); assertThat(def, hasTypeAndResult(ConvertsToInteger.class, "System.Boolean")); ConvertsToInteger convert = (ConvertsToInteger) def.getExpression(); @@ -389,7 +389,7 @@ public void testConvertsToInteger() { } @Test - public void testToLong() { + void toLong() { ExpressionDef def = defs.get("StringToLong"); assertThat(def, hasTypeAndResult(ToLong.class, "System.Long")); ToLong convert = (ToLong) def.getExpression(); @@ -398,7 +398,7 @@ public void testToLong() { } @Test - public void testConvertsToLong() { + void convertsToLong() { ExpressionDef def = defs.get("StringConvertsToLong"); assertThat(def, hasTypeAndResult(ConvertsToLong.class, "System.Boolean")); ConvertsToLong convert = (ConvertsToLong) def.getExpression(); @@ -408,7 +408,7 @@ public void testConvertsToLong() { } @Test - public void testToDecimal() { + void toDecimal() { ExpressionDef def = defs.get("StringToDecimal"); assertThat(def, hasTypeAndResult(ToDecimal.class, "System.Decimal")); ToDecimal convert = (ToDecimal) def.getExpression(); @@ -423,7 +423,7 @@ public void testToDecimal() { } @Test - public void testToDecimalFunction() { + void toDecimalFunction() { ExpressionDef def = defs.get("StringToDecimalFun"); assertThat(def, hasTypeAndResult(ToDecimal.class, "System.Decimal")); ToDecimal convert = (ToDecimal) def.getExpression(); @@ -439,7 +439,7 @@ public void testToDecimalFunction() { } @Test - public void testConvertsToDecimal() { + void convertsToDecimal() { ExpressionDef def = defs.get("StringConvertsToDecimal"); assertThat(def, hasTypeAndResult(ConvertsToDecimal.class, "System.Boolean")); ConvertsToDecimal convert = (ConvertsToDecimal) def.getExpression(); @@ -455,7 +455,7 @@ public void testConvertsToDecimal() { } @Test - public void testToDate() { + void toDate() { ExpressionDef def = defs.get("StringToDate"); assertThat(def, hasTypeAndResult(ToDate.class, "System.Date")); ToDate convert = (ToDate) def.getExpression(); @@ -464,7 +464,7 @@ public void testToDate() { } @Test - public void testToDateFunction() { + void toDateFunction() { ExpressionDef def = defs.get("StringToDateFun"); assertThat(def, hasTypeAndResult(ToDate.class, "System.Date")); ToDate convert = (ToDate) def.getExpression(); @@ -474,7 +474,7 @@ public void testToDateFunction() { } @Test - public void testConvertsToDate() { + void convertsToDate() { ExpressionDef def = defs.get("StringConvertsToDate"); assertThat(def, hasTypeAndResult(ConvertsToDate.class, "System.Boolean")); ConvertsToDate convert = (ConvertsToDate) def.getExpression(); @@ -484,7 +484,7 @@ public void testConvertsToDate() { } @Test - public void testToDateTime() { + void toDateTime() { ExpressionDef def = defs.get("StringToDateTime"); assertThat(def, hasTypeAndResult(ToDateTime.class, "System.DateTime")); ToDateTime convert = (ToDateTime) def.getExpression(); @@ -493,7 +493,7 @@ public void testToDateTime() { } @Test - public void testToDateTimeFunction() { + void toDateTimeFunction() { ExpressionDef def = defs.get("StringToDateTimeFun"); assertThat(def, hasTypeAndResult(ToDateTime.class, "System.DateTime")); ToDateTime convert = (ToDateTime) def.getExpression(); @@ -503,7 +503,7 @@ public void testToDateTimeFunction() { } @Test - public void testConvertsToDateTime() { + void convertsToDateTime() { ExpressionDef def = defs.get("StringConvertsToDateTime"); assertThat(def, hasTypeAndResult(ConvertsToDateTime.class, "System.Boolean")); ConvertsToDateTime convert = (ConvertsToDateTime) def.getExpression(); @@ -513,7 +513,7 @@ public void testConvertsToDateTime() { } @Test - public void testToTime() { + void toTime() { ExpressionDef def = defs.get("StringToTime"); assertThat(def, hasTypeAndResult(ToTime.class, "System.Time")); ToTime convert = (ToTime) def.getExpression(); @@ -522,7 +522,7 @@ public void testToTime() { } @Test - public void testToTimeFunction() { + void toTimeFunction() { ExpressionDef def = defs.get("StringToTimeFun"); assertThat(def, hasTypeAndResult(ToTime.class, "System.Time")); ToTime convert = (ToTime) def.getExpression(); @@ -532,7 +532,7 @@ public void testToTimeFunction() { } @Test - public void testConvertsToTime() { + void convertsToTime() { ExpressionDef def = defs.get("StringConvertsToTime"); assertThat(def, hasTypeAndResult(ConvertsToTime.class, "System.Boolean")); ConvertsToTime convert = (ConvertsToTime) def.getExpression(); @@ -542,7 +542,7 @@ public void testConvertsToTime() { } @Test - public void testToQuantity() { + void toQuantity() { ExpressionDef def = defs.get("StringToQuantity"); assertThat(def, hasTypeAndResult(ToQuantity.class, "System.Quantity")); ToQuantity convert = (ToQuantity) def.getExpression(); @@ -563,7 +563,7 @@ public void testToQuantity() { } @Test - public void testToQuantityFunction() { + void toQuantityFunction() { ExpressionDef def = defs.get("StringToQuantityFun"); assertThat(def, hasTypeAndResult(ToQuantity.class, "System.Quantity")); ToQuantity convert = (ToQuantity) def.getExpression(); @@ -585,7 +585,7 @@ public void testToQuantityFunction() { } @Test - public void testConvertsToQuantity() { + void convertsToQuantity() { ExpressionDef def = defs.get("StringConvertsToQuantity"); assertThat(def, hasTypeAndResult(ConvertsToQuantity.class, "System.Boolean")); ConvertsToQuantity convert = (ConvertsToQuantity) def.getExpression(); @@ -607,7 +607,7 @@ public void testConvertsToQuantity() { } @Test - public void testToRatio() { + void toRatio() { ExpressionDef def = defs.get("StringToRatio"); assertThat(def, hasTypeAndResult(ToRatio.class, "System.Ratio")); ToRatio convert = (ToRatio) def.getExpression(); @@ -616,7 +616,7 @@ public void testToRatio() { } @Test - public void testToRatioFunction() { + void toRatioFunction() { ExpressionDef def = defs.get("StringToRatioFun"); assertThat(def, hasTypeAndResult(ToRatio.class, "System.Ratio")); ToRatio convert = (ToRatio) def.getExpression(); @@ -626,7 +626,7 @@ public void testToRatioFunction() { } @Test - public void testConvertsToRatio() { + void convertsToRatio() { ExpressionDef def = defs.get("StringConvertsToRatio"); assertThat(def, hasTypeAndResult(ConvertsToRatio.class, "System.Boolean")); ConvertsToRatio convert = (ConvertsToRatio) def.getExpression(); @@ -636,7 +636,7 @@ public void testConvertsToRatio() { } @Test - public void testToConcept() { + void toConcept() { ExpressionDef def = defs.get("CodeToConcept"); assertThat(def, hasTypeAndResult(ToConcept.class, "System.Concept")); ToConcept toConcept = (ToConcept) def.getExpression(); @@ -657,7 +657,7 @@ public void testToConcept() { } @Test - public void testToConceptFunction() { + void toConceptFunction() { ExpressionDef def = defs.get("CodeToConceptFun"); assertThat(def, hasTypeAndResult(ToConcept.class, "System.Concept")); ToConcept convert = (ToConcept) def.getExpression(); @@ -680,7 +680,7 @@ public void testToConceptFunction() { } @Test - public void testMinValue() { + void minValue() { ExpressionDef def = defs.get("MinimumInteger"); assertThat(def, hasTypeAndResult(MinValue.class, "System.Integer")); MinValue minValue = (MinValue) def.getExpression(); @@ -703,7 +703,7 @@ public void testMinValue() { } @Test - public void testMaxValue() { + void maxValue() { ExpressionDef def = defs.get("MaximumInteger"); assertThat(def, hasTypeAndResult(MaxValue.class, "System.Integer")); MaxValue maxValue = (MaxValue) def.getExpression(); diff --git a/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/qdm/v54/BaseTest.java b/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/qdm/v54/BaseTest.java index 5b90f2e2c..556f41658 100644 --- a/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/qdm/v54/BaseTest.java +++ b/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/qdm/v54/BaseTest.java @@ -9,11 +9,11 @@ import org.cqframework.cql.cql2elm.CqlTranslator; import org.cqframework.cql.cql2elm.TestUtils; import org.hl7.elm.r1.*; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Test; -public class BaseTest { +class BaseTest { @Test - public void testChoiceTypes() throws IOException { + void choiceTypes() throws IOException { CqlTranslator translator = TestUtils.runSemanticTest("qdm/v54/TestChoiceTypes.cql", 0); Library library = translator.toELM(); Map defs = new HashMap<>(); diff --git a/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/qdm/v55/BaseTest.java b/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/qdm/v55/BaseTest.java index 35ce45e16..e59c8029c 100644 --- a/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/qdm/v55/BaseTest.java +++ b/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/qdm/v55/BaseTest.java @@ -10,11 +10,11 @@ import org.cqframework.cql.cql2elm.CqlTranslator; import org.cqframework.cql.cql2elm.TestUtils; import org.hl7.elm.r1.*; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Test; -public class BaseTest { +class BaseTest { @Test - public void testChoiceTypes() throws IOException { + void choiceTypes() throws IOException { CqlTranslator translator = TestUtils.runSemanticTest("qdm/v55/TestChoiceTypes.cql", 0); Library library = translator.toELM(); Map defs = new HashMap<>(); diff --git a/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/qdm/v56/BaseTest.java b/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/qdm/v56/BaseTest.java index aae1b6578..177623fc1 100644 --- a/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/qdm/v56/BaseTest.java +++ b/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/qdm/v56/BaseTest.java @@ -10,16 +10,16 @@ import org.cqframework.cql.cql2elm.CqlTranslator; import org.cqframework.cql.cql2elm.TestUtils; import org.hl7.elm.r1.*; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Test; -public class BaseTest { +class BaseTest { @Test - public void testEntities() throws IOException { + void entities() throws IOException { TestUtils.runSemanticTest("qdm/v56/TestEntities.cql", 0); } @Test - public void testChoiceTypes() throws IOException { + void choiceTypes() throws IOException { CqlTranslator translator = TestUtils.runSemanticTest("qdm/v56/TestChoiceTypes.cql", 0); Library library = translator.toELM(); Map defs = new HashMap<>(); diff --git a/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/qicore/v410/BaseTest.java b/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/qicore/v410/BaseTest.java index 61654febb..09eaf142f 100644 --- a/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/qicore/v410/BaseTest.java +++ b/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/qicore/v410/BaseTest.java @@ -12,11 +12,11 @@ import org.hl7.elm.r1.ExpressionDef; import org.hl7.elm.r1.Library; import org.hl7.elm.r1.Retrieve; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Test; -public class BaseTest { +class BaseTest { @Test - public void testQICore() throws IOException { + void qICore() throws IOException { CqlTranslator translator = TestUtils.runSemanticTest("qicore/v410/TestQICore.cql", 0); Library library = translator.toELM(); @@ -36,7 +36,7 @@ public void testQICore() throws IOException { } @Test - public void testEXM124() throws IOException { + void exm124() throws IOException { CqlTranslator translator = TestUtils.runSemanticTest("qicore/v410/EXM124_QICore4-8.2.000.cql", 0); Library library = translator.toELM(); @@ -52,7 +52,7 @@ public void testEXM124() throws IOException { } @Test - public void testEXM165() throws IOException { + void exm165() throws IOException { CqlTranslator translator = TestUtils.runSemanticTest("qicore/v410/EXM165_QICore4-8.5.000.cql", 0); Library library = translator.toELM(); diff --git a/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/qicore/v411/BaseTest.java b/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/qicore/v411/BaseTest.java index 895fcf09f..322507d5a 100644 --- a/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/qicore/v411/BaseTest.java +++ b/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/qicore/v411/BaseTest.java @@ -4,7 +4,7 @@ import static org.hamcrest.CoreMatchers.notNullValue; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.*; -import static org.testng.Assert.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNotNull; import java.io.IOException; import java.util.HashMap; @@ -14,11 +14,11 @@ import org.cqframework.cql.cql2elm.LibraryBuilder; import org.cqframework.cql.cql2elm.TestUtils; import org.hl7.elm.r1.*; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Test; public class BaseTest { @Test - public void testAuthoringPatterns() throws IOException { + void authoringPatterns() throws IOException { final CqlTranslator translator = TestUtils.runSemanticTest( "qicore/v411/AuthoringPatterns.cql", 0, LibraryBuilder.SignatureLevel.Overloads); @@ -33,7 +33,7 @@ public void testAuthoringPatterns() throws IOException { } @Test - public void testQICore() throws IOException { + void qICore() throws IOException { CqlTranslator translator = TestUtils.runSemanticTest("qicore/v411/TestQICore.cql", 0); Library library = translator.toELM(); @@ -198,7 +198,7 @@ public void testQICore() throws IOException { } @Test - public void testEXM124() throws IOException { + void exm124() throws IOException { CqlTranslator translator = TestUtils.runSemanticTest("qicore/v411/EXM124_QICore4-8.2.000.cql", 0); Library library = translator.toELM(); @@ -215,7 +215,7 @@ public void testEXM124() throws IOException { } @Test - public void testEXM165() throws IOException { + void exm165() throws IOException { CqlTranslator translator = TestUtils.runSemanticTest("qicore/v411/EXM165_QICore4-8.5.000.cql", 0); Library library = translator.toELM(); @@ -232,7 +232,7 @@ public void testEXM165() throws IOException { } @Test - public void testAdultOutpatientEncounters() throws IOException { + void adultOutpatientEncounters() throws IOException { CqlTranslator translator = TestUtils.runSemanticTest("qicore/v411/AdultOutpatientEncounters_QICore4-2.0.000.cql", 0); Library library = translator.toELM(); @@ -272,7 +272,7 @@ public void testAdultOutpatientEncounters() throws IOException { } @Test - public void testPapTestWithResults() throws IOException { + void papTestWithResults() throws IOException { CqlTranslator translator = TestUtils.runSemanticTest("qicore/v411/EXM124_QICore4-8.2.000.cql", 0); Library library = translator.toELM(); Map defs = new HashMap<>(); @@ -314,7 +314,7 @@ public void testPapTestWithResults() throws IOException { } @Test - public void TestMedicationRequest() throws IOException { + void medicationRequest() throws IOException { CqlTranslator translator = TestUtils.runSemanticTest("qicore/v411/TestMedicationRequest.cql", 0); Library library = translator.toELM(); Map defs = new HashMap<>(); @@ -379,7 +379,7 @@ public void TestMedicationRequest() throws IOException { } @Test - public void TestChoiceUnion() throws IOException { + void choiceUnion() throws IOException { CqlTranslator translator = TestUtils.runSemanticTest("qicore/v411/TestChoiceUnion.cql", 0); Library library = translator.toELM(); Map defs = new HashMap<>(); @@ -422,7 +422,7 @@ public void TestChoiceUnion() throws IOException { // TODO: Apparently (enabled=false) doesn't work on the CI server? // @Test(enabled = false, description = "Signature overloads not yet working for derived models") - public void TestSignatureOnInterval() throws IOException { + public void testSignatureOnInterval() throws IOException { CqlTranslator translator = TestUtils.runSemanticTest("qicore/v411/SupplementalDataElements_QICore4-2.0.0.cql", 0); diff --git a/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/qicore/v500/BaseTest.java b/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/qicore/v500/BaseTest.java index 5b2b064a3..8f0ee22c4 100644 --- a/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/qicore/v500/BaseTest.java +++ b/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/qicore/v500/BaseTest.java @@ -13,21 +13,21 @@ import org.cqframework.cql.cql2elm.LibraryBuilder; import org.cqframework.cql.cql2elm.TestUtils; import org.hl7.elm.r1.*; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Test; -public class BaseTest { +class BaseTest { @Test - public void testQICoreCommon() throws IOException { - CqlTranslator translator = TestUtils.runSemanticTest("qicore/v500/QICoreCommon-2.0.000.cql", 0); + void qICoreCommon() throws IOException { + TestUtils.runSemanticTest("qicore/v500/QICoreCommon-2.0.000.cql", 0); } @Test - public void testCQMCommon() throws IOException { - CqlTranslator translator = TestUtils.runSemanticTest("qicore/v500/CQMCommon-2.0.000.cql", 0); + void cqmCommon() throws IOException { + TestUtils.runSemanticTest("qicore/v500/CQMCommon-2.0.000.cql", 0); } @Test - public void testAuthoringPatterns() throws IOException { + void authoringPatterns() throws IOException { final CqlTranslator translator = TestUtils.runSemanticTest( "qicore/v500/AuthoringPatterns.cql", 0, LibraryBuilder.SignatureLevel.Overloads); @@ -42,7 +42,7 @@ public void testAuthoringPatterns() throws IOException { } @Test - public void testQICore() throws IOException { + void qICore() throws IOException { CqlTranslator translator = TestUtils.runSemanticTest("qicore/v500/TestQICore.cql", 0); Library library = translator.toELM(); @@ -195,7 +195,7 @@ public void testQICore() throws IOException { } @Test - public void testEXM124() throws IOException { + void exm124() throws IOException { CqlTranslator translator = TestUtils.runSemanticTest("qicore/v411/EXM124_QICore4-8.2.000.cql", 0); Library library = translator.toELM(); @@ -212,7 +212,7 @@ public void testEXM124() throws IOException { } @Test - public void testEXM165() throws IOException { + void exm165() throws IOException { CqlTranslator translator = TestUtils.runSemanticTest("qicore/v411/EXM165_QICore4-8.5.000.cql", 0); Library library = translator.toELM(); @@ -229,7 +229,7 @@ public void testEXM165() throws IOException { } @Test - public void testAdultOutpatientEncounters() throws IOException { + void adultOutpatientEncounters() throws IOException { CqlTranslator translator = TestUtils.runSemanticTest("qicore/v411/AdultOutpatientEncounters_QICore4-2.0.000.cql", 0); Library library = translator.toELM(); @@ -269,7 +269,7 @@ public void testAdultOutpatientEncounters() throws IOException { } @Test - public void testPapTestWithResults() throws IOException { + void papTestWithResults() throws IOException { CqlTranslator translator = TestUtils.runSemanticTest("qicore/v411/EXM124_QICore4-8.2.000.cql", 0); Library library = translator.toELM(); Map defs = new HashMap<>(); diff --git a/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/qicore/v600/BaseTest.java b/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/qicore/v600/BaseTest.java index 7eae5420a..16981fdce 100644 --- a/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/qicore/v600/BaseTest.java +++ b/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/qicore/v600/BaseTest.java @@ -10,11 +10,11 @@ import org.cqframework.cql.cql2elm.CqlTranslator; import org.cqframework.cql.cql2elm.TestUtils; import org.hl7.elm.r1.*; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Test; -public class BaseTest { +class BaseTest { @Test - public void testQICore() throws IOException { + void qICore() throws IOException { CqlTranslator translator = TestUtils.runSemanticTest("qicore/v600/TestQICore.cql", 0); Library library = translator.toELM(); diff --git a/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/quick/v330/BaseTest.java b/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/quick/v330/BaseTest.java index 1191aa732..67133edf9 100644 --- a/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/quick/v330/BaseTest.java +++ b/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/quick/v330/BaseTest.java @@ -13,7 +13,7 @@ import org.cqframework.cql.cql2elm.TestUtils; import org.cqframework.cql.cql2elm.model.CompiledLibrary; import org.hl7.elm.r1.*; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Test; public class BaseTest { @@ -51,7 +51,7 @@ public void testURIConversion() throws IOException { } @Test - public void testFHIRTiming() throws IOException { + void fhirTiming() throws IOException { ExpressionDef def = (ExpressionDef) visitFile("quick/v330/TestFHIRTiming.cql"); // Query-> // where-> @@ -86,7 +86,7 @@ public void testFHIRTiming() throws IOException { } @Test - public void testEqualityWithConversions() throws IOException { + void equalityWithConversions() throws IOException { CompiledLibrary library = visitFileLibrary("quick/v330/EqualityWithConversions.cql"); ExpressionDef getGender = library.resolveExpressionRef("GetGender"); assertThat(getGender.getExpression(), instanceOf(Equal.class)); @@ -97,7 +97,7 @@ public void testEqualityWithConversions() throws IOException { } @Test - public void testDoubleListPromotion() throws IOException { + void doubleListPromotion() throws IOException { CqlTranslator translator = TestUtils.runSemanticTest("quick/v330/TestDoubleListPromotion.cql", 0); Library library = translator.toELM(); Map defs = new HashMap<>(); @@ -119,12 +119,12 @@ public void testDoubleListPromotion() throws IOException { } @Test - public void testIntervalImplicitConversion() throws IOException { + void intervalImplicitConversion() throws IOException { TestUtils.runSemanticTest("quick/v330/TestIntervalImplicitConversion.cql", 0); } @Test - public void testImplicitFHIRHelpers() throws IOException { + void implicitFHIRHelpers() throws IOException { TestUtils.runSemanticTest("quick/v330/TestImplicitFHIRHelpers.cql", 0); } } diff --git a/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/uscore/v310/BaseTest.java b/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/uscore/v310/BaseTest.java index b79b31895..304017901 100644 --- a/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/uscore/v310/BaseTest.java +++ b/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/uscore/v310/BaseTest.java @@ -9,12 +9,12 @@ import org.cqframework.cql.cql2elm.CqlTranslator; import org.cqframework.cql.cql2elm.TestUtils; import org.hl7.elm.r1.*; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Test; -public class BaseTest { +class BaseTest { @Test - public void testUSCore() throws IOException { + void uSCore() throws IOException { CqlTranslator translator = TestUtils.runSemanticTest("uscore/v310/TestUSCore.cql", 0); Library library = translator.toELM(); Map defs = new HashMap<>(); diff --git a/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/uscore/v311/BaseTest.java b/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/uscore/v311/BaseTest.java index a665d4cdc..6f97a2dfe 100644 --- a/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/uscore/v311/BaseTest.java +++ b/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/uscore/v311/BaseTest.java @@ -9,12 +9,12 @@ import org.cqframework.cql.cql2elm.CqlTranslator; import org.cqframework.cql.cql2elm.TestUtils; import org.hl7.elm.r1.*; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Test; -public class BaseTest { +class BaseTest { @Test - public void testUSCore() throws IOException { + void uSCore() throws IOException { CqlTranslator translator = TestUtils.runSemanticTest("uscore/v311/TestUSCore.cql", 0); Library library = translator.toELM(); Map defs = new HashMap<>(); diff --git a/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/uscore/v610/BaseTest.java b/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/uscore/v610/BaseTest.java index 6c2190857..6acd354d0 100644 --- a/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/uscore/v610/BaseTest.java +++ b/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/uscore/v610/BaseTest.java @@ -10,12 +10,12 @@ import org.cqframework.cql.cql2elm.CqlTranslator; import org.cqframework.cql.cql2elm.TestUtils; import org.hl7.elm.r1.*; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Test; -public class BaseTest { +class BaseTest { @Test - public void testUSCore() throws IOException { + void uSCore() throws IOException { CqlTranslator translator = TestUtils.runSemanticTest("uscore/v610/TestUSCore.cql", 0); Library library = translator.toELM(); Map defs = new HashMap<>(); diff --git a/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/validation/LocalIdTests.java b/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/validation/LocalIdTests.java index 1e70d8261..834cf78b3 100644 --- a/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/validation/LocalIdTests.java +++ b/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/validation/LocalIdTests.java @@ -1,6 +1,6 @@ package org.cqframework.cql.cql2elm.validation; -import static org.testng.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertTrue; import java.util.ArrayList; import java.util.List; diff --git a/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/who/BaseTest.java b/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/who/BaseTest.java index e38af743b..1d6d0a9e0 100644 --- a/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/who/BaseTest.java +++ b/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/who/BaseTest.java @@ -7,11 +7,11 @@ import org.cqframework.cql.cql2elm.CqlTranslator; import org.cqframework.cql.cql2elm.TestUtils; import org.hl7.elm.r1.*; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Test; -public class BaseTest { +class BaseTest { @Test - public void testWho() throws IOException { + void who() throws IOException { var options = CqlCompilerOptions.defaultOptions(); CqlTranslator translator = TestUtils.runSemanticTest("who/TestSignature.cql", 0, options); Library library = translator.toELM(); diff --git a/Src/java/cql/src/test/java/org/cqframework/cql/grammar/GrammarTest.java b/Src/java/cql/src/test/java/org/cqframework/cql/grammar/GrammarTest.java index 437e2bfa5..25cf6a460 100644 --- a/Src/java/cql/src/test/java/org/cqframework/cql/grammar/GrammarTest.java +++ b/Src/java/cql/src/test/java/org/cqframework/cql/grammar/GrammarTest.java @@ -1,7 +1,7 @@ package org.cqframework.cql.grammar; import static org.cqframework.cql.gen.cqlParser.*; -import static org.testng.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import org.antlr.v4.runtime.CharStream; import org.antlr.v4.runtime.CharStreams; @@ -9,17 +9,17 @@ import org.antlr.v4.runtime.tree.ParseTree; import org.cqframework.cql.gen.cqlLexer; import org.cqframework.cql.gen.cqlParser; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Test; /** * GrammarTest ensures that the grammar (and generated parsers) work as expected. If non-compatible changes are made * to the grammar, these tests should fail. If the change is intentional, modify the tests to pass-- otherwise, fix * the grammar. */ -public class GrammarTest { +class GrammarTest { @Test - public void ageAt() { + void ageAt() { ParseTree tree = parseToTree("define inIPP : AgeAt(start of MeasurementPeriod) < 18"); LibraryContext logic = (LibraryContext) tree.getPayload(); diff --git a/Src/java/elm-fhir/src/test/java/org/cqframework/cql/elm/requirements/fhir/DataRequirementsProcessorTest.java b/Src/java/elm-fhir/src/test/java/org/cqframework/cql/elm/requirements/fhir/DataRequirementsProcessorTest.java index 35804bb5d..8febb814f 100644 --- a/Src/java/elm-fhir/src/test/java/org/cqframework/cql/elm/requirements/fhir/DataRequirementsProcessorTest.java +++ b/Src/java/elm-fhir/src/test/java/org/cqframework/cql/elm/requirements/fhir/DataRequirementsProcessorTest.java @@ -1,6 +1,6 @@ package org.cqframework.cql.elm.requirements.fhir; -import static org.testng.Assert.*; +import static org.junit.jupiter.api.Assertions.*; import ca.uhn.fhir.context.FhirContext; import ca.uhn.fhir.parser.IParser; @@ -22,9 +22,9 @@ import org.hl7.cql.model.NamespaceInfo; import org.hl7.elm.r1.*; import org.hl7.fhir.r5.model.*; +import org.junit.jupiter.api.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.testng.annotations.Test; public class DataRequirementsProcessorTest { private static Logger logger = LoggerFactory.getLogger(DataRequirementsProcessorTest.class); @@ -34,7 +34,7 @@ private static FhirContext getFhirContext() { } @Test - public void TestDataRequirementsProcessor() { + void dataRequirementsProcessor() { CqlCompilerOptions cqlTranslatorOptions = new CqlCompilerOptions(); cqlTranslatorOptions.getOptions().add(CqlCompilerOptions.Options.EnableAnnotations); try { @@ -103,7 +103,7 @@ private ParameterDefinition getParameter( } @Test - public void TestDataRequirementsProcessorOpioidIssueExpression() { + void dataRequirementsProcessorOpioidIssueExpression() { CqlCompilerOptions cqlTranslatorOptions = new CqlCompilerOptions(); cqlTranslatorOptions.setCollapseDataRequirements(true); cqlTranslatorOptions.setAnalyzeDataRequirements(true); @@ -143,10 +143,10 @@ public void TestDataRequirementsProcessorOpioidIssueExpression() { assertNotNull(ra, "Expected depends-on http://fhir.org/guides/cdc/opioid-cds/ValueSet/pcp-medications"); // parameter "Negative PCP Screenings Count Since Last POS": integer - assertTrue(moduleDefinitionLibrary.getParameter().size() == 1); + assertEquals(1, moduleDefinitionLibrary.getParameter().size()); ParameterDefinition pd = moduleDefinitionLibrary.getParameter().get(0); - assertEquals(pd.getName(), "Negative PCP Screenings Count Since Last POS"); - assertEquals(pd.getType(), Enumerations.FHIRTypes.INTEGER); + assertEquals("Negative PCP Screenings Count Since Last POS", pd.getName()); + assertEquals(Enumerations.FHIRTypes.INTEGER, pd.getType()); // dataRequirement Observation { // ms: { code, category, value, status, status.value, effective }, @@ -155,35 +155,41 @@ public void TestDataRequirementsProcessorOpioidIssueExpression() { // { code in http://fhir.org/guides/cdc/opioid-cds/ValueSet/pcp-medications } // } // } - assertTrue(moduleDefinitionLibrary.getDataRequirement().size() == 1); + assertEquals(1, moduleDefinitionLibrary.getDataRequirement().size()); DataRequirement dr = moduleDefinitionLibrary.getDataRequirement().get(0); - assertEquals(dr.getType(), Enumerations.FHIRTypes.OBSERVATION); - assertTrue(dr.getMustSupport().size() == 6); - assertTrue(dr.getMustSupport().stream() + assertEquals(Enumerations.FHIRTypes.OBSERVATION, dr.getType()); + assertEquals(6, dr.getMustSupport().size()); + assertEquals( + 1, + dr.getMustSupport().stream() .filter(x -> x.getValue().equals("code")) - .count() - == 1); - assertTrue(dr.getMustSupport().stream() + .count()); + assertEquals( + 1, + dr.getMustSupport().stream() .filter(x -> x.getValue().equals("category")) - .count() - == 1); - assertTrue(dr.getMustSupport().stream() + .count()); + assertEquals( + 1, + dr.getMustSupport().stream() .filter(x -> x.getValue().equals("value")) - .count() - == 1); - assertTrue(dr.getMustSupport().stream() + .count()); + assertEquals( + 1, + dr.getMustSupport().stream() .filter(x -> x.getValue().equals("status")) - .count() - == 1); - assertTrue(dr.getMustSupport().stream() + .count()); + assertEquals( + 1, + dr.getMustSupport().stream() .filter(x -> x.getValue().equals("status.value")) - .count() - == 1); - assertTrue(dr.getMustSupport().stream() + .count()); + assertEquals( + 1, + dr.getMustSupport().stream() .filter(x -> x.getValue().equals("effective")) - .count() - == 1); - assertTrue(dr.getCodeFilter().size() == 2); + .count()); + assertEquals(2, dr.getCodeFilter().size()); DataRequirement.DataRequirementCodeFilterComponent cf = null; for (DataRequirement.DataRequirementCodeFilterComponent drcf : dr.getCodeFilter()) { if (drcf.getPath().equals("category") @@ -213,7 +219,7 @@ public void TestDataRequirementsProcessorOpioidIssueExpression() { } @Test - public void TestDataRequirementsProcessorOpioidIssueLibrary() { + void dataRequirementsProcessorOpioidIssueLibrary() { CqlCompilerOptions cqlTranslatorOptions = new CqlCompilerOptions(); cqlTranslatorOptions.setCollapseDataRequirements(true); cqlTranslatorOptions.setAnalyzeDataRequirements(true); @@ -278,63 +284,63 @@ public void TestDataRequirementsProcessorOpioidIssueLibrary() { pd = getParameter(moduleDefinitionLibrary, "ContextPrescriptions"); assertNotNull(pd, "Expected parameter ContextPrescriptions"); - assertEquals(pd.getType(), Enumerations.FHIRTypes.MEDICATIONREQUEST); - assertEquals(pd.getUse(), Enumerations.OperationParameterUse.IN); - assertEquals(pd.getMax(), "*"); + assertEquals(Enumerations.FHIRTypes.MEDICATIONREQUEST, pd.getType()); + assertEquals(Enumerations.OperationParameterUse.IN, pd.getUse()); + assertEquals("*", pd.getMax()); pd = getParameter(moduleDefinitionLibrary, "Patient"); assertNotNull(pd, "Expected parameter Patient"); - assertEquals(pd.getType(), Enumerations.FHIRTypes.PATIENT); - assertEquals(pd.getUse(), Enumerations.OperationParameterUse.OUT); - assertEquals(pd.getMax(), "1"); + assertEquals(Enumerations.FHIRTypes.PATIENT, pd.getType()); + assertEquals(Enumerations.OperationParameterUse.OUT, pd.getUse()); + assertEquals("1", pd.getMax()); pd = getParameter(moduleDefinitionLibrary, "Lookback Year"); assertNotNull(pd, "Expected parameter Lookback Year"); - assertEquals(pd.getType(), Enumerations.FHIRTypes.PERIOD); - assertEquals(pd.getUse(), Enumerations.OperationParameterUse.OUT); - assertEquals(pd.getMax(), "1"); + assertEquals(Enumerations.FHIRTypes.PERIOD, pd.getType()); + assertEquals(Enumerations.OperationParameterUse.OUT, pd.getUse()); + assertEquals("1", pd.getMax()); pd = getParameter(moduleDefinitionLibrary, "PCP Screenings"); assertNotNull(pd, "Expected parameter PCP Screenings"); - assertEquals(pd.getType(), Enumerations.FHIRTypes.OBSERVATION); - assertEquals(pd.getUse(), Enumerations.OperationParameterUse.OUT); - assertEquals(pd.getMax(), "*"); + assertEquals(Enumerations.FHIRTypes.OBSERVATION, pd.getType()); + assertEquals(Enumerations.OperationParameterUse.OUT, pd.getUse()); + assertEquals("*", pd.getMax()); pd = getParameter(moduleDefinitionLibrary, "Positive PCP Screenings"); assertNotNull(pd, "Expected parameter Positive PCP Screenings"); - assertEquals(pd.getType(), Enumerations.FHIRTypes.OBSERVATION); - assertEquals(pd.getUse(), Enumerations.OperationParameterUse.OUT); - assertEquals(pd.getMax(), "*"); + assertEquals(Enumerations.FHIRTypes.OBSERVATION, pd.getType()); + assertEquals(Enumerations.OperationParameterUse.OUT, pd.getUse()); + assertEquals("*", pd.getMax()); pd = getParameter(moduleDefinitionLibrary, "Negative PCP Screenings"); assertNotNull(pd, "Expected parameter Negative PCP Screenings"); - assertEquals(pd.getType(), Enumerations.FHIRTypes.OBSERVATION); - assertEquals(pd.getUse(), Enumerations.OperationParameterUse.OUT); - assertEquals(pd.getMax(), "*"); + assertEquals(Enumerations.FHIRTypes.OBSERVATION, pd.getType()); + assertEquals(Enumerations.OperationParameterUse.OUT, pd.getUse()); + assertEquals("*", pd.getMax()); pd = getParameter(moduleDefinitionLibrary, "Negative PCP Screenings Count Since Last POS"); assertNotNull(pd, "Expected parameter Negative PCP Screenings Count Since Last POS"); - assertEquals(pd.getType(), Enumerations.FHIRTypes.INTEGER); - assertEquals(pd.getUse(), Enumerations.OperationParameterUse.OUT); - assertEquals(pd.getMax(), "1"); + assertEquals(Enumerations.FHIRTypes.INTEGER, pd.getType()); + assertEquals(Enumerations.OperationParameterUse.OUT, pd.getUse()); + assertEquals("1", pd.getMax()); pd = getParameter(moduleDefinitionLibrary, "Positive PCP Dates in Lookback Period"); assertNotNull(pd, "Expected parameter Positive PCP Dates in Lookback Period"); - assertEquals(pd.getType(), Enumerations.FHIRTypes.STRING); - assertEquals(pd.getUse(), Enumerations.OperationParameterUse.OUT); - assertEquals(pd.getMax(), "*"); + assertEquals(Enumerations.FHIRTypes.STRING, pd.getType()); + assertEquals(Enumerations.OperationParameterUse.OUT, pd.getUse()); + assertEquals("*", pd.getMax()); pd = getParameter(moduleDefinitionLibrary, "Has Positive Screening for PCP in Last 12 Months"); assertNotNull(pd, "Expected parameter Has Positive Screening for PCP in Last 12 Months"); - assertEquals(pd.getType(), Enumerations.FHIRTypes.BOOLEAN); - assertEquals(pd.getUse(), Enumerations.OperationParameterUse.OUT); - assertEquals(pd.getMax(), "1"); + assertEquals(Enumerations.FHIRTypes.BOOLEAN, pd.getType()); + assertEquals(Enumerations.OperationParameterUse.OUT, pd.getUse()); + assertEquals("1", pd.getMax()); pd = getParameter(moduleDefinitionLibrary, "PCP Summary"); assertNotNull(pd, "Expected parameter PCPSummary"); - assertEquals(pd.getType(), Enumerations.FHIRTypes.STRING); - assertEquals(pd.getUse(), Enumerations.OperationParameterUse.OUT); - assertEquals(pd.getMax(), "1"); + assertEquals(Enumerations.FHIRTypes.STRING, pd.getType()); + assertEquals(Enumerations.OperationParameterUse.OUT, pd.getUse()); + assertEquals("1", pd.getMax()); // dataRequirement Observation { // ms: { code, category, value, status, status.value, effective }, @@ -343,7 +349,7 @@ public void TestDataRequirementsProcessorOpioidIssueLibrary() { // { code in http://fhir.org/guides/cdc/opioid-cds/ValueSet/pcp-medications } // } // } - assertTrue(moduleDefinitionLibrary.getDataRequirement().size() == 2); + assertEquals(2, moduleDefinitionLibrary.getDataRequirement().size()); DataRequirement dr = null; for (DataRequirement r : moduleDefinitionLibrary.getDataRequirement()) { if (r.getType() == Enumerations.FHIRTypes.OBSERVATION) { @@ -352,33 +358,39 @@ public void TestDataRequirementsProcessorOpioidIssueLibrary() { } } assertNotNull(dr); - assertEquals(dr.getType(), Enumerations.FHIRTypes.OBSERVATION); - assertTrue(dr.getMustSupport().size() == 6); - assertTrue(dr.getMustSupport().stream() + assertEquals(Enumerations.FHIRTypes.OBSERVATION, dr.getType()); + assertEquals(6, dr.getMustSupport().size()); + assertEquals( + 1, + dr.getMustSupport().stream() .filter(x -> x.getValue().equals("code")) - .count() - == 1); - assertTrue(dr.getMustSupport().stream() + .count()); + assertEquals( + 1, + dr.getMustSupport().stream() .filter(x -> x.getValue().equals("category")) - .count() - == 1); - assertTrue(dr.getMustSupport().stream() + .count()); + assertEquals( + 1, + dr.getMustSupport().stream() .filter(x -> x.getValue().equals("value")) - .count() - == 1); - assertTrue(dr.getMustSupport().stream() + .count()); + assertEquals( + 1, + dr.getMustSupport().stream() .filter(x -> x.getValue().equals("status")) - .count() - == 1); - assertTrue(dr.getMustSupport().stream() + .count()); + assertEquals( + 1, + dr.getMustSupport().stream() .filter(x -> x.getValue().equals("status.value")) - .count() - == 1); - assertTrue(dr.getMustSupport().stream() + .count()); + assertEquals( + 1, + dr.getMustSupport().stream() .filter(x -> x.getValue().equals("effective")) - .count() - == 1); - assertTrue(dr.getCodeFilter().size() == 2); + .count()); + assertEquals(2, dr.getCodeFilter().size()); DataRequirement.DataRequirementCodeFilterComponent cf = null; for (DataRequirement.DataRequirementCodeFilterComponent drcf : dr.getCodeFilter()) { if (drcf.getPath().equals("category") @@ -408,7 +420,7 @@ public void TestDataRequirementsProcessorOpioidIssueLibrary() { } @Test - public void TestDataRequirementsProcessorWithExpressions() { + void dataRequirementsProcessorWithExpressions() { CqlCompilerOptions cqlTranslatorOptions = new CqlCompilerOptions(); try { Set expressions = new HashSet<>(); @@ -428,14 +440,14 @@ public void TestDataRequirementsProcessorWithExpressions() { List directReferenceCodes = moduleDefinitionLibrary.getExtensionsByUrl( "http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cqfm-directReferenceCode"); - assertTrue(directReferenceCodes.size() == 4); + assertEquals(4, directReferenceCodes.size()); Extension directReferenceCode = directReferenceCodes.get(0); Coding coding = directReferenceCode.getValueCoding(); assertEquals("http://hl7.org/fhir/condition-category", coding.getSystem()); assertEquals("encounter-diagnosis", coding.getCode()); assertEquals("Encounter Diagnosis", coding.getDisplay()); - assertTrue(moduleDefinitionLibrary.getRelatedArtifact().size() == 6); + assertEquals(6, moduleDefinitionLibrary.getRelatedArtifact().size()); RelatedArtifact conditionCategoryCodes = null; for (RelatedArtifact relatedArtifact : moduleDefinitionLibrary.getRelatedArtifact()) { if (relatedArtifact.getType() == RelatedArtifact.RelatedArtifactType.DEPENDSON @@ -447,7 +459,7 @@ public void TestDataRequirementsProcessorWithExpressions() { } assertTrue(conditionCategoryCodes != null); - assertTrue(moduleDefinitionLibrary.getParameter().size() == 1); + assertEquals(1, moduleDefinitionLibrary.getParameter().size()); ParameterDefinition conditionsIndicatingEndOfLife = null; for (ParameterDefinition parameter : moduleDefinitionLibrary.getParameter()) { if (parameter.getName().equals("Conditions Indicating End of Life or With Limited Life Expectancy")) { @@ -457,7 +469,7 @@ public void TestDataRequirementsProcessorWithExpressions() { } assertTrue(conditionsIndicatingEndOfLife != null); - assertTrue(moduleDefinitionLibrary.getDataRequirement().size() == 3); + assertEquals(3, moduleDefinitionLibrary.getDataRequirement().size()); DataRequirement diagnosisRequirement = null; for (DataRequirement requirement : moduleDefinitionLibrary.getDataRequirement()) { if (requirement.getType() == Enumerations.FHIRTypes.CONDITION @@ -485,7 +497,7 @@ public void TestDataRequirementsProcessorWithExpressions() { } @Test - public void TestLibraryDataRequirements() { + void libraryDataRequirements() { CqlCompilerOptions cqlTranslatorOptions = new CqlCompilerOptions(); try { @@ -503,7 +515,7 @@ public void TestLibraryDataRequirements() { List directReferenceCodes = moduleDefinitionLibrary.getExtensionsByUrl( "http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cqfm-directReferenceCode"); - assertTrue(directReferenceCodes.size() == 5); + assertEquals(5, directReferenceCodes.size()); Extension directReferenceCode = directReferenceCodes.get(0); Coding coding = directReferenceCode.getValueCoding(); assertEquals("http://loinc.org", coding.getSystem()); @@ -561,7 +573,7 @@ public void TestLibraryDataRequirements() { } @Test - public void TestLibraryDataRequirementsRecursive() { + void libraryDataRequirementsRecursive() { CqlCompilerOptions cqlTranslatorOptions = new CqlCompilerOptions(); cqlTranslatorOptions.setCollapseDataRequirements(true); try { @@ -593,7 +605,7 @@ public void TestLibraryDataRequirementsRecursive() { } @Test - public void TestDataRequirementsFHIRReferences() { + void dataRequirementsFHIRReferences() { CqlCompilerOptions cqlTranslatorOptions = new CqlCompilerOptions(); try { @@ -700,7 +712,7 @@ private org.hl7.fhir.r5.model.Library getModuleDefinitionLibrary( evaluationDateTime, false, false); - assertEquals(moduleDefinitionLibrary.getName(), "EffectiveDataRequirements"); + assertEquals("EffectiveDataRequirements", moduleDefinitionLibrary.getName()); assertTrue(moduleDefinitionLibrary .getType() .getCode("http://terminology.hl7.org/CodeSystem/library-type") @@ -774,7 +786,7 @@ private Iterable getDataRequirementsForType( } @Test - public void TestFunctionDataRequirements() throws IOException { + void functionDataRequirements() throws IOException { CqlCompilerOptions compilerOptions = getCompilerOptions(); var manager = setupDataRequirementsGather("CMS104/MATGlobalCommonFunctionsFHIR4.cql", compilerOptions); org.hl7.fhir.r5.model.Library moduleDefinitionLibrary = @@ -789,7 +801,7 @@ public void TestFunctionDataRequirements() throws IOException { } @Test - public void TestNonElectiveInpatientEncounterDataRequirements() throws IOException { + void nonElectiveInpatientEncounterDataRequirements() throws IOException { CqlCompilerOptions compilerOptions = getCompilerOptions(); var manager = setupDataRequirementsGather("CMS104/TJCOverallFHIR.cql", compilerOptions); org.hl7.fhir.r5.model.Library moduleDefinitionLibrary = getModuleDefinitionLibrary( @@ -815,7 +827,7 @@ public void TestNonElectiveInpatientEncounterDataRequirements() throws IOExcepti } @Test - public void TestAllStrokeEncounterDataRequirements() throws IOException { + void allStrokeEncounterDataRequirements() throws IOException { CqlCompilerOptions compilerOptions = getCompilerOptions(); var manager = setupDataRequirementsGather("CMS104/TJCOverallFHIR.cql", compilerOptions); org.hl7.fhir.r5.model.Library moduleDefinitionLibrary = @@ -847,7 +859,7 @@ public void TestAllStrokeEncounterDataRequirements() throws IOException { } @Test - public void TestCMS104DataRequirements() throws IOException { + void cms104DataRequirements() throws IOException { CqlCompilerOptions compilerOptions = getCompilerOptions(); var manager = setupDataRequirementsGather("CMS104/DischargedonAntithromboticTherapyFHIR.cql", compilerOptions); org.hl7.fhir.r5.model.Library moduleDefinitionLibrary = getModuleDefinitionLibrary(manager, compilerOptions); @@ -881,7 +893,7 @@ public void TestCMS104DataRequirements() throws IOException { } @Test - public void TestDataRequirementsAnalysisCase1() throws IOException { + void dataRequirementsAnalysisCase1() throws IOException { CqlCompilerOptions compilerOptions = getCompilerOptions(); var manager = setupDataRequirementsAnalysis("TestCases/TestCase1.cql", compilerOptions); org.hl7.fhir.r5.model.Library moduleDefinitionLibrary = getModuleDefinitionLibrary(manager, compilerOptions); @@ -897,9 +909,9 @@ public void TestDataRequirementsAnalysisCase1() throws IOException { ExpressionDef ed = manager.library().resolveExpressionRef("ESRD Observations"); assertTrue(ed.getExpression() instanceof Retrieve); Retrieve r = (Retrieve) ed.getExpression(); - assertEquals(r.getCodeProperty(), "code"); + assertEquals("code", r.getCodeProperty()); assertTrue(r.getCodes() instanceof ValueSetRef); - assertEquals(((ValueSetRef) r.getCodes()).getName(), "ESRD Diagnosis"); + assertEquals("ESRD Diagnosis", ((ValueSetRef) r.getCodes()).getName()); // Validate the data requirement is reported in the module definition library DataRequirement expectedDataRequirement = null; @@ -921,7 +933,7 @@ public void TestDataRequirementsAnalysisCase1() throws IOException { } @Test - public void TestDataRequirementsAnalysisCase1b() throws IOException { + void dataRequirementsAnalysisCase1b() throws IOException { CqlCompilerOptions compilerOptions = getCompilerOptions(); var manager = setupDataRequirementsAnalysis("TestCases/TestCase1b.cql", compilerOptions); org.hl7.fhir.r5.model.Library moduleDefinitionLibrary = getModuleDefinitionLibrary(manager, compilerOptions); @@ -944,12 +956,12 @@ public void TestDataRequirementsAnalysisCase1b() throws IOException { assertTrue(r.getCodeProperty() == null); assertTrue(r.getCodes() == null); assertTrue(r.getCodeFilter() != null); - assertTrue(r.getCodeFilter().size() == 1); + assertEquals(1, r.getCodeFilter().size()); CodeFilterElement cfe = r.getCodeFilter().get(0); - assertEquals(cfe.getProperty(), "status"); - assertEquals(cfe.getComparator(), "="); + assertEquals("status", cfe.getProperty()); + assertEquals("=", cfe.getComparator()); assertTrue(cfe.getValue() instanceof Literal); - assertEquals(((Literal) cfe.getValue()).getValue(), "final"); + assertEquals("final", ((Literal) cfe.getValue()).getValue()); // Validate the data requirement is reported in the module definition library DataRequirement expectedDataRequirement = null; @@ -974,7 +986,7 @@ public void TestDataRequirementsAnalysisCase1b() throws IOException { } @Test - public void TestDataRequirementsAnalysisCase1c() throws IOException { + void dataRequirementsAnalysisCase1c() throws IOException { CqlCompilerOptions compilerOptions = getCompilerOptions(); var manager = setupDataRequirementsAnalysis("TestCases/TestCase1c.cql", compilerOptions); Set expressions = new HashSet<>(); @@ -999,7 +1011,7 @@ public void TestDataRequirementsAnalysisCase1c() throws IOException { // Validate the TestReferencedDataRequirement is the only output parameter... ParameterDefinition expectedParameterDefinition = null; - assertEquals(moduleDefinitionLibrary.getParameter().size(), 1); + assertEquals(1, moduleDefinitionLibrary.getParameter().size()); for (ParameterDefinition pd : moduleDefinitionLibrary.getParameter()) { if ("TestReferencedDataRequirement".equals(pd.getName()) && pd.getUse() == Enumerations.OperationParameterUse.OUT @@ -1017,7 +1029,7 @@ public void TestDataRequirementsAnalysisCase1c() throws IOException { DataRequirement expectedDataRequirement = null; // TODO: This really should be 1, but we're using the recursive gather, so it reports the [Medication] retrieve // in the referenced expression as well - assertEquals(moduleDefinitionLibrary.getDataRequirement().size(), 2); + assertEquals(2, moduleDefinitionLibrary.getDataRequirement().size()); for (DataRequirement dr : moduleDefinitionLibrary.getDataRequirement()) { if (dr.getType() == Enumerations.FHIRTypes.MEDICATION) { if (dr.getCodeFilter().size() == 1) { @@ -1037,7 +1049,7 @@ public void TestDataRequirementsAnalysisCase1c() throws IOException { } @Test - public void TestDataRequirementsAnalysisCase2a() throws IOException { + void dataRequirementsAnalysisCase2a() throws IOException { CqlCompilerOptions compilerOptions = getCompilerOptions(); var manager = setupDataRequirementsAnalysis("TestCases/TestCase2a.cql", compilerOptions); org.hl7.fhir.r5.model.Library moduleDefinitionLibrary = getModuleDefinitionLibrary(manager, compilerOptions); @@ -1065,12 +1077,12 @@ public void TestDataRequirementsAnalysisCase2a() throws IOException { assertTrue(r.getCodeProperty() == null); assertTrue(r.getCodes() == null); assertTrue(r.getCodeFilter() != null); - assertTrue(r.getCodeFilter().size() == 1); + assertEquals(1, r.getCodeFilter().size()); CodeFilterElement cfe = r.getCodeFilter().get(0); - assertEquals(cfe.getProperty(), "item.revenue"); - assertEquals(cfe.getComparator(), "in"); + assertEquals("item.revenue", cfe.getProperty()); + assertEquals("in", cfe.getComparator()); assertTrue(cfe.getValue() instanceof ValueSetRef); - assertEquals(((ValueSetRef) cfe.getValue()).getName(), "Hospice Encounter"); + assertEquals("Hospice Encounter", ((ValueSetRef) cfe.getValue()).getName()); // Validate the data requirement is reported in the module definition library DataRequirement expectedDataRequirement = null; @@ -1092,7 +1104,7 @@ public void TestDataRequirementsAnalysisCase2a() throws IOException { } @Test - public void TestDataRequirementsAnalysisCase2b() throws IOException { + void dataRequirementsAnalysisCase2b() throws IOException { CqlCompilerOptions compilerOptions = getCompilerOptions(); var manager = setupDataRequirementsAnalysis("TestCases/TestCase2b.cql", compilerOptions); org.hl7.fhir.r5.model.Library moduleDefinitionLibrary = getModuleDefinitionLibrary(manager, compilerOptions); @@ -1121,11 +1133,11 @@ public void TestDataRequirementsAnalysisCase2b() throws IOException { assertTrue(r.getDateProperty() == null); assertTrue(r.getDateRange() == null); assertTrue(r.getDateFilter() != null); - assertTrue(r.getDateFilter().size() == 1); + assertEquals(1, r.getDateFilter().size()); DateFilterElement dfe = r.getDateFilter().get(0); - assertEquals(dfe.getProperty(), "item.serviced.start"); + assertEquals("item.serviced.start", dfe.getProperty()); assertTrue(dfe.getValue() instanceof ParameterRef); - assertEquals(((ParameterRef) dfe.getValue()).getName(), "Measurement Period"); + assertEquals("Measurement Period", ((ParameterRef) dfe.getValue()).getName()); // Validate the data requirement is reported in the module definition library DataRequirement expectedDataRequirement = null; @@ -1152,7 +1164,7 @@ public void TestDataRequirementsAnalysisCase2b() throws IOException { } @Test - public void TestDataRequirementsAnalysisCase2e() throws IOException { + void dataRequirementsAnalysisCase2e() throws IOException { CqlCompilerOptions compilerOptions = getCompilerOptions(); var manager = setupDataRequirementsAnalysis("TestCases/TestCase2e.cql", compilerOptions); // Evaluate this test as of 12/31/2022 @@ -1180,7 +1192,7 @@ public void TestDataRequirementsAnalysisCase2e() throws IOException { Retrieve r = (Retrieve) source.getExpression(); assertTrue(r.getDateFilter() != null && r.getDateFilter().size() == 1); DateFilterElement dfe = r.getDateFilter().get(0); - assertEquals(dfe.getProperty(), "onset"); + assertEquals("onset", dfe.getProperty()); assertTrue(dfe.getValue() instanceof Interval); OffsetDateTime expectedPeriodStart = @@ -1225,7 +1237,7 @@ public void TestDataRequirementsAnalysisCase2e() throws IOException { } @Test - public void TestDataRequirementsAnalysisCase2g() throws IOException { + void dataRequirementsAnalysisCase2g() throws IOException { CqlCompilerOptions compilerOptions = getCompilerOptions(); var manager = setupDataRequirementsAnalysis("TestCases/TestCase2g.cql", compilerOptions); org.hl7.fhir.r5.model.Library moduleDefinitionLibrary = @@ -1251,7 +1263,7 @@ public void TestDataRequirementsAnalysisCase2g() throws IOException { Retrieve r = (Retrieve) source.getExpression(); assertTrue(r.getDateFilter() != null && r.getDateFilter().size() == 1); DateFilterElement dfe = r.getDateFilter().get(0); - assertEquals(dfe.getProperty(), "onset"); + assertEquals("onset", dfe.getProperty()); assertTrue(dfe.getValue() instanceof Interval); DataRequirement expectedDataRequirement = null; @@ -1273,7 +1285,7 @@ public void TestDataRequirementsAnalysisCase2g() throws IOException { } @Test - public void TestDataRequirementsAnalysisCase2i() throws IOException { + void dataRequirementsAnalysisCase2i() throws IOException { CqlCompilerOptions compilerOptions = getCompilerOptions(); var manager = setupDataRequirementsAnalysis("TestCases/TestCase2i.cql", compilerOptions); org.hl7.fhir.r5.model.Library moduleDefinitionLibrary = @@ -1302,7 +1314,7 @@ public void TestDataRequirementsAnalysisCase2i() throws IOException { Retrieve r = (Retrieve) source.getExpression(); assertTrue(r.getDateFilter() != null && r.getDateFilter().size() == 1); DateFilterElement dfe = r.getDateFilter().get(0); - assertEquals(dfe.getProperty(), "onset"); + assertEquals("onset", dfe.getProperty()); assertTrue(dfe.getValue() instanceof Interval); DataRequirement expectedDataRequirement = null; @@ -1331,7 +1343,7 @@ public void TestDataRequirementsAnalysisCase2i() throws IOException { } @Test - public void TestDataRequirementsAnalysisCase2j() throws IOException { + void dataRequirementsAnalysisCase2j() throws IOException { CqlCompilerOptions compilerOptions = getCompilerOptions(); var manager = setupDataRequirementsAnalysis("TestCases/TestCase2j.cql", compilerOptions); org.hl7.fhir.r5.model.Library moduleDefinitionLibrary = @@ -1366,10 +1378,10 @@ public void TestDataRequirementsAnalysisCase2j() throws IOException { Retrieve r = (Retrieve) source.getExpression(); assertTrue(r.getDateFilter() != null && r.getDateFilter().size() == 2); DateFilterElement dfe = r.getDateFilter().get(0); - assertEquals(dfe.getProperty(), "onset"); + assertEquals("onset", dfe.getProperty()); assertTrue(dfe.getValue() instanceof Interval); dfe = r.getDateFilter().get(1); - assertEquals(dfe.getProperty(), "onset"); + assertEquals("onset", dfe.getProperty()); assertTrue(dfe.getValue() instanceof Interval); DataRequirement expectedDataRequirement = null; @@ -1431,7 +1443,7 @@ public void TestDataRequirementsAnalysisCase2j() throws IOException { } @Test - public void TestDataRequirementsAnalysisCase9a() throws IOException { + void dataRequirementsAnalysisCase9a() throws IOException { CqlCompilerOptions compilerOptions = getCompilerOptions(); var manager = setupDataRequirementsAnalysis("TestCases/TestCase9a.cql", compilerOptions); org.hl7.fhir.r5.model.Library moduleDefinitionLibrary = getModuleDefinitionLibrary(manager, compilerOptions); @@ -1455,20 +1467,20 @@ public void TestDataRequirementsAnalysisCase9a() throws IOException { AliasedQuerySource source = q.getSource().get(0); assertTrue(source.getExpression() instanceof Retrieve); Retrieve r = (Retrieve) source.getExpression(); - assertTrue(r.getDataType().getLocalPart().equals("MedicationRequest")); - assertTrue(r.getInclude().size() == 1); + assertEquals("MedicationRequest", r.getDataType().getLocalPart()); + assertEquals(1, r.getInclude().size()); String primarySourceId = r.getLocalId(); IncludeElement ie = r.getInclude().get(0); - assertTrue(ie.getRelatedDataType().getLocalPart().equals("Encounter")); - assertTrue(ie.getRelatedProperty().equals("encounter.reference")); - assertTrue(!ie.isIsReverse()); - assertTrue(q.getRelationship().size() == 1); + assertEquals("Encounter", ie.getRelatedDataType().getLocalPart()); + assertEquals("encounter.reference", ie.getRelatedProperty()); + assertFalse(ie.isIsReverse()); + assertEquals(1, q.getRelationship().size()); assertTrue(q.getRelationship().get(0) instanceof With); With w = (With) q.getRelationship().get(0); assertTrue(w.getExpression() instanceof Retrieve); r = (Retrieve) w.getExpression(); - assertTrue(r.getDataType().getLocalPart().equals("Encounter")); - assertTrue(r.getIncludedIn().equals(primarySourceId)); + assertEquals("Encounter", r.getDataType().getLocalPart()); + assertEquals(r.getIncludedIn(), primarySourceId); // Validate the data requirement is reported in the module definition library DataRequirement expectedDataRequirement = null; @@ -1502,7 +1514,7 @@ public void TestDataRequirementsAnalysisCase9a() throws IOException { // @Test // TODO: Enable include when the reference is in a let - public void TestDataRequirementsAnalysisCase9d() throws IOException { + public void testDataRequirementsAnalysisCase9d() throws IOException { CqlCompilerOptions compilerOptions = getCompilerOptions(); var manager = setupDataRequirementsAnalysis("TestCases/TestCase9d.cql", compilerOptions); org.hl7.fhir.r5.model.Library moduleDefinitionLibrary = getModuleDefinitionLibrary(manager, compilerOptions); @@ -1530,33 +1542,33 @@ public void TestDataRequirementsAnalysisCase9d() throws IOException { AliasedQuerySource source = q.getSource().get(0); assertTrue(source.getExpression() instanceof Retrieve); Retrieve r = (Retrieve) source.getExpression(); - assertTrue(r.getDataType().getLocalPart().equals("MedicationRequest")); - assertTrue(r.getInclude().size() == 1); + assertEquals("MedicationRequest", r.getDataType().getLocalPart()); + assertEquals(1, r.getInclude().size()); String primarySourceId = r.getLocalId(); IncludeElement ie = r.getInclude().get(0); - assertTrue(ie.getRelatedDataType().getLocalPart().equals("Medication")); - assertTrue(ie.getRelatedProperty().equals("medication.reference")); - assertTrue(!ie.isIsReverse()); + assertEquals("Medication", ie.getRelatedDataType().getLocalPart()); + assertEquals("medication.reference", ie.getRelatedProperty()); + assertFalse(ie.isIsReverse()); - assertTrue(q.getLet().size() == 1); + assertEquals(1, q.getLet().size()); LetClause lc = q.getLet().get(0); assertTrue(lc.getExpression() instanceof SingletonFrom); SingletonFrom sf = (SingletonFrom) lc.getExpression(); assertTrue(sf.getOperand() instanceof Query); q = (Query) sf.getOperand(); - assertTrue(q.getSource().size() == 1); + assertEquals(1, q.getSource().size()); source = q.getSource().get(0); assertTrue(source.getExpression() instanceof Retrieve); r = (Retrieve) source.getExpression(); - assertTrue(r.getDataType().getLocalPart().equals("Medication")); - assertTrue(r.getIncludedIn().equals(primarySourceId)); - assertTrue(r.getCodeFilter().size() == 2); + assertEquals("Medication", r.getDataType().getLocalPart()); + assertEquals(r.getIncludedIn(), primarySourceId); + assertEquals(2, r.getCodeFilter().size()); CodeFilterElement cfe = r.getCodeFilter().get(0); - assertTrue(cfe.getProperty().equals("id")); - assertTrue(cfe.getComparator().equals("=")); + assertEquals("id", cfe.getProperty()); + assertEquals("=", cfe.getComparator()); cfe = r.getCodeFilter().get(1); - assertTrue(cfe.getProperty().equals("code")); - assertTrue(cfe.getComparator().equals("in")); + assertEquals("code", cfe.getProperty()); + assertEquals("in", cfe.getComparator()); // Validate the data requirement is reported in the module definition library DataRequirement expectedDataRequirement = null; @@ -1589,7 +1601,7 @@ public void TestDataRequirementsAnalysisCase9d() throws IOException { } @Test - public void TestDataRequirementsAnalysisCase9e() throws IOException { + void dataRequirementsAnalysisCase9e() throws IOException { CqlCompilerOptions compilerOptions = getCompilerOptions(); var manager = setupDataRequirementsAnalysis("TestCases/TestCase9e.cql", compilerOptions); org.hl7.fhir.r5.model.Library moduleDefinitionLibrary = getModuleDefinitionLibrary(manager, compilerOptions); @@ -1617,29 +1629,29 @@ where exists ( AliasedQuerySource source = q.getSource().get(0); assertTrue(source.getExpression() instanceof Retrieve); Retrieve r = (Retrieve) source.getExpression(); - assertTrue(r.getDataType().getLocalPart().equals("MedicationRequest")); - assertTrue(r.getInclude().size() == 1); + assertEquals("MedicationRequest", r.getDataType().getLocalPart()); + assertEquals(1, r.getInclude().size()); String primarySourceId = r.getLocalId(); IncludeElement ie = r.getInclude().get(0); - assertTrue(ie.getRelatedDataType().getLocalPart().equals("Medication")); - assertTrue(ie.getRelatedProperty().equals("medication.reference")); - assertTrue(!ie.isIsReverse()); + assertEquals("Medication", ie.getRelatedDataType().getLocalPart()); + assertEquals("medication.reference", ie.getRelatedProperty()); + assertFalse(ie.isIsReverse()); assertTrue(q.getWhere() != null); assertTrue(q.getWhere() instanceof Exists); Exists ex = (Exists) q.getWhere(); assertTrue(ex.getOperand() instanceof Query); q = (Query) ex.getOperand(); - assertTrue(q.getSource().size() == 1); + assertEquals(1, q.getSource().size()); source = q.getSource().get(0); assertTrue(source.getExpression() instanceof Retrieve); r = (Retrieve) source.getExpression(); - assertTrue(r.getDataType().getLocalPart().equals("Medication")); - assertTrue(r.getIncludedIn().equals(primarySourceId)); - assertTrue(r.getCodeFilter().size() == 1); + assertEquals("Medication", r.getDataType().getLocalPart()); + assertEquals(r.getIncludedIn(), primarySourceId); + assertEquals(1, r.getCodeFilter().size()); CodeFilterElement cfe = r.getCodeFilter().get(0); - assertTrue(cfe.getProperty().equals("code")); - assertTrue(cfe.getComparator().equals("in")); + assertEquals("code", cfe.getProperty()); + assertEquals("in", cfe.getComparator()); // Validate the data requirement is reported in the module definition library DataRequirement expectedDataRequirement = null; @@ -1672,7 +1684,7 @@ where exists ( } @Test - public void TestDataRequirementsAnalysisCase9f() throws IOException { + void dataRequirementsAnalysisCase9f() throws IOException { CqlCompilerOptions compilerOptions = getCompilerOptions(); var manager = setupDataRequirementsAnalysis("TestCases/TestCase9f.cql", compilerOptions); org.hl7.fhir.r5.model.Library moduleDefinitionLibrary = getModuleDefinitionLibrary(manager, compilerOptions); @@ -1699,23 +1711,23 @@ public void TestDataRequirementsAnalysisCase9f() throws IOException { AliasedQuerySource source = q.getSource().get(0); assertTrue(source.getExpression() instanceof Retrieve); Retrieve r = (Retrieve) source.getExpression(); - assertTrue(r.getDataType().getLocalPart().equals("MedicationRequest")); - assertTrue(r.getInclude().size() == 1); + assertEquals("MedicationRequest", r.getDataType().getLocalPart()); + assertEquals(1, r.getInclude().size()); String primarySourceId = r.getLocalId(); IncludeElement ie = r.getInclude().get(0); - assertTrue(ie.getRelatedDataType().getLocalPart().equals("Medication")); - assertTrue(ie.getRelatedProperty().equals("medication.reference")); - assertTrue(!ie.isIsReverse()); + assertEquals("Medication", ie.getRelatedDataType().getLocalPart()); + assertEquals("medication.reference", ie.getRelatedProperty()); + assertFalse(ie.isIsReverse()); source = q.getSource().get(1); assertTrue(source.getExpression() instanceof Retrieve); r = (Retrieve) source.getExpression(); - assertTrue(r.getDataType().getLocalPart().equals("Medication")); - assertTrue(r.getIncludedIn().equals(primarySourceId)); - assertTrue(r.getCodeFilter().size() == 1); + assertEquals("Medication", r.getDataType().getLocalPart()); + assertEquals(r.getIncludedIn(), primarySourceId); + assertEquals(1, r.getCodeFilter().size()); CodeFilterElement cfe = r.getCodeFilter().get(0); - assertTrue(cfe.getProperty().equals("code")); - assertTrue(cfe.getComparator().equals("in")); + assertEquals("code", cfe.getProperty()); + assertEquals("in", cfe.getComparator()); // Validate the data requirement is reported in the module definition library DataRequirement expectedDataRequirement = null; @@ -1748,7 +1760,7 @@ public void TestDataRequirementsAnalysisCase9f() throws IOException { } @Test - public void TestDataRequirementsAnalysisCase10a() throws IOException { + void dataRequirementsAnalysisCase10a() throws IOException { CqlCompilerOptions compilerOptions = getCompilerOptions(); var manager = setupDataRequirementsAnalysis("TestCases/TestCase10a.cql", compilerOptions); org.hl7.fhir.r5.model.Library moduleDefinitionLibrary = getModuleDefinitionLibrary(manager, compilerOptions); @@ -1784,7 +1796,7 @@ public void TestDataRequirementsAnalysisCase10a() throws IOException { AliasedQuerySource source = q.getSource().get(0); assertTrue(source.getExpression() instanceof Retrieve); Retrieve r = (Retrieve) source.getExpression(); - assertTrue(r.getDataType().getLocalPart().equals("Observation")); + assertEquals("Observation", r.getDataType().getLocalPart()); // Validate the data requirement is reported in the module definition library DataRequirement expectedDataRequirement = null; @@ -1795,38 +1807,41 @@ public void TestDataRequirementsAnalysisCase10a() throws IOException { } assertTrue(expectedDataRequirement != null); - assertTrue(expectedDataRequirement.getMustSupport().size() == 2); + assertEquals(2, expectedDataRequirement.getMustSupport().size()); boolean hasCode = false; - assertTrue(expectedDataRequirement.getMustSupport().stream() + assertEquals( + 1, + expectedDataRequirement.getMustSupport().stream() .filter(s -> s.getValue().equals("code")) - .count() - == 1); - assertTrue(expectedDataRequirement.getMustSupport().stream() + .count()); + assertEquals( + 1, + expectedDataRequirement.getMustSupport().stream() .filter(s -> s.getValue().equals("issued")) - .count() - == 1); + .count()); - assertTrue(expectedDataRequirement.getCodeFilter().size() == 1); + assertEquals(1, expectedDataRequirement.getCodeFilter().size()); DataRequirement.DataRequirementCodeFilterComponent drcfc = expectedDataRequirement.getCodeFilter().get(0); - assertTrue(drcfc.getPath().equals("code")); - assertTrue(drcfc.getValueSet().equals("http://fakeurl.com/ersd-diagnosis")); + assertEquals("code", drcfc.getPath()); + assertEquals("http://fakeurl.com/ersd-diagnosis", drcfc.getValueSet()); - assertTrue(expectedDataRequirement.getDateFilter().size() == 1); + assertEquals(1, expectedDataRequirement.getDateFilter().size()); DataRequirement.DataRequirementDateFilterComponent drdfc = expectedDataRequirement.getDateFilter().get(0); LocalDate ld = LocalDate.of(2022, 2, 15); - assertTrue(drdfc.getValuePeriod() + assertEquals( + 0, + drdfc.getValuePeriod() .getStart() .compareTo(Date.from( - ld.atStartOfDay(ZoneId.systemDefault()).toInstant())) - == 0); + ld.atStartOfDay(ZoneId.systemDefault()).toInstant()))); // outputModuleDefinitionLibrary(moduleDefinitionLibrary); } @Test - public void TestDataRequirementsAnalysisCase10b() throws IOException { + void dataRequirementsAnalysisCase10b() throws IOException { CqlCompilerOptions compilerOptions = getCompilerOptions(); var manager = setupDataRequirementsAnalysis("TestCases/TestCase10b.cql", compilerOptions); org.hl7.fhir.r5.model.Library moduleDefinitionLibrary = getModuleDefinitionLibrary(manager, compilerOptions); @@ -1847,7 +1862,7 @@ where Coalesce(O.effective, O.issued) same day or after @2022-02-15 AliasedQuerySource source = q.getSource().get(0); assertTrue(source.getExpression() instanceof Retrieve); Retrieve r = (Retrieve) source.getExpression(); - assertTrue(r.getDataType().getLocalPart().equals("Observation")); + assertEquals("Observation", r.getDataType().getLocalPart()); // Validate the data requirement is reported in the module definition library DataRequirement expectedDataRequirement = null; @@ -1862,7 +1877,7 @@ where Coalesce(O.effective, O.issued) same day or after @2022-02-15 } @Test - public void TestDataRequirementsAnalysisCase10c() throws IOException { + void dataRequirementsAnalysisCase10c() throws IOException { // TODO: Complete this test case CqlCompilerOptions compilerOptions = getCompilerOptions(); var manager = setupDataRequirementsAnalysis("TestCases/TestCase10c.cql", compilerOptions); @@ -1884,7 +1899,7 @@ public void TestDataRequirementsAnalysisCase10c() throws IOException { AliasedQuerySource source = q.getSource().get(0); assertTrue(source.getExpression() instanceof Retrieve); Retrieve r = (Retrieve) source.getExpression(); - assertTrue(r.getDataType().getLocalPart().equals("Observation")); + assertEquals("Observation", r.getDataType().getLocalPart()); // Validate the data requirement is reported in the module definition library DataRequirement expectedDataRequirement = null; @@ -1899,7 +1914,7 @@ public void TestDataRequirementsAnalysisCase10c() throws IOException { } @Test - public void TestHEDISBCSE() throws IOException { + void hedisbcse() throws IOException { CqlCompilerOptions compilerOptions = getCompilerOptions(); compilerOptions.setCompatibilityLevel("1.4"); var manager = setupDataRequirementsAnalysis("BCSE/BCSE_HEDIS_MY2022.cql", compilerOptions); @@ -1922,7 +1937,7 @@ private void assertEqualToExpectedModuleDefinitionLibrary( } @Test - public void TestEXMLogic() throws IOException { + void exmLogic() throws IOException { CqlCompilerOptions compilerOptions = getCompilerOptions(); compilerOptions.setAnalyzeDataRequirements(false); var manager = setupDataRequirementsAnalysis("EXMLogic/EXMLogic.cql", compilerOptions); @@ -1935,7 +1950,7 @@ public void TestEXMLogic() throws IOException { } @Test - public void TestWithDependencies() throws IOException { + void withDependencies() throws IOException { CqlCompilerOptions compilerOptions = getCompilerOptions(); compilerOptions.setAnalyzeDataRequirements(false); var manager = setupDataRequirementsAnalysis("WithDependencies/BSElements.cql", compilerOptions); @@ -1952,7 +1967,7 @@ public void TestWithDependencies() throws IOException { } @Test - public void TestCMS645() throws IOException { + void cms645() throws IOException { CqlCompilerOptions compilerOptions = getCompilerOptions(); compilerOptions.setAnalyzeDataRequirements(false); var manager = setupDataRequirementsAnalysis("CMS645/CMS645Test.cql", compilerOptions); @@ -1969,7 +1984,7 @@ public void TestCMS645() throws IOException { } @Test - public void TestPCSBMI() throws IOException { + void pcsbmi() throws IOException { CqlCompilerOptions compilerOptions = CqlCompilerOptions.defaultOptions(); var manager = setupDataRequirementsAnalysis("PCSBMI/PCSBMIScreenAndFollowUpFHIR.cql", compilerOptions); org.hl7.fhir.r5.model.Library moduleDefinitionLibrary = getModuleDefinitionLibrary( @@ -1985,7 +2000,7 @@ public void TestPCSBMI() throws IOException { } @Test - public void TestCMS143() throws IOException { + void cms143() throws IOException { CqlCompilerOptions compilerOptions = CqlCompilerOptions.defaultOptions(); compilerOptions.getOptions().add(CqlCompilerOptions.Options.EnableResultTypes); Set expressions = new HashSet<>(); @@ -2016,7 +2031,7 @@ public void TestCMS143() throws IOException { } @Test - public void TestSDESex() throws IOException { + void sdeSex() throws IOException { CqlCompilerOptions compilerOptions = CqlCompilerOptions.defaultOptions(); compilerOptions.getOptions().add(CqlCompilerOptions.Options.EnableResultTypes); Set expressions = new HashSet<>(); @@ -2041,7 +2056,7 @@ public void TestSDESex() throws IOException { } @Test - public void TestSDEPayer() throws IOException { + void sdePayer() throws IOException { CqlCompilerOptions compilerOptions = CqlCompilerOptions.defaultOptions(); compilerOptions.getOptions().add(CqlCompilerOptions.Options.EnableResultTypes); Set expressions = new HashSet<>(); @@ -2065,7 +2080,7 @@ public void TestSDEPayer() throws IOException { } @Test - public void TestSDEEthnicity() throws IOException { + void sdeEthnicity() throws IOException { CqlCompilerOptions compilerOptions = CqlCompilerOptions.defaultOptions(); compilerOptions.getOptions().add(CqlCompilerOptions.Options.EnableResultTypes); Set expressions = new HashSet<>(); @@ -2087,7 +2102,7 @@ public void TestSDEEthnicity() throws IOException { } @Test - public void TestSDERace() throws IOException { + void sdeRace() throws IOException { CqlCompilerOptions compilerOptions = CqlCompilerOptions.defaultOptions(); compilerOptions.getOptions().add(CqlCompilerOptions.Options.EnableResultTypes); Set expressions = new HashSet<>(); @@ -2109,7 +2124,7 @@ public void TestSDERace() throws IOException { } @Test - public void TestQualifyingEncounterMP() throws IOException { + void qualifyingEncounterMP() throws IOException { CqlCompilerOptions compilerOptions = CqlCompilerOptions.defaultOptions(); compilerOptions.getOptions().add(CqlCompilerOptions.Options.EnableResultTypes); Set expressions = new HashSet<>(); @@ -2139,7 +2154,7 @@ public void TestQualifyingEncounterMP() throws IOException { } @Test - public void TestCMS149() throws IOException { + void cms149() throws IOException { CqlCompilerOptions compilerOptions = getCompilerOptions(); compilerOptions.setAnalyzeDataRequirements(false); var manager = setupDataRequirementsAnalysis( @@ -2171,7 +2186,7 @@ private Extension getLogicDefinitionByName(List logicDefinitions, Str } @Test - public void TestDeviceOrder() throws IOException { + void deviceOrder() throws IOException { CqlCompilerOptions compilerOptions = CqlCompilerOptions.defaultOptions(); var manager = setupDataRequirementsGather("DeviceOrder/TestDeviceOrder.cql", compilerOptions); org.hl7.fhir.r5.model.Library moduleDefinitionLibrary = getModuleDefinitionLibrary( @@ -2194,7 +2209,7 @@ public void TestDeviceOrder() throws IOException { } @Test - public void TestDataRequirementsProcessorWithPertinence() { + void dataRequirementsProcessorWithPertinence() { CqlCompilerOptions cqlTranslatorOptions = new CqlCompilerOptions(); cqlTranslatorOptions.getOptions().add(CqlCompilerOptions.Options.EnableAnnotations); @@ -2207,13 +2222,13 @@ public void TestDataRequirementsProcessorWithPertinence() { org.hl7.fhir.r5.model.Library moduleDefinitionLibrary = dqReqTrans.gatherDataRequirements( setup.manager(), setup.library(), cqlTranslatorOptions, null, false); - assertTrue(moduleDefinitionLibrary.getDataRequirement().size() == 3); + assertEquals(3, moduleDefinitionLibrary.getDataRequirement().size()); DataRequirement dr = moduleDefinitionLibrary.getDataRequirement().get(1); - assertEquals(dr.getType(), Enumerations.FHIRTypes.CONDITION); + assertEquals(Enumerations.FHIRTypes.CONDITION, dr.getType()); assertEquals( - dr.getExtension().get(0).getUrl(), - "http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cqfm-pertinence"); - assertEquals(((Coding) dr.getExtension().get(0).getValue()).getCode(), "pathognomonic"); + "http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cqfm-pertinence", + dr.getExtension().get(0).getUrl()); + assertEquals("pathognomonic", ((Coding) dr.getExtension().get(0).getValue()).getCode()); FhirContext context = getFhirContext(); IParser parser = context.newJsonParser(); @@ -2225,7 +2240,7 @@ public void TestDataRequirementsProcessorWithPertinence() { } @Test - public void TestDataRequirementsProcessorWithPertinenceAgain() { + void dataRequirementsProcessorWithPertinenceAgain() { CqlCompilerOptions cqlTranslatorOptions = new CqlCompilerOptions(); cqlTranslatorOptions.getOptions().add(CqlCompilerOptions.Options.EnableAnnotations); @@ -2239,25 +2254,26 @@ public void TestDataRequirementsProcessorWithPertinenceAgain() { setup.manager(), setup.library(), cqlTranslatorOptions, null, false); DataRequirement dr = moduleDefinitionLibrary.getDataRequirement().get(1); - assertEquals(dr.getType(), Enumerations.FHIRTypes.CONDITION); + assertEquals(Enumerations.FHIRTypes.CONDITION, dr.getType()); assertEquals( - dr.getExtension().get(0).getUrl(), - "http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cqfm-pertinence"); - assertEquals(((Coding) dr.getExtension().get(0).getValue()).getCode(), "weakly-negative"); + "http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cqfm-pertinence", + dr.getExtension().get(0).getUrl()); + assertEquals("weakly-negative", ((Coding) dr.getExtension().get(0).getValue()).getCode()); DataRequirement dr2 = moduleDefinitionLibrary.getDataRequirement().get(2); - assertEquals(dr2.getType(), Enumerations.FHIRTypes.ENCOUNTER); + assertEquals(Enumerations.FHIRTypes.ENCOUNTER, dr2.getType()); assertEquals( - dr2.getExtension().get(0).getUrl(), - "http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cqfm-pertinence"); - assertEquals(((Coding) dr2.getExtension().get(0).getValue()).getCode(), "pathognomonic"); + "http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cqfm-pertinence", + dr2.getExtension().get(0).getUrl()); + assertEquals("pathognomonic", ((Coding) dr2.getExtension().get(0).getValue()).getCode()); DataRequirement dr5 = moduleDefinitionLibrary.getDataRequirement().get(5); - assertEquals(dr5.getType(), Enumerations.FHIRTypes.DEVICEREQUEST); + assertEquals(Enumerations.FHIRTypes.DEVICEREQUEST, dr5.getType()); + assertEquals( + "http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cqfm-pertinence", + dr5.getExtension().get(0).getUrl()); assertEquals( - dr5.getExtension().get(0).getUrl(), - "http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cqfm-pertinence"); - assertEquals(((Coding) dr5.getExtension().get(0).getValue()).getCode(), "strongly-positive"); + "strongly-positive", ((Coding) dr5.getExtension().get(0).getValue()).getCode()); FhirContext context = getFhirContext(); IParser parser = context.newJsonParser(); diff --git a/Src/java/elm-jaxb/src/test/java/org/cqframework/cql/elm/serializing/jaxb/ElmJsonLibraryReaderTest.java b/Src/java/elm-jaxb/src/test/java/org/cqframework/cql/elm/serializing/jaxb/ElmJsonLibraryReaderTest.java index f3507acc7..690537f27 100644 --- a/Src/java/elm-jaxb/src/test/java/org/cqframework/cql/elm/serializing/jaxb/ElmJsonLibraryReaderTest.java +++ b/Src/java/elm-jaxb/src/test/java/org/cqframework/cql/elm/serializing/jaxb/ElmJsonLibraryReaderTest.java @@ -1,16 +1,16 @@ package org.cqframework.cql.elm.serializing.jaxb; -import static org.testng.Assert.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNotNull; import java.io.ByteArrayInputStream; import java.io.IOException; import org.hl7.elm.r1.Library; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Test; -public class ElmJsonLibraryReaderTest { +class ElmJsonLibraryReaderTest { @Test - public void testRead() throws IOException { + void read() throws IOException { var reader = new ElmJsonLibraryReader(); Library library = reader.read(new ByteArrayInputStream("{\"library\" : { \"type\" : \"Library\"}}".getBytes())); assertNotNull(library); diff --git a/Src/java/elm-jaxb/src/test/java/org/cqframework/cql/elm/serializing/jaxb/ElmXmlLibraryReaderTest.java b/Src/java/elm-jaxb/src/test/java/org/cqframework/cql/elm/serializing/jaxb/ElmXmlLibraryReaderTest.java index aee68f751..942f00e13 100644 --- a/Src/java/elm-jaxb/src/test/java/org/cqframework/cql/elm/serializing/jaxb/ElmXmlLibraryReaderTest.java +++ b/Src/java/elm-jaxb/src/test/java/org/cqframework/cql/elm/serializing/jaxb/ElmXmlLibraryReaderTest.java @@ -1,16 +1,16 @@ package org.cqframework.cql.elm.serializing.jaxb; -import static org.testng.Assert.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNotNull; import java.io.ByteArrayInputStream; import java.io.IOException; import org.hl7.elm.r1.Library; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Test; -public class ElmXmlLibraryReaderTest { +class ElmXmlLibraryReaderTest { @Test - public void testRead() throws IOException { + void read() throws IOException { var reader = new ElmXmlLibraryReader(); Library library = reader.read(new ByteArrayInputStream("".getBytes())); diff --git a/Src/java/elm-test/src/test/java/org/cqframework/cql/elm/ElmDeserializeTests.java b/Src/java/elm-test/src/test/java/org/cqframework/cql/elm/ElmDeserializeTests.java index acd8e2ead..6f57e6e31 100644 --- a/Src/java/elm-test/src/test/java/org/cqframework/cql/elm/ElmDeserializeTests.java +++ b/Src/java/elm-test/src/test/java/org/cqframework/cql/elm/ElmDeserializeTests.java @@ -1,6 +1,6 @@ package org.cqframework.cql.elm; -import static org.testng.Assert.*; +import static org.junit.jupiter.api.Assertions.*; import jakarta.xml.bind.JAXBException; import java.io.*; @@ -15,12 +15,12 @@ import org.cqframework.cql.cql2elm.LibraryBuilder; import org.hl7.cql_annotations.r1.CqlToElmInfo; import org.hl7.elm.r1.*; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Test; -public class ElmDeserializeTests { +class ElmDeserializeTests { @Test - public void testElmTests() { + void elmTests() { try { deserializeXmlLibrary("ElmDeserialize/ElmTests.xml"); } catch (IOException e) { @@ -30,7 +30,7 @@ public void testElmTests() { } @Test - public void testJsonANCFHIRDummyLibraryLoad() { + void jsonANCFHIRDummyLibraryLoad() { try { final Library library = deserializeJsonLibrary("ElmDeserialize/ANCFHIRDummy.json"); assertNotNull(library); @@ -64,7 +64,7 @@ public void testJsonANCFHIRDummyLibraryLoad() { } @Test - public void testJsonAdultOutpatientEncountersFHIR4LibraryLoad() { + void jsonAdultOutpatientEncountersFHIR4LibraryLoad() { try { final Library library = deserializeJsonLibrary("ElmDeserialize/fhir/AdultOutpatientEncounters_FHIR4-2.0.000.json"); @@ -73,8 +73,9 @@ public void testJsonAdultOutpatientEncountersFHIR4LibraryLoad() { EnumSet translatorOptions = EnumSet.of(CqlCompilerOptions.Options.EnableAnnotations); assertEquals(CompilerOptions.getCompilerOptions(library), translatorOptions); - assertEquals(library.getIdentifier().getId(), "AdultOutpatientEncounters_FHIR4"); - assertEquals(library.getIdentifier().getVersion(), "2.0.000"); + assertEquals( + "AdultOutpatientEncounters_FHIR4", library.getIdentifier().getId()); + assertEquals("2.0.000", library.getIdentifier().getVersion()); assertNotNull(library.getUsings()); assertNotNull(library.getUsings().getDef()); assertTrue(library.getUsings().getDef().size() >= 2); @@ -85,7 +86,9 @@ public void testJsonAdultOutpatientEncountersFHIR4LibraryLoad() { assertTrue( ((SingletonFrom) library.getStatements().getDef().get(0).getExpression()).getOperand() instanceof Retrieve); - assertEquals(library.getStatements().getDef().get(1).getName(), "Qualifying Encounters"); + assertEquals( + "Qualifying Encounters", + library.getStatements().getDef().get(1).getName()); assertNotNull(library.getStatements().getDef().get(1)); assertTrue(library.getStatements().getDef().get(1).getExpression() instanceof Query); @@ -96,13 +99,14 @@ public void testJsonAdultOutpatientEncountersFHIR4LibraryLoad() { } @Test - public void testXmlLibraryLoad() { + void xmlLibraryLoad() { try { final Library library = deserializeXmlLibrary("ElmDeserialize/fhir/AdultOutpatientEncounters_FHIR4-2.0.000.xml"); assertNotNull(library); - assertEquals(library.getIdentifier().getId(), "AdultOutpatientEncounters_FHIR4"); - assertEquals(library.getIdentifier().getVersion(), "2.0.000"); + assertEquals( + "AdultOutpatientEncounters_FHIR4", library.getIdentifier().getId()); + assertEquals("2.0.000", library.getIdentifier().getVersion()); EnumSet translatorOptions = EnumSet.of( CqlCompilerOptions.Options.EnableDateRangeOptimization, @@ -124,7 +128,9 @@ public void testXmlLibraryLoad() { assertTrue( ((SingletonFrom) library.getStatements().getDef().get(0).getExpression()).getOperand() instanceof Retrieve); - assertEquals(library.getStatements().getDef().get(1).getName(), "Qualifying Encounters"); + assertEquals( + "Qualifying Encounters", + library.getStatements().getDef().get(1).getName()); assertNotNull(library.getStatements().getDef().get(1)); assertTrue(library.getStatements().getDef().get(1).getExpression() instanceof Query); @@ -136,7 +142,7 @@ public void testXmlLibraryLoad() { } @Test - public void testJsonTerminologyLibraryLoad() { + void jsonTerminologyLibraryLoad() { try { final Library library = deserializeJsonLibrary("ElmDeserialize/ANCFHIRTerminologyDummy.json"); assertNotNull(library); @@ -192,7 +198,7 @@ private void testElmDeserialization(String directoryName) throws URISyntaxExcept } @Test - public void regressionTestJsonSerializer() throws URISyntaxException, IOException, JAXBException { + void regressionTestJsonSerializer() throws URISyntaxException, IOException, JAXBException { // This test validates that the ELM library deserialized from the Json matches the ELM library deserialized from // Xml // Regression inputs are annual update measure Xml for QDM and FHIR @@ -315,10 +321,10 @@ private String toJacksonJson(Library library) { } @Test - public void emptyStringsTest() throws IOException { + void emptyStringsTest() throws IOException { InputStream inputStream = ElmDeserializeTests.class.getResourceAsStream("ElmDeserialize/EmptyStringsTest.cql"); CqlTranslator translator = TestUtils.createTranslatorFromStream(inputStream); - assertEquals(translator.getErrors().size(), 0); + assertEquals(0, translator.getErrors().size()); String jaxbXml = toJaxbXml(translator.toELM()); String jaxbJson = toJaxbJson(translator.toELM()); @@ -388,7 +394,7 @@ private static void verifySigLevels(Library library, LibraryBuilder.SignatureLev .map(CqlToElmInfo::getSignatureLevel) .collect(Collectors.toList()); - assertEquals(sigLevels.size(), 1); + assertEquals(1, sigLevels.size()); assertEquals(sigLevels.get(0), expectedSignatureLevel.name()); } } diff --git a/Src/java/elm/src/test/java/org/cqframework/cql/elm/IdObjectFactoryTest.java b/Src/java/elm/src/test/java/org/cqframework/cql/elm/IdObjectFactoryTest.java index 7c4659b78..501421992 100644 --- a/Src/java/elm/src/test/java/org/cqframework/cql/elm/IdObjectFactoryTest.java +++ b/Src/java/elm/src/test/java/org/cqframework/cql/elm/IdObjectFactoryTest.java @@ -3,12 +3,12 @@ import java.lang.reflect.InvocationTargetException; import java.util.Arrays; import org.hl7.elm.r1.Element; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Test; -public class IdObjectFactoryTest { +class IdObjectFactoryTest { @Test - public void ensureAllElementsHaveLocalId() { + void ensureAllElementsHaveLocalId() { var factory = new IdObjectFactory(); var methods = Arrays.asList(IdObjectFactory.class.getMethods()).stream() .filter(x -> Element.class.isAssignableFrom(x.getReturnType())); diff --git a/Src/java/elm/src/test/java/org/cqframework/cql/elm/utility/VisitorsTest.java b/Src/java/elm/src/test/java/org/cqframework/cql/elm/utility/VisitorsTest.java index 0e3dbe38c..1e25a4a5e 100644 --- a/Src/java/elm/src/test/java/org/cqframework/cql/elm/utility/VisitorsTest.java +++ b/Src/java/elm/src/test/java/org/cqframework/cql/elm/utility/VisitorsTest.java @@ -1,17 +1,17 @@ package org.cqframework.cql.elm.utility; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertThrows; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; import org.hl7.elm.r1.ExpressionDef; import org.hl7.elm.r1.Library; import org.hl7.elm.r1.Library.Statements; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Test; -public class VisitorsTest { +class VisitorsTest { @Test - public void constructVisitorTest() { + void constructVisitorTest() { // set up visitor that counts all visited elements var trackableCounter = Visitors.from((elm, context) -> 1, Integer::sum); @@ -31,7 +31,7 @@ public void constructVisitorTest() { } @Test - public void nullVisitorTest() { + void nullVisitorTest() { assertThrows(NullPointerException.class, () -> Visitors.from(null)); assertThrows(NullPointerException.class, () -> Visitors.from(null, null)); assertThrows(NullPointerException.class, () -> Visitors.from(null, (a, b) -> b)); diff --git a/Src/java/elm/src/test/java/org/cqframework/cql/elm/visiting/BaseElmVisitorTest.java b/Src/java/elm/src/test/java/org/cqframework/cql/elm/visiting/BaseElmVisitorTest.java index 714c5f107..d15479a2b 100644 --- a/Src/java/elm/src/test/java/org/cqframework/cql/elm/visiting/BaseElmVisitorTest.java +++ b/Src/java/elm/src/test/java/org/cqframework/cql/elm/visiting/BaseElmVisitorTest.java @@ -1,19 +1,19 @@ package org.cqframework.cql.elm.visiting; -import static org.testng.Assert.assertFalse; -import static org.testng.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; import org.cqframework.cql.elm.tracking.Trackable; import org.hl7.elm.r1.ByDirection; import org.hl7.elm.r1.Sort; import org.hl7.elm.r1.SortByItem; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Test; @SuppressWarnings("checkstyle:abstractclassname") -public class BaseElmVisitorTest { +class BaseElmVisitorTest { @Test - public void sortByVisited() { + void sortByVisited() { // set up visitor that returns true if it visits a SortByItem var sortByFinder = new BaseElmVisitor() { @Override diff --git a/Src/java/elm/src/test/java/org/cqframework/cql/elm/visiting/DesignTests.java b/Src/java/elm/src/test/java/org/cqframework/cql/elm/visiting/DesignTests.java index ba43501a1..b1adff4c0 100644 --- a/Src/java/elm/src/test/java/org/cqframework/cql/elm/visiting/DesignTests.java +++ b/Src/java/elm/src/test/java/org/cqframework/cql/elm/visiting/DesignTests.java @@ -14,15 +14,15 @@ import com.tngtech.archunit.lang.ConditionEvents; import com.tngtech.archunit.lang.SimpleConditionEvent; import org.hl7.elm.r1.Element; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Test; -public class DesignTests { +class DesignTests { private static final JavaClasses importedClasses = new ClassFileImporter().importPackages("org.cqframework.cql.elm", "org.hl7.elm.r1"); @Test - public void ensureVisitAbstractDoesNotCallDefaultResult() { + void ensureVisitAbstractDoesNotCallDefaultResult() { var isAbstractElementType = and(modifier(JavaModifier.ABSTRACT), assignableTo(Element.class)); diff --git a/Src/java/elm/src/test/java/org/cqframework/cql/elm/visiting/FunctionalElmVisitorTest.java b/Src/java/elm/src/test/java/org/cqframework/cql/elm/visiting/FunctionalElmVisitorTest.java index ea1772263..9ec337cb7 100644 --- a/Src/java/elm/src/test/java/org/cqframework/cql/elm/visiting/FunctionalElmVisitorTest.java +++ b/Src/java/elm/src/test/java/org/cqframework/cql/elm/visiting/FunctionalElmVisitorTest.java @@ -1,18 +1,18 @@ package org.cqframework.cql.elm.visiting; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertThrows; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; import org.hl7.elm.r1.Element; import org.hl7.elm.r1.ExpressionDef; import org.hl7.elm.r1.Library; import org.hl7.elm.r1.Library.Statements; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Test; -public class FunctionalElmVisitorTest { +class FunctionalElmVisitorTest { @Test - public void countTest() { + void countTest() { // set up visitor that counts all visited elements var trackableCounter = new FunctionalElmVisitor((elm, context) -> 1, Integer::sum); @@ -40,7 +40,7 @@ public void countTest() { } @Test - public void nullVisitorTest() { + void nullVisitorTest() { assertThrows(NullPointerException.class, () -> new FunctionalElmVisitor(null, null)); assertThrows(NullPointerException.class, () -> new FunctionalElmVisitor(null, Integer::sum)); assertThrows(NullPointerException.class, () -> new FunctionalElmVisitor((x, y) -> 1, null)); diff --git a/Src/java/elm/src/test/java/org/cqframework/cql/elm/visiting/RandomElmGraphTest.java b/Src/java/elm/src/test/java/org/cqframework/cql/elm/visiting/RandomElmGraphTest.java index 90c260ee5..c29a18c27 100644 --- a/Src/java/elm/src/test/java/org/cqframework/cql/elm/visiting/RandomElmGraphTest.java +++ b/Src/java/elm/src/test/java/org/cqframework/cql/elm/visiting/RandomElmGraphTest.java @@ -1,6 +1,6 @@ package org.cqframework.cql.elm.visiting; -import static org.testng.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import java.lang.reflect.Field; import java.nio.charset.Charset; @@ -16,12 +16,11 @@ import org.jeasy.random.ObjenesisObjectFactory; import org.jeasy.random.api.ExclusionPolicy; import org.jeasy.random.api.RandomizerContext; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; public class RandomElmGraphTest { - @DataProvider(name = "seed") public static Object[] seeds() { // I randomly picked these seeds until // I got 3 in a row that passed without errors. @@ -29,8 +28,9 @@ public static Object[] seeds() { return new Object[] {96874, 15895, 121873, 174617}; } - @Test(dataProvider = "seed") - public void allNodesVisited(int seed) { + @ParameterizedTest + @MethodSource("seeds") + void allNodesVisited(int seed) { // This test generates a random ELM graph and verifies that all nodes are // visited exactly once. var elementsGenerated = new HashMap(); @@ -105,7 +105,7 @@ private void printContext(Element t, RandomizerContext context) { } // No missed nodes, working as intended - assertEquals(elementsGenerated.size(), 0); + assertEquals(0, elementsGenerated.size()); // Check that we didn't double-visit any nodes if (!elementsDuplicated.isEmpty()) { @@ -115,7 +115,7 @@ private void printContext(Element t, RandomizerContext context) { } // No duplicate visits, working as intended - assertEquals(elementsDuplicated.size(), 0); + assertEquals(0, elementsDuplicated.size()); // if these are equal, then aggregateResult // ran once for every node in the graph (working as intended) diff --git a/Src/java/engine-fhir/build.gradle b/Src/java/engine-fhir/build.gradle index 389a431bd..4b1b9dd34 100644 --- a/Src/java/engine-fhir/build.gradle +++ b/Src/java/engine-fhir/build.gradle @@ -6,7 +6,7 @@ plugins { dependencies { api project(':engine') - testImplementation 'com.github.tomakehurst:wiremock-jre8:2.35.0' + testImplementation 'com.github.tomakehurst:wiremock-jre8:2.35.2' testImplementation project(':cql-to-elm') testImplementation project(':model-jackson') testImplementation project(':elm-jackson') diff --git a/Src/java/engine-fhir/src/main/java/org/opencds/cqf/cql/engine/fhir/retrieve/BaseFhirQueryGenerator.java b/Src/java/engine-fhir/src/main/java/org/opencds/cqf/cql/engine/fhir/retrieve/BaseFhirQueryGenerator.java index 951043833..3663e9a0d 100644 --- a/Src/java/engine-fhir/src/main/java/org/opencds/cqf/cql/engine/fhir/retrieve/BaseFhirQueryGenerator.java +++ b/Src/java/engine-fhir/src/main/java/org/opencds/cqf/cql/engine/fhir/retrieve/BaseFhirQueryGenerator.java @@ -122,8 +122,6 @@ public abstract List generateFhirQueries( Map parameters, IBaseConformance capabilityStatement); - public abstract FhirVersionEnum getFhirVersion(); - protected Pair getTemplateParam(String dataType, String templateId) { if (templateId == null || templateId.equals("")) { return null; @@ -379,9 +377,9 @@ protected List innerSetupQueries( } List maps = new ArrayList<>(); - for (TokenOrListParam tolp : chunkedCodeParam.getValue()) { + for (TokenOrListParam t : chunkedCodeParam.getValue()) { SearchParameterMap base = this.getBaseMap(templateParam, contextParam, dateRangeParams, codeParams); - base.add(chunkedCodeParam.getKey(), tolp); + base.add(chunkedCodeParam.getKey(), t); maps.add(base); } diff --git a/Src/java/engine-fhir/src/test/java/org/hl7/fhirpath/CQLOperationsDstu3Test.java b/Src/java/engine-fhir/src/test/java/org/hl7/fhirpath/CQLOperationsDstu3Test.java index fe968ded3..33a5d2157 100644 --- a/Src/java/engine-fhir/src/test/java/org/hl7/fhirpath/CQLOperationsDstu3Test.java +++ b/Src/java/engine-fhir/src/test/java/org/hl7/fhirpath/CQLOperationsDstu3Test.java @@ -9,6 +9,9 @@ import org.fhir.ucum.UcumException; import org.hl7.fhir.dstu3.model.*; import org.hl7.fhirpath.tests.Group; +import org.junit.jupiter.api.Assumptions; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import org.opencds.cqf.cql.engine.data.CompositeDataProvider; import org.opencds.cqf.cql.engine.elm.executing.EqualEvaluator; import org.opencds.cqf.cql.engine.execution.State; @@ -18,13 +21,8 @@ import org.opencds.cqf.cql.engine.fhir.retrieve.RestFhirRetrieveProvider; import org.opencds.cqf.cql.engine.fhir.searchparam.SearchParameterResolver; import org.opencds.cqf.cql.engine.runtime.Code; -import org.testng.ITest; -import org.testng.SkipException; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Factory; -import org.testng.annotations.Test; -public class CQLOperationsDstu3Test extends TestFhirPath implements ITest { +public class CQLOperationsDstu3Test extends TestFhirPath { private static FhirContext fhirContext = FhirContext.forCached(FhirVersionEnum.DSTU3); private static Dstu3FhirModelResolver fhirModelResolver = new CachedDstu3FhirModelResolver(); private static RestFhirRetrieveProvider retrieveProvider = new RestFhirRetrieveProvider( @@ -33,18 +31,6 @@ public class CQLOperationsDstu3Test extends TestFhirPath implements ITest { fhirContext.newRestfulGenericClient("http://fhirtest.uhn.ca/baseDstu3")); private static CompositeDataProvider provider = new CompositeDataProvider(fhirModelResolver, retrieveProvider); - private final String file; - private final org.hl7.fhirpath.tests.Test test; - private final Group group; - - @Factory(dataProvider = "dataMethod") - public CQLOperationsDstu3Test(String file, Group group, org.hl7.fhirpath.tests.Test test) { - this.file = file; - this.group = group; - this.test = test; - } - - @DataProvider public static Object[][] dataMethod() { String[] listOfFiles = {"stu3/tests-fhir-r3.xml"}; @@ -160,20 +146,18 @@ public static Object[][] dataMethod() { "stu3/tests-fhir-r3/testWhere(Patient.name.where(given = 'Jim').count() = 1)", "stu3/tests-fhir-r3/testWhere(Patient.name.where(given = 'X').count() = 0)"); - @Override - public String getTestName() { + public String getTestName(String file, Group group, org.hl7.fhirpath.tests.Test test) { return file.replaceAll(".xml", "") + "/" + group.getName() + (test.getName() != null ? "/" + test.getName() : "") + "(" + test.getExpression().getValue() + ")"; } - @Test - public void test() throws UcumException { - if (SKIP.contains(getTestName())) { - throw new SkipException("Skipping " + getTestName()); - } - + @ParameterizedTest + @MethodSource("dataMethod") + void test(String file, Group group, org.hl7.fhirpath.tests.Test test) throws UcumException { + var name = getTestName(file, group, test); + Assumptions.assumeFalse(SKIP.contains(name), "Skipping " + name); runTest(test, "stu3/input/", fhirContext, provider, fhirModelResolver); } 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 06e72b8d3..02429fc0e 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 @@ -9,6 +9,9 @@ import org.fhir.ucum.UcumException; import org.hl7.fhir.r4.model.*; import org.hl7.fhirpath.tests.Group; +import org.junit.jupiter.api.Assumptions; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import org.opencds.cqf.cql.engine.data.CompositeDataProvider; import org.opencds.cqf.cql.engine.elm.executing.EqualEvaluator; import org.opencds.cqf.cql.engine.execution.State; @@ -18,13 +21,8 @@ import org.opencds.cqf.cql.engine.fhir.retrieve.RestFhirRetrieveProvider; import org.opencds.cqf.cql.engine.fhir.searchparam.SearchParameterResolver; import org.opencds.cqf.cql.engine.runtime.Code; -import org.testng.ITest; -import org.testng.SkipException; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Factory; -import org.testng.annotations.Test; -public class CQLOperationsR4Test extends TestFhirPath implements ITest { +public class CQLOperationsR4Test extends TestFhirPath { private static FhirContext fhirContext = FhirContext.forCached(FhirVersionEnum.R4); private static R4FhirModelResolver fhirModelResolver = new CachedR4FhirModelResolver(); @@ -34,18 +32,6 @@ public class CQLOperationsR4Test extends TestFhirPath implements ITest { fhirContext.newRestfulGenericClient("http://fhirtest.uhn.ca/baseR4")); private static CompositeDataProvider provider = new CompositeDataProvider(fhirModelResolver, retrieveProvider); - private final String file; - private final org.hl7.fhirpath.tests.Test test; - private final org.hl7.fhirpath.tests.Group group; - - @Factory(dataProvider = "dataMethod") - public CQLOperationsR4Test(String file, Group group, org.hl7.fhirpath.tests.Test test) { - this.file = file; - this.group = group; - this.test = test; - } - - @DataProvider public static Object[][] dataMethod() { String[] listOfFiles = { "r4/tests-fhir-r4.xml", @@ -320,8 +306,7 @@ public static Object[][] dataMethod() { "r4/tests-fhir-r4/testWhere/testWhere3", "r4/tests-fhir-r4/testWhere/testWhere4"); - @Override - public String getTestName() { + public String getTestName(String file, Group group, org.hl7.fhirpath.tests.Test test) { return file.replaceAll(".xml", "") + "/" + group.getName() + "/" + (test.getName() != null @@ -329,13 +314,11 @@ public String getTestName() { : test.getExpression().getValue()); } - @Test - public void test() throws UcumException { - - if (SKIP.contains(getTestName())) { - throw new SkipException("Skipping " + getTestName()); - } - + @ParameterizedTest + @MethodSource("dataMethod") + void test(String file, Group group, org.hl7.fhirpath.tests.Test test) throws UcumException { + var name = getTestName(file, group, test); + Assumptions.assumeFalse(SKIP.contains(name), "Skipping " + name); runTest(test, "r4/input/", fhirContext, provider, fhirModelResolver); } diff --git a/Src/java/engine-fhir/src/test/java/org/hl7/fhirpath/DateTypeTest.java b/Src/java/engine-fhir/src/test/java/org/hl7/fhirpath/DateTypeTest.java index 592d5223c..fdead7bf3 100644 --- a/Src/java/engine-fhir/src/test/java/org/hl7/fhirpath/DateTypeTest.java +++ b/Src/java/engine-fhir/src/test/java/org/hl7/fhirpath/DateTypeTest.java @@ -7,11 +7,11 @@ import java.util.GregorianCalendar; import java.util.TimeZone; import org.hl7.fhir.r4.model.DateType; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Test; -public class DateTypeTest { +class DateTypeTest { @Test - public void testDateType() { + void dateType() { // DateType Month is zero-based (11 == December) DateType birthDate = new DateType(1974, 11, 25); assertThat(birthDate.getYear(), is(1974)); @@ -20,7 +20,7 @@ public void testDateType() { } @Test - public void testDate() { + void date() { // NOTE: DateType uses default GMT java.util.Date birthDate = new DateType(1974, 11, 25).getValue(); GregorianCalendar calendar = new GregorianCalendar(TimeZone.getTimeZone("GMT")); diff --git a/Src/java/engine-fhir/src/test/java/org/hl7/fhirpath/FhirHelpersDstu2Test.java b/Src/java/engine-fhir/src/test/java/org/hl7/fhirpath/FhirHelpersDstu2Test.java index 6721a3e33..7de66814b 100644 --- a/Src/java/engine-fhir/src/test/java/org/hl7/fhirpath/FhirHelpersDstu2Test.java +++ b/Src/java/engine-fhir/src/test/java/org/hl7/fhirpath/FhirHelpersDstu2Test.java @@ -53,9 +53,9 @@ public void testFhirHelpersDstu2() throws UcumException { // TODO - millis shouldn't be populated - issue with DateTime.fromJavaDate(Date date) Object value = results.forExpression("TestPeriodToInterval").value(); - // Assert.assertEquals(((DateTime)((Interval) value).getStart()).getPartial(), new + // Assertions.assertEquals(((DateTime)((Interval) value).getStart()).getPartial(), new // Partial(DateTime.getFields(7), new int[] {2017, 5, 6, 18, 8, 0, 0})); - // Assert.assertEquals(((DateTime)((Interval) value).getEnd()).getPartial(), new + // Assertions.assertEquals(((DateTime)((Interval) value).getEnd()).getPartial(), new // Partial(DateTime.getFields(7), new int[] {2017, 5, 6, 19, 8, 0, 0})); value = results.forExpression("TestToQuantity").value(); value = results.forExpression("TestRangeToInterval").value(); diff --git a/Src/java/engine-fhir/src/test/java/org/hl7/fhirpath/FhirHelpersDstu3Test.java b/Src/java/engine-fhir/src/test/java/org/hl7/fhirpath/FhirHelpersDstu3Test.java index 51176341f..2a83d9d30 100644 --- a/Src/java/engine-fhir/src/test/java/org/hl7/fhirpath/FhirHelpersDstu3Test.java +++ b/Src/java/engine-fhir/src/test/java/org/hl7/fhirpath/FhirHelpersDstu3Test.java @@ -58,9 +58,9 @@ public void testFhirHelpersStu3() throws UcumException { // TODO - fix Object value = results.forExpression("TestPeriodToInterval").value(); - // Assert.assertEquals(((DateTime)((Interval) value).getStart()).getPartial(), + // Assertions.assertEquals(((DateTime)((Interval) value).getStart()).getPartial(), // new Partial(DateTime.getFields(6), new int[] {2017, 5, 6, 18, 8, 0})); - // Assert.assertEquals(((DateTime)((Interval) value).getEnd()).getPartial(), + // Assertions.assertEquals(((DateTime)((Interval) value).getEnd()).getPartial(), // new Partial(DateTime.getFields(6), new int[] {2017, 5, 6, 19, 8, 0})); value = results.forExpression("TestToQuantity").value(); // TODO: ModelInfo bug. Not aware of SimpleQuantity diff --git a/Src/java/engine-fhir/src/test/java/org/opencds/cqf/cql/engine/fhir/Dstu3FhirTest.java b/Src/java/engine-fhir/src/test/java/org/opencds/cqf/cql/engine/fhir/Dstu3FhirTest.java index 49bad1d41..d3183968b 100644 --- a/Src/java/engine-fhir/src/test/java/org/opencds/cqf/cql/engine/fhir/Dstu3FhirTest.java +++ b/Src/java/engine-fhir/src/test/java/org/opencds/cqf/cql/engine/fhir/Dstu3FhirTest.java @@ -14,20 +14,19 @@ import java.net.ServerSocket; import java.util.List; import org.hl7.fhir.dstu3.model.*; -import org.testng.annotations.AfterMethod; -import org.testng.annotations.BeforeMethod; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; public class Dstu3FhirTest { private static FhirContext FHIR_CONTEXT = FhirContext.forCached(FhirVersionEnum.DSTU3); private static IParser FHIR_PARSER = FHIR_CONTEXT.newJsonParser().setPrettyPrint(true); private static int HTTP_PORT = 0; - // emulate wiremock's testng.WireMockRule with testng features WireMockServer wireMockServer; WireMock wireMock; - @BeforeMethod() - public void start() { + @BeforeEach() + void start() { wireMockServer = new WireMockServer(getHttpPort()); wireMockServer.start(); WireMock.configureFor("localhost", getHttpPort()); @@ -36,20 +35,20 @@ public void start() { mockFhirRead("/metadata", getCapabilityStatement()); } - @AfterMethod - public void stop() { + @AfterEach + void stop() { wireMockServer.stop(); } - public FhirContext getFhirContext() { + public static FhirContext getFhirContext() { return FHIR_CONTEXT; } - public IParser getFhirParser() { + public static IParser getFhirParser() { return FHIR_PARSER; } - public int getHttpPort() { + public static int getHttpPort() { if (HTTP_PORT == 0) { try (ServerSocket socket = new ServerSocket(0)) { HTTP_PORT = socket.getLocalPort(); @@ -60,7 +59,7 @@ public int getHttpPort() { return HTTP_PORT; } - public IGenericClient newClient() { + public static IGenericClient newClient() { IGenericClient client = getFhirContext().newRestfulGenericClient(String.format("http://localhost:%d/", getHttpPort())); diff --git a/Src/java/engine-fhir/src/test/java/org/opencds/cqf/cql/engine/fhir/R4FhirTest.java b/Src/java/engine-fhir/src/test/java/org/opencds/cqf/cql/engine/fhir/R4FhirTest.java index df5ba010d..a00b840da 100644 --- a/Src/java/engine-fhir/src/test/java/org/opencds/cqf/cql/engine/fhir/R4FhirTest.java +++ b/Src/java/engine-fhir/src/test/java/org/opencds/cqf/cql/engine/fhir/R4FhirTest.java @@ -22,19 +22,18 @@ import org.hl7.fhir.r4.model.OperationOutcome; import org.hl7.fhir.r4.model.OperationOutcome.IssueSeverity; import org.hl7.fhir.r4.model.Resource; -import org.testng.annotations.AfterMethod; -import org.testng.annotations.BeforeMethod; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; public abstract class R4FhirTest { private static FhirContext FHIR_CONTEXT = FhirContext.forCached(FhirVersionEnum.R4); private static IParser FHIR_PARSER = FHIR_CONTEXT.newJsonParser().setPrettyPrint(true); private static int HTTP_PORT = 0; - // emulate wiremock's testng.WireMockRule with testng features WireMockServer wireMockServer; WireMock wireMock; - @BeforeMethod() + @BeforeEach public void start() { wireMockServer = new WireMockServer(getHttpPort()); wireMockServer.start(); @@ -44,12 +43,12 @@ public void start() { mockFhirRead("/metadata", getCapabilityStatement()); } - @AfterMethod + @AfterEach public void stop() { wireMockServer.stop(); } - public FhirContext getFhirContext() { + public static FhirContext getFhirContext() { return FHIR_CONTEXT; } @@ -57,7 +56,7 @@ public IParser getFhirParser() { return FHIR_PARSER; } - public int getHttpPort() { + public static int getHttpPort() { if (HTTP_PORT == 0) { try (ServerSocket socket = new ServerSocket(0)) { HTTP_PORT = socket.getLocalPort(); @@ -68,7 +67,7 @@ public int getHttpPort() { return HTTP_PORT; } - public IGenericClient newClient() { + public static IGenericClient newClient() { IGenericClient client = getFhirContext().newRestfulGenericClient(String.format("http://localhost:%d/", getHttpPort())); diff --git a/Src/java/engine-fhir/src/test/java/org/opencds/cqf/cql/engine/fhir/converter/ConverterTestUtils.java b/Src/java/engine-fhir/src/test/java/org/opencds/cqf/cql/engine/fhir/converter/ConverterTestUtils.java index 7635e3032..cafd1f3fd 100644 --- a/Src/java/engine-fhir/src/test/java/org/opencds/cqf/cql/engine/fhir/converter/ConverterTestUtils.java +++ b/Src/java/engine-fhir/src/test/java/org/opencds/cqf/cql/engine/fhir/converter/ConverterTestUtils.java @@ -3,7 +3,6 @@ import java.time.LocalDateTime; import java.time.Month; import java.time.format.DateTimeFormatter; -import org.testng.annotations.DataProvider; public class ConverterTestUtils { static final LocalDateTime DST_2022_11_01 = LocalDateTime.of(2022, Month.NOVEMBER, 1, 0, 0, 0); @@ -16,7 +15,6 @@ public class ConverterTestUtils { static final LocalDateTime NON_DST_2023_11_14 = LocalDateTime.of(2023, Month.NOVEMBER, 14, 0, 0, 0); static final DateTimeFormatter YYYY_MM_DD = DateTimeFormatter.ofPattern("yyyy-MM-dd"); - @DataProvider static Object[][] dateTimes() { return new Object[][] { {DST_2023_11_01, DST_2023_11_01, DST_2023_11_03}, @@ -26,7 +24,6 @@ static Object[][] dateTimes() { }; } - @DataProvider static Object[][] startAndEndTimes() { return new Object[][] { {DST_2023_11_01, DST_2023_11_03}, @@ -39,7 +36,6 @@ static Object[][] startAndEndTimes() { }; } - @DataProvider static Object[][] startAndEndYears() { return new Object[][] { {DST_2022_11_01, 2019, 2020}, @@ -49,7 +45,6 @@ static Object[][] startAndEndYears() { }; } - @DataProvider static Object[][] nowsAndEvaluationTimes() { return new Object[][] { {NON_DST_2022_01_01, NON_DST_2023_01_01}, diff --git a/Src/java/engine-fhir/src/test/java/org/opencds/cqf/cql/engine/fhir/converter/Dstu2TypeConverterTests.java b/Src/java/engine-fhir/src/test/java/org/opencds/cqf/cql/engine/fhir/converter/Dstu2TypeConverterTests.java index 378d46c15..44c468525 100644 --- a/Src/java/engine-fhir/src/test/java/org/opencds/cqf/cql/engine/fhir/converter/Dstu2TypeConverterTests.java +++ b/Src/java/engine-fhir/src/test/java/org/opencds/cqf/cql/engine/fhir/converter/Dstu2TypeConverterTests.java @@ -2,11 +2,12 @@ import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.instanceOf; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; import static org.opencds.cqf.cql.engine.fhir.converter.ConverterTestUtils.*; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertFalse; -import static org.testng.Assert.assertNull; -import static org.testng.Assert.assertTrue; import ca.uhn.fhir.model.api.TemporalPrecisionEnum; import java.math.BigDecimal; @@ -39,14 +40,15 @@ import org.hl7.fhir.instance.model.api.ICompositeType; import org.hl7.fhir.instance.model.api.IIdType; import org.hl7.fhir.instance.model.api.IPrimitiveType; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import org.opencds.cqf.cql.engine.runtime.*; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; -public class Dstu2TypeConverterTests { +class Dstu2TypeConverterTests { - private Dstu2FhirTypeConverter typeConverter; + private static Dstu2FhirTypeConverter typeConverter; protected Boolean compareIterables(Iterable left, Iterable right) { Iterator leftIterator = left.iterator(); @@ -94,73 +96,84 @@ protected Boolean compareObjects(Object left, Object right) { return left.equals(right); } - @BeforeClass - public void initialize() { - this.typeConverter = new Dstu2FhirTypeConverter(); + @BeforeAll + static void initialize() { + typeConverter = new Dstu2FhirTypeConverter(); } // CQL-to-FHIR @Test - public void TestIsFhirType() { - assertTrue(this.typeConverter.isFhirType(new Patient())); - assertTrue(this.typeConverter.isFhirType(new IdType())); - assertTrue(this.typeConverter.isFhirType(new org.hl7.fhir.dstu2.model.Quantity())); - assertTrue(this.typeConverter.isFhirType(new org.hl7.fhir.dstu2.model.Ratio())); - assertTrue(this.typeConverter.isFhirType(new BooleanType())); - assertTrue(this.typeConverter.isFhirType(new IntegerType())); - assertTrue(this.typeConverter.isFhirType(new DecimalType())); - assertTrue(this.typeConverter.isFhirType(new DateType())); - assertTrue(this.typeConverter.isFhirType(new InstantType())); - assertTrue(this.typeConverter.isFhirType(new DateTimeType())); - assertTrue(this.typeConverter.isFhirType(new TimeType())); - assertTrue(this.typeConverter.isFhirType(new StringType())); - assertTrue(this.typeConverter.isFhirType(new Coding())); - assertTrue(this.typeConverter.isFhirType(new CodeableConcept())); - assertTrue(this.typeConverter.isFhirType(new Period())); - assertTrue(this.typeConverter.isFhirType(new Range())); - - assertFalse(this.typeConverter.isFhirType(5)); - assertFalse(this.typeConverter.isFhirType(new BigDecimal(0))); - assertFalse(this.typeConverter.isFhirType(new Code())); + void isFhirType() { + assertTrue(typeConverter.isFhirType(new Patient())); + assertTrue(typeConverter.isFhirType(new IdType())); + assertTrue(typeConverter.isFhirType(new org.hl7.fhir.dstu2.model.Quantity())); + assertTrue(typeConverter.isFhirType(new org.hl7.fhir.dstu2.model.Ratio())); + assertTrue(typeConverter.isFhirType(new BooleanType())); + assertTrue(typeConverter.isFhirType(new IntegerType())); + assertTrue(typeConverter.isFhirType(new DecimalType())); + assertTrue(typeConverter.isFhirType(new DateType())); + assertTrue(typeConverter.isFhirType(new InstantType())); + assertTrue(typeConverter.isFhirType(new DateTimeType())); + assertTrue(typeConverter.isFhirType(new TimeType())); + assertTrue(typeConverter.isFhirType(new StringType())); + assertTrue(typeConverter.isFhirType(new Coding())); + assertTrue(typeConverter.isFhirType(new CodeableConcept())); + assertTrue(typeConverter.isFhirType(new Period())); + assertTrue(typeConverter.isFhirType(new Range())); + + assertFalse(typeConverter.isFhirType(5)); + assertFalse(typeConverter.isFhirType(new BigDecimal(0))); + assertFalse(typeConverter.isFhirType(new Code())); } - @Test(expectedExceptions = NullPointerException.class) - public void TestNullIsFhirType() { - this.typeConverter.isFhirType(null); + @Test + void nullIsFhirType() { + assertThrows(NullPointerException.class, () -> { + typeConverter.isFhirType(null); + }); } - @Test(expectedExceptions = IllegalArgumentException.class) - public void TestIterableIsFhirType() { - this.typeConverter.isFhirType(new ArrayList<>()); + @Test + void iterableIsFhirType() { + var value = new ArrayList<>(); + assertThrows(IllegalArgumentException.class, () -> { + typeConverter.isFhirType(value); + }); } @Test - public void TestToFhirType() { - IBase actual = this.typeConverter.toFhirType(new Code()); + void toFhirType() { + IBase actual = typeConverter.toFhirType(new Code()); assertThat(actual, instanceOf(Coding.class)); - actual = this.typeConverter.toFhirType(5); + actual = typeConverter.toFhirType(5); assertThat(actual, instanceOf(IntegerType.class)); - actual = this.typeConverter.toFhirType(new IdType()); + actual = typeConverter.toFhirType(new IdType()); assertThat(actual, instanceOf(IdType.class)); - actual = this.typeConverter.toFhirType(null); + actual = typeConverter.toFhirType(null); assertNull(null); } - @Test(expectedExceptions = IllegalArgumentException.class) - public void TestToFhirTypeIterable() { - this.typeConverter.toFhirType(new ArrayList<>()); + @Test + void toFhirTypeIterable() { + var value = new ArrayList<>(); + assertThrows(IllegalArgumentException.class, () -> { + typeConverter.toFhirType(value); + }); } - @Test(expectedExceptions = IllegalArgumentException.class) - public void TestToFhirTypeNotCql() { - this.typeConverter.toFhirType(ZoneOffset.ofHours(3)); + @Test + void toFhirTypeNotCql() { + var offset = ZoneOffset.ofHours(3); + assertThrows(IllegalArgumentException.class, () -> { + typeConverter.toFhirType(offset); + }); } @Test - public void TestToFhirTypes() { + void toFhirTypes() { List innerExpected = new ArrayList<>(); innerExpected.add(new StringType("123")); innerExpected.add(null); @@ -177,70 +190,70 @@ public void TestToFhirTypes() { test.add(null); test.add(5); - Iterable actual = this.typeConverter.toFhirTypes(test); + Iterable actual = typeConverter.toFhirTypes(test); assertTrue(compareIterables(expected, actual)); } @Test - public void TestStringToFhirId() { + void stringToFhirId() { IIdType expected = new IdType("123"); - IIdType actual = this.typeConverter.toFhirId("123"); + IIdType actual = typeConverter.toFhirId("123"); assertEquals(expected.getValue(), actual.getValue()); - actual = this.typeConverter.toFhirId(null); + actual = typeConverter.toFhirId(null); assertNull(actual); } @Test - public void TestPrimitiveCqlTypeToFhirType() { + void primitiveCqlTypeToFhirType() { IPrimitiveType expectedBoolean = new BooleanType(false); - IPrimitiveType actualBoolean = this.typeConverter.toFhirBoolean(false); + IPrimitiveType actualBoolean = typeConverter.toFhirBoolean(false); assertEquals(expectedBoolean.getValue(), actualBoolean.getValue()); - expectedBoolean = this.typeConverter.toFhirBoolean(null); + expectedBoolean = typeConverter.toFhirBoolean(null); assertNull(expectedBoolean); IPrimitiveType expectedInteger = new IntegerType(5); - IPrimitiveType actualInteger = this.typeConverter.toFhirInteger(5); + IPrimitiveType actualInteger = typeConverter.toFhirInteger(5); assertEquals(expectedInteger.getValue(), actualInteger.getValue()); - expectedInteger = this.typeConverter.toFhirInteger(null); + expectedInteger = typeConverter.toFhirInteger(null); assertNull(expectedInteger); IPrimitiveType expectedString = new StringType("5"); - IPrimitiveType actualString = this.typeConverter.toFhirString("5"); + IPrimitiveType actualString = typeConverter.toFhirString("5"); assertEquals(expectedString.getValue(), actualString.getValue()); - expectedString = this.typeConverter.toFhirString(null); + expectedString = typeConverter.toFhirString(null); assertNull(expectedString); IPrimitiveType expectedDecimal = new DecimalType(new BigDecimal(2.0)); - IPrimitiveType actualDecimal = this.typeConverter.toFhirDecimal(new BigDecimal(2.0)); + IPrimitiveType actualDecimal = typeConverter.toFhirDecimal(new BigDecimal(2.0)); assertEquals(expectedDecimal.getValue(), actualDecimal.getValue()); - expectedDecimal = this.typeConverter.toFhirDecimal(null); + expectedDecimal = typeConverter.toFhirDecimal(null); assertNull(expectedDecimal); } @Test - public void TestDateToFhirDate() { + void dateToFhirDate() { IPrimitiveType expectedDate = new DateType("2019-02-03"); - IPrimitiveType actualDate = this.typeConverter.toFhirDate(new Date("2019-02-03")); + IPrimitiveType actualDate = typeConverter.toFhirDate(new Date("2019-02-03")); assertEquals(expectedDate.getValue(), actualDate.getValue()); expectedDate = new DateType("2019"); - actualDate = this.typeConverter.toFhirDate(new Date("2019")); + actualDate = typeConverter.toFhirDate(new Date("2019")); assertEquals(expectedDate.getValue(), actualDate.getValue()); } - @DataProvider private static Object[][] nowsAndEvaluationTimes() { return ConverterTestUtils.nowsAndEvaluationTimes(); } - @Test(dataProvider = "nowsAndEvaluationTimes") - public void TestDateTimeToFhirDateTime(LocalDateTime now, LocalDateTime evaluationTime) { + @ParameterizedTest + @MethodSource("nowsAndEvaluationTimes") + void dateTimeToFhirDateTime(LocalDateTime now, LocalDateTime evaluationTime) { final ZonedDateTime zonedDateTime = ZonedDateTime.of(now, ZoneId.systemDefault()); final ZoneOffset defaultOffset = zonedDateTime.getOffset(); @@ -249,46 +262,44 @@ public void TestDateTimeToFhirDateTime(LocalDateTime now, LocalDateTime evaluati final String evalDate = DateTimeFormatter.ISO_DATE.format(evaluationTime); var expectedDate = new DateTimeType(evalTimeWithOffset); - IPrimitiveType actualDate = - this.typeConverter.toFhirDateTime(new DateTime(evalDate, defaultOffset)); + IPrimitiveType actualDate = typeConverter.toFhirDateTime(new DateTime(evalDate, defaultOffset)); assertEquals(expectedDate.getValue(), actualDate.getValue()); expectedDate = new DateTimeType(evalTimeWithOffset); - actualDate = this.typeConverter.toFhirDateTime(new DateTime("" + evaluationTime.getYear(), defaultOffset)); + actualDate = typeConverter.toFhirDateTime(new DateTime("" + evaluationTime.getYear(), defaultOffset)); expectedDate.setPrecision(TemporalPrecisionEnum.YEAR); assertEquals(expectedDate.getValue(), actualDate.getValue()); assertEquals(expectedDate.getValueAsString(), actualDate.getValueAsString()); } @Test - public void TestDateTimeToFhirDateTime_Timezones() { + void dateTimeToFhirDateTimeTimezones() { var expectedDate = new DateTimeType("2019-10-10T01:00:00-06:00"); ((DateTimeType) expectedDate).setTimeZone(TimeZone.getTimeZone("MST")); - var actualDate = this.typeConverter.toFhirDateTime(new DateTime("2019-10-10T00:00:00", ZoneOffset.ofHours(-7))); + var actualDate = typeConverter.toFhirDateTime(new DateTime("2019-10-10T00:00:00", ZoneOffset.ofHours(-7))); assertEquals(expectedDate.getValueAsString(), actualDate.getValueAsString()); expectedDate = new DateTimeType("2019-10-10T19:35:53.000Z"); ((DateTimeType) expectedDate).setPrecision(TemporalPrecisionEnum.MILLI); - actualDate = this.typeConverter.toFhirDateTime( + actualDate = typeConverter.toFhirDateTime( new DateTime("2019-10-10T19:35:53", ZoneOffset.UTC).withPrecision(Precision.MILLISECOND)); assertEquals(expectedDate.getValueAsString(), actualDate.getValueAsString()); } @Test - public void TestQuantityToFhirQuantity() { + void quantityToFhirQuantity() { org.hl7.fhir.dstu2.model.Quantity expected = new org.hl7.fhir.dstu2.model.Quantity() .setValue(new BigDecimal("2.0")) .setCode("ml") .setSystem("http://unitsofmeasure.org") .setUnit("ml"); - org.hl7.fhir.dstu2.model.Quantity actual = - (org.hl7.fhir.dstu2.model.Quantity) this.typeConverter.toFhirQuantity( - new Quantity().withValue(new BigDecimal("2.0")).withUnit("ml")); + org.hl7.fhir.dstu2.model.Quantity actual = (org.hl7.fhir.dstu2.model.Quantity) typeConverter.toFhirQuantity( + new Quantity().withValue(new BigDecimal("2.0")).withUnit("ml")); assertTrue(expected.equalsDeep(actual)); } @Test - public void TestRatioToFhirRatio() { + void ratioToFhirRatio() { org.hl7.fhir.dstu2.model.Quantity expectedNumerator = new org.hl7.fhir.dstu2.model.Quantity() .setValue(new BigDecimal("1.0")) .setCode("ml") @@ -309,50 +320,51 @@ public void TestRatioToFhirRatio() { testData.setDenominator( new Quantity().withValue(BigDecimal.valueOf(2.0)).withUnit("ml")); - org.hl7.fhir.dstu2.model.Ratio actual = - (org.hl7.fhir.dstu2.model.Ratio) this.typeConverter.toFhirRatio(testData); + org.hl7.fhir.dstu2.model.Ratio actual = (org.hl7.fhir.dstu2.model.Ratio) typeConverter.toFhirRatio(testData); assertTrue(expected.equalsDeep(actual)); } - @Test() - public void TestNullToFhirAny() { - IBase expected = this.typeConverter.toFhirAny(null); + @Test + void nullToFhirAny() { + IBase expected = typeConverter.toFhirAny(null); assertNull(expected); } - @Test(expectedExceptions = NotImplementedException.class) - public void TestObjectToFhirAny() { - this.typeConverter.toFhirAny("Huh"); + @Test + void objectToFhirAny() { + assertThrows(NotImplementedException.class, () -> { + typeConverter.toFhirAny("Huh"); + }); } @Test - public void TestCodeToFhirCoding() { + void codeToFhirCoding() { Coding expected = new Coding() .setSystem("http://the-system.com") .setCode("test") .setDisplay("system-test") .setVersion("1.5"); - Coding actual = (Coding) this.typeConverter.toFhirCoding(new Code() + Coding actual = (Coding) typeConverter.toFhirCoding(new Code() .withSystem("http://the-system.com") .withCode("test") .withDisplay("system-test") .withVersion("1.5")); assertTrue(expected.equalsDeep(actual)); - expected = (Coding) this.typeConverter.toFhirCoding(null); + expected = (Coding) typeConverter.toFhirCoding(null); assertNull(expected); } @Test - public void TestConceptToFhirCodeableConcept() { + void conceptToFhirCodeableConcept() { CodeableConcept expected = new CodeableConcept(new Coding() .setSystem("http://the-system.com") .setCode("test") .setDisplay("system-test") .setVersion("1.5")) .setText("additional-text"); - CodeableConcept actual = (CodeableConcept) this.typeConverter.toFhirCodeableConcept(new Concept() + CodeableConcept actual = (CodeableConcept) typeConverter.toFhirCodeableConcept(new Concept() .withCode(new Code() .withSystem("http://the-system.com") .withCode("test") @@ -361,36 +373,35 @@ public void TestConceptToFhirCodeableConcept() { .withDisplay("additional-text")); assertTrue(expected.equalsDeep(actual)); - expected = (CodeableConcept) this.typeConverter.toFhirCodeableConcept(null); + expected = (CodeableConcept) typeConverter.toFhirCodeableConcept(null); assertNull(expected); } - @DataProvider private static Object[][] startAndEndTimes() { return ConverterTestUtils.startAndEndTimes(); } - @Test(dataProvider = "startAndEndTimes") - public void TestIntervalToFhirPeriod_yyyyMMdd(LocalDateTime startTime, LocalDateTime endTime) { + @ParameterizedTest + @MethodSource("startAndEndTimes") + void intervalToFhirPeriodYyyyMMdd(LocalDateTime startTime, LocalDateTime endTime) { final String startTime_yyyyMMdd = YYYY_MM_DD.format(startTime); final String endTime_yyyyMMdd = YYYY_MM_DD.format(endTime); final Period expected = new Period() .setStartElement(new DateTimeType(startTime_yyyyMMdd)) .setEndElement(new DateTimeType(endTime_yyyyMMdd)); - final Period actual = (Period) this.typeConverter.toFhirPeriod( + final Period actual = (Period) typeConverter.toFhirPeriod( new Interval(new Date(startTime_yyyyMMdd), true, new Date(endTime_yyyyMMdd), true)); assertTrue(expected.equalsDeep(actual)); } - @DataProvider private static Object[][] dateTimes() { return ConverterTestUtils.dateTimes(); } - @Test(dataProvider = "dateTimes") - public void TestIntervalToFhirPeriod_timestampWithOffsets( - LocalDateTime now, LocalDateTime startTime, LocalDateTime endTime) { + @ParameterizedTest + @MethodSource("dateTimes") + void intervalToFhirPeriodTimestampWithOffsets(LocalDateTime now, LocalDateTime startTime, LocalDateTime endTime) { final ZonedDateTime zonedDateTime = ZonedDateTime.of(now, ZoneId.systemDefault()); final ZoneOffset defaultOffset = zonedDateTime.getOffset(); @@ -407,41 +418,44 @@ public void TestIntervalToFhirPeriod_timestampWithOffsets( final DateTime dateTimeStart = new DateTime(startTimeNoOffset, defaultOffset); final DateTime dateTimeEnd = new DateTime(endTimeNoOffset, defaultOffset); final Interval intervalStartEnd = new Interval(dateTimeStart, true, dateTimeEnd, true); - var actual = (Period) this.typeConverter.toFhirPeriod(intervalStartEnd); + var actual = (Period) typeConverter.toFhirPeriod(intervalStartEnd); assertTrue(expected.equalsDeep(actual)); } - @DataProvider private static Object[][] startAndEndYears() { return ConverterTestUtils.startAndEndYears(); } - @Test(dataProvider = "startAndEndYears") - public void TestIntervalToFhirPeriod_startAndEndYears(LocalDateTime now, int startYear, int endYear) { + @ParameterizedTest + @MethodSource("startAndEndYears") + void intervalToFhirPeriodStartAndEndYears(LocalDateTime now, int startYear, int endYear) { final ZonedDateTime zonedDateTime = ZonedDateTime.of(now, ZoneId.systemDefault()); final ZoneOffset defaultOffset = zonedDateTime.getOffset(); final Period expected = new Period() .setStartElement(new DateTimeType(startYear + "-01-01T00:00:00" + defaultOffset)) .setEndElement(new DateTimeType(endYear + "-01-01T00:00:00" + defaultOffset)); - final Period actual = (Period) this.typeConverter.toFhirPeriod(new Interval( + final Period actual = (Period) typeConverter.toFhirPeriod(new Interval( new DateTime("" + startYear, defaultOffset), true, new DateTime("" + endYear, defaultOffset), true)); assertTrue(expected.equalsDeep(actual)); } @Test - public void TestIntervalToFhirPeriod_null() { - assertNull(this.typeConverter.toFhirPeriod(null)); + void intervalToFhirPeriodNull() { + assertNull(typeConverter.toFhirPeriod(null)); } - @Test(expectedExceptions = IllegalArgumentException.class) - public void TestInvalidIntervalToFhirPeriod() { - this.typeConverter.toFhirPeriod(new Interval(5, true, 6, true)); + @Test + void invalidIntervalToFhirPeriod() { + var interval = new Interval(5, true, 6, true); + assertThrows(IllegalArgumentException.class, () -> { + typeConverter.toFhirPeriod(interval); + }); } @Test - public void TestIntervalToFhirRange() { + void intervalToFhirRange() { Range expected = new Range() .setLow((SimpleQuantity) new org.hl7.fhir.dstu2.model.SimpleQuantity() .setValue(new BigDecimal("2.0")) @@ -451,29 +465,32 @@ public void TestIntervalToFhirRange() { .setValue(new BigDecimal("5.0")) .setCode("ml") .setSystem("http://unitsofmeasure.org")); - Range actual = (Range) this.typeConverter.toFhirRange(new Interval( + Range actual = (Range) typeConverter.toFhirRange(new Interval( new Quantity().withValue(new BigDecimal("2.0")).withUnit("ml"), true, new Quantity().withValue(new BigDecimal("5.0")).withUnit("ml"), true)); assertTrue(expected.equalsDeep(actual)); - actual = (Range) this.typeConverter.toFhirRange(null); + actual = (Range) typeConverter.toFhirRange(null); assertNull(null); } - @Test(expectedExceptions = IllegalArgumentException.class) - public void TestInvalidIntervalToFhirRange() { - this.typeConverter.toFhirRange(new Interval(5, true, 6, true)); + @Test + void invalidIntervalToFhirRange() { + var interval = new Interval(5, true, 6, true); + assertThrows(IllegalArgumentException.class, () -> { + typeConverter.toFhirRange(interval); + }); } @Test - public void TestIntervalToFhirInterval() { + void intervalToFhirInterval() { Period expectedPeriod = new Period() .setStartElement(new DateTimeType("2019-02-03")) .setEndElement(new DateTimeType("2019-02-05")); - Period actualPeriod = (Period) this.typeConverter.toFhirInterval( - new Interval(new Date("2019-02-03"), true, new Date("2019-02-05"), true)); + Period actualPeriod = (Period) + typeConverter.toFhirInterval(new Interval(new Date("2019-02-03"), true, new Date("2019-02-05"), true)); assertTrue(expectedPeriod.equalsDeep(actualPeriod)); Range expectedRange = new Range() @@ -485,100 +502,107 @@ public void TestIntervalToFhirInterval() { .setValue(new BigDecimal("5.0")) .setCode("ml") .setSystem("http://unitsofmeasure.org")); - Range actualRange = (Range) this.typeConverter.toFhirInterval(new Interval( + Range actualRange = (Range) typeConverter.toFhirInterval(new Interval( new Quantity().withValue(new BigDecimal("2.0")).withUnit("ml"), true, new Quantity().withValue(new BigDecimal("5.0")).withUnit("ml"), true)); assertTrue(expectedRange.equalsDeep(actualRange)); - ICompositeType expected = this.typeConverter.toFhirInterval(null); + ICompositeType expected = typeConverter.toFhirInterval(null); assertNull(expected); } - @Test(expectedExceptions = IllegalArgumentException.class) - public void TestInvalidIntervalToFhirInterval() { - this.typeConverter.toFhirInterval(new Interval(5, true, 6, true)); + @Test + void invalidIntervalToFhirInterval() { + var interval = new Interval(5, true, 6, true); + + assertThrows(IllegalArgumentException.class, () -> { + typeConverter.toFhirInterval(interval); + }); } - @Test(expectedExceptions = NotImplementedException.class) - public void TestTupleToFhirTuple() { - IBase expected = this.typeConverter.toFhirTuple(null); + @Test + void tupleToFhirTuple() { + IBase expected = typeConverter.toFhirTuple(null); assertNull(expected); - this.typeConverter.toFhirTuple(new Tuple()); + var tuple = new Tuple(); + assertThrows(NotImplementedException.class, () -> { + typeConverter.toFhirTuple(tuple); + }); } // FHIR-to-CQL @Test - public void TestIsCqlType() { - assertTrue(this.typeConverter.isCqlType(5)); - assertTrue(this.typeConverter.isCqlType(new BigDecimal(0))); - assertTrue(this.typeConverter.isCqlType(new Code())); + void isCqlType() { + assertTrue(typeConverter.isCqlType(5)); + assertTrue(typeConverter.isCqlType(new BigDecimal(0))); + assertTrue(typeConverter.isCqlType(new Code())); - assertFalse(this.typeConverter.isCqlType(new Patient())); - assertFalse(this.typeConverter.isCqlType(new IdType())); + assertFalse(typeConverter.isCqlType(new Patient())); + assertFalse(typeConverter.isCqlType(new IdType())); } - @Test(expectedExceptions = NullPointerException.class) - public void TestNullIsCqlType() { - this.typeConverter.isCqlType(null); + @Test + void nullIsCqlType() { + assertThrows(NullPointerException.class, () -> typeConverter.isCqlType(null)); } - @Test(expectedExceptions = IllegalArgumentException.class) - public void TestIterableIsCqlType() { - this.typeConverter.isCqlType(new ArrayList<>()); + @Test + void iterableIsCqlType() { + var value = new ArrayList<>(); + assertThrows(IllegalArgumentException.class, () -> typeConverter.isCqlType(value)); } @Test - public void TestToCqlType() { - Object actual = this.typeConverter.toCqlType(new Code()); + void toCqlType() { + Object actual = typeConverter.toCqlType(new Code()); assertThat(actual, instanceOf(Code.class)); - actual = this.typeConverter.toCqlType(new IntegerType(5)); + actual = typeConverter.toCqlType(new IntegerType(5)); assertThat(actual, instanceOf(Integer.class)); - actual = this.typeConverter.toCqlType(new StringType("test")); + actual = typeConverter.toCqlType(new StringType("test")); assertThat(actual, instanceOf(String.class)); - actual = this.typeConverter.toCqlType(new IdType("test")); + actual = typeConverter.toCqlType(new IdType("test")); assertThat(actual, instanceOf(String.class)); - actual = this.typeConverter.toCqlType(new BooleanType(true)); + actual = typeConverter.toCqlType(new BooleanType(true)); assertThat(actual, instanceOf(Boolean.class)); - actual = this.typeConverter.toCqlType(new DecimalType(1.0)); + actual = typeConverter.toCqlType(new DecimalType(1.0)); assertThat(actual, instanceOf(BigDecimal.class)); - actual = - this.typeConverter.toCqlType(new DateType(Calendar.getInstance().getTime())); + actual = typeConverter.toCqlType(new DateType(Calendar.getInstance().getTime())); assertThat(actual, instanceOf(Date.class)); - actual = this.typeConverter.toCqlType(new InstantType(Calendar.getInstance())); + actual = typeConverter.toCqlType(new InstantType(Calendar.getInstance())); assertThat(actual, instanceOf(DateTime.class)); - actual = this.typeConverter.toCqlType(new DateTimeType(Calendar.getInstance())); + actual = typeConverter.toCqlType(new DateTimeType(Calendar.getInstance())); assertThat(actual, instanceOf(DateTime.class)); - actual = this.typeConverter.toCqlType(new TimeType("10:00:00.0000")); + actual = typeConverter.toCqlType(new TimeType("10:00:00.0000")); assertThat(actual, instanceOf(Time.class)); - actual = this.typeConverter.toCqlType(new StringType("test")); + actual = typeConverter.toCqlType(new StringType("test")); assertThat(actual, instanceOf(String.class)); - actual = this.typeConverter.toCqlType(new org.hl7.fhir.dstu2.model.Quantity()); + actual = typeConverter.toCqlType(new org.hl7.fhir.dstu2.model.Quantity()); assertThat(actual, instanceOf(Quantity.class)); - actual = this.typeConverter.toCqlType(new org.hl7.fhir.dstu2.model.Ratio()); + actual = typeConverter.toCqlType(new org.hl7.fhir.dstu2.model.Ratio()); assertThat(actual, instanceOf(Ratio.class)); - actual = this.typeConverter.toCqlType(new Coding()); + actual = typeConverter.toCqlType(new Coding()); assertThat(actual, instanceOf(Code.class)); - actual = this.typeConverter.toCqlType(new CodeableConcept()); + actual = typeConverter.toCqlType(new CodeableConcept()); assertThat(actual, instanceOf(Concept.class)); - actual = this.typeConverter.toCqlType(new Period() + actual = typeConverter.toCqlType(new Period() .setStart(Calendar.getInstance().getTime()) .setEnd(Calendar.getInstance().getTime())); assertThat(actual, instanceOf(Interval.class)); @@ -590,25 +614,30 @@ public void TestToCqlType() { SimpleQuantity high = new SimpleQuantity(); high.setValue(BigDecimal.valueOf(4.0)); high.setUnit("d"); - actual = this.typeConverter.toCqlType(new Range().setLow(low).setHigh(high)); + actual = typeConverter.toCqlType(new Range().setLow(low).setHigh(high)); assertThat(actual, instanceOf(Interval.class)); - actual = this.typeConverter.toCqlType(null); + actual = typeConverter.toCqlType(null); assertNull(null); } - @Test(expectedExceptions = IllegalArgumentException.class) - public void TestToCqlTypeIterable() { - this.typeConverter.toCqlType(new ArrayList<>()); + @Test + void toCqlTypeIterable() { + assertThrows(IllegalArgumentException.class, () -> { + typeConverter.toCqlType(new ArrayList<>()); + }); } - @Test(expectedExceptions = IllegalArgumentException.class) - public void TestToCqlTypeNotCql() { - this.typeConverter.toCqlType(ZoneOffset.ofHours(3)); + @Test + void toCqlTypeNotCql() { + var offset = ZoneOffset.ofHours(3); + assertThrows(IllegalArgumentException.class, () -> { + typeConverter.toCqlType(offset); + }); } @Test - public void TestToCqlTypes() { + void toCqlTypes() { List innerExpected = new ArrayList<>(); innerExpected.add("123"); @@ -626,82 +655,82 @@ public void TestToCqlTypes() { test.add(null); test.add(new IntegerType(5)); - Iterable actual = this.typeConverter.toCqlTypes(test); + Iterable actual = typeConverter.toCqlTypes(test); assertTrue(compareIterables(expected, actual)); } @Test - public void TestStringToCqlId() { + void stringToCqlId() { String expected = "123"; - String actual = this.typeConverter.toCqlId(new IdType("123")); + String actual = typeConverter.toCqlId(new IdType("123")); assertEquals(expected, actual); - actual = this.typeConverter.toCqlId(null); + actual = typeConverter.toCqlId(null); assertNull(actual); } @Test - public void TestPrimitiveFhirTypeToCqlType() { + void primitiveFhirTypeToCqlType() { Boolean expectedBoolean = false; - Boolean actualBoolean = this.typeConverter.toCqlBoolean(new BooleanType(false)); + Boolean actualBoolean = typeConverter.toCqlBoolean(new BooleanType(false)); assertEquals(expectedBoolean, actualBoolean); - expectedBoolean = this.typeConverter.toCqlBoolean(null); + expectedBoolean = typeConverter.toCqlBoolean(null); assertNull(expectedBoolean); Integer expectedInteger = 5; - Integer actualInteger = this.typeConverter.toCqlInteger(new IntegerType(5)); + Integer actualInteger = typeConverter.toCqlInteger(new IntegerType(5)); assertEquals(expectedInteger, actualInteger); - expectedInteger = this.typeConverter.toCqlInteger(null); + expectedInteger = typeConverter.toCqlInteger(null); assertNull(expectedInteger); String expectedString = "5"; - String actualString = this.typeConverter.toCqlString(new StringType("5")); + String actualString = typeConverter.toCqlString(new StringType("5")); assertEquals(expectedString, actualString); - expectedString = this.typeConverter.toCqlString(null); + expectedString = typeConverter.toCqlString(null); assertNull(expectedString); BigDecimal expectedDecimal = new BigDecimal(2.0); - BigDecimal actualDecimal = this.typeConverter.toCqlDecimal(new DecimalType(new BigDecimal(2.0))); + BigDecimal actualDecimal = typeConverter.toCqlDecimal(new DecimalType(new BigDecimal(2.0))); assertEquals(expectedDecimal, actualDecimal); - expectedDecimal = this.typeConverter.toCqlDecimal(null); + expectedDecimal = typeConverter.toCqlDecimal(null); assertNull(expectedDecimal); } @Test - public void TestDateToCqlType() { + void dateToCqlType() { Date expectedDate = new Date("2019-02-03"); - Date actualDate = this.typeConverter.toCqlDate(new org.hl7.fhir.dstu2.model.DateType("2019-02-03")); + Date actualDate = typeConverter.toCqlDate(new org.hl7.fhir.dstu2.model.DateType("2019-02-03")); assertTrue(expectedDate.equal(actualDate)); expectedDate = new Date("2019"); - actualDate = this.typeConverter.toCqlDate(new DateType("2019")); + actualDate = typeConverter.toCqlDate(new DateType("2019")); assertTrue(expectedDate.equal(actualDate)); } @Test - public void TestDateTimeToCqlType() { + void dateTimeToCqlType() { DateTime expectedDate = new DateTime("2019-02-03", ZoneOffset.UTC); - DateTime actualDate = this.typeConverter.toCqlDateTime(new DateTimeType("2019-02-03")); + DateTime actualDate = typeConverter.toCqlDateTime(new DateTimeType("2019-02-03")); assertTrue(expectedDate.equal(actualDate)); expectedDate = new DateTime("2019", ZoneOffset.UTC); - actualDate = this.typeConverter.toCqlDateTime(new DateTimeType("2019")); + actualDate = typeConverter.toCqlDateTime(new DateTimeType("2019")); assertTrue(expectedDate.equal(actualDate)); expectedDate = new DateTime("2019", ZoneOffset.UTC); - actualDate = this.typeConverter.toCqlDateTime(new DateTimeType("2019")); + actualDate = typeConverter.toCqlDateTime(new DateTimeType("2019")); assertTrue(expectedDate.equal(actualDate)); } @Test - public void TestQuantityToCqlType() { + void quantityToCqlType() { Quantity expected = (new Quantity().withValue(new BigDecimal("2.0")).withUnit("ml")); - Quantity actual = this.typeConverter.toCqlQuantity(new org.hl7.fhir.dstu2.model.Quantity() + Quantity actual = typeConverter.toCqlQuantity(new org.hl7.fhir.dstu2.model.Quantity() .setValue(new BigDecimal("2.0")) .setUnit("ml") .setSystem("http://unitsofmeasure.org")); @@ -709,7 +738,7 @@ public void TestQuantityToCqlType() { } @Test - public void TestRatioToCqlType() { + void ratioToCqlType() { Ratio expected = new Ratio(); expected.setNumerator(new Quantity().withValue(BigDecimal.valueOf(1.0)).withUnit("ml")); expected.setDenominator( @@ -727,41 +756,44 @@ public void TestRatioToCqlType() { org.hl7.fhir.dstu2.model.Ratio test = new org.hl7.fhir.dstu2.model.Ratio().setNumerator(testNumerator).setDenominator(testDenominator); - Ratio actual = this.typeConverter.toCqlRatio(test); + Ratio actual = typeConverter.toCqlRatio(test); assertTrue(expected.equal(actual)); } - @Test() - public void TestNullToCqlType() { - Object expected = this.typeConverter.toCqlAny(null); + @Test + void nullToCqlType() { + Object expected = typeConverter.toCqlAny(null); assertNull(expected); } - @Test(expectedExceptions = NotImplementedException.class) - public void TestObjectToCqlType() { - this.typeConverter.toCqlAny(new IdType()); + @Test + void objectToCqlType() { + var id = new IdType(); + assertThrows(NotImplementedException.class, () -> { + typeConverter.toCqlAny(id); + }); } @Test - public void TestCodingToCqlCode() { + void codingToCqlCode() { Code expected = new Code() .withSystem("http://the-system.com") .withCode("test") .withDisplay("system-test") .withVersion("1.5"); - Code actual = this.typeConverter.toCqlCode(new Coding() + Code actual = typeConverter.toCqlCode(new Coding() .setSystem("http://the-system.com") .setCode("test") .setDisplay("system-test") .setVersion("1.5")); assertTrue(expected.equal(actual)); - expected = this.typeConverter.toCqlCode(null); + expected = typeConverter.toCqlCode(null); assertNull(expected); } @Test - public void TestCodeableConceptToCqlConcept() { + void codeableConceptToCqlConcept() { Concept expected = new Concept() .withCode(new Code() .withSystem("http://the-system.com") @@ -769,7 +801,7 @@ public void TestCodeableConceptToCqlConcept() { .withDisplay("system-test") .withVersion("1.5")) .withDisplay("additional-text"); - Concept actual = this.typeConverter.toCqlConcept(new CodeableConcept(new Coding() + Concept actual = typeConverter.toCqlConcept(new CodeableConcept(new Coding() .setSystem("http://the-system.com") .setCode("test") .setDisplay("system-test") @@ -778,20 +810,20 @@ public void TestCodeableConceptToCqlConcept() { assertTrue(expected.equal(actual)); - expected = this.typeConverter.toCqlConcept(null); + expected = typeConverter.toCqlConcept(null); assertNull(expected); } @Test - public void TestPeriodToCqlInterval() { + void periodToCqlInterval() { Interval expected = new Interval(new Date("2019-02-03"), true, new Date("2019-02-05"), true); - Interval actual = this.typeConverter.toCqlInterval(new Period() + Interval actual = typeConverter.toCqlInterval(new Period() .setStartElement(new DateTimeType("2019-02-03")) .setEndElement(new DateTimeType("2019-02-05"))); assertTrue(expected.equal(actual)); expected = new Interval(new Date("2019"), true, new Date("2020"), true); - actual = this.typeConverter.toCqlInterval( + actual = typeConverter.toCqlInterval( new Period().setStartElement(new DateTimeType("2019")).setEndElement(new DateTimeType("2020"))); assertTrue(expected.equal(actual)); @@ -800,23 +832,23 @@ public void TestPeriodToCqlInterval() { true, new DateTime("2020-09-18T19:37:00", ZoneOffset.UTC), true); - actual = this.typeConverter.toCqlInterval(new Period() + actual = typeConverter.toCqlInterval(new Period() .setStartElement(new DateTimeType("2020-09-18T19:35:53+00:00")) .setEndElement(new DateTimeType("2020-09-18T19:37:00+00:00"))); assertTrue(expected.equal(actual)); - actual = this.typeConverter.toCqlInterval(null); + actual = typeConverter.toCqlInterval(null); assertNull(null); } @Test - public void TestRangeToCqlInterval() { + void rangeToCqlInterval() { Interval expected = new Interval( new Quantity().withValue(new BigDecimal("2.0")).withUnit("ml"), true, new Quantity().withValue(new BigDecimal("5.0")).withUnit("ml"), true); - Interval actual = this.typeConverter.toCqlInterval(new Range() + Interval actual = typeConverter.toCqlInterval(new Range() .setLow((SimpleQuantity) new org.hl7.fhir.dstu2.model.SimpleQuantity() .setValue(new BigDecimal("2.0")) .setUnit("ml") @@ -827,20 +859,26 @@ public void TestRangeToCqlInterval() { .setSystem("http://unitsofmeasure.org"))); assertTrue(expected.equal(actual)); - actual = this.typeConverter.toCqlInterval(null); + actual = typeConverter.toCqlInterval(null); assertNull(null); } - @Test(expectedExceptions = IllegalArgumentException.class) - public void TestInvalidTypeToCqlInterval() { - this.typeConverter.toCqlInterval(new Attachment()); + @Test + void invalidTypeToCqlInterval() { + var attachment = new Attachment(); + assertThrows(IllegalArgumentException.class, () -> { + typeConverter.toCqlInterval(attachment); + }); } - @Test(expectedExceptions = NotImplementedException.class) - public void TestTupleToCqlTuple() { - Object expected = this.typeConverter.toCqlTuple(null); + @Test + void tupleToCqlTuple() { + Object expected = typeConverter.toCqlTuple(null); assertNull(expected); - this.typeConverter.toCqlTuple(new Patient()); + var p = new Patient(); + assertThrows(NotImplementedException.class, () -> { + typeConverter.toCqlTuple(p); + }); } } diff --git a/Src/java/engine-fhir/src/test/java/org/opencds/cqf/cql/engine/fhir/converter/Dstu3TypeConverterTests.java b/Src/java/engine-fhir/src/test/java/org/opencds/cqf/cql/engine/fhir/converter/Dstu3TypeConverterTests.java index b5cbd7d32..61cdc6519 100644 --- a/Src/java/engine-fhir/src/test/java/org/opencds/cqf/cql/engine/fhir/converter/Dstu3TypeConverterTests.java +++ b/Src/java/engine-fhir/src/test/java/org/opencds/cqf/cql/engine/fhir/converter/Dstu3TypeConverterTests.java @@ -2,11 +2,12 @@ import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.instanceOf; -import static org.opencds.cqf.cql.engine.fhir.converter.ConverterTestUtils.YYYY_MM_DD; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertFalse; -import static org.testng.Assert.assertNull; -import static org.testng.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.opencds.cqf.cql.engine.fhir.converter.ConverterTestUtils.*; import ca.uhn.fhir.model.api.TemporalPrecisionEnum; import java.math.BigDecimal; @@ -18,7 +19,6 @@ import java.util.List; import java.util.TimeZone; import org.apache.commons.lang3.NotImplementedException; -import org.hl7.fhir.dstu2.model.IdType; import org.hl7.fhir.dstu3.model.Attachment; import org.hl7.fhir.dstu3.model.Base; import org.hl7.fhir.dstu3.model.BooleanType; @@ -27,6 +27,7 @@ import org.hl7.fhir.dstu3.model.DateTimeType; import org.hl7.fhir.dstu3.model.DateType; import org.hl7.fhir.dstu3.model.DecimalType; +import org.hl7.fhir.dstu3.model.IdType; import org.hl7.fhir.dstu3.model.InstantType; import org.hl7.fhir.dstu3.model.IntegerType; import org.hl7.fhir.dstu3.model.Patient; @@ -39,24 +40,15 @@ import org.hl7.fhir.instance.model.api.ICompositeType; import org.hl7.fhir.instance.model.api.IIdType; import org.hl7.fhir.instance.model.api.IPrimitiveType; -import org.opencds.cqf.cql.engine.runtime.Code; -import org.opencds.cqf.cql.engine.runtime.Concept; -import org.opencds.cqf.cql.engine.runtime.CqlType; -import org.opencds.cqf.cql.engine.runtime.Date; -import org.opencds.cqf.cql.engine.runtime.DateTime; -import org.opencds.cqf.cql.engine.runtime.Interval; -import org.opencds.cqf.cql.engine.runtime.Precision; -import org.opencds.cqf.cql.engine.runtime.Quantity; -import org.opencds.cqf.cql.engine.runtime.Ratio; -import org.opencds.cqf.cql.engine.runtime.Time; -import org.opencds.cqf.cql.engine.runtime.Tuple; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; - -public class Dstu3TypeConverterTests { - - private Dstu3FhirTypeConverter typeConverter; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; +import org.opencds.cqf.cql.engine.runtime.*; + +class Dstu3TypeConverterTests { + + private static Dstu3FhirTypeConverter typeConverter; protected Boolean compareIterables(Iterable left, Iterable right) { Iterator leftIterator = left.iterator(); @@ -104,73 +96,84 @@ protected Boolean compareObjects(Object left, Object right) { return left.equals(right); } - @BeforeClass - public void initialize() { - this.typeConverter = new Dstu3FhirTypeConverter(); + @BeforeAll + static void initialize() { + typeConverter = new Dstu3FhirTypeConverter(); } // CQL-to-FHIR @Test - public void TestIsFhirType() { - assertTrue(this.typeConverter.isFhirType(new Patient())); - assertTrue(this.typeConverter.isFhirType(new IdType())); - assertTrue(this.typeConverter.isFhirType(new org.hl7.fhir.dstu3.model.Quantity())); - assertTrue(this.typeConverter.isFhirType(new org.hl7.fhir.dstu3.model.Ratio())); - assertTrue(this.typeConverter.isFhirType(new BooleanType())); - assertTrue(this.typeConverter.isFhirType(new IntegerType())); - assertTrue(this.typeConverter.isFhirType(new DecimalType())); - assertTrue(this.typeConverter.isFhirType(new DateType())); - assertTrue(this.typeConverter.isFhirType(new InstantType())); - assertTrue(this.typeConverter.isFhirType(new DateTimeType())); - assertTrue(this.typeConverter.isFhirType(new TimeType())); - assertTrue(this.typeConverter.isFhirType(new StringType())); - assertTrue(this.typeConverter.isFhirType(new Coding())); - assertTrue(this.typeConverter.isFhirType(new CodeableConcept())); - assertTrue(this.typeConverter.isFhirType(new Period())); - assertTrue(this.typeConverter.isFhirType(new Range())); - - assertFalse(this.typeConverter.isFhirType(5)); - assertFalse(this.typeConverter.isFhirType(new BigDecimal(0))); - assertFalse(this.typeConverter.isFhirType(new Code())); + void isFhirType() { + assertTrue(typeConverter.isFhirType(new Patient())); + assertTrue(typeConverter.isFhirType(new IdType())); + assertTrue(typeConverter.isFhirType(new org.hl7.fhir.dstu3.model.Quantity())); + assertTrue(typeConverter.isFhirType(new org.hl7.fhir.dstu3.model.Ratio())); + assertTrue(typeConverter.isFhirType(new BooleanType())); + assertTrue(typeConverter.isFhirType(new IntegerType())); + assertTrue(typeConverter.isFhirType(new DecimalType())); + assertTrue(typeConverter.isFhirType(new DateType())); + assertTrue(typeConverter.isFhirType(new InstantType())); + assertTrue(typeConverter.isFhirType(new DateTimeType())); + assertTrue(typeConverter.isFhirType(new TimeType())); + assertTrue(typeConverter.isFhirType(new StringType())); + assertTrue(typeConverter.isFhirType(new Coding())); + assertTrue(typeConverter.isFhirType(new CodeableConcept())); + assertTrue(typeConverter.isFhirType(new Period())); + assertTrue(typeConverter.isFhirType(new Range())); + + assertFalse(typeConverter.isFhirType(5)); + assertFalse(typeConverter.isFhirType(new BigDecimal(0))); + assertFalse(typeConverter.isFhirType(new Code())); } - @Test(expectedExceptions = NullPointerException.class) - public void TestNullIsFhirType() { - this.typeConverter.isFhirType(null); + @Test + void nullIsFhirType() { + assertThrows(NullPointerException.class, () -> { + typeConverter.isFhirType(null); + }); } - @Test(expectedExceptions = IllegalArgumentException.class) - public void TestIterableIsFhirType() { - this.typeConverter.isFhirType(new ArrayList<>()); + @Test + void iterableIsFhirType() { + var value = new ArrayList<>(); + assertThrows(IllegalArgumentException.class, () -> { + typeConverter.isFhirType(value); + }); } @Test - public void TestToFhirType() { - IBase actual = this.typeConverter.toFhirType(new Code()); + void toFhirType() { + IBase actual = typeConverter.toFhirType(new Code()); assertThat(actual, instanceOf(Coding.class)); - actual = this.typeConverter.toFhirType(5); + actual = typeConverter.toFhirType(5); assertThat(actual, instanceOf(IntegerType.class)); - actual = this.typeConverter.toFhirType(new IdType()); + actual = typeConverter.toFhirType(new IdType()); assertThat(actual, instanceOf(IdType.class)); - actual = this.typeConverter.toFhirType(null); + actual = typeConverter.toFhirType(null); assertNull(null); } - @Test(expectedExceptions = IllegalArgumentException.class) - public void TestToFhirTypeIterable() { - this.typeConverter.toFhirType(new ArrayList<>()); + @Test + void toFhirTypeIterable() { + var value = new ArrayList<>(); + assertThrows(IllegalArgumentException.class, () -> { + typeConverter.toFhirType(value); + }); } - @Test(expectedExceptions = IllegalArgumentException.class) - public void TestToFhirTypeNotCql() { - this.typeConverter.toFhirType(ZoneOffset.ofHours(3)); + @Test + void toFhirTypeNotCql() { + var offset = ZoneOffset.ofHours(3); + assertThrows(IllegalArgumentException.class, () -> { + typeConverter.toFhirType(offset); + }); } @Test - public void TestToFhirTypes() { + void toFhirTypes() { List innerExpected = new ArrayList<>(); innerExpected.add(new StringType("123")); innerExpected.add(null); @@ -187,70 +190,70 @@ public void TestToFhirTypes() { test.add(null); test.add(5); - Iterable actual = this.typeConverter.toFhirTypes(test); + Iterable actual = typeConverter.toFhirTypes(test); assertTrue(compareIterables(expected, actual)); } @Test - public void TestStringToFhirId() { + void stringToFhirId() { IIdType expected = new IdType("123"); - IIdType actual = this.typeConverter.toFhirId("123"); + IIdType actual = typeConverter.toFhirId("123"); assertEquals(expected.getValue(), actual.getValue()); - actual = this.typeConverter.toFhirId(null); + actual = typeConverter.toFhirId(null); assertNull(actual); } @Test - public void TestPrimitiveCqlTypeToFhirType() { + void primitiveCqlTypeToFhirType() { IPrimitiveType expectedBoolean = new BooleanType(false); - IPrimitiveType actualBoolean = this.typeConverter.toFhirBoolean(false); + IPrimitiveType actualBoolean = typeConverter.toFhirBoolean(false); assertEquals(expectedBoolean.getValue(), actualBoolean.getValue()); - expectedBoolean = this.typeConverter.toFhirBoolean(null); + expectedBoolean = typeConverter.toFhirBoolean(null); assertNull(expectedBoolean); IPrimitiveType expectedInteger = new IntegerType(5); - IPrimitiveType actualInteger = this.typeConverter.toFhirInteger(5); + IPrimitiveType actualInteger = typeConverter.toFhirInteger(5); assertEquals(expectedInteger.getValue(), actualInteger.getValue()); - expectedInteger = this.typeConverter.toFhirInteger(null); + expectedInteger = typeConverter.toFhirInteger(null); assertNull(expectedInteger); IPrimitiveType expectedString = new StringType("5"); - IPrimitiveType actualString = this.typeConverter.toFhirString("5"); + IPrimitiveType actualString = typeConverter.toFhirString("5"); assertEquals(expectedString.getValue(), actualString.getValue()); - expectedString = this.typeConverter.toFhirString(null); + expectedString = typeConverter.toFhirString(null); assertNull(expectedString); IPrimitiveType expectedDecimal = new DecimalType(new BigDecimal(2.0)); - IPrimitiveType actualDecimal = this.typeConverter.toFhirDecimal(new BigDecimal(2.0)); + IPrimitiveType actualDecimal = typeConverter.toFhirDecimal(new BigDecimal(2.0)); assertEquals(expectedDecimal.getValue(), actualDecimal.getValue()); - expectedDecimal = this.typeConverter.toFhirDecimal(null); + expectedDecimal = typeConverter.toFhirDecimal(null); assertNull(expectedDecimal); } @Test - public void TestDateToFhirDate() { + void dateToFhirDate() { IPrimitiveType expectedDate = new DateType("2019-02-03"); - IPrimitiveType actualDate = this.typeConverter.toFhirDate(new Date("2019-02-03")); + IPrimitiveType actualDate = typeConverter.toFhirDate(new Date("2019-02-03")); assertEquals(expectedDate.getValue(), actualDate.getValue()); expectedDate = new DateType("2019"); - actualDate = this.typeConverter.toFhirDate(new Date("2019")); + actualDate = typeConverter.toFhirDate(new Date("2019")); assertEquals(expectedDate.getValue(), actualDate.getValue()); } - @DataProvider private static Object[][] nowsAndEvaluationTimes() { return ConverterTestUtils.nowsAndEvaluationTimes(); } - @Test(dataProvider = "nowsAndEvaluationTimes") - public void TestDateTimeToFhirDateTime(LocalDateTime now, LocalDateTime evaluationTime) { + @ParameterizedTest + @MethodSource("nowsAndEvaluationTimes") + void dateTimeToFhirDateTime(LocalDateTime now, LocalDateTime evaluationTime) { final ZonedDateTime zonedDateTime = ZonedDateTime.of(now, ZoneId.systemDefault()); final ZoneOffset defaultOffset = zonedDateTime.getOffset(); @@ -259,50 +262,51 @@ public void TestDateTimeToFhirDateTime(LocalDateTime now, LocalDateTime evaluati final String evalDate = DateTimeFormatter.ISO_DATE.format(evaluationTime); var expectedDate = new DateTimeType(evalTimeWithOffset); - IPrimitiveType actualDate = - this.typeConverter.toFhirDateTime(new DateTime(evalDate, defaultOffset)); + IPrimitiveType actualDate = typeConverter.toFhirDateTime(new DateTime(evalDate, defaultOffset)); assertEquals(expectedDate.getValue(), actualDate.getValue()); expectedDate = new DateTimeType(evalTimeWithOffset); - actualDate = this.typeConverter.toFhirDateTime(new DateTime("" + evaluationTime.getYear(), defaultOffset)); + actualDate = typeConverter.toFhirDateTime(new DateTime("" + evaluationTime.getYear(), defaultOffset)); expectedDate.setPrecision(TemporalPrecisionEnum.YEAR); assertEquals(expectedDate.getValue(), actualDate.getValue()); assertEquals(expectedDate.getValueAsString(), actualDate.getValueAsString()); } @Test - public void TestDateTimeToFhirDateTime_Timezones() { - var expectedDate = new DateTimeType("2019-10-10T00:00:00-07:00"); + void dateTimeToFhirDateTimeTimezones() { + var expectedDate = new DateTimeType("2019-10-10T01:00:00-06:00"); ((DateTimeType) expectedDate).setTimeZone(TimeZone.getTimeZone("MST")); - var actualDate = this.typeConverter.toFhirDateTime(new DateTime("2019-10-10T00:00:00", ZoneOffset.ofHours(-7))); + var actualDate = typeConverter.toFhirDateTime(new DateTime("2019-10-10T00:00:00", ZoneOffset.ofHours(-7))); assertEquals(expectedDate.getValueAsString(), actualDate.getValueAsString()); expectedDate = new DateTimeType("2019-10-10T19:35:53.000Z"); ((DateTimeType) expectedDate).setPrecision(TemporalPrecisionEnum.MILLI); - actualDate = this.typeConverter.toFhirDateTime( + actualDate = typeConverter.toFhirDateTime( new DateTime("2019-10-10T19:35:53", ZoneOffset.UTC).withPrecision(Precision.MILLISECOND)); assertEquals(expectedDate.getValueAsString(), actualDate.getValueAsString()); } @Test - public void TestQuantityToFhirQuantity() { - org.hl7.fhir.dstu3.model.Quantity expected = new org.hl7.fhir.dstu3.model.Quantity(2.0) + void quantityToFhirQuantity() { + org.hl7.fhir.dstu3.model.Quantity expected = new org.hl7.fhir.dstu3.model.Quantity() + .setValue(new BigDecimal("2.0")) .setCode("ml") .setSystem("http://unitsofmeasure.org") .setUnit("ml"); - org.hl7.fhir.dstu3.model.Quantity actual = - (org.hl7.fhir.dstu3.model.Quantity) this.typeConverter.toFhirQuantity( - new Quantity().withValue(new BigDecimal("2.0")).withUnit("ml")); + org.hl7.fhir.dstu3.model.Quantity actual = (org.hl7.fhir.dstu3.model.Quantity) typeConverter.toFhirQuantity( + new Quantity().withValue(new BigDecimal("2.0")).withUnit("ml")); assertTrue(expected.equalsDeep(actual)); } @Test - public void TestRatioToFhirRatio() { - org.hl7.fhir.dstu3.model.Quantity expectedNumerator = new org.hl7.fhir.dstu3.model.Quantity(1.0) + void ratioToFhirRatio() { + org.hl7.fhir.dstu3.model.Quantity expectedNumerator = new org.hl7.fhir.dstu3.model.Quantity() + .setValue(new BigDecimal("1.0")) .setCode("ml") .setSystem("http://unitsofmeasure.org") .setUnit("ml"); - org.hl7.fhir.dstu3.model.Quantity expectedDenominator = new org.hl7.fhir.dstu3.model.Quantity(2.0) + org.hl7.fhir.dstu3.model.Quantity expectedDenominator = new org.hl7.fhir.dstu3.model.Quantity() + .setValue(new BigDecimal("2.0")) .setCode("ml") .setSystem("http://unitsofmeasure.org") .setUnit("ml"); @@ -316,43 +320,51 @@ public void TestRatioToFhirRatio() { testData.setDenominator( new Quantity().withValue(BigDecimal.valueOf(2.0)).withUnit("ml")); - org.hl7.fhir.dstu3.model.Ratio actual = - (org.hl7.fhir.dstu3.model.Ratio) this.typeConverter.toFhirRatio(testData); + org.hl7.fhir.dstu3.model.Ratio actual = (org.hl7.fhir.dstu3.model.Ratio) typeConverter.toFhirRatio(testData); assertTrue(expected.equalsDeep(actual)); } - @Test() - public void TestNullToFhirAny() { - IBase expected = this.typeConverter.toFhirAny(null); + @Test + void nullToFhirAny() { + IBase expected = typeConverter.toFhirAny(null); assertNull(expected); } - @Test(expectedExceptions = NotImplementedException.class) - public void TestObjectToFhirAny() { - this.typeConverter.toFhirAny("Huh"); + @Test + void objectToFhirAny() { + assertThrows(NotImplementedException.class, () -> { + typeConverter.toFhirAny("Huh"); + }); } @Test - public void TestCodeToFhirCoding() { - Coding expected = new Coding("http://the-system.com", "test", "system-test").setVersion("1.5"); - Coding actual = (Coding) this.typeConverter.toFhirCoding(new Code() + void codeToFhirCoding() { + Coding expected = new Coding() + .setSystem("http://the-system.com") + .setCode("test") + .setDisplay("system-test") + .setVersion("1.5"); + Coding actual = (Coding) typeConverter.toFhirCoding(new Code() .withSystem("http://the-system.com") .withCode("test") .withDisplay("system-test") .withVersion("1.5")); assertTrue(expected.equalsDeep(actual)); - expected = (Coding) this.typeConverter.toFhirCoding(null); + expected = (Coding) typeConverter.toFhirCoding(null); assertNull(expected); } @Test - public void TestConceptToFhirCodeableConcept() { - CodeableConcept expected = new CodeableConcept( - new Coding("http://the-system.com", "test", "system-test").setVersion("1.5")) + void conceptToFhirCodeableConcept() { + CodeableConcept expected = new CodeableConcept(new Coding() + .setSystem("http://the-system.com") + .setCode("test") + .setDisplay("system-test") + .setVersion("1.5")) .setText("additional-text"); - CodeableConcept actual = (CodeableConcept) this.typeConverter.toFhirCodeableConcept(new Concept() + CodeableConcept actual = (CodeableConcept) typeConverter.toFhirCodeableConcept(new Concept() .withCode(new Code() .withSystem("http://the-system.com") .withCode("test") @@ -361,36 +373,35 @@ public void TestConceptToFhirCodeableConcept() { .withDisplay("additional-text")); assertTrue(expected.equalsDeep(actual)); - expected = (CodeableConcept) this.typeConverter.toFhirCodeableConcept(null); + expected = (CodeableConcept) typeConverter.toFhirCodeableConcept(null); assertNull(expected); } - @DataProvider private static Object[][] startAndEndTimes() { return ConverterTestUtils.startAndEndTimes(); } - @Test(dataProvider = "startAndEndTimes") - public void TestIntervalToFhirPeriod_yyyyMMdd(LocalDateTime startTime, LocalDateTime endTime) { + @ParameterizedTest + @MethodSource("startAndEndTimes") + void intervalToFhirPeriodYyyyMMdd(LocalDateTime startTime, LocalDateTime endTime) { final String startTime_yyyyMMdd = YYYY_MM_DD.format(startTime); final String endTime_yyyyMMdd = YYYY_MM_DD.format(endTime); final Period expected = new Period() .setStartElement(new DateTimeType(startTime_yyyyMMdd)) .setEndElement(new DateTimeType(endTime_yyyyMMdd)); - final Period actual = (Period) this.typeConverter.toFhirPeriod( + final Period actual = (Period) typeConverter.toFhirPeriod( new Interval(new Date(startTime_yyyyMMdd), true, new Date(endTime_yyyyMMdd), true)); assertTrue(expected.equalsDeep(actual)); } - @DataProvider private static Object[][] dateTimes() { return ConverterTestUtils.dateTimes(); } - @Test(dataProvider = "dateTimes") - public void TestIntervalToFhirPeriod_timestampWithOffsets( - LocalDateTime now, LocalDateTime startTime, LocalDateTime endTime) { + @ParameterizedTest + @MethodSource("dateTimes") + void intervalToFhirPeriodTimestampWithOffsets(LocalDateTime now, LocalDateTime startTime, LocalDateTime endTime) { final ZonedDateTime zonedDateTime = ZonedDateTime.of(now, ZoneId.systemDefault()); final ZoneOffset defaultOffset = zonedDateTime.getOffset(); @@ -407,211 +418,230 @@ public void TestIntervalToFhirPeriod_timestampWithOffsets( final DateTime dateTimeStart = new DateTime(startTimeNoOffset, defaultOffset); final DateTime dateTimeEnd = new DateTime(endTimeNoOffset, defaultOffset); final Interval intervalStartEnd = new Interval(dateTimeStart, true, dateTimeEnd, true); - var actual = (Period) this.typeConverter.toFhirPeriod(intervalStartEnd); + var actual = (Period) typeConverter.toFhirPeriod(intervalStartEnd); assertTrue(expected.equalsDeep(actual)); } - @DataProvider private static Object[][] startAndEndYears() { return ConverterTestUtils.startAndEndYears(); } - @Test(dataProvider = "startAndEndYears") - public void TestIntervalToFhirPeriod_startAndEndYears(LocalDateTime now, int startYear, int endYear) { + @ParameterizedTest + @MethodSource("startAndEndYears") + void intervalToFhirPeriodStartAndEndYears(LocalDateTime now, int startYear, int endYear) { final ZonedDateTime zonedDateTime = ZonedDateTime.of(now, ZoneId.systemDefault()); final ZoneOffset defaultOffset = zonedDateTime.getOffset(); final Period expected = new Period() .setStartElement(new DateTimeType(startYear + "-01-01T00:00:00" + defaultOffset)) .setEndElement(new DateTimeType(endYear + "-01-01T00:00:00" + defaultOffset)); - final Period actual = (Period) this.typeConverter.toFhirPeriod(new Interval( + final Period actual = (Period) typeConverter.toFhirPeriod(new Interval( new DateTime("" + startYear, defaultOffset), true, new DateTime("" + endYear, defaultOffset), true)); assertTrue(expected.equalsDeep(actual)); } @Test - public void TestIntervalToFhirPeriod_null() { - assertNull(this.typeConverter.toFhirPeriod(null)); + void intervalToFhirPeriodNull() { + assertNull(typeConverter.toFhirPeriod(null)); } - @Test(expectedExceptions = IllegalArgumentException.class) - public void TestInvalidIntervalToFhirPeriod() { - this.typeConverter.toFhirPeriod(new Interval(5, true, 6, true)); + @Test + void invalidIntervalToFhirPeriod() { + var interval = new Interval(5, true, 6, true); + assertThrows(IllegalArgumentException.class, () -> { + typeConverter.toFhirPeriod(interval); + }); } @Test - public void TestIntervalToFhirRange() { + void intervalToFhirRange() { Range expected = new Range() .setLow((SimpleQuantity) new org.hl7.fhir.dstu3.model.SimpleQuantity() .setValue(2.0) .setCode("ml") - .setSystem("http://unitsofmeasure.org") - .setUnit("ml")) + .setUnit("ml") + .setSystem("http://unitsofmeasure.org")) .setHigh((SimpleQuantity) new org.hl7.fhir.dstu3.model.SimpleQuantity() .setValue(5.0) .setCode("ml") - .setSystem("http://unitsofmeasure.org") - .setUnit("ml")); - Range actual = (Range) this.typeConverter.toFhirRange(new Interval( + .setUnit("ml") + .setSystem("http://unitsofmeasure.org")); + Range actual = (Range) typeConverter.toFhirRange(new Interval( new Quantity().withValue(new BigDecimal("2.0")).withUnit("ml"), true, new Quantity().withValue(new BigDecimal("5.0")).withUnit("ml"), true)); assertTrue(expected.equalsDeep(actual)); - actual = (Range) this.typeConverter.toFhirRange(null); + actual = (Range) typeConverter.toFhirRange(null); assertNull(null); } - @Test(expectedExceptions = IllegalArgumentException.class) - public void TestInvalidIntervalToFhirRange() { - this.typeConverter.toFhirRange(new Interval(5, true, 6, true)); + @Test + void invalidIntervalToFhirRange() { + var interval = new Interval(5, true, 6, true); + assertThrows(IllegalArgumentException.class, () -> { + typeConverter.toFhirRange(interval); + }); } @Test - public void TestIntervalToFhirInterval() { + void intervalToFhirInterval() { Period expectedPeriod = new Period() .setStartElement(new DateTimeType("2019-02-03")) .setEndElement(new DateTimeType("2019-02-05")); - Period actualPeriod = (Period) this.typeConverter.toFhirInterval( - new Interval(new Date("2019-02-03"), true, new Date("2019-02-05"), true)); + Period actualPeriod = (Period) + typeConverter.toFhirInterval(new Interval(new Date("2019-02-03"), true, new Date("2019-02-05"), true)); assertTrue(expectedPeriod.equalsDeep(actualPeriod)); Range expectedRange = new Range() .setLow((SimpleQuantity) new org.hl7.fhir.dstu3.model.SimpleQuantity() .setValue(2.0) .setCode("ml") - .setSystem("http://unitsofmeasure.org") - .setUnit("ml")) + .setUnit("ml") + .setSystem("http://unitsofmeasure.org")) .setHigh((SimpleQuantity) new org.hl7.fhir.dstu3.model.SimpleQuantity() .setValue(5.0) .setCode("ml") - .setSystem("http://unitsofmeasure.org") - .setUnit("ml")); - Range actualRange = (Range) this.typeConverter.toFhirInterval(new Interval( + .setUnit("ml") + .setSystem("http://unitsofmeasure.org")); + Range actualRange = (Range) typeConverter.toFhirInterval(new Interval( new Quantity().withValue(new BigDecimal("2.0")).withUnit("ml"), true, new Quantity().withValue(new BigDecimal("5.0")).withUnit("ml"), true)); assertTrue(expectedRange.equalsDeep(actualRange)); - ICompositeType expected = this.typeConverter.toFhirInterval(null); + ICompositeType expected = typeConverter.toFhirInterval(null); assertNull(expected); } - @Test(expectedExceptions = IllegalArgumentException.class) - public void TestInvalidIntervalToFhirInterval() { - this.typeConverter.toFhirInterval(new Interval(5, true, 6, true)); + @Test + void invalidIntervalToFhirInterval() { + var interval = new Interval(5, true, 6, true); + + assertThrows(IllegalArgumentException.class, () -> { + typeConverter.toFhirInterval(interval); + }); } - @Test(expectedExceptions = NotImplementedException.class) - public void TestTupleToFhirTuple() { - IBase expected = this.typeConverter.toFhirTuple(null); + @Test + void tupleToFhirTuple() { + IBase expected = typeConverter.toFhirTuple(null); assertNull(expected); - this.typeConverter.toFhirTuple(new Tuple()); + var tuple = new Tuple(); + assertThrows(NotImplementedException.class, () -> { + typeConverter.toFhirTuple(tuple); + }); } // FHIR-to-CQL @Test - public void TestIsCqlType() { - assertTrue(this.typeConverter.isCqlType(5)); - assertTrue(this.typeConverter.isCqlType(new BigDecimal(0))); - assertTrue(this.typeConverter.isCqlType(new Code())); + void isCqlType() { + assertTrue(typeConverter.isCqlType(5)); + assertTrue(typeConverter.isCqlType(new BigDecimal(0))); + assertTrue(typeConverter.isCqlType(new Code())); - assertFalse(this.typeConverter.isCqlType(new Patient())); - assertFalse(this.typeConverter.isCqlType(new IdType())); + assertFalse(typeConverter.isCqlType(new Patient())); + assertFalse(typeConverter.isCqlType(new IdType())); } - @Test(expectedExceptions = NullPointerException.class) - public void TestNullIsCqlType() { - this.typeConverter.isCqlType(null); + @Test + void nullIsCqlType() { + assertThrows(NullPointerException.class, () -> typeConverter.isCqlType(null)); } - @Test(expectedExceptions = IllegalArgumentException.class) - public void TestIterableIsCqlType() { - this.typeConverter.isCqlType(new ArrayList<>()); + @Test + void iterableIsCqlType() { + var value = new ArrayList<>(); + assertThrows(IllegalArgumentException.class, () -> typeConverter.isCqlType(value)); } @Test - public void TestToCqlType() { - Object actual = this.typeConverter.toCqlType(new Code()); + void toCqlType() { + Object actual = typeConverter.toCqlType(new Code()); assertThat(actual, instanceOf(Code.class)); - actual = this.typeConverter.toCqlType(new IntegerType(5)); + actual = typeConverter.toCqlType(new IntegerType(5)); assertThat(actual, instanceOf(Integer.class)); - actual = this.typeConverter.toCqlType(new StringType("test")); + actual = typeConverter.toCqlType(new StringType("test")); assertThat(actual, instanceOf(String.class)); - actual = this.typeConverter.toCqlType(new IdType("test")); + actual = typeConverter.toCqlType(new IdType("test")); assertThat(actual, instanceOf(String.class)); - actual = this.typeConverter.toCqlType(new BooleanType(true)); + actual = typeConverter.toCqlType(new BooleanType(true)); assertThat(actual, instanceOf(Boolean.class)); - actual = this.typeConverter.toCqlType(new DecimalType(1.0)); + actual = typeConverter.toCqlType(new DecimalType(1.0)); assertThat(actual, instanceOf(BigDecimal.class)); - actual = this.typeConverter.toCqlType(new DateType(Calendar.getInstance())); + actual = typeConverter.toCqlType(new DateType(Calendar.getInstance().getTime())); assertThat(actual, instanceOf(Date.class)); - actual = this.typeConverter.toCqlType(new InstantType(Calendar.getInstance())); + actual = typeConverter.toCqlType(new InstantType(Calendar.getInstance())); assertThat(actual, instanceOf(DateTime.class)); - actual = this.typeConverter.toCqlType(new DateTimeType(Calendar.getInstance())); + actual = typeConverter.toCqlType(new DateTimeType(Calendar.getInstance())); assertThat(actual, instanceOf(DateTime.class)); - actual = this.typeConverter.toCqlType(new TimeType("10:00:00.0000")); + actual = typeConverter.toCqlType(new TimeType("10:00:00.0000")); assertThat(actual, instanceOf(Time.class)); - actual = this.typeConverter.toCqlType(new StringType("test")); + actual = typeConverter.toCqlType(new StringType("test")); assertThat(actual, instanceOf(String.class)); - actual = this.typeConverter.toCqlType(new org.hl7.fhir.dstu3.model.Quantity()); + actual = typeConverter.toCqlType(new org.hl7.fhir.dstu3.model.Quantity()); assertThat(actual, instanceOf(Quantity.class)); - actual = this.typeConverter.toCqlType(new org.hl7.fhir.dstu3.model.Ratio()); + actual = typeConverter.toCqlType(new org.hl7.fhir.dstu3.model.Ratio()); assertThat(actual, instanceOf(Ratio.class)); - actual = this.typeConverter.toCqlType(new Coding()); + actual = typeConverter.toCqlType(new Coding()); assertThat(actual, instanceOf(Code.class)); - actual = this.typeConverter.toCqlType(new CodeableConcept()); + actual = typeConverter.toCqlType(new CodeableConcept()); assertThat(actual, instanceOf(Concept.class)); - actual = this.typeConverter.toCqlType(new Period() + actual = typeConverter.toCqlType(new Period() .setStart(Calendar.getInstance().getTime()) .setEnd(Calendar.getInstance().getTime())); assertThat(actual, instanceOf(Interval.class)); SimpleQuantity low = new SimpleQuantity(); - low.setValue(1.0); + low.setValue(BigDecimal.valueOf(1.0)); low.setUnit("d"); SimpleQuantity high = new SimpleQuantity(); - high.setValue(4.0); + high.setValue(BigDecimal.valueOf(4.0)); high.setUnit("d"); - actual = this.typeConverter.toCqlType(new Range().setLow(low).setHigh(high)); + actual = typeConverter.toCqlType(new Range().setLow(low).setHigh(high)); assertThat(actual, instanceOf(Interval.class)); - actual = this.typeConverter.toCqlType(null); + actual = typeConverter.toCqlType(null); assertNull(null); } - @Test(expectedExceptions = IllegalArgumentException.class) - public void TestToCqlTypeIterable() { - this.typeConverter.toCqlType(new ArrayList<>()); + @Test + void toCqlTypeIterable() { + assertThrows(IllegalArgumentException.class, () -> { + typeConverter.toCqlType(new ArrayList<>()); + }); } - @Test(expectedExceptions = IllegalArgumentException.class) - public void TestToCqlTypeNotCql() { - this.typeConverter.toCqlType(ZoneOffset.ofHours(3)); + @Test + void toCqlTypeNotCql() { + var offset = ZoneOffset.ofHours(3); + assertThrows(IllegalArgumentException.class, () -> { + typeConverter.toCqlType(offset); + }); } @Test - public void TestToCqlTypes() { + void toCqlTypes() { List innerExpected = new ArrayList<>(); innerExpected.add("123"); @@ -629,133 +659,145 @@ public void TestToCqlTypes() { test.add(null); test.add(new IntegerType(5)); - Iterable actual = this.typeConverter.toCqlTypes(test); + Iterable actual = typeConverter.toCqlTypes(test); assertTrue(compareIterables(expected, actual)); } @Test - public void TestStringToCqlId() { + void stringToCqlId() { String expected = "123"; - String actual = this.typeConverter.toCqlId(new IdType("123")); + String actual = typeConverter.toCqlId(new IdType("123")); assertEquals(expected, actual); - actual = this.typeConverter.toCqlId(null); + actual = typeConverter.toCqlId(null); assertNull(actual); } @Test - public void TestPrimitiveFhirTypeToCqlType() { + void primitiveFhirTypeToCqlType() { Boolean expectedBoolean = false; - Boolean actualBoolean = this.typeConverter.toCqlBoolean(new BooleanType(false)); + Boolean actualBoolean = typeConverter.toCqlBoolean(new BooleanType(false)); assertEquals(expectedBoolean, actualBoolean); - expectedBoolean = this.typeConverter.toCqlBoolean(null); + expectedBoolean = typeConverter.toCqlBoolean(null); assertNull(expectedBoolean); Integer expectedInteger = 5; - Integer actualInteger = this.typeConverter.toCqlInteger(new IntegerType(5)); + Integer actualInteger = typeConverter.toCqlInteger(new IntegerType(5)); assertEquals(expectedInteger, actualInteger); - expectedInteger = this.typeConverter.toCqlInteger(null); + expectedInteger = typeConverter.toCqlInteger(null); assertNull(expectedInteger); String expectedString = "5"; - String actualString = this.typeConverter.toCqlString(new StringType("5")); + String actualString = typeConverter.toCqlString(new StringType("5")); assertEquals(expectedString, actualString); - expectedString = this.typeConverter.toCqlString(null); + expectedString = typeConverter.toCqlString(null); assertNull(expectedString); BigDecimal expectedDecimal = new BigDecimal(2.0); - BigDecimal actualDecimal = this.typeConverter.toCqlDecimal(new DecimalType(new BigDecimal(2.0))); + BigDecimal actualDecimal = typeConverter.toCqlDecimal(new DecimalType(new BigDecimal(2.0))); assertEquals(expectedDecimal, actualDecimal); - expectedDecimal = this.typeConverter.toCqlDecimal(null); + expectedDecimal = typeConverter.toCqlDecimal(null); assertNull(expectedDecimal); } @Test - public void TestDateToCqlType() { + void dateToCqlType() { Date expectedDate = new Date("2019-02-03"); - Date actualDate = this.typeConverter.toCqlDate(new org.hl7.fhir.dstu3.model.DateType("2019-02-03")); + Date actualDate = typeConverter.toCqlDate(new org.hl7.fhir.dstu3.model.DateType("2019-02-03")); assertTrue(expectedDate.equal(actualDate)); expectedDate = new Date("2019"); - actualDate = this.typeConverter.toCqlDate(new DateType("2019")); + actualDate = typeConverter.toCqlDate(new DateType("2019")); assertTrue(expectedDate.equal(actualDate)); } @Test - public void TestDateTimeToCqlType() { + void dateTimeToCqlType() { DateTime expectedDate = new DateTime("2019-02-03", ZoneOffset.UTC); - DateTime actualDate = this.typeConverter.toCqlDateTime(new DateTimeType("2019-02-03")); + DateTime actualDate = typeConverter.toCqlDateTime(new DateTimeType("2019-02-03")); assertTrue(expectedDate.equal(actualDate)); expectedDate = new DateTime("2019", ZoneOffset.UTC); - actualDate = this.typeConverter.toCqlDateTime(new DateTimeType("2019")); + actualDate = typeConverter.toCqlDateTime(new DateTimeType("2019")); assertTrue(expectedDate.equal(actualDate)); expectedDate = new DateTime("2019", ZoneOffset.UTC); - actualDate = this.typeConverter.toCqlDateTime(new DateTimeType("2019")); + actualDate = typeConverter.toCqlDateTime(new DateTimeType("2019")); assertTrue(expectedDate.equal(actualDate)); } @Test - public void TestQuantityToCqlType() { + void quantityToCqlType() { Quantity expected = (new Quantity().withValue(new BigDecimal("2.0")).withUnit("ml")); - Quantity actual = this.typeConverter.toCqlQuantity( - new org.hl7.fhir.dstu3.model.Quantity(2.0).setUnit("ml").setSystem("http://unitsofmeasure.org")); + Quantity actual = typeConverter.toCqlQuantity(new org.hl7.fhir.dstu3.model.Quantity() + .setValue(new BigDecimal("2.0")) + .setUnit("ml") + .setSystem("http://unitsofmeasure.org")); assertTrue(expected.equal(actual)); } @Test - public void TestRatioToCqlType() { + void ratioToCqlType() { Ratio expected = new Ratio(); expected.setNumerator(new Quantity().withValue(BigDecimal.valueOf(1.0)).withUnit("ml")); expected.setDenominator( new Quantity().withValue(BigDecimal.valueOf(2.0)).withUnit("ml")); - org.hl7.fhir.dstu3.model.Quantity testNumerator = - new org.hl7.fhir.dstu3.model.Quantity(1.0).setUnit("ml").setSystem("http://unitsofmeasure.org"); - org.hl7.fhir.dstu3.model.Quantity testDenominator = - new org.hl7.fhir.dstu3.model.Quantity(2.0).setUnit("ml").setSystem("http://unitsofmeasure.org"); + org.hl7.fhir.dstu3.model.Quantity testNumerator = new org.hl7.fhir.dstu3.model.Quantity() + .setValue(new BigDecimal("1.0")) + .setUnit("ml") + .setSystem("http://unitsofmeasure.org"); + org.hl7.fhir.dstu3.model.Quantity testDenominator = new org.hl7.fhir.dstu3.model.Quantity() + .setValue(new BigDecimal("2.0")) + .setUnit("ml") + .setSystem("http://unitsofmeasure.org"); org.hl7.fhir.dstu3.model.Ratio test = new org.hl7.fhir.dstu3.model.Ratio().setNumerator(testNumerator).setDenominator(testDenominator); - Ratio actual = this.typeConverter.toCqlRatio(test); + Ratio actual = typeConverter.toCqlRatio(test); assertTrue(expected.equal(actual)); } - @Test() - public void TestNullToCqlType() { - Object expected = this.typeConverter.toCqlAny(null); + @Test + void nullToCqlType() { + Object expected = typeConverter.toCqlAny(null); assertNull(expected); } - @Test(expectedExceptions = NotImplementedException.class) - public void TestObjectToCqlType() { - this.typeConverter.toCqlAny(new IdType()); + @Test + void objectToCqlType() { + var id = new IdType(); + assertThrows(NotImplementedException.class, () -> { + typeConverter.toCqlAny(id); + }); } @Test - public void TestCodingToCqlCode() { + void codingToCqlCode() { Code expected = new Code() .withSystem("http://the-system.com") .withCode("test") .withDisplay("system-test") .withVersion("1.5"); - Code actual = this.typeConverter.toCqlCode( - new Coding("http://the-system.com", "test", "system-test").setVersion("1.5")); + Code actual = typeConverter.toCqlCode(new Coding() + .setSystem("http://the-system.com") + .setCode("test") + .setDisplay("system-test") + .setVersion("1.5")); assertTrue(expected.equal(actual)); - expected = this.typeConverter.toCqlCode(null); + expected = typeConverter.toCqlCode(null); assertNull(expected); } @Test - public void TestCodeableConceptToCqlConcept() { + void codeableConceptToCqlConcept() { Concept expected = new Concept() .withCode(new Code() .withSystem("http://the-system.com") @@ -763,26 +805,29 @@ public void TestCodeableConceptToCqlConcept() { .withDisplay("system-test") .withVersion("1.5")) .withDisplay("additional-text"); - Concept actual = this.typeConverter.toCqlConcept( - new CodeableConcept(new Coding("http://the-system.com", "test", "system-test").setVersion("1.5")) - .setText("additional-text")); + Concept actual = typeConverter.toCqlConcept(new CodeableConcept(new Coding() + .setSystem("http://the-system.com") + .setCode("test") + .setDisplay("system-test") + .setVersion("1.5")) + .setText("additional-text")); assertTrue(expected.equal(actual)); - expected = this.typeConverter.toCqlConcept(null); + expected = typeConverter.toCqlConcept(null); assertNull(expected); } @Test - public void TestPeriodToCqlInterval() { + void periodToCqlInterval() { Interval expected = new Interval(new Date("2019-02-03"), true, new Date("2019-02-05"), true); - Interval actual = this.typeConverter.toCqlInterval(new Period() + Interval actual = typeConverter.toCqlInterval(new Period() .setStartElement(new DateTimeType("2019-02-03")) .setEndElement(new DateTimeType("2019-02-05"))); assertTrue(expected.equal(actual)); expected = new Interval(new Date("2019"), true, new Date("2020"), true); - actual = this.typeConverter.toCqlInterval( + actual = typeConverter.toCqlInterval( new Period().setStartElement(new DateTimeType("2019")).setEndElement(new DateTimeType("2020"))); assertTrue(expected.equal(actual)); @@ -791,47 +836,53 @@ public void TestPeriodToCqlInterval() { true, new DateTime("2020-09-18T19:37:00", ZoneOffset.UTC), true); - actual = this.typeConverter.toCqlInterval(new Period() + actual = typeConverter.toCqlInterval(new Period() .setStartElement(new DateTimeType("2020-09-18T19:35:53+00:00")) .setEndElement(new DateTimeType("2020-09-18T19:37:00+00:00"))); assertTrue(expected.equal(actual)); - actual = this.typeConverter.toCqlInterval(null); + actual = typeConverter.toCqlInterval(null); assertNull(null); } @Test - public void TestRangeToCqlInterval() { + void rangeToCqlInterval() { Interval expected = new Interval( new Quantity().withValue(new BigDecimal("2.0")).withUnit("ml"), true, new Quantity().withValue(new BigDecimal("5.0")).withUnit("ml"), true); - Interval actual = this.typeConverter.toCqlInterval(new Range() + Interval actual = typeConverter.toCqlInterval(new Range() .setLow((SimpleQuantity) new org.hl7.fhir.dstu3.model.SimpleQuantity() - .setValue(2.0) + .setValue(new BigDecimal("2.0")) .setUnit("ml") .setSystem("http://unitsofmeasure.org")) .setHigh((SimpleQuantity) new org.hl7.fhir.dstu3.model.SimpleQuantity() - .setValue(5.0) + .setValue(new BigDecimal("5.0")) .setUnit("ml") .setSystem("http://unitsofmeasure.org"))); assertTrue(expected.equal(actual)); - actual = this.typeConverter.toCqlInterval(null); + actual = typeConverter.toCqlInterval(null); assertNull(null); } - @Test(expectedExceptions = IllegalArgumentException.class) - public void TestInvalidTypeToCqlInterval() { - this.typeConverter.toCqlInterval(new Attachment()); + @Test + void invalidTypeToCqlInterval() { + var attachment = new Attachment(); + assertThrows(IllegalArgumentException.class, () -> { + typeConverter.toCqlInterval(attachment); + }); } - @Test(expectedExceptions = NotImplementedException.class) - public void TestTupleToCqlTuple() { - Object expected = this.typeConverter.toCqlTuple(null); + @Test + void tupleToCqlTuple() { + Object expected = typeConverter.toCqlTuple(null); assertNull(expected); - this.typeConverter.toCqlTuple(new Patient()); + var p = new Patient(); + assertThrows(NotImplementedException.class, () -> { + typeConverter.toCqlTuple(p); + }); } } diff --git a/Src/java/engine-fhir/src/test/java/org/opencds/cqf/cql/engine/fhir/converter/R4TypeConverterTests.java b/Src/java/engine-fhir/src/test/java/org/opencds/cqf/cql/engine/fhir/converter/R4TypeConverterTests.java index d1c3d56e1..a040bddf7 100644 --- a/Src/java/engine-fhir/src/test/java/org/opencds/cqf/cql/engine/fhir/converter/R4TypeConverterTests.java +++ b/Src/java/engine-fhir/src/test/java/org/opencds/cqf/cql/engine/fhir/converter/R4TypeConverterTests.java @@ -2,17 +2,22 @@ import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.instanceOf; -import static org.opencds.cqf.cql.engine.fhir.converter.ConverterTestUtils.YYYY_MM_DD; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertFalse; -import static org.testng.Assert.assertNull; -import static org.testng.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.opencds.cqf.cql.engine.fhir.converter.ConverterTestUtils.*; import ca.uhn.fhir.model.api.TemporalPrecisionEnum; import java.math.BigDecimal; import java.time.*; import java.time.format.DateTimeFormatter; -import java.util.*; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.Iterator; +import java.util.List; +import java.util.TimeZone; import org.apache.commons.lang3.NotImplementedException; import org.hl7.fhir.instance.model.api.IBase; import org.hl7.fhir.instance.model.api.ICompositeType; @@ -32,26 +37,18 @@ import org.hl7.fhir.r4.model.Patient; import org.hl7.fhir.r4.model.Period; import org.hl7.fhir.r4.model.Range; +import org.hl7.fhir.r4.model.SimpleQuantity; import org.hl7.fhir.r4.model.StringType; import org.hl7.fhir.r4.model.TimeType; -import org.opencds.cqf.cql.engine.runtime.Code; -import org.opencds.cqf.cql.engine.runtime.Concept; -import org.opencds.cqf.cql.engine.runtime.CqlType; -import org.opencds.cqf.cql.engine.runtime.Date; -import org.opencds.cqf.cql.engine.runtime.DateTime; -import org.opencds.cqf.cql.engine.runtime.Interval; -import org.opencds.cqf.cql.engine.runtime.Precision; -import org.opencds.cqf.cql.engine.runtime.Quantity; -import org.opencds.cqf.cql.engine.runtime.Ratio; -import org.opencds.cqf.cql.engine.runtime.Time; -import org.opencds.cqf.cql.engine.runtime.Tuple; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; - -public class R4TypeConverterTests { - - private R4FhirTypeConverter typeConverter; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; +import org.opencds.cqf.cql.engine.runtime.*; + +class R4TypeConverterTests { + + private static R4FhirTypeConverter typeConverter; protected Boolean compareIterables(Iterable left, Iterable right) { Iterator leftIterator = left.iterator(); @@ -99,73 +96,84 @@ protected Boolean compareObjects(Object left, Object right) { return left.equals(right); } - @BeforeClass - public void initialize() { - this.typeConverter = new R4FhirTypeConverter(); + @BeforeAll + static void initialize() { + typeConverter = new R4FhirTypeConverter(); } // CQL-to-FHIR @Test - public void TestIsFhirType() { - assertTrue(this.typeConverter.isFhirType(new Patient())); - assertTrue(this.typeConverter.isFhirType(new IdType())); - assertTrue(this.typeConverter.isFhirType(new org.hl7.fhir.r4.model.Quantity())); - assertTrue(this.typeConverter.isFhirType(new org.hl7.fhir.r4.model.Ratio())); - assertTrue(this.typeConverter.isFhirType(new BooleanType())); - assertTrue(this.typeConverter.isFhirType(new IntegerType())); - assertTrue(this.typeConverter.isFhirType(new DecimalType())); - assertTrue(this.typeConverter.isFhirType(new DateType())); - assertTrue(this.typeConverter.isFhirType(new InstantType())); - assertTrue(this.typeConverter.isFhirType(new DateTimeType())); - assertTrue(this.typeConverter.isFhirType(new TimeType())); - assertTrue(this.typeConverter.isFhirType(new StringType())); - assertTrue(this.typeConverter.isFhirType(new Coding())); - assertTrue(this.typeConverter.isFhirType(new CodeableConcept())); - assertTrue(this.typeConverter.isFhirType(new Period())); - assertTrue(this.typeConverter.isFhirType(new Range())); - - assertFalse(this.typeConverter.isFhirType(5)); - assertFalse(this.typeConverter.isFhirType(new BigDecimal(0))); - assertFalse(this.typeConverter.isFhirType(new Code())); + void isFhirType() { + assertTrue(typeConverter.isFhirType(new Patient())); + assertTrue(typeConverter.isFhirType(new IdType())); + assertTrue(typeConverter.isFhirType(new org.hl7.fhir.r4.model.Quantity())); + assertTrue(typeConverter.isFhirType(new org.hl7.fhir.r4.model.Ratio())); + assertTrue(typeConverter.isFhirType(new BooleanType())); + assertTrue(typeConverter.isFhirType(new IntegerType())); + assertTrue(typeConverter.isFhirType(new DecimalType())); + assertTrue(typeConverter.isFhirType(new DateType())); + assertTrue(typeConverter.isFhirType(new InstantType())); + assertTrue(typeConverter.isFhirType(new DateTimeType())); + assertTrue(typeConverter.isFhirType(new TimeType())); + assertTrue(typeConverter.isFhirType(new StringType())); + assertTrue(typeConverter.isFhirType(new Coding())); + assertTrue(typeConverter.isFhirType(new CodeableConcept())); + assertTrue(typeConverter.isFhirType(new Period())); + assertTrue(typeConverter.isFhirType(new Range())); + + assertFalse(typeConverter.isFhirType(5)); + assertFalse(typeConverter.isFhirType(new BigDecimal(0))); + assertFalse(typeConverter.isFhirType(new Code())); } - @Test(expectedExceptions = NullPointerException.class) - public void TestNullIsFhirType() { - this.typeConverter.isFhirType(null); + @Test + void nullIsFhirType() { + assertThrows(NullPointerException.class, () -> { + typeConverter.isFhirType(null); + }); } - @Test(expectedExceptions = IllegalArgumentException.class) - public void TestIterableIsFhirType() { - this.typeConverter.isFhirType(new ArrayList<>()); + @Test + void iterableIsFhirType() { + var value = new ArrayList<>(); + assertThrows(IllegalArgumentException.class, () -> { + typeConverter.isFhirType(value); + }); } @Test - public void TestToFhirType() { - IBase actual = this.typeConverter.toFhirType(new Code()); + void toFhirType() { + IBase actual = typeConverter.toFhirType(new Code()); assertThat(actual, instanceOf(Coding.class)); - actual = this.typeConverter.toFhirType(5); + actual = typeConverter.toFhirType(5); assertThat(actual, instanceOf(IntegerType.class)); - actual = this.typeConverter.toFhirType(new IdType()); + actual = typeConverter.toFhirType(new IdType()); assertThat(actual, instanceOf(IdType.class)); - actual = this.typeConverter.toFhirType(null); + actual = typeConverter.toFhirType(null); assertNull(null); } - @Test(expectedExceptions = IllegalArgumentException.class) - public void TestToFhirTypeIterable() { - this.typeConverter.toFhirType(new ArrayList<>()); + @Test + void toFhirTypeIterable() { + var value = new ArrayList<>(); + assertThrows(IllegalArgumentException.class, () -> { + typeConverter.toFhirType(value); + }); } - @Test(expectedExceptions = IllegalArgumentException.class) - public void TestToFhirTypeNotCql() { - this.typeConverter.toFhirType(ZoneOffset.ofHours(3)); + @Test + void toFhirTypeNotCql() { + var offset = ZoneOffset.ofHours(3); + assertThrows(IllegalArgumentException.class, () -> { + typeConverter.toFhirType(offset); + }); } @Test - public void TestToFhirTypes() { + void toFhirTypes() { List innerExpected = new ArrayList<>(); innerExpected.add(new StringType("123")); innerExpected.add(null); @@ -182,70 +190,70 @@ public void TestToFhirTypes() { test.add(null); test.add(5); - Iterable actual = this.typeConverter.toFhirTypes(test); + Iterable actual = typeConverter.toFhirTypes(test); assertTrue(compareIterables(expected, actual)); } @Test - public void TestStringToFhirId() { + void stringToFhirId() { IIdType expected = new IdType("123"); - IIdType actual = this.typeConverter.toFhirId("123"); + IIdType actual = typeConverter.toFhirId("123"); assertEquals(expected.getValue(), actual.getValue()); - actual = this.typeConverter.toFhirId(null); + actual = typeConverter.toFhirId(null); assertNull(actual); } @Test - public void TestPrimitiveCqlTypeToFhirType() { + void primitiveCqlTypeToFhirType() { IPrimitiveType expectedBoolean = new BooleanType(false); - IPrimitiveType actualBoolean = this.typeConverter.toFhirBoolean(false); + IPrimitiveType actualBoolean = typeConverter.toFhirBoolean(false); assertEquals(expectedBoolean.getValue(), actualBoolean.getValue()); - expectedBoolean = this.typeConverter.toFhirBoolean(null); + expectedBoolean = typeConverter.toFhirBoolean(null); assertNull(expectedBoolean); IPrimitiveType expectedInteger = new IntegerType(5); - IPrimitiveType actualInteger = this.typeConverter.toFhirInteger(5); + IPrimitiveType actualInteger = typeConverter.toFhirInteger(5); assertEquals(expectedInteger.getValue(), actualInteger.getValue()); - expectedInteger = this.typeConverter.toFhirInteger(null); + expectedInteger = typeConverter.toFhirInteger(null); assertNull(expectedInteger); IPrimitiveType expectedString = new StringType("5"); - IPrimitiveType actualString = this.typeConverter.toFhirString("5"); + IPrimitiveType actualString = typeConverter.toFhirString("5"); assertEquals(expectedString.getValue(), actualString.getValue()); - expectedString = this.typeConverter.toFhirString(null); + expectedString = typeConverter.toFhirString(null); assertNull(expectedString); IPrimitiveType expectedDecimal = new DecimalType(new BigDecimal(2.0)); - IPrimitiveType actualDecimal = this.typeConverter.toFhirDecimal(new BigDecimal(2.0)); + IPrimitiveType actualDecimal = typeConverter.toFhirDecimal(new BigDecimal(2.0)); assertEquals(expectedDecimal.getValue(), actualDecimal.getValue()); - expectedDecimal = this.typeConverter.toFhirDecimal(null); + expectedDecimal = typeConverter.toFhirDecimal(null); assertNull(expectedDecimal); } @Test - public void TestDateToFhirDate() { + void dateToFhirDate() { IPrimitiveType expectedDate = new DateType("2019-02-03"); - IPrimitiveType actualDate = this.typeConverter.toFhirDate(new Date("2019-02-03")); + IPrimitiveType actualDate = typeConverter.toFhirDate(new Date("2019-02-03")); assertEquals(expectedDate.getValue(), actualDate.getValue()); expectedDate = new DateType("2019"); - actualDate = this.typeConverter.toFhirDate(new Date("2019")); + actualDate = typeConverter.toFhirDate(new Date("2019")); assertEquals(expectedDate.getValue(), actualDate.getValue()); } - @DataProvider private static Object[][] nowsAndEvaluationTimes() { return ConverterTestUtils.nowsAndEvaluationTimes(); } - @Test(dataProvider = "nowsAndEvaluationTimes") - public void TestDateTimeToFhirDateTime(LocalDateTime now, LocalDateTime evaluationTime) { + @ParameterizedTest + @MethodSource("nowsAndEvaluationTimes") + void dateTimeToFhirDateTime(LocalDateTime now, LocalDateTime evaluationTime) { final ZonedDateTime zonedDateTime = ZonedDateTime.of(now, ZoneId.systemDefault()); final ZoneOffset defaultOffset = zonedDateTime.getOffset(); @@ -254,49 +262,51 @@ public void TestDateTimeToFhirDateTime(LocalDateTime now, LocalDateTime evaluati final String evalDate = DateTimeFormatter.ISO_DATE.format(evaluationTime); var expectedDate = new DateTimeType(evalTimeWithOffset); - IPrimitiveType actualDate = - this.typeConverter.toFhirDateTime(new DateTime(evalDate, defaultOffset)); + IPrimitiveType actualDate = typeConverter.toFhirDateTime(new DateTime(evalDate, defaultOffset)); assertEquals(expectedDate.getValue(), actualDate.getValue()); expectedDate = new DateTimeType(evalTimeWithOffset); - actualDate = this.typeConverter.toFhirDateTime(new DateTime("" + evaluationTime.getYear(), defaultOffset)); + actualDate = typeConverter.toFhirDateTime(new DateTime("" + evaluationTime.getYear(), defaultOffset)); expectedDate.setPrecision(TemporalPrecisionEnum.YEAR); assertEquals(expectedDate.getValue(), actualDate.getValue()); assertEquals(expectedDate.getValueAsString(), actualDate.getValueAsString()); } @Test - public void TestDateTimeToFhirDateTime_Timezones() { - var expectedDate = new DateTimeType("2019-10-10T00:00:00-07:00"); + void dateTimeToFhirDateTimeTimezones() { + var expectedDate = new DateTimeType("2019-10-10T01:00:00-06:00"); ((DateTimeType) expectedDate).setTimeZone(TimeZone.getTimeZone("MST")); - var actualDate = this.typeConverter.toFhirDateTime(new DateTime("2019-10-10T00:00:00", ZoneOffset.ofHours(-7))); + var actualDate = typeConverter.toFhirDateTime(new DateTime("2019-10-10T00:00:00", ZoneOffset.ofHours(-7))); assertEquals(expectedDate.getValueAsString(), actualDate.getValueAsString()); expectedDate = new DateTimeType("2019-10-10T19:35:53.000Z"); ((DateTimeType) expectedDate).setPrecision(TemporalPrecisionEnum.MILLI); - actualDate = this.typeConverter.toFhirDateTime( + actualDate = typeConverter.toFhirDateTime( new DateTime("2019-10-10T19:35:53", ZoneOffset.UTC).withPrecision(Precision.MILLISECOND)); assertEquals(expectedDate.getValueAsString(), actualDate.getValueAsString()); } @Test - public void TestQuantityToFhirQuantity() { - org.hl7.fhir.r4.model.Quantity expected = new org.hl7.fhir.r4.model.Quantity(2.0) + void quantityToFhirQuantity() { + org.hl7.fhir.r4.model.Quantity expected = new org.hl7.fhir.r4.model.Quantity() + .setValue(new BigDecimal("2.0")) .setCode("ml") .setSystem("http://unitsofmeasure.org") .setUnit("ml"); - org.hl7.fhir.r4.model.Quantity actual = (org.hl7.fhir.r4.model.Quantity) this.typeConverter.toFhirQuantity( + org.hl7.fhir.r4.model.Quantity actual = (org.hl7.fhir.r4.model.Quantity) typeConverter.toFhirQuantity( new Quantity().withValue(new BigDecimal("2.0")).withUnit("ml")); assertTrue(expected.equalsDeep(actual)); } @Test - public void TestRatioToFhirRatio() { - org.hl7.fhir.r4.model.Quantity expectedNumerator = new org.hl7.fhir.r4.model.Quantity(1.0) + void ratioToFhirRatio() { + org.hl7.fhir.r4.model.Quantity expectedNumerator = new org.hl7.fhir.r4.model.Quantity() + .setValue(new BigDecimal("1.0")) .setCode("ml") .setSystem("http://unitsofmeasure.org") .setUnit("ml"); - org.hl7.fhir.r4.model.Quantity expectedDenominator = new org.hl7.fhir.r4.model.Quantity(2.0) + org.hl7.fhir.r4.model.Quantity expectedDenominator = new org.hl7.fhir.r4.model.Quantity() + .setValue(new BigDecimal("2.0")) .setCode("ml") .setSystem("http://unitsofmeasure.org") .setUnit("ml"); @@ -310,42 +320,51 @@ public void TestRatioToFhirRatio() { testData.setDenominator( new Quantity().withValue(BigDecimal.valueOf(2.0)).withUnit("ml")); - org.hl7.fhir.r4.model.Ratio actual = (org.hl7.fhir.r4.model.Ratio) this.typeConverter.toFhirRatio(testData); + org.hl7.fhir.r4.model.Ratio actual = (org.hl7.fhir.r4.model.Ratio) typeConverter.toFhirRatio(testData); assertTrue(expected.equalsDeep(actual)); } - @Test() - public void TestNullToFhirAny() { - IBase expected = this.typeConverter.toFhirAny(null); + @Test + void nullToFhirAny() { + IBase expected = typeConverter.toFhirAny(null); assertNull(expected); } - @Test(expectedExceptions = NotImplementedException.class) - public void TestObjectToFhirAny() { - this.typeConverter.toFhirAny("Huh"); + @Test + void objectToFhirAny() { + assertThrows(NotImplementedException.class, () -> { + typeConverter.toFhirAny("Huh"); + }); } @Test - public void TestCodeToFhirCoding() { - Coding expected = new Coding("http://the-system.com", "test", "system-test").setVersion("1.5"); - Coding actual = (Coding) this.typeConverter.toFhirCoding(new Code() + void codeToFhirCoding() { + Coding expected = new Coding() + .setSystem("http://the-system.com") + .setCode("test") + .setDisplay("system-test") + .setVersion("1.5"); + Coding actual = (Coding) typeConverter.toFhirCoding(new Code() .withSystem("http://the-system.com") .withCode("test") .withDisplay("system-test") .withVersion("1.5")); assertTrue(expected.equalsDeep(actual)); - expected = (Coding) this.typeConverter.toFhirCoding(null); + expected = (Coding) typeConverter.toFhirCoding(null); assertNull(expected); } @Test - public void TestConceptToFhirCodeableConcept() { - CodeableConcept expected = new CodeableConcept( - new Coding("http://the-system.com", "test", "system-test").setVersion("1.5")) + void conceptToFhirCodeableConcept() { + CodeableConcept expected = new CodeableConcept(new Coding() + .setSystem("http://the-system.com") + .setCode("test") + .setDisplay("system-test") + .setVersion("1.5")) .setText("additional-text"); - CodeableConcept actual = (CodeableConcept) this.typeConverter.toFhirCodeableConcept(new Concept() + CodeableConcept actual = (CodeableConcept) typeConverter.toFhirCodeableConcept(new Concept() .withCode(new Code() .withSystem("http://the-system.com") .withCode("test") @@ -354,36 +373,35 @@ public void TestConceptToFhirCodeableConcept() { .withDisplay("additional-text")); assertTrue(expected.equalsDeep(actual)); - expected = (CodeableConcept) this.typeConverter.toFhirCodeableConcept(null); + expected = (CodeableConcept) typeConverter.toFhirCodeableConcept(null); assertNull(expected); } - @DataProvider private static Object[][] startAndEndTimes() { return ConverterTestUtils.startAndEndTimes(); } - @Test(dataProvider = "startAndEndTimes") - public void TestIntervalToFhirPeriod_yyyyMMdd(LocalDateTime startTime, LocalDateTime endTime) { + @ParameterizedTest + @MethodSource("startAndEndTimes") + void intervalToFhirPeriodYyyyMMdd(LocalDateTime startTime, LocalDateTime endTime) { final String startTime_yyyyMMdd = YYYY_MM_DD.format(startTime); final String endTime_yyyyMMdd = YYYY_MM_DD.format(endTime); final Period expected = new Period() .setStartElement(new DateTimeType(startTime_yyyyMMdd)) .setEndElement(new DateTimeType(endTime_yyyyMMdd)); - final Period actual = (Period) this.typeConverter.toFhirPeriod( + final Period actual = (Period) typeConverter.toFhirPeriod( new Interval(new Date(startTime_yyyyMMdd), true, new Date(endTime_yyyyMMdd), true)); assertTrue(expected.equalsDeep(actual)); } - @DataProvider private static Object[][] dateTimes() { return ConverterTestUtils.dateTimes(); } - @Test(dataProvider = "dateTimes") - public void TestIntervalToFhirPeriod_timestampWithOffsets( - LocalDateTime now, LocalDateTime startTime, LocalDateTime endTime) { + @ParameterizedTest + @MethodSource("dateTimes") + void intervalToFhirPeriodTimestampWithOffsets(LocalDateTime now, LocalDateTime startTime, LocalDateTime endTime) { final ZonedDateTime zonedDateTime = ZonedDateTime.of(now, ZoneId.systemDefault()); final ZoneOffset defaultOffset = zonedDateTime.getOffset(); @@ -400,202 +418,230 @@ public void TestIntervalToFhirPeriod_timestampWithOffsets( final DateTime dateTimeStart = new DateTime(startTimeNoOffset, defaultOffset); final DateTime dateTimeEnd = new DateTime(endTimeNoOffset, defaultOffset); final Interval intervalStartEnd = new Interval(dateTimeStart, true, dateTimeEnd, true); - var actual = (Period) this.typeConverter.toFhirPeriod(intervalStartEnd); + var actual = (Period) typeConverter.toFhirPeriod(intervalStartEnd); assertTrue(expected.equalsDeep(actual)); } - @DataProvider private static Object[][] startAndEndYears() { return ConverterTestUtils.startAndEndYears(); } - @Test(dataProvider = "startAndEndYears") - public void TestIntervalToFhirPeriod_startAndEndYears(LocalDateTime now, int startYear, int endYear) { + @ParameterizedTest + @MethodSource("startAndEndYears") + void intervalToFhirPeriodStartAndEndYears(LocalDateTime now, int startYear, int endYear) { final ZonedDateTime zonedDateTime = ZonedDateTime.of(now, ZoneId.systemDefault()); final ZoneOffset defaultOffset = zonedDateTime.getOffset(); final Period expected = new Period() .setStartElement(new DateTimeType(startYear + "-01-01T00:00:00" + defaultOffset)) .setEndElement(new DateTimeType(endYear + "-01-01T00:00:00" + defaultOffset)); - final Period actual = (Period) this.typeConverter.toFhirPeriod(new Interval( + final Period actual = (Period) typeConverter.toFhirPeriod(new Interval( new DateTime("" + startYear, defaultOffset), true, new DateTime("" + endYear, defaultOffset), true)); assertTrue(expected.equalsDeep(actual)); } @Test - public void TestIntervalToFhirPeriod_null() { - assertNull(this.typeConverter.toFhirPeriod(null)); + void intervalToFhirPeriodNull() { + assertNull(typeConverter.toFhirPeriod(null)); } - @Test(expectedExceptions = IllegalArgumentException.class) - public void TestInvalidIntervalToFhirPeriod() { - this.typeConverter.toFhirPeriod(new Interval(5, true, 6, true)); + @Test + void invalidIntervalToFhirPeriod() { + var interval = new Interval(5, true, 6, true); + assertThrows(IllegalArgumentException.class, () -> { + typeConverter.toFhirPeriod(interval); + }); } @Test - public void TestIntervalToFhirRange() { + void intervalToFhirRange() { Range expected = new Range() - .setLow(new org.hl7.fhir.r4.model.Quantity(2.0) + .setLow(new org.hl7.fhir.r4.model.Quantity() + .setValue(new BigDecimal("2.0")) .setCode("ml") - .setSystem("http://unitsofmeasure.org") - .setUnit("ml")) - .setHigh(new org.hl7.fhir.r4.model.Quantity(5.0) + .setUnit("ml") + .setSystem("http://unitsofmeasure.org")) + .setHigh(new org.hl7.fhir.r4.model.Quantity() + .setValue(new BigDecimal("5.0")) .setCode("ml") - .setSystem("http://unitsofmeasure.org") - .setUnit("ml")); - Range actual = (Range) this.typeConverter.toFhirRange(new Interval( + .setUnit("ml") + .setSystem("http://unitsofmeasure.org")); + Range actual = (Range) typeConverter.toFhirRange(new Interval( new Quantity().withValue(new BigDecimal("2.0")).withUnit("ml"), true, new Quantity().withValue(new BigDecimal("5.0")).withUnit("ml"), true)); assertTrue(expected.equalsDeep(actual)); - actual = (Range) this.typeConverter.toFhirRange(null); + actual = (Range) typeConverter.toFhirRange(null); assertNull(null); } - @Test(expectedExceptions = IllegalArgumentException.class) - public void TestInvalidIntervalToFhirRange() { - this.typeConverter.toFhirRange(new Interval(5, true, 6, true)); + @Test + void invalidIntervalToFhirRange() { + var interval = new Interval(5, true, 6, true); + assertThrows(IllegalArgumentException.class, () -> { + typeConverter.toFhirRange(interval); + }); } @Test - public void TestIntervalToFhirInterval() { + void intervalToFhirInterval() { Period expectedPeriod = new Period() .setStartElement(new DateTimeType("2019-02-03")) .setEndElement(new DateTimeType("2019-02-05")); - Period actualPeriod = (Period) this.typeConverter.toFhirInterval( - new Interval(new Date("2019-02-03"), true, new Date("2019-02-05"), true)); + Period actualPeriod = (Period) + typeConverter.toFhirInterval(new Interval(new Date("2019-02-03"), true, new Date("2019-02-05"), true)); assertTrue(expectedPeriod.equalsDeep(actualPeriod)); Range expectedRange = new Range() - .setLow(new org.hl7.fhir.r4.model.Quantity(2.0) + .setLow(new org.hl7.fhir.r4.model.Quantity() + .setValue(new BigDecimal("2.0")) .setCode("ml") - .setSystem("http://unitsofmeasure.org") - .setUnit("ml")) - .setHigh(new org.hl7.fhir.r4.model.Quantity(5.0) + .setUnit("ml") + .setSystem("http://unitsofmeasure.org")) + .setHigh(new org.hl7.fhir.r4.model.Quantity() + .setValue(new BigDecimal("5.0")) .setCode("ml") - .setSystem("http://unitsofmeasure.org") - .setUnit("ml")); - Range actualRange = (Range) this.typeConverter.toFhirInterval(new Interval( + .setUnit("ml") + .setSystem("http://unitsofmeasure.org")); + Range actualRange = (Range) typeConverter.toFhirInterval(new Interval( new Quantity().withValue(new BigDecimal("2.0")).withUnit("ml"), true, new Quantity().withValue(new BigDecimal("5.0")).withUnit("ml"), true)); assertTrue(expectedRange.equalsDeep(actualRange)); - ICompositeType expected = this.typeConverter.toFhirInterval(null); + ICompositeType expected = typeConverter.toFhirInterval(null); assertNull(expected); } - @Test(expectedExceptions = IllegalArgumentException.class) - public void TestInvalidIntervalToFhirInterval() { - this.typeConverter.toFhirInterval(new Interval(5, true, 6, true)); + @Test + void invalidIntervalToFhirInterval() { + var interval = new Interval(5, true, 6, true); + + assertThrows(IllegalArgumentException.class, () -> { + typeConverter.toFhirInterval(interval); + }); } - @Test(expectedExceptions = NotImplementedException.class) - public void TestTupleToFhirTuple() { - IBase expected = this.typeConverter.toFhirTuple(null); + @Test + void tupleToFhirTuple() { + IBase expected = typeConverter.toFhirTuple(null); assertNull(expected); - this.typeConverter.toFhirTuple(new Tuple()); + var tuple = new Tuple(); + assertThrows(NotImplementedException.class, () -> { + typeConverter.toFhirTuple(tuple); + }); } // FHIR-to-CQL @Test - public void TestIsCqlType() { - assertTrue(this.typeConverter.isCqlType(5)); - assertTrue(this.typeConverter.isCqlType(new BigDecimal(0))); - assertTrue(this.typeConverter.isCqlType(new Code())); + void isCqlType() { + assertTrue(typeConverter.isCqlType(5)); + assertTrue(typeConverter.isCqlType(new BigDecimal(0))); + assertTrue(typeConverter.isCqlType(new Code())); - assertFalse(this.typeConverter.isCqlType(new Patient())); - assertFalse(this.typeConverter.isCqlType(new IdType())); + assertFalse(typeConverter.isCqlType(new Patient())); + assertFalse(typeConverter.isCqlType(new IdType())); } - @Test(expectedExceptions = NullPointerException.class) - public void TestNullIsCqlType() { - this.typeConverter.isCqlType(null); + @Test + void nullIsCqlType() { + assertThrows(NullPointerException.class, () -> typeConverter.isCqlType(null)); } - @Test(expectedExceptions = IllegalArgumentException.class) - public void TestIterableIsCqlType() { - this.typeConverter.isCqlType(new ArrayList<>()); + @Test + void iterableIsCqlType() { + var value = new ArrayList<>(); + assertThrows(IllegalArgumentException.class, () -> typeConverter.isCqlType(value)); } @Test - public void TestToCqlType() { - Object actual = this.typeConverter.toCqlType(new Code()); + void toCqlType() { + Object actual = typeConverter.toCqlType(new Code()); assertThat(actual, instanceOf(Code.class)); - actual = this.typeConverter.toCqlType(new IntegerType(5)); + actual = typeConverter.toCqlType(new IntegerType(5)); assertThat(actual, instanceOf(Integer.class)); - actual = this.typeConverter.toCqlType(new StringType("test")); + actual = typeConverter.toCqlType(new StringType("test")); assertThat(actual, instanceOf(String.class)); - actual = this.typeConverter.toCqlType(new IdType("test")); + actual = typeConverter.toCqlType(new IdType("test")); assertThat(actual, instanceOf(String.class)); - actual = this.typeConverter.toCqlType(new BooleanType(true)); + actual = typeConverter.toCqlType(new BooleanType(true)); assertThat(actual, instanceOf(Boolean.class)); - actual = this.typeConverter.toCqlType(new DecimalType(1.0)); + actual = typeConverter.toCqlType(new DecimalType(1.0)); assertThat(actual, instanceOf(BigDecimal.class)); - actual = this.typeConverter.toCqlType(new DateType(Calendar.getInstance())); + actual = typeConverter.toCqlType(new DateType(Calendar.getInstance().getTime())); assertThat(actual, instanceOf(Date.class)); - actual = this.typeConverter.toCqlType(new InstantType(Calendar.getInstance())); + actual = typeConverter.toCqlType(new InstantType(Calendar.getInstance())); assertThat(actual, instanceOf(DateTime.class)); - actual = this.typeConverter.toCqlType(new DateTimeType(Calendar.getInstance())); + actual = typeConverter.toCqlType(new DateTimeType(Calendar.getInstance())); assertThat(actual, instanceOf(DateTime.class)); - actual = this.typeConverter.toCqlType(new TimeType("10:00:00.0000")); + actual = typeConverter.toCqlType(new TimeType("10:00:00.0000")); assertThat(actual, instanceOf(Time.class)); - actual = this.typeConverter.toCqlType(new StringType("test")); + actual = typeConverter.toCqlType(new StringType("test")); assertThat(actual, instanceOf(String.class)); - actual = this.typeConverter.toCqlType(new org.hl7.fhir.r4.model.Quantity()); + actual = typeConverter.toCqlType(new org.hl7.fhir.r4.model.Quantity()); assertThat(actual, instanceOf(Quantity.class)); - actual = this.typeConverter.toCqlType(new org.hl7.fhir.r4.model.Ratio()); + actual = typeConverter.toCqlType(new org.hl7.fhir.r4.model.Ratio()); assertThat(actual, instanceOf(Ratio.class)); - actual = this.typeConverter.toCqlType(new Coding()); + actual = typeConverter.toCqlType(new Coding()); assertThat(actual, instanceOf(Code.class)); - actual = this.typeConverter.toCqlType(new CodeableConcept()); + actual = typeConverter.toCqlType(new CodeableConcept()); assertThat(actual, instanceOf(Concept.class)); - actual = this.typeConverter.toCqlType(new Period() + actual = typeConverter.toCqlType(new Period() .setStart(Calendar.getInstance().getTime()) .setEnd(Calendar.getInstance().getTime())); assertThat(actual, instanceOf(Interval.class)); - actual = this.typeConverter.toCqlType(new Range() - .setLow(org.hl7.fhir.r4.model.Quantity.fromUcum("1", "d")) - .setHigh(org.hl7.fhir.r4.model.Quantity.fromUcum("5", "d"))); + SimpleQuantity low = new SimpleQuantity(); + low.setValue(BigDecimal.valueOf(1.0)); + low.setUnit("d"); + + SimpleQuantity high = new SimpleQuantity(); + high.setValue(BigDecimal.valueOf(4.0)); + high.setUnit("d"); + actual = typeConverter.toCqlType(new Range().setLow(low).setHigh(high)); assertThat(actual, instanceOf(Interval.class)); - actual = this.typeConverter.toCqlType(null); + actual = typeConverter.toCqlType(null); assertNull(null); } - @Test(expectedExceptions = IllegalArgumentException.class) - public void TestToCqlTypeIterable() { - this.typeConverter.toCqlType(new ArrayList<>()); + @Test + void toCqlTypeIterable() { + assertThrows(IllegalArgumentException.class, () -> { + typeConverter.toCqlType(new ArrayList<>()); + }); } - @Test(expectedExceptions = IllegalArgumentException.class) - public void TestToCqlTypeNotCql() { - this.typeConverter.toCqlType(ZoneOffset.ofHours(3)); + @Test + void toCqlTypeNotCql() { + var offset = ZoneOffset.ofHours(3); + assertThrows(IllegalArgumentException.class, () -> { + typeConverter.toCqlType(offset); + }); } @Test - public void TestToCqlTypes() { + void toCqlTypes() { List innerExpected = new ArrayList<>(); innerExpected.add("123"); @@ -613,133 +659,145 @@ public void TestToCqlTypes() { test.add(null); test.add(new IntegerType(5)); - Iterable actual = this.typeConverter.toCqlTypes(test); + Iterable actual = typeConverter.toCqlTypes(test); assertTrue(compareIterables(expected, actual)); } @Test - public void TestStringToCqlId() { + void stringToCqlId() { String expected = "123"; - String actual = this.typeConverter.toCqlId(new IdType("123")); + String actual = typeConverter.toCqlId(new IdType("123")); assertEquals(expected, actual); - actual = this.typeConverter.toCqlId(null); + actual = typeConverter.toCqlId(null); assertNull(actual); } @Test - public void TestPrimitiveFhirTypeToCqlType() { + void primitiveFhirTypeToCqlType() { Boolean expectedBoolean = false; - Boolean actualBoolean = this.typeConverter.toCqlBoolean(new BooleanType(false)); + Boolean actualBoolean = typeConverter.toCqlBoolean(new BooleanType(false)); assertEquals(expectedBoolean, actualBoolean); - expectedBoolean = this.typeConverter.toCqlBoolean(null); + expectedBoolean = typeConverter.toCqlBoolean(null); assertNull(expectedBoolean); Integer expectedInteger = 5; - Integer actualInteger = this.typeConverter.toCqlInteger(new IntegerType(5)); + Integer actualInteger = typeConverter.toCqlInteger(new IntegerType(5)); assertEquals(expectedInteger, actualInteger); - expectedInteger = this.typeConverter.toCqlInteger(null); + expectedInteger = typeConverter.toCqlInteger(null); assertNull(expectedInteger); String expectedString = "5"; - String actualString = this.typeConverter.toCqlString(new StringType("5")); + String actualString = typeConverter.toCqlString(new StringType("5")); assertEquals(expectedString, actualString); - expectedString = this.typeConverter.toCqlString(null); + expectedString = typeConverter.toCqlString(null); assertNull(expectedString); BigDecimal expectedDecimal = new BigDecimal(2.0); - BigDecimal actualDecimal = this.typeConverter.toCqlDecimal(new DecimalType(new BigDecimal(2.0))); + BigDecimal actualDecimal = typeConverter.toCqlDecimal(new DecimalType(new BigDecimal(2.0))); assertEquals(expectedDecimal, actualDecimal); - expectedDecimal = this.typeConverter.toCqlDecimal(null); + expectedDecimal = typeConverter.toCqlDecimal(null); assertNull(expectedDecimal); } @Test - public void TestDateToCqlType() { + void dateToCqlType() { Date expectedDate = new Date("2019-02-03"); - Date actualDate = this.typeConverter.toCqlDate(new org.hl7.fhir.r4.model.DateType("2019-02-03")); + Date actualDate = typeConverter.toCqlDate(new org.hl7.fhir.r4.model.DateType("2019-02-03")); assertTrue(expectedDate.equal(actualDate)); expectedDate = new Date("2019"); - actualDate = this.typeConverter.toCqlDate(new DateType("2019")); + actualDate = typeConverter.toCqlDate(new DateType("2019")); assertTrue(expectedDate.equal(actualDate)); } @Test - public void TestDateTimeToCqlType() { + void dateTimeToCqlType() { DateTime expectedDate = new DateTime("2019-02-03", ZoneOffset.UTC); - DateTime actualDate = this.typeConverter.toCqlDateTime(new DateTimeType("2019-02-03")); + DateTime actualDate = typeConverter.toCqlDateTime(new DateTimeType("2019-02-03")); assertTrue(expectedDate.equal(actualDate)); expectedDate = new DateTime("2019", ZoneOffset.UTC); - actualDate = this.typeConverter.toCqlDateTime(new DateTimeType("2019")); + actualDate = typeConverter.toCqlDateTime(new DateTimeType("2019")); assertTrue(expectedDate.equal(actualDate)); expectedDate = new DateTime("2019", ZoneOffset.UTC); - actualDate = this.typeConverter.toCqlDateTime(new DateTimeType("2019")); + actualDate = typeConverter.toCqlDateTime(new DateTimeType("2019")); assertTrue(expectedDate.equal(actualDate)); } @Test - public void TestQuantityToCqlType() { + void quantityToCqlType() { Quantity expected = (new Quantity().withValue(new BigDecimal("2.0")).withUnit("ml")); - Quantity actual = this.typeConverter.toCqlQuantity( - new org.hl7.fhir.r4.model.Quantity(2.0).setUnit("ml").setSystem("http://unitsofmeasure.org")); + Quantity actual = typeConverter.toCqlQuantity(new org.hl7.fhir.r4.model.Quantity() + .setValue(new BigDecimal("2.0")) + .setUnit("ml") + .setSystem("http://unitsofmeasure.org")); assertTrue(expected.equal(actual)); } @Test - public void TestRatioToCqlType() { + void ratioToCqlType() { Ratio expected = new Ratio(); expected.setNumerator(new Quantity().withValue(BigDecimal.valueOf(1.0)).withUnit("ml")); expected.setDenominator( new Quantity().withValue(BigDecimal.valueOf(2.0)).withUnit("ml")); - org.hl7.fhir.r4.model.Quantity testNumerator = - new org.hl7.fhir.r4.model.Quantity(1.0).setUnit("ml").setSystem("http://unitsofmeasure.org"); - org.hl7.fhir.r4.model.Quantity testDenominator = - new org.hl7.fhir.r4.model.Quantity(2.0).setUnit("ml").setSystem("http://unitsofmeasure.org"); + org.hl7.fhir.r4.model.Quantity testNumerator = new org.hl7.fhir.r4.model.Quantity() + .setValue(new BigDecimal("1.0")) + .setUnit("ml") + .setSystem("http://unitsofmeasure.org"); + org.hl7.fhir.r4.model.Quantity testDenominator = new org.hl7.fhir.r4.model.Quantity() + .setValue(new BigDecimal("2.0")) + .setUnit("ml") + .setSystem("http://unitsofmeasure.org"); org.hl7.fhir.r4.model.Ratio test = new org.hl7.fhir.r4.model.Ratio().setNumerator(testNumerator).setDenominator(testDenominator); - Ratio actual = this.typeConverter.toCqlRatio(test); + Ratio actual = typeConverter.toCqlRatio(test); assertTrue(expected.equal(actual)); } - @Test() - public void TestNullToCqlType() { - Object expected = this.typeConverter.toCqlAny(null); + @Test + void nullToCqlType() { + Object expected = typeConverter.toCqlAny(null); assertNull(expected); } - @Test(expectedExceptions = NotImplementedException.class) - public void TestObjectToCqlType() { - this.typeConverter.toCqlAny(new IdType()); + @Test + void objectToCqlType() { + var id = new IdType(); + assertThrows(NotImplementedException.class, () -> { + typeConverter.toCqlAny(id); + }); } @Test - public void TestCodingToCqlCode() { + void codingToCqlCode() { Code expected = new Code() .withSystem("http://the-system.com") .withCode("test") .withDisplay("system-test") .withVersion("1.5"); - Code actual = this.typeConverter.toCqlCode( - new Coding("http://the-system.com", "test", "system-test").setVersion("1.5")); + Code actual = typeConverter.toCqlCode(new Coding() + .setSystem("http://the-system.com") + .setCode("test") + .setDisplay("system-test") + .setVersion("1.5")); assertTrue(expected.equal(actual)); - expected = this.typeConverter.toCqlCode(null); + expected = typeConverter.toCqlCode(null); assertNull(expected); } @Test - public void TestCodeableConceptToCqlConcept() { + void codeableConceptToCqlConcept() { Concept expected = new Concept() .withCode(new Code() .withSystem("http://the-system.com") @@ -747,26 +805,29 @@ public void TestCodeableConceptToCqlConcept() { .withDisplay("system-test") .withVersion("1.5")) .withDisplay("additional-text"); - Concept actual = this.typeConverter.toCqlConcept( - new CodeableConcept(new Coding("http://the-system.com", "test", "system-test").setVersion("1.5")) - .setText("additional-text")); + Concept actual = typeConverter.toCqlConcept(new CodeableConcept(new Coding() + .setSystem("http://the-system.com") + .setCode("test") + .setDisplay("system-test") + .setVersion("1.5")) + .setText("additional-text")); assertTrue(expected.equal(actual)); - expected = this.typeConverter.toCqlConcept(null); + expected = typeConverter.toCqlConcept(null); assertNull(expected); } @Test - public void TestPeriodToCqlInterval() { + void periodToCqlInterval() { Interval expected = new Interval(new Date("2019-02-03"), true, new Date("2019-02-05"), true); - Interval actual = this.typeConverter.toCqlInterval(new Period() + Interval actual = typeConverter.toCqlInterval(new Period() .setStartElement(new DateTimeType("2019-02-03")) .setEndElement(new DateTimeType("2019-02-05"))); assertTrue(expected.equal(actual)); expected = new Interval(new Date("2019"), true, new Date("2020"), true); - actual = this.typeConverter.toCqlInterval( + actual = typeConverter.toCqlInterval( new Period().setStartElement(new DateTimeType("2019")).setEndElement(new DateTimeType("2020"))); assertTrue(expected.equal(actual)); @@ -775,41 +836,53 @@ public void TestPeriodToCqlInterval() { true, new DateTime("2020-09-18T19:37:00", ZoneOffset.UTC), true); - actual = this.typeConverter.toCqlInterval(new Period() + actual = typeConverter.toCqlInterval(new Period() .setStartElement(new DateTimeType("2020-09-18T19:35:53+00:00")) .setEndElement(new DateTimeType("2020-09-18T19:37:00+00:00"))); assertTrue(expected.equal(actual)); - actual = this.typeConverter.toCqlInterval(null); + actual = typeConverter.toCqlInterval(null); assertNull(null); } @Test - public void TestRangeToCqlInterval() { + void rangeToCqlInterval() { Interval expected = new Interval( new Quantity().withValue(new BigDecimal("2.0")).withUnit("ml"), true, new Quantity().withValue(new BigDecimal("5.0")).withUnit("ml"), true); - Interval actual = this.typeConverter.toCqlInterval(new Range() - .setLow(new org.hl7.fhir.r4.model.Quantity(2.0).setUnit("ml").setSystem("http://unitsofmeasure.org")) - .setHigh(new org.hl7.fhir.r4.model.Quantity(5.0).setUnit("ml").setSystem("http://unitsofmeasure.org"))); + Interval actual = typeConverter.toCqlInterval(new Range() + .setLow((SimpleQuantity) new org.hl7.fhir.r4.model.SimpleQuantity() + .setValue(new BigDecimal("2.0")) + .setUnit("ml") + .setSystem("http://unitsofmeasure.org")) + .setHigh((SimpleQuantity) new org.hl7.fhir.r4.model.SimpleQuantity() + .setValue(new BigDecimal("5.0")) + .setUnit("ml") + .setSystem("http://unitsofmeasure.org"))); assertTrue(expected.equal(actual)); - actual = this.typeConverter.toCqlInterval(null); + actual = typeConverter.toCqlInterval(null); assertNull(null); } - @Test(expectedExceptions = IllegalArgumentException.class) - public void TestInvalidTypeToCqlInterval() { - this.typeConverter.toCqlInterval(new Attachment()); + @Test + void invalidTypeToCqlInterval() { + var attachment = new Attachment(); + assertThrows(IllegalArgumentException.class, () -> { + typeConverter.toCqlInterval(attachment); + }); } - @Test(expectedExceptions = NotImplementedException.class) - public void TestTupleToCqlTuple() { - Object expected = this.typeConverter.toCqlTuple(null); + @Test + void tupleToCqlTuple() { + Object expected = typeConverter.toCqlTuple(null); assertNull(expected); - this.typeConverter.toCqlTuple(new Patient()); + var p = new Patient(); + assertThrows(NotImplementedException.class, () -> { + typeConverter.toCqlTuple(p); + }); } } diff --git a/Src/java/engine-fhir/src/test/java/org/opencds/cqf/cql/engine/fhir/converter/R5TypeConverterTests.java b/Src/java/engine-fhir/src/test/java/org/opencds/cqf/cql/engine/fhir/converter/R5TypeConverterTests.java index 6ef81ebab..ac055c092 100644 --- a/Src/java/engine-fhir/src/test/java/org/opencds/cqf/cql/engine/fhir/converter/R5TypeConverterTests.java +++ b/Src/java/engine-fhir/src/test/java/org/opencds/cqf/cql/engine/fhir/converter/R5TypeConverterTests.java @@ -2,11 +2,12 @@ import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.instanceOf; -import static org.opencds.cqf.cql.engine.fhir.converter.ConverterTestUtils.YYYY_MM_DD; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertFalse; -import static org.testng.Assert.assertNull; -import static org.testng.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.opencds.cqf.cql.engine.fhir.converter.ConverterTestUtils.*; import ca.uhn.fhir.model.api.TemporalPrecisionEnum; import java.math.BigDecimal; @@ -18,7 +19,6 @@ import java.util.List; import java.util.TimeZone; import org.apache.commons.lang3.NotImplementedException; -import org.hl7.fhir.dstu2.model.IdType; import org.hl7.fhir.instance.model.api.IBase; import org.hl7.fhir.instance.model.api.ICompositeType; import org.hl7.fhir.instance.model.api.IIdType; @@ -31,21 +31,24 @@ import org.hl7.fhir.r5.model.DateTimeType; import org.hl7.fhir.r5.model.DateType; import org.hl7.fhir.r5.model.DecimalType; +import org.hl7.fhir.r5.model.IdType; import org.hl7.fhir.r5.model.InstantType; import org.hl7.fhir.r5.model.IntegerType; import org.hl7.fhir.r5.model.Patient; import org.hl7.fhir.r5.model.Period; import org.hl7.fhir.r5.model.Range; +import org.hl7.fhir.r5.model.SimpleQuantity; import org.hl7.fhir.r5.model.StringType; import org.hl7.fhir.r5.model.TimeType; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import org.opencds.cqf.cql.engine.runtime.*; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; -public class R5TypeConverterTests { +class R5TypeConverterTests { - private R5FhirTypeConverter typeConverter; + private static R5FhirTypeConverter typeConverter; protected Boolean compareIterables(Iterable left, Iterable right) { Iterator leftIterator = left.iterator(); @@ -93,73 +96,84 @@ protected Boolean compareObjects(Object left, Object right) { return left.equals(right); } - @BeforeClass - public void initialize() { - this.typeConverter = new R5FhirTypeConverter(); + @BeforeAll + static void initialize() { + typeConverter = new R5FhirTypeConverter(); } // CQL-to-FHIR @Test - public void TestIsFhirType() { - assertTrue(this.typeConverter.isFhirType(new Patient())); - assertTrue(this.typeConverter.isFhirType(new IdType())); - assertTrue(this.typeConverter.isFhirType(new org.hl7.fhir.r5.model.Quantity())); - assertTrue(this.typeConverter.isFhirType(new org.hl7.fhir.r5.model.Ratio())); - assertTrue(this.typeConverter.isFhirType(new BooleanType())); - assertTrue(this.typeConverter.isFhirType(new IntegerType())); - assertTrue(this.typeConverter.isFhirType(new DecimalType())); - assertTrue(this.typeConverter.isFhirType(new DateType())); - assertTrue(this.typeConverter.isFhirType(new InstantType())); - assertTrue(this.typeConverter.isFhirType(new DateTimeType())); - assertTrue(this.typeConverter.isFhirType(new TimeType())); - assertTrue(this.typeConverter.isFhirType(new StringType())); - assertTrue(this.typeConverter.isFhirType(new Coding())); - assertTrue(this.typeConverter.isFhirType(new CodeableConcept())); - assertTrue(this.typeConverter.isFhirType(new Period())); - assertTrue(this.typeConverter.isFhirType(new Range())); - - assertFalse(this.typeConverter.isFhirType(5)); - assertFalse(this.typeConverter.isFhirType(new BigDecimal(0))); - assertFalse(this.typeConverter.isFhirType(new Code())); + void isFhirType() { + assertTrue(typeConverter.isFhirType(new Patient())); + assertTrue(typeConverter.isFhirType(new IdType())); + assertTrue(typeConverter.isFhirType(new org.hl7.fhir.r5.model.Quantity())); + assertTrue(typeConverter.isFhirType(new org.hl7.fhir.r5.model.Ratio())); + assertTrue(typeConverter.isFhirType(new BooleanType())); + assertTrue(typeConverter.isFhirType(new IntegerType())); + assertTrue(typeConverter.isFhirType(new DecimalType())); + assertTrue(typeConverter.isFhirType(new DateType())); + assertTrue(typeConverter.isFhirType(new InstantType())); + assertTrue(typeConverter.isFhirType(new DateTimeType())); + assertTrue(typeConverter.isFhirType(new TimeType())); + assertTrue(typeConverter.isFhirType(new StringType())); + assertTrue(typeConverter.isFhirType(new Coding())); + assertTrue(typeConverter.isFhirType(new CodeableConcept())); + assertTrue(typeConverter.isFhirType(new Period())); + assertTrue(typeConverter.isFhirType(new Range())); + + assertFalse(typeConverter.isFhirType(5)); + assertFalse(typeConverter.isFhirType(new BigDecimal(0))); + assertFalse(typeConverter.isFhirType(new Code())); } - @Test(expectedExceptions = NullPointerException.class) - public void TestNullIsFhirType() { - this.typeConverter.isFhirType(null); + @Test + void nullIsFhirType() { + assertThrows(NullPointerException.class, () -> { + typeConverter.isFhirType(null); + }); } - @Test(expectedExceptions = IllegalArgumentException.class) - public void TestIterableIsFhirType() { - this.typeConverter.isFhirType(new ArrayList<>()); + @Test + void iterableIsFhirType() { + var value = new ArrayList<>(); + assertThrows(IllegalArgumentException.class, () -> { + typeConverter.isFhirType(value); + }); } @Test - public void TestToFhirType() { - IBase actual = this.typeConverter.toFhirType(new Code()); + void toFhirType() { + IBase actual = typeConverter.toFhirType(new Code()); assertThat(actual, instanceOf(Coding.class)); - actual = this.typeConverter.toFhirType(5); + actual = typeConverter.toFhirType(5); assertThat(actual, instanceOf(IntegerType.class)); - actual = this.typeConverter.toFhirType(new IdType()); + actual = typeConverter.toFhirType(new IdType()); assertThat(actual, instanceOf(IdType.class)); - actual = this.typeConverter.toFhirType(null); + actual = typeConverter.toFhirType(null); assertNull(null); } - @Test(expectedExceptions = IllegalArgumentException.class) - public void TestToFhirTypeIterable() { - this.typeConverter.toFhirType(new ArrayList<>()); + @Test + void toFhirTypeIterable() { + var value = new ArrayList<>(); + assertThrows(IllegalArgumentException.class, () -> { + typeConverter.toFhirType(value); + }); } - @Test(expectedExceptions = IllegalArgumentException.class) - public void TestToFhirTypeNotCql() { - this.typeConverter.toFhirType(ZoneOffset.ofHours(3)); + @Test + void toFhirTypeNotCql() { + var offset = ZoneOffset.ofHours(3); + assertThrows(IllegalArgumentException.class, () -> { + typeConverter.toFhirType(offset); + }); } @Test - public void TestToFhirTypes() { + void toFhirTypes() { List innerExpected = new ArrayList<>(); innerExpected.add(new StringType("123")); innerExpected.add(null); @@ -176,70 +190,70 @@ public void TestToFhirTypes() { test.add(null); test.add(5); - Iterable actual = this.typeConverter.toFhirTypes(test); + Iterable actual = typeConverter.toFhirTypes(test); assertTrue(compareIterables(expected, actual)); } @Test - public void TestStringToFhirId() { + void stringToFhirId() { IIdType expected = new IdType("123"); - IIdType actual = this.typeConverter.toFhirId("123"); + IIdType actual = typeConverter.toFhirId("123"); assertEquals(expected.getValue(), actual.getValue()); - actual = this.typeConverter.toFhirId(null); + actual = typeConverter.toFhirId(null); assertNull(actual); } @Test - public void TestPrimitiveCqlTypeToFhirType() { + void primitiveCqlTypeToFhirType() { IPrimitiveType expectedBoolean = new BooleanType(false); - IPrimitiveType actualBoolean = this.typeConverter.toFhirBoolean(false); + IPrimitiveType actualBoolean = typeConverter.toFhirBoolean(false); assertEquals(expectedBoolean.getValue(), actualBoolean.getValue()); - expectedBoolean = this.typeConverter.toFhirBoolean(null); + expectedBoolean = typeConverter.toFhirBoolean(null); assertNull(expectedBoolean); IPrimitiveType expectedInteger = new IntegerType(5); - IPrimitiveType actualInteger = this.typeConverter.toFhirInteger(5); + IPrimitiveType actualInteger = typeConverter.toFhirInteger(5); assertEquals(expectedInteger.getValue(), actualInteger.getValue()); - expectedInteger = this.typeConverter.toFhirInteger(null); + expectedInteger = typeConverter.toFhirInteger(null); assertNull(expectedInteger); IPrimitiveType expectedString = new StringType("5"); - IPrimitiveType actualString = this.typeConverter.toFhirString("5"); + IPrimitiveType actualString = typeConverter.toFhirString("5"); assertEquals(expectedString.getValue(), actualString.getValue()); - expectedString = this.typeConverter.toFhirString(null); + expectedString = typeConverter.toFhirString(null); assertNull(expectedString); IPrimitiveType expectedDecimal = new DecimalType(new BigDecimal(2.0)); - IPrimitiveType actualDecimal = this.typeConverter.toFhirDecimal(new BigDecimal(2.0)); + IPrimitiveType actualDecimal = typeConverter.toFhirDecimal(new BigDecimal(2.0)); assertEquals(expectedDecimal.getValue(), actualDecimal.getValue()); - expectedDecimal = this.typeConverter.toFhirDecimal(null); + expectedDecimal = typeConverter.toFhirDecimal(null); assertNull(expectedDecimal); } @Test - public void TestDateToFhirDate() { + void dateToFhirDate() { IPrimitiveType expectedDate = new DateType("2019-02-03"); - IPrimitiveType actualDate = this.typeConverter.toFhirDate(new Date("2019-02-03")); + IPrimitiveType actualDate = typeConverter.toFhirDate(new Date("2019-02-03")); assertEquals(expectedDate.getValue(), actualDate.getValue()); expectedDate = new DateType("2019"); - actualDate = this.typeConverter.toFhirDate(new Date("2019")); + actualDate = typeConverter.toFhirDate(new Date("2019")); assertEquals(expectedDate.getValue(), actualDate.getValue()); } - @DataProvider private static Object[][] nowsAndEvaluationTimes() { return ConverterTestUtils.nowsAndEvaluationTimes(); } - @Test(dataProvider = "nowsAndEvaluationTimes") - public void TestDateTimeToFhirDateTime(LocalDateTime now, LocalDateTime evaluationTime) { + @ParameterizedTest + @MethodSource("nowsAndEvaluationTimes") + void dateTimeToFhirDateTime(LocalDateTime now, LocalDateTime evaluationTime) { final ZonedDateTime zonedDateTime = ZonedDateTime.of(now, ZoneId.systemDefault()); final ZoneOffset defaultOffset = zonedDateTime.getOffset(); @@ -248,49 +262,51 @@ public void TestDateTimeToFhirDateTime(LocalDateTime now, LocalDateTime evaluati final String evalDate = DateTimeFormatter.ISO_DATE.format(evaluationTime); var expectedDate = new DateTimeType(evalTimeWithOffset); - IPrimitiveType actualDate = - this.typeConverter.toFhirDateTime(new DateTime(evalDate, defaultOffset)); + IPrimitiveType actualDate = typeConverter.toFhirDateTime(new DateTime(evalDate, defaultOffset)); assertEquals(expectedDate.getValue(), actualDate.getValue()); expectedDate = new DateTimeType(evalTimeWithOffset); - actualDate = this.typeConverter.toFhirDateTime(new DateTime("" + evaluationTime.getYear(), defaultOffset)); + actualDate = typeConverter.toFhirDateTime(new DateTime("" + evaluationTime.getYear(), defaultOffset)); expectedDate.setPrecision(TemporalPrecisionEnum.YEAR); assertEquals(expectedDate.getValue(), actualDate.getValue()); assertEquals(expectedDate.getValueAsString(), actualDate.getValueAsString()); } @Test - public void TestDateTimeToFhirDateTime_Timezones() { + void dateTimeToFhirDateTimeTimezones() { var expectedDate = new DateTimeType("2019-10-10T01:00:00-06:00"); ((DateTimeType) expectedDate).setTimeZone(TimeZone.getTimeZone("MST")); - var actualDate = this.typeConverter.toFhirDateTime(new DateTime("2019-10-10T00:00:00", ZoneOffset.ofHours(-7))); + var actualDate = typeConverter.toFhirDateTime(new DateTime("2019-10-10T00:00:00", ZoneOffset.ofHours(-7))); assertEquals(expectedDate.getValueAsString(), actualDate.getValueAsString()); expectedDate = new DateTimeType("2019-10-10T19:35:53.000Z"); ((DateTimeType) expectedDate).setPrecision(TemporalPrecisionEnum.MILLI); - actualDate = this.typeConverter.toFhirDateTime( + actualDate = typeConverter.toFhirDateTime( new DateTime("2019-10-10T19:35:53", ZoneOffset.UTC).withPrecision(Precision.MILLISECOND)); assertEquals(expectedDate.getValueAsString(), actualDate.getValueAsString()); } @Test - public void TestQuantityToFhirQuantity() { - org.hl7.fhir.r5.model.Quantity expected = new org.hl7.fhir.r5.model.Quantity(2.0) + void quantityToFhirQuantity() { + org.hl7.fhir.r5.model.Quantity expected = new org.hl7.fhir.r5.model.Quantity() + .setValue(new BigDecimal("2.0")) .setCode("ml") .setSystem("http://unitsofmeasure.org") .setUnit("ml"); - org.hl7.fhir.r5.model.Quantity actual = (org.hl7.fhir.r5.model.Quantity) this.typeConverter.toFhirQuantity( + org.hl7.fhir.r5.model.Quantity actual = (org.hl7.fhir.r5.model.Quantity) typeConverter.toFhirQuantity( new Quantity().withValue(new BigDecimal("2.0")).withUnit("ml")); assertTrue(expected.equalsDeep(actual)); } @Test - public void TestRatioToFhirRatio() { - org.hl7.fhir.r5.model.Quantity expectedNumerator = new org.hl7.fhir.r5.model.Quantity(1.0) + void ratioToFhirRatio() { + org.hl7.fhir.r5.model.Quantity expectedNumerator = new org.hl7.fhir.r5.model.Quantity() + .setValue(new BigDecimal("1.0")) .setCode("ml") .setSystem("http://unitsofmeasure.org") .setUnit("ml"); - org.hl7.fhir.r5.model.Quantity expectedDenominator = new org.hl7.fhir.r5.model.Quantity(2.0) + org.hl7.fhir.r5.model.Quantity expectedDenominator = new org.hl7.fhir.r5.model.Quantity() + .setValue(new BigDecimal("2.0")) .setCode("ml") .setSystem("http://unitsofmeasure.org") .setUnit("ml"); @@ -304,42 +320,51 @@ public void TestRatioToFhirRatio() { testData.setDenominator( new Quantity().withValue(BigDecimal.valueOf(2.0)).withUnit("ml")); - org.hl7.fhir.r5.model.Ratio actual = (org.hl7.fhir.r5.model.Ratio) this.typeConverter.toFhirRatio(testData); + org.hl7.fhir.r5.model.Ratio actual = (org.hl7.fhir.r5.model.Ratio) typeConverter.toFhirRatio(testData); assertTrue(expected.equalsDeep(actual)); } - @Test() - public void TestNullToFhirAny() { - IBase expected = this.typeConverter.toFhirAny(null); + @Test + void nullToFhirAny() { + IBase expected = typeConverter.toFhirAny(null); assertNull(expected); } - @Test(expectedExceptions = NotImplementedException.class) - public void TestObjectToFhirAny() { - this.typeConverter.toFhirAny("Huh"); + @Test + void objectToFhirAny() { + assertThrows(NotImplementedException.class, () -> { + typeConverter.toFhirAny("Huh"); + }); } @Test - public void TestCodeToFhirCoding() { - Coding expected = new Coding("http://the-system.com", "test", "system-test").setVersion("1.5"); - Coding actual = (Coding) this.typeConverter.toFhirCoding(new Code() + void codeToFhirCoding() { + Coding expected = new Coding() + .setSystem("http://the-system.com") + .setCode("test") + .setDisplay("system-test") + .setVersion("1.5"); + Coding actual = (Coding) typeConverter.toFhirCoding(new Code() .withSystem("http://the-system.com") .withCode("test") .withDisplay("system-test") .withVersion("1.5")); assertTrue(expected.equalsDeep(actual)); - expected = (Coding) this.typeConverter.toFhirCoding(null); + expected = (Coding) typeConverter.toFhirCoding(null); assertNull(expected); } @Test - public void TestConceptToFhirCodeableConcept() { - CodeableConcept expected = new CodeableConcept( - new Coding("http://the-system.com", "test", "system-test").setVersion("1.5")) + void conceptToFhirCodeableConcept() { + CodeableConcept expected = new CodeableConcept(new Coding() + .setSystem("http://the-system.com") + .setCode("test") + .setDisplay("system-test") + .setVersion("1.5")) .setText("additional-text"); - CodeableConcept actual = (CodeableConcept) this.typeConverter.toFhirCodeableConcept(new Concept() + CodeableConcept actual = (CodeableConcept) typeConverter.toFhirCodeableConcept(new Concept() .withCode(new Code() .withSystem("http://the-system.com") .withCode("test") @@ -348,36 +373,35 @@ public void TestConceptToFhirCodeableConcept() { .withDisplay("additional-text")); assertTrue(expected.equalsDeep(actual)); - expected = (CodeableConcept) this.typeConverter.toFhirCodeableConcept(null); + expected = (CodeableConcept) typeConverter.toFhirCodeableConcept(null); assertNull(expected); } - @DataProvider private static Object[][] startAndEndTimes() { return ConverterTestUtils.startAndEndTimes(); } - @Test(dataProvider = "startAndEndTimes") - public void TestIntervalToFhirPeriod_yyyyMMdd(LocalDateTime startTime, LocalDateTime endTime) { + @ParameterizedTest + @MethodSource("startAndEndTimes") + void intervalToFhirPeriodYyyyMMdd(LocalDateTime startTime, LocalDateTime endTime) { final String startTime_yyyyMMdd = YYYY_MM_DD.format(startTime); final String endTime_yyyyMMdd = YYYY_MM_DD.format(endTime); final Period expected = new Period() .setStartElement(new DateTimeType(startTime_yyyyMMdd)) .setEndElement(new DateTimeType(endTime_yyyyMMdd)); - final Period actual = (Period) this.typeConverter.toFhirPeriod( + final Period actual = (Period) typeConverter.toFhirPeriod( new Interval(new Date(startTime_yyyyMMdd), true, new Date(endTime_yyyyMMdd), true)); assertTrue(expected.equalsDeep(actual)); } - @DataProvider private static Object[][] dateTimes() { return ConverterTestUtils.dateTimes(); } - @Test(dataProvider = "dateTimes") - public void TestIntervalToFhirPeriod_timestampWithOffsets( - LocalDateTime now, LocalDateTime startTime, LocalDateTime endTime) { + @ParameterizedTest + @MethodSource("dateTimes") + void intervalToFhirPeriodTimestampWithOffsets(LocalDateTime now, LocalDateTime startTime, LocalDateTime endTime) { final ZonedDateTime zonedDateTime = ZonedDateTime.of(now, ZoneId.systemDefault()); final ZoneOffset defaultOffset = zonedDateTime.getOffset(); @@ -394,202 +418,230 @@ public void TestIntervalToFhirPeriod_timestampWithOffsets( final DateTime dateTimeStart = new DateTime(startTimeNoOffset, defaultOffset); final DateTime dateTimeEnd = new DateTime(endTimeNoOffset, defaultOffset); final Interval intervalStartEnd = new Interval(dateTimeStart, true, dateTimeEnd, true); - var actual = (Period) this.typeConverter.toFhirPeriod(intervalStartEnd); + var actual = (Period) typeConverter.toFhirPeriod(intervalStartEnd); assertTrue(expected.equalsDeep(actual)); } - @DataProvider private static Object[][] startAndEndYears() { return ConverterTestUtils.startAndEndYears(); } - @Test(dataProvider = "startAndEndYears") - public void TestIntervalToFhirPeriod_startAndEndYears(LocalDateTime now, int startYear, int endYear) { + @ParameterizedTest + @MethodSource("startAndEndYears") + void intervalToFhirPeriodStartAndEndYears(LocalDateTime now, int startYear, int endYear) { final ZonedDateTime zonedDateTime = ZonedDateTime.of(now, ZoneId.systemDefault()); final ZoneOffset defaultOffset = zonedDateTime.getOffset(); final Period expected = new Period() .setStartElement(new DateTimeType(startYear + "-01-01T00:00:00" + defaultOffset)) .setEndElement(new DateTimeType(endYear + "-01-01T00:00:00" + defaultOffset)); - final Period actual = (Period) this.typeConverter.toFhirPeriod(new Interval( + final Period actual = (Period) typeConverter.toFhirPeriod(new Interval( new DateTime("" + startYear, defaultOffset), true, new DateTime("" + endYear, defaultOffset), true)); assertTrue(expected.equalsDeep(actual)); } @Test - public void TestIntervalToFhirPeriod_null() { - assertNull(this.typeConverter.toFhirPeriod(null)); + void intervalToFhirPeriodNull() { + assertNull(typeConverter.toFhirPeriod(null)); } - @Test(expectedExceptions = IllegalArgumentException.class) - public void TestInvalidIntervalToFhirPeriod() { - this.typeConverter.toFhirPeriod(new Interval(5, true, 6, true)); + @Test + void invalidIntervalToFhirPeriod() { + var interval = new Interval(5, true, 6, true); + assertThrows(IllegalArgumentException.class, () -> { + typeConverter.toFhirPeriod(interval); + }); } @Test - public void TestIntervalToFhirRange() { + void intervalToFhirRange() { Range expected = new Range() - .setLow(new org.hl7.fhir.r5.model.Quantity(2.0) + .setLow(new org.hl7.fhir.r5.model.Quantity() + .setValue(new BigDecimal("2.0")) .setCode("ml") - .setSystem("http://unitsofmeasure.org") - .setUnit("ml")) - .setHigh(new org.hl7.fhir.r5.model.Quantity(5.0) + .setUnit("ml") + .setSystem("http://unitsofmeasure.org")) + .setHigh(new org.hl7.fhir.r5.model.Quantity() + .setValue(new BigDecimal("5.0")) .setCode("ml") - .setSystem("http://unitsofmeasure.org") - .setUnit("ml")); - Range actual = (Range) this.typeConverter.toFhirRange(new Interval( + .setUnit("ml") + .setSystem("http://unitsofmeasure.org")); + Range actual = (Range) typeConverter.toFhirRange(new Interval( new Quantity().withValue(new BigDecimal("2.0")).withUnit("ml"), true, new Quantity().withValue(new BigDecimal("5.0")).withUnit("ml"), true)); assertTrue(expected.equalsDeep(actual)); - actual = (Range) this.typeConverter.toFhirRange(null); + actual = (Range) typeConverter.toFhirRange(null); assertNull(null); } - @Test(expectedExceptions = IllegalArgumentException.class) - public void TestInvalidIntervalToFhirRange() { - this.typeConverter.toFhirRange(new Interval(5, true, 6, true)); + @Test + void invalidIntervalToFhirRange() { + var interval = new Interval(5, true, 6, true); + assertThrows(IllegalArgumentException.class, () -> { + typeConverter.toFhirRange(interval); + }); } @Test - public void TestIntervalToFhirInterval() { + void intervalToFhirInterval() { Period expectedPeriod = new Period() .setStartElement(new DateTimeType("2019-02-03")) .setEndElement(new DateTimeType("2019-02-05")); - Period actualPeriod = (Period) this.typeConverter.toFhirInterval( - new Interval(new Date("2019-02-03"), true, new Date("2019-02-05"), true)); + Period actualPeriod = (Period) + typeConverter.toFhirInterval(new Interval(new Date("2019-02-03"), true, new Date("2019-02-05"), true)); assertTrue(expectedPeriod.equalsDeep(actualPeriod)); Range expectedRange = new Range() - .setLow(new org.hl7.fhir.r5.model.Quantity(2.0) + .setLow(new org.hl7.fhir.r5.model.Quantity() + .setValue(new BigDecimal("2.0")) .setCode("ml") - .setSystem("http://unitsofmeasure.org") - .setUnit("ml")) - .setHigh(new org.hl7.fhir.r5.model.Quantity(5.0) + .setUnit("ml") + .setSystem("http://unitsofmeasure.org")) + .setHigh(new org.hl7.fhir.r5.model.Quantity() + .setValue(new BigDecimal("5.0")) .setCode("ml") - .setSystem("http://unitsofmeasure.org") - .setUnit("ml")); - Range actualRange = (Range) this.typeConverter.toFhirInterval(new Interval( + .setUnit("ml") + .setSystem("http://unitsofmeasure.org")); + Range actualRange = (Range) typeConverter.toFhirInterval(new Interval( new Quantity().withValue(new BigDecimal("2.0")).withUnit("ml"), true, new Quantity().withValue(new BigDecimal("5.0")).withUnit("ml"), true)); assertTrue(expectedRange.equalsDeep(actualRange)); - ICompositeType expected = this.typeConverter.toFhirInterval(null); + ICompositeType expected = typeConverter.toFhirInterval(null); assertNull(expected); } - @Test(expectedExceptions = IllegalArgumentException.class) - public void TestInvalidIntervalToFhirInterval() { - this.typeConverter.toFhirInterval(new Interval(5, true, 6, true)); + @Test + void invalidIntervalToFhirInterval() { + var interval = new Interval(5, true, 6, true); + + assertThrows(IllegalArgumentException.class, () -> { + typeConverter.toFhirInterval(interval); + }); } - @Test(expectedExceptions = NotImplementedException.class) - public void TestTupleToFhirTuple() { - IBase expected = this.typeConverter.toFhirTuple(null); + @Test + void tupleToFhirTuple() { + IBase expected = typeConverter.toFhirTuple(null); assertNull(expected); - this.typeConverter.toFhirTuple(new Tuple()); + var tuple = new Tuple(); + assertThrows(NotImplementedException.class, () -> { + typeConverter.toFhirTuple(tuple); + }); } // FHIR-to-CQL @Test - public void TestIsCqlType() { - assertTrue(this.typeConverter.isCqlType(5)); - assertTrue(this.typeConverter.isCqlType(new BigDecimal(0))); - assertTrue(this.typeConverter.isCqlType(new Code())); + void isCqlType() { + assertTrue(typeConverter.isCqlType(5)); + assertTrue(typeConverter.isCqlType(new BigDecimal(0))); + assertTrue(typeConverter.isCqlType(new Code())); - assertFalse(this.typeConverter.isCqlType(new Patient())); - assertFalse(this.typeConverter.isCqlType(new IdType())); + assertFalse(typeConverter.isCqlType(new Patient())); + assertFalse(typeConverter.isCqlType(new IdType())); } - @Test(expectedExceptions = NullPointerException.class) - public void TestNullIsCqlType() { - this.typeConverter.isCqlType(null); + @Test + void nullIsCqlType() { + assertThrows(NullPointerException.class, () -> typeConverter.isCqlType(null)); } - @Test(expectedExceptions = IllegalArgumentException.class) - public void TestIterableIsCqlType() { - this.typeConverter.isCqlType(new ArrayList<>()); + @Test + void iterableIsCqlType() { + var value = new ArrayList<>(); + assertThrows(IllegalArgumentException.class, () -> typeConverter.isCqlType(value)); } @Test - public void TestToCqlType() { - Object actual = this.typeConverter.toCqlType(new Code()); + void toCqlType() { + Object actual = typeConverter.toCqlType(new Code()); assertThat(actual, instanceOf(Code.class)); - actual = this.typeConverter.toCqlType(new IntegerType(5)); + actual = typeConverter.toCqlType(new IntegerType(5)); assertThat(actual, instanceOf(Integer.class)); - actual = this.typeConverter.toCqlType(new StringType("test")); + actual = typeConverter.toCqlType(new StringType("test")); assertThat(actual, instanceOf(String.class)); - actual = this.typeConverter.toCqlType(new IdType("test")); + actual = typeConverter.toCqlType(new IdType("test")); assertThat(actual, instanceOf(String.class)); - actual = this.typeConverter.toCqlType(new BooleanType(true)); + actual = typeConverter.toCqlType(new BooleanType(true)); assertThat(actual, instanceOf(Boolean.class)); - actual = this.typeConverter.toCqlType(new DecimalType(1.0)); + actual = typeConverter.toCqlType(new DecimalType(1.0)); assertThat(actual, instanceOf(BigDecimal.class)); - actual = this.typeConverter.toCqlType(new DateType(Calendar.getInstance())); + actual = typeConverter.toCqlType(new DateType(Calendar.getInstance().getTime())); assertThat(actual, instanceOf(Date.class)); - actual = this.typeConverter.toCqlType(new InstantType(Calendar.getInstance())); + actual = typeConverter.toCqlType(new InstantType(Calendar.getInstance())); assertThat(actual, instanceOf(DateTime.class)); - actual = this.typeConverter.toCqlType(new DateTimeType(Calendar.getInstance())); + actual = typeConverter.toCqlType(new DateTimeType(Calendar.getInstance())); assertThat(actual, instanceOf(DateTime.class)); - actual = this.typeConverter.toCqlType(new TimeType("10:00:00.0000")); + actual = typeConverter.toCqlType(new TimeType("10:00:00.0000")); assertThat(actual, instanceOf(Time.class)); - actual = this.typeConverter.toCqlType(new StringType("test")); + actual = typeConverter.toCqlType(new StringType("test")); assertThat(actual, instanceOf(String.class)); - actual = this.typeConverter.toCqlType(new org.hl7.fhir.r5.model.Quantity()); + actual = typeConverter.toCqlType(new org.hl7.fhir.r5.model.Quantity()); assertThat(actual, instanceOf(Quantity.class)); - actual = this.typeConverter.toCqlType(new org.hl7.fhir.r5.model.Ratio()); + actual = typeConverter.toCqlType(new org.hl7.fhir.r5.model.Ratio()); assertThat(actual, instanceOf(Ratio.class)); - actual = this.typeConverter.toCqlType(new Coding()); + actual = typeConverter.toCqlType(new Coding()); assertThat(actual, instanceOf(Code.class)); - actual = this.typeConverter.toCqlType(new CodeableConcept()); + actual = typeConverter.toCqlType(new CodeableConcept()); assertThat(actual, instanceOf(Concept.class)); - actual = this.typeConverter.toCqlType(new Period() + actual = typeConverter.toCqlType(new Period() .setStart(Calendar.getInstance().getTime()) .setEnd(Calendar.getInstance().getTime())); assertThat(actual, instanceOf(Interval.class)); - actual = this.typeConverter.toCqlType(new Range() - .setLow(org.hl7.fhir.r5.model.Quantity.fromUcum("1", "d")) - .setHigh(org.hl7.fhir.r5.model.Quantity.fromUcum("5", "d"))); + SimpleQuantity low = new SimpleQuantity(); + low.setValue(BigDecimal.valueOf(1.0)); + low.setUnit("d"); + + SimpleQuantity high = new SimpleQuantity(); + high.setValue(BigDecimal.valueOf(4.0)); + high.setUnit("d"); + actual = typeConverter.toCqlType(new Range().setLow(low).setHigh(high)); assertThat(actual, instanceOf(Interval.class)); - actual = this.typeConverter.toCqlType(null); + actual = typeConverter.toCqlType(null); assertNull(null); } - @Test(expectedExceptions = IllegalArgumentException.class) - public void TestToCqlTypeIterable() { - this.typeConverter.toCqlType(new ArrayList<>()); + @Test + void toCqlTypeIterable() { + assertThrows(IllegalArgumentException.class, () -> { + typeConverter.toCqlType(new ArrayList<>()); + }); } - @Test(expectedExceptions = IllegalArgumentException.class) - public void TestToCqlTypeNotCql() { - this.typeConverter.toCqlType(ZoneOffset.ofHours(3)); + @Test + void toCqlTypeNotCql() { + var offset = ZoneOffset.ofHours(3); + assertThrows(IllegalArgumentException.class, () -> { + typeConverter.toCqlType(offset); + }); } @Test - public void TestToCqlTypes() { + void toCqlTypes() { List innerExpected = new ArrayList<>(); innerExpected.add("123"); @@ -607,133 +659,145 @@ public void TestToCqlTypes() { test.add(null); test.add(new IntegerType(5)); - Iterable actual = this.typeConverter.toCqlTypes(test); + Iterable actual = typeConverter.toCqlTypes(test); assertTrue(compareIterables(expected, actual)); } @Test - public void TestStringToCqlId() { + void stringToCqlId() { String expected = "123"; - String actual = this.typeConverter.toCqlId(new IdType("123")); + String actual = typeConverter.toCqlId(new IdType("123")); assertEquals(expected, actual); - actual = this.typeConverter.toCqlId(null); + actual = typeConverter.toCqlId(null); assertNull(actual); } @Test - public void TestPrimitiveFhirTypeToCqlType() { + void primitiveFhirTypeToCqlType() { Boolean expectedBoolean = false; - Boolean actualBoolean = this.typeConverter.toCqlBoolean(new BooleanType(false)); + Boolean actualBoolean = typeConverter.toCqlBoolean(new BooleanType(false)); assertEquals(expectedBoolean, actualBoolean); - expectedBoolean = this.typeConverter.toCqlBoolean(null); + expectedBoolean = typeConverter.toCqlBoolean(null); assertNull(expectedBoolean); Integer expectedInteger = 5; - Integer actualInteger = this.typeConverter.toCqlInteger(new IntegerType(5)); + Integer actualInteger = typeConverter.toCqlInteger(new IntegerType(5)); assertEquals(expectedInteger, actualInteger); - expectedInteger = this.typeConverter.toCqlInteger(null); + expectedInteger = typeConverter.toCqlInteger(null); assertNull(expectedInteger); String expectedString = "5"; - String actualString = this.typeConverter.toCqlString(new StringType("5")); + String actualString = typeConverter.toCqlString(new StringType("5")); assertEquals(expectedString, actualString); - expectedString = this.typeConverter.toCqlString(null); + expectedString = typeConverter.toCqlString(null); assertNull(expectedString); BigDecimal expectedDecimal = new BigDecimal(2.0); - BigDecimal actualDecimal = this.typeConverter.toCqlDecimal(new DecimalType(new BigDecimal(2.0))); + BigDecimal actualDecimal = typeConverter.toCqlDecimal(new DecimalType(new BigDecimal(2.0))); assertEquals(expectedDecimal, actualDecimal); - expectedDecimal = this.typeConverter.toCqlDecimal(null); + expectedDecimal = typeConverter.toCqlDecimal(null); assertNull(expectedDecimal); } @Test - public void TestDateToCqlType() { + void dateToCqlType() { Date expectedDate = new Date("2019-02-03"); - Date actualDate = this.typeConverter.toCqlDate(new org.hl7.fhir.r5.model.DateType("2019-02-03")); + Date actualDate = typeConverter.toCqlDate(new org.hl7.fhir.r5.model.DateType("2019-02-03")); assertTrue(expectedDate.equal(actualDate)); expectedDate = new Date("2019"); - actualDate = this.typeConverter.toCqlDate(new DateType("2019")); + actualDate = typeConverter.toCqlDate(new DateType("2019")); assertTrue(expectedDate.equal(actualDate)); } @Test - public void TestDateTimeToCqlType() { + void dateTimeToCqlType() { DateTime expectedDate = new DateTime("2019-02-03", ZoneOffset.UTC); - DateTime actualDate = this.typeConverter.toCqlDateTime(new DateTimeType("2019-02-03")); + DateTime actualDate = typeConverter.toCqlDateTime(new DateTimeType("2019-02-03")); assertTrue(expectedDate.equal(actualDate)); expectedDate = new DateTime("2019", ZoneOffset.UTC); - actualDate = this.typeConverter.toCqlDateTime(new DateTimeType("2019")); + actualDate = typeConverter.toCqlDateTime(new DateTimeType("2019")); assertTrue(expectedDate.equal(actualDate)); expectedDate = new DateTime("2019", ZoneOffset.UTC); - actualDate = this.typeConverter.toCqlDateTime(new DateTimeType("2019")); + actualDate = typeConverter.toCqlDateTime(new DateTimeType("2019")); assertTrue(expectedDate.equal(actualDate)); } @Test - public void TestQuantityToCqlType() { + void quantityToCqlType() { Quantity expected = (new Quantity().withValue(new BigDecimal("2.0")).withUnit("ml")); - Quantity actual = this.typeConverter.toCqlQuantity( - new org.hl7.fhir.r5.model.Quantity(2.0).setUnit("ml").setSystem("http://unitsofmeasure.org")); + Quantity actual = typeConverter.toCqlQuantity(new org.hl7.fhir.r5.model.Quantity() + .setValue(new BigDecimal("2.0")) + .setUnit("ml") + .setSystem("http://unitsofmeasure.org")); assertTrue(expected.equal(actual)); } @Test - public void TestRatioToCqlType() { + void ratioToCqlType() { Ratio expected = new Ratio(); expected.setNumerator(new Quantity().withValue(BigDecimal.valueOf(1.0)).withUnit("ml")); expected.setDenominator( new Quantity().withValue(BigDecimal.valueOf(2.0)).withUnit("ml")); - org.hl7.fhir.r5.model.Quantity testNumerator = - new org.hl7.fhir.r5.model.Quantity(1.0).setUnit("ml").setSystem("http://unitsofmeasure.org"); - org.hl7.fhir.r5.model.Quantity testDenominator = - new org.hl7.fhir.r5.model.Quantity(2.0).setUnit("ml").setSystem("http://unitsofmeasure.org"); + org.hl7.fhir.r5.model.Quantity testNumerator = new org.hl7.fhir.r5.model.Quantity() + .setValue(new BigDecimal("1.0")) + .setUnit("ml") + .setSystem("http://unitsofmeasure.org"); + org.hl7.fhir.r5.model.Quantity testDenominator = new org.hl7.fhir.r5.model.Quantity() + .setValue(new BigDecimal("2.0")) + .setUnit("ml") + .setSystem("http://unitsofmeasure.org"); org.hl7.fhir.r5.model.Ratio test = new org.hl7.fhir.r5.model.Ratio().setNumerator(testNumerator).setDenominator(testDenominator); - Ratio actual = this.typeConverter.toCqlRatio(test); + Ratio actual = typeConverter.toCqlRatio(test); assertTrue(expected.equal(actual)); } - @Test() - public void TestNullToCqlType() { - Object expected = this.typeConverter.toCqlAny(null); + @Test + void nullToCqlType() { + Object expected = typeConverter.toCqlAny(null); assertNull(expected); } - @Test(expectedExceptions = NotImplementedException.class) - public void TestObjectToCqlType() { - this.typeConverter.toCqlAny(new IdType()); + @Test + void objectToCqlType() { + var id = new IdType(); + assertThrows(NotImplementedException.class, () -> { + typeConverter.toCqlAny(id); + }); } @Test - public void TestCodingToCqlCode() { + void codingToCqlCode() { Code expected = new Code() .withSystem("http://the-system.com") .withCode("test") .withDisplay("system-test") .withVersion("1.5"); - Code actual = this.typeConverter.toCqlCode( - new Coding("http://the-system.com", "test", "system-test").setVersion("1.5")); + Code actual = typeConverter.toCqlCode(new Coding() + .setSystem("http://the-system.com") + .setCode("test") + .setDisplay("system-test") + .setVersion("1.5")); assertTrue(expected.equal(actual)); - expected = this.typeConverter.toCqlCode(null); + expected = typeConverter.toCqlCode(null); assertNull(expected); } @Test - public void TestCodeableConceptToCqlConcept() { + void codeableConceptToCqlConcept() { Concept expected = new Concept() .withCode(new Code() .withSystem("http://the-system.com") @@ -741,26 +805,29 @@ public void TestCodeableConceptToCqlConcept() { .withDisplay("system-test") .withVersion("1.5")) .withDisplay("additional-text"); - Concept actual = this.typeConverter.toCqlConcept( - new CodeableConcept(new Coding("http://the-system.com", "test", "system-test").setVersion("1.5")) - .setText("additional-text")); + Concept actual = typeConverter.toCqlConcept(new CodeableConcept(new Coding() + .setSystem("http://the-system.com") + .setCode("test") + .setDisplay("system-test") + .setVersion("1.5")) + .setText("additional-text")); assertTrue(expected.equal(actual)); - expected = this.typeConverter.toCqlConcept(null); + expected = typeConverter.toCqlConcept(null); assertNull(expected); } @Test - public void TestPeriodToCqlInterval() { + void periodToCqlInterval() { Interval expected = new Interval(new Date("2019-02-03"), true, new Date("2019-02-05"), true); - Interval actual = this.typeConverter.toCqlInterval(new Period() + Interval actual = typeConverter.toCqlInterval(new Period() .setStartElement(new DateTimeType("2019-02-03")) .setEndElement(new DateTimeType("2019-02-05"))); assertTrue(expected.equal(actual)); expected = new Interval(new Date("2019"), true, new Date("2020"), true); - actual = this.typeConverter.toCqlInterval( + actual = typeConverter.toCqlInterval( new Period().setStartElement(new DateTimeType("2019")).setEndElement(new DateTimeType("2020"))); assertTrue(expected.equal(actual)); @@ -769,41 +836,53 @@ public void TestPeriodToCqlInterval() { true, new DateTime("2020-09-18T19:37:00", ZoneOffset.UTC), true); - actual = this.typeConverter.toCqlInterval(new Period() + actual = typeConverter.toCqlInterval(new Period() .setStartElement(new DateTimeType("2020-09-18T19:35:53+00:00")) .setEndElement(new DateTimeType("2020-09-18T19:37:00+00:00"))); assertTrue(expected.equal(actual)); - actual = this.typeConverter.toCqlInterval(null); + actual = typeConverter.toCqlInterval(null); assertNull(null); } @Test - public void TestRangeToCqlInterval() { + void rangeToCqlInterval() { Interval expected = new Interval( new Quantity().withValue(new BigDecimal("2.0")).withUnit("ml"), true, new Quantity().withValue(new BigDecimal("5.0")).withUnit("ml"), true); - Interval actual = this.typeConverter.toCqlInterval(new Range() - .setLow(new org.hl7.fhir.r5.model.Quantity(2.0).setUnit("ml").setSystem("http://unitsofmeasure.org")) - .setHigh(new org.hl7.fhir.r5.model.Quantity(5.0).setUnit("ml").setSystem("http://unitsofmeasure.org"))); + Interval actual = typeConverter.toCqlInterval(new Range() + .setLow((SimpleQuantity) new org.hl7.fhir.r5.model.SimpleQuantity() + .setValue(new BigDecimal("2.0")) + .setUnit("ml") + .setSystem("http://unitsofmeasure.org")) + .setHigh((SimpleQuantity) new org.hl7.fhir.r5.model.SimpleQuantity() + .setValue(new BigDecimal("5.0")) + .setUnit("ml") + .setSystem("http://unitsofmeasure.org"))); assertTrue(expected.equal(actual)); - actual = this.typeConverter.toCqlInterval(null); + actual = typeConverter.toCqlInterval(null); assertNull(null); } - @Test(expectedExceptions = IllegalArgumentException.class) - public void TestInvalidTypeToCqlInterval() { - this.typeConverter.toCqlInterval(new Attachment()); + @Test + void invalidTypeToCqlInterval() { + var attachment = new Attachment(); + assertThrows(IllegalArgumentException.class, () -> { + typeConverter.toCqlInterval(attachment); + }); } - @Test(expectedExceptions = NotImplementedException.class) - public void TestTupleToCqlTuple() { - Object expected = this.typeConverter.toCqlTuple(null); + @Test + void tupleToCqlTuple() { + Object expected = typeConverter.toCqlTuple(null); assertNull(expected); - this.typeConverter.toCqlTuple(new Patient()); + var p = new Patient(); + assertThrows(NotImplementedException.class, () -> { + typeConverter.toCqlTuple(p); + }); } } diff --git a/Src/java/engine-fhir/src/test/java/org/opencds/cqf/cql/engine/fhir/data/EvaluatedResourcesTest.java b/Src/java/engine-fhir/src/test/java/org/opencds/cqf/cql/engine/fhir/data/EvaluatedResourcesTest.java index a06a6ce89..6f355df16 100644 --- a/Src/java/engine-fhir/src/test/java/org/opencds/cqf/cql/engine/fhir/data/EvaluatedResourcesTest.java +++ b/Src/java/engine-fhir/src/test/java/org/opencds/cqf/cql/engine/fhir/data/EvaluatedResourcesTest.java @@ -10,14 +10,14 @@ import org.hl7.fhir.r4.model.Condition; import org.hl7.fhir.r4.model.Encounter; import org.hl7.fhir.r4.model.Patient; +import org.junit.jupiter.api.Test; import org.opencds.cqf.cql.engine.data.CompositeDataProvider; import org.opencds.cqf.cql.engine.execution.CqlEngine; import org.opencds.cqf.cql.engine.retrieve.RetrieveProvider; import org.opencds.cqf.cql.engine.runtime.Code; import org.opencds.cqf.cql.engine.runtime.Interval; -import org.testng.annotations.Test; -public class EvaluatedResourcesTest extends FhirExecutionTestBase { +class EvaluatedResourcesTest extends FhirExecutionTestBase { private static RetrieveProvider rp = new RetrieveProvider() { @@ -51,7 +51,7 @@ public Iterable retrieve( }; @Test - public void testWithCache() { + void withCache() { CqlEngine engine = getEngine(); engine.getState() .getEnvironment() @@ -77,7 +77,7 @@ public void testWithCache() { } @Test - public void testWithoutCache() { + void withoutCache() { CqlEngine engine = getEngine(); engine.getState() .getEnvironment() diff --git a/Src/java/engine-fhir/src/test/java/org/opencds/cqf/cql/engine/fhir/data/FhirExecutionTestBase.java b/Src/java/engine-fhir/src/test/java/org/opencds/cqf/cql/engine/fhir/data/FhirExecutionTestBase.java index 10663b02a..39401d3fd 100644 --- a/Src/java/engine-fhir/src/test/java/org/opencds/cqf/cql/engine/fhir/data/FhirExecutionTestBase.java +++ b/Src/java/engine-fhir/src/test/java/org/opencds/cqf/cql/engine/fhir/data/FhirExecutionTestBase.java @@ -12,22 +12,22 @@ import org.cqframework.cql.elm.tracking.TrackBack; import org.fhir.ucum.UcumException; import org.hl7.elm.r1.Library; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; import org.opencds.cqf.cql.engine.data.CompositeDataProvider; import org.opencds.cqf.cql.engine.execution.CqlEngine; import org.opencds.cqf.cql.engine.execution.Environment; import org.opencds.cqf.cql.engine.fhir.model.*; import org.opencds.cqf.cql.engine.fhir.retrieve.RestFhirRetrieveProvider; import org.opencds.cqf.cql.engine.fhir.searchparam.SearchParameterResolver; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeMethod; public abstract class FhirExecutionTestBase { public LibraryManager getLibraryManager() { - return this.libraryManager; + return libraryManager; } public ModelManager getModelManager() { - return this.modelManager; + return modelManager; } public Environment getEnvironment() { @@ -38,26 +38,26 @@ public CqlEngine getEngine() { return new CqlEngine(getEnvironment()); } - private LibraryManager libraryManager; - private ModelManager modelManager; + private static LibraryManager libraryManager; + private static ModelManager modelManager; - protected Dstu2FhirModelResolver dstu2ModelResolver; - protected RestFhirRetrieveProvider dstu2RetrieveProvider; - protected CompositeDataProvider dstu2Provider; + protected static Dstu2FhirModelResolver dstu2ModelResolver; + protected static RestFhirRetrieveProvider dstu2RetrieveProvider; + protected static CompositeDataProvider dstu2Provider; - protected Dstu3FhirModelResolver dstu3ModelResolver; - protected RestFhirRetrieveProvider dstu3RetrieveProvider; - protected CompositeDataProvider dstu3Provider; + protected static Dstu3FhirModelResolver dstu3ModelResolver; + protected static RestFhirRetrieveProvider dstu3RetrieveProvider; + protected static CompositeDataProvider dstu3Provider; - protected R4FhirModelResolver r4ModelResolver; - protected RestFhirRetrieveProvider r4RetrieveProvider; - protected CompositeDataProvider r4Provider; + protected static R4FhirModelResolver r4ModelResolver; + protected static RestFhirRetrieveProvider r4RetrieveProvider; + protected static CompositeDataProvider r4Provider; Library library = null; // protected File xmlFile = null; - @BeforeClass - public void setup() { + @BeforeAll + public static void setup() { FhirContext dstu2Context = FhirContext.forCached(FhirVersionEnum.DSTU2); dstu2ModelResolver = new CachedDstu2FhirModelResolver(); dstu2RetrieveProvider = new RestFhirRetrieveProvider( @@ -82,18 +82,18 @@ public void setup() { r4Context.newRestfulGenericClient("http://measure.eval.kanvix.com/cqf-ruler/baseDstu4")); r4Provider = new CompositeDataProvider(r4ModelResolver, r4RetrieveProvider); - this.modelManager = new ModelManager(); + modelManager = new ModelManager(); var compilerOptions = new CqlCompilerOptions( CqlCompilerException.ErrorSeverity.Info, LibraryBuilder.SignatureLevel.All, CqlCompilerOptions.Options.EnableDateRangeOptimization); - this.libraryManager = new LibraryManager(modelManager, compilerOptions); + libraryManager = new LibraryManager(modelManager, compilerOptions); libraryManager.getLibrarySourceLoader().clearProviders(); libraryManager.getLibrarySourceLoader().registerProvider(new FhirLibrarySourceProvider()); libraryManager.getLibrarySourceLoader().registerProvider(new TestLibrarySourceProvider()); } - @BeforeMethod + @BeforeEach public void beforeEachTestMethod() throws JAXBException, IOException, UcumException { String fileName = this.getClass().getSimpleName(); if (library == null) { diff --git a/Src/java/engine-fhir/src/test/java/org/opencds/cqf/cql/engine/fhir/data/Issue1225.java b/Src/java/engine-fhir/src/test/java/org/opencds/cqf/cql/engine/fhir/data/Issue1225.java index 64cf0ec38..c4bb22b97 100644 --- a/Src/java/engine-fhir/src/test/java/org/opencds/cqf/cql/engine/fhir/data/Issue1225.java +++ b/Src/java/engine-fhir/src/test/java/org/opencds/cqf/cql/engine/fhir/data/Issue1225.java @@ -1,21 +1,21 @@ package org.opencds.cqf.cql.engine.fhir.data; -import static org.testng.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import java.util.Collections; import org.hl7.fhir.r4.model.Address; import org.hl7.fhir.r4.model.Patient; +import org.junit.jupiter.api.Test; import org.opencds.cqf.cql.engine.data.CompositeDataProvider; import org.opencds.cqf.cql.engine.retrieve.RetrieveProvider; import org.opencds.cqf.cql.engine.runtime.Code; import org.opencds.cqf.cql.engine.runtime.Interval; -import org.testng.annotations.Test; // https://github.com/cqframework/clinical_quality_language/issues/1225 -public class Issue1225 extends FhirExecutionTestBase { +class Issue1225 extends FhirExecutionTestBase { @Test - public void addressResolvesWithoutError() { + void addressResolvesWithoutError() { var r = new RetrieveProvider() { @Override public Iterable retrieve( diff --git a/Src/java/engine-fhir/src/test/java/org/opencds/cqf/cql/engine/fhir/data/Issue1226.java b/Src/java/engine-fhir/src/test/java/org/opencds/cqf/cql/engine/fhir/data/Issue1226.java index ce80a24dc..45e84b486 100644 --- a/Src/java/engine-fhir/src/test/java/org/opencds/cqf/cql/engine/fhir/data/Issue1226.java +++ b/Src/java/engine-fhir/src/test/java/org/opencds/cqf/cql/engine/fhir/data/Issue1226.java @@ -1,22 +1,22 @@ package org.opencds.cqf.cql.engine.fhir.data; -import static org.testng.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import java.util.Collections; import org.hl7.fhir.r4.model.MedicationRequest; import org.hl7.fhir.r4.model.Patient; import org.hl7.fhir.r4.model.Reference; +import org.junit.jupiter.api.Test; import org.opencds.cqf.cql.engine.data.CompositeDataProvider; import org.opencds.cqf.cql.engine.retrieve.RetrieveProvider; import org.opencds.cqf.cql.engine.runtime.Code; import org.opencds.cqf.cql.engine.runtime.Interval; -import org.testng.annotations.Test; // https://github.com/cqframework/clinical_quality_language/issues/1226 -public class Issue1226 extends FhirExecutionTestBase { +class Issue1226 extends FhirExecutionTestBase { @Test - public void medicationReferenceFound() { + void medicationReferenceFound() { var r = new RetrieveProvider() { @Override public Iterable retrieve( diff --git a/Src/java/engine-fhir/src/test/java/org/opencds/cqf/cql/engine/fhir/data/TestCodeRef.java b/Src/java/engine-fhir/src/test/java/org/opencds/cqf/cql/engine/fhir/data/TestCodeRef.java index 0b604d5e4..b78f3919c 100644 --- a/Src/java/engine-fhir/src/test/java/org/opencds/cqf/cql/engine/fhir/data/TestCodeRef.java +++ b/Src/java/engine-fhir/src/test/java/org/opencds/cqf/cql/engine/fhir/data/TestCodeRef.java @@ -1,6 +1,6 @@ package org.opencds.cqf.cql.engine.fhir.data; -import static org.testng.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertTrue; import ca.uhn.fhir.context.FhirContext; import ca.uhn.fhir.context.FhirVersionEnum; diff --git a/Src/java/engine-fhir/src/test/java/org/opencds/cqf/cql/engine/fhir/data/TestCqlEngineRelatedContextSupport.java b/Src/java/engine-fhir/src/test/java/org/opencds/cqf/cql/engine/fhir/data/TestCqlEngineRelatedContextSupport.java index 9d5bcb426..6f3a31228 100644 --- a/Src/java/engine-fhir/src/test/java/org/opencds/cqf/cql/engine/fhir/data/TestCqlEngineRelatedContextSupport.java +++ b/Src/java/engine-fhir/src/test/java/org/opencds/cqf/cql/engine/fhir/data/TestCqlEngineRelatedContextSupport.java @@ -3,7 +3,7 @@ import static org.hamcrest.CoreMatchers.instanceOf; import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.MatcherAssert.assertThat; -import static org.testng.Assert.fail; +import static org.junit.jupiter.api.Assertions.fail; import jakarta.annotation.Nonnull; import java.time.LocalDate; @@ -13,14 +13,14 @@ import java.util.stream.Collectors; import org.apache.commons.lang3.tuple.Pair; import org.hl7.fhir.r4.model.*; +import org.junit.jupiter.api.Test; import org.opencds.cqf.cql.engine.data.CompositeDataProvider; import org.opencds.cqf.cql.engine.execution.CqlEngine; import org.opencds.cqf.cql.engine.retrieve.RetrieveProvider; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.testng.annotations.Test; -public class TestCqlEngineRelatedContextSupport extends FhirExecutionTestBase { +class TestCqlEngineRelatedContextSupport extends FhirExecutionTestBase { private static final Logger logger = LoggerFactory.getLogger(TestCqlEngineRelatedContextSupport.class); private static final String PATIENT = "Patient"; private static final String PRACTITIONER = "Practitioner"; @@ -151,7 +151,7 @@ private static String getIdFromReference(Reference theInnerReference) { } @Test - public void testCqlEngineRelatedContext() { + void cqlEngineRelatedContext() { final CqlEngine cqlEngine = getEngine(); cqlEngine diff --git a/Src/java/engine-fhir/src/test/java/org/opencds/cqf/cql/engine/fhir/data/TestFHIRHelpers.java b/Src/java/engine-fhir/src/test/java/org/opencds/cqf/cql/engine/fhir/data/TestFHIRHelpers.java index e004211f8..e74b0dcec 100644 --- a/Src/java/engine-fhir/src/test/java/org/opencds/cqf/cql/engine/fhir/data/TestFHIRHelpers.java +++ b/Src/java/engine-fhir/src/test/java/org/opencds/cqf/cql/engine/fhir/data/TestFHIRHelpers.java @@ -4,13 +4,13 @@ import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.MatcherAssert.assertThat; +import org.junit.jupiter.api.Test; import org.opencds.cqf.cql.engine.execution.CqlEngine; -import org.testng.annotations.Test; -public class TestFHIRHelpers extends FhirExecutionTestBase { +class TestFHIRHelpers extends FhirExecutionTestBase { @Test - public void test() { + void test() { CqlEngine engine = getEngine(); engine.getEnvironment().registerDataProvider("http://hl7.org/fhir", r4Provider); diff --git a/Src/java/engine-fhir/src/test/java/org/opencds/cqf/cql/engine/fhir/data/TestFhirDataProviderDstu2.java b/Src/java/engine-fhir/src/test/java/org/opencds/cqf/cql/engine/fhir/data/TestFhirDataProviderDstu2.java index 8efc47312..1aaccc7fb 100644 --- a/Src/java/engine-fhir/src/test/java/org/opencds/cqf/cql/engine/fhir/data/TestFhirDataProviderDstu2.java +++ b/Src/java/engine-fhir/src/test/java/org/opencds/cqf/cql/engine/fhir/data/TestFhirDataProviderDstu2.java @@ -1,21 +1,19 @@ package org.opencds.cqf.cql.engine.fhir.data; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.*; import org.hl7.fhir.dstu2.model.Encounter; +import org.junit.jupiter.api.BeforeEach; import org.opencds.cqf.cql.engine.execution.CqlEngine; import org.opencds.cqf.cql.engine.execution.EvaluationResult; import org.opencds.cqf.cql.engine.fhir.retrieve.FhirBundleCursor; -import org.testng.Assert; -import org.testng.annotations.BeforeMethod; public class TestFhirDataProviderDstu2 extends FhirExecutionTestBase { private EvaluationResult results; - @BeforeMethod - public void before() { + @BeforeEach + void before() { CqlEngine engine = getEngine(); engine.getState().getEnvironment().registerDataProvider("http://hl7.org/fhir", dstu2Provider); results = engine.evaluate(library.getIdentifier()); @@ -38,7 +36,7 @@ public void testDstu2ProviderRetrieve() { for (Object result : results) { Encounter e = (Encounter) result; if (!e.getPatient().getIdElement().getIdPart().equals("2822")) { - Assert.fail("Invalid patient id in Resource"); + fail("Invalid patient id in Resource"); } } diff --git a/Src/java/engine-fhir/src/test/java/org/opencds/cqf/cql/engine/fhir/data/TestFhirDataProviderDstu3.java b/Src/java/engine-fhir/src/test/java/org/opencds/cqf/cql/engine/fhir/data/TestFhirDataProviderDstu3.java index 3f6f9eda4..6c7961e1d 100644 --- a/Src/java/engine-fhir/src/test/java/org/opencds/cqf/cql/engine/fhir/data/TestFhirDataProviderDstu3.java +++ b/Src/java/engine-fhir/src/test/java/org/opencds/cqf/cql/engine/fhir/data/TestFhirDataProviderDstu3.java @@ -1,6 +1,6 @@ package org.opencds.cqf.cql.engine.fhir.data; -import static org.testng.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.*; import ca.uhn.fhir.context.FhirContext; import ca.uhn.fhir.context.FhirVersionEnum; @@ -11,6 +11,7 @@ import org.hl7.fhir.dstu3.model.Bundle; import org.hl7.fhir.dstu3.model.ListResource; import org.hl7.fhir.dstu3.model.Patient; +import org.junit.jupiter.api.Test; import org.opencds.cqf.cql.engine.data.CompositeDataProvider; import org.opencds.cqf.cql.engine.execution.CqlEngine; import org.opencds.cqf.cql.engine.fhir.model.CachedDstu3FhirModelResolver; @@ -19,8 +20,6 @@ import org.opencds.cqf.cql.engine.fhir.retrieve.RestFhirRetrieveProvider; import org.opencds.cqf.cql.engine.fhir.searchparam.SearchParameterResolver; import org.opencds.cqf.cql.engine.fhir.terminology.Dstu3FhirTerminologyProvider; -import org.testng.Assert; -import org.testng.annotations.Test; public class TestFhirDataProviderDstu3 extends FhirExecutionTestBase { @@ -82,7 +81,7 @@ public void testPatientRetrieve() { resultCount++; } - assertTrue(patients.size() == resultCount); + assertEquals(patients.size(), resultCount); } // @Test @@ -92,7 +91,7 @@ public void testChoiceTypes() { var results = engine.evaluate(library.getIdentifier(), Set.of("testChoiceTypes")); Object value = results.forExpression("testChoiceTypes").value(); - Assert.assertNotNull(value); + assertNotNull(value); } // @Test @@ -103,25 +102,25 @@ public void testDateType() { var results = engine.evaluate(library.getIdentifier(), Set.of("testDateType")); Object value = results.forExpression("testDateType").value(); - Assert.assertNotNull(value); + assertNotNull(value); } @Test - public void testFhirObjectEqual() { + void fhirObjectEqual() { CqlEngine engine = getEngine(); engine.getEnvironment().registerDataProvider("http://hl7.org/fhir", r4Provider); var results = engine.evaluate(library.getIdentifier(), Set.of("testFhirObjectEqual")); Object value = results.forExpression("testFhirObjectEqual").value(); - Assert.assertTrue((Boolean) value); + assertTrue((Boolean) value); } @Test - public void testFhirObjectEquivalent() { + void fhirObjectEquivalent() { CqlEngine engine = getEngine(); engine.getEnvironment().registerDataProvider("http://hl7.org/fhir", r4Provider); var results = engine.evaluate(library.getIdentifier(), Set.of("testFhirObjectEquivalent")); var value = results.forExpression("testFhirObjectEquivalent").value(); - Assert.assertTrue((Boolean) value); + assertTrue((Boolean) value); } // TODO - fix @@ -153,7 +152,7 @@ public void testFhirObjectEquivalent() { // var value = context.resolveExpressionRef("Active Ambulatory Opioid // Rx").getExpression().evaluate(context); - // Assert.assertTrue(value instanceof List && ((List) value).size() == 1); + // Assertions.assertTrue(value instanceof List && ((List) value).size() == 1); // } // @Test @@ -178,7 +177,7 @@ public void testList() { resultCount++; } - assertTrue(lists.size() == resultCount); + assertEquals(lists.size(), resultCount); } // @Test @@ -260,6 +259,6 @@ public void testContained() { var results = engine.evaluate(library.getIdentifier(), Set.of("GetProvenance")); Object value = results.forExpression("GetProvenance").value(); - Assert.assertTrue(value instanceof List && ((List) value).size() == 1); + assertTrue(value instanceof List && ((List) value).size() == 1); } } diff --git a/Src/java/engine-fhir/src/test/java/org/opencds/cqf/cql/engine/fhir/data/TestFhirExecution.java b/Src/java/engine-fhir/src/test/java/org/opencds/cqf/cql/engine/fhir/data/TestFhirExecution.java index c913525b8..72d1b5ebf 100644 --- a/Src/java/engine-fhir/src/test/java/org/opencds/cqf/cql/engine/fhir/data/TestFhirExecution.java +++ b/Src/java/engine-fhir/src/test/java/org/opencds/cqf/cql/engine/fhir/data/TestFhirExecution.java @@ -1,9 +1,11 @@ package org.opencds.cqf.cql.engine.fhir.data; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; + import java.util.List; import java.util.Set; import org.opencds.cqf.cql.engine.execution.CqlEngine; -import org.testng.Assert; public class TestFhirExecution extends FhirExecutionTestBase { @@ -15,7 +17,7 @@ public void testCoalesce() { var results = engine.evaluate(library.getIdentifier(), Set.of("testCoalesce")); Object value = results.forExpression("testCoalesce").value(); - Assert.assertTrue((Integer) ((List) value).get(0) == 72); + assertTrue((Integer) ((List) value).get(0) == 72); } // @Test @@ -25,7 +27,7 @@ public void testMonthFrom() { engine.getState().setParameter(null, "MAXYEAR", 2014); var results = engine.evaluate(library.getIdentifier(), Set.of("testMonthFrom")); Object value = results.forExpression("testMonthFrom").value(); - Assert.assertNotNull(value); + assertNotNull(value); } // @Test @@ -34,7 +36,7 @@ public void testMultisourceQueryCreatingDatePeriod() { engine.getEnvironment().registerDataProvider("http://hl7.org/fhir", dstu3Provider); var results = engine.evaluate(library.getIdentifier(), Set.of("Immunizations in range")); Object value = results.forExpression("Immunizations in range").value(); - Assert.assertNotNull(value); + assertNotNull(value); } // @Test @@ -43,6 +45,6 @@ public void testIdResolution() { engine.getEnvironment().registerDataProvider("http://hl7.org/fhir", dstu3Provider); var results = engine.evaluate(library.getIdentifier(), Set.of("Resource Id")); Object value = results.forExpression("Resource Id").value(); - Assert.assertNotNull(value); + assertNotNull(value); } } diff --git a/Src/java/engine-fhir/src/test/java/org/opencds/cqf/cql/engine/fhir/data/TestFhirLibrary.java b/Src/java/engine-fhir/src/test/java/org/opencds/cqf/cql/engine/fhir/data/TestFhirLibrary.java index 2f04c69cd..40670a26b 100644 --- a/Src/java/engine-fhir/src/test/java/org/opencds/cqf/cql/engine/fhir/data/TestFhirLibrary.java +++ b/Src/java/engine-fhir/src/test/java/org/opencds/cqf/cql/engine/fhir/data/TestFhirLibrary.java @@ -4,7 +4,7 @@ public class TestFhirLibrary { // @Test /* TODO: These tests haven't been run for a while. Why not just deleting them? I am not sure what their purpose is. - public void TestCBP() throws IOException, JAXBException { + public void testCBP() throws IOException, JAXBException { File xmlFile = new File(URLDecoder.decode(TestFhirLibrary.class.getResource("library-cbp.elm.xml").getFile(), "UTF-8")); Library library = CqlLibraryReader.read(xmlFile); @@ -39,7 +39,7 @@ public void TestCBP() throws IOException, JAXBException { // TODO: Fix this, it depends on the Convert... //@Test - public void TestCMS9v4_CQM() throws IOException, JAXBException { + public void testCMS9v4_CQM() throws IOException, JAXBException { File xmlFile = new File(URLDecoder.decode(TestFhirLibrary.class.getResource("CMS9v4_CQM.xml").getFile(), "UTF-8")); Library library = CqlLibraryReader.read(xmlFile); diff --git a/Src/java/engine-fhir/src/test/java/org/opencds/cqf/cql/engine/fhir/data/TestPrimitiveProfiles.java b/Src/java/engine-fhir/src/test/java/org/opencds/cqf/cql/engine/fhir/data/TestPrimitiveProfiles.java index 1830d4612..7d72e3f0c 100644 --- a/Src/java/engine-fhir/src/test/java/org/opencds/cqf/cql/engine/fhir/data/TestPrimitiveProfiles.java +++ b/Src/java/engine-fhir/src/test/java/org/opencds/cqf/cql/engine/fhir/data/TestPrimitiveProfiles.java @@ -6,13 +6,13 @@ import java.math.BigDecimal; import org.hl7.fhir.r4.model.*; +import org.junit.jupiter.api.Test; import org.opencds.cqf.cql.engine.execution.CqlEngine; -import org.testng.annotations.Test; -public class TestPrimitiveProfiles extends FhirExecutionTestBase { +class TestPrimitiveProfiles extends FhirExecutionTestBase { @Test - public void testProfileCast() { + void profileCast() { CqlEngine engine = getEngine(); engine.getEnvironment().registerDataProvider("http://hl7.org/fhir", r4Provider); diff --git a/Src/java/engine-fhir/src/test/java/org/opencds/cqf/cql/engine/fhir/model/TestDstu2ModelResolver.java b/Src/java/engine-fhir/src/test/java/org/opencds/cqf/cql/engine/fhir/model/TestDstu2ModelResolver.java index 131a94d0e..d5132fce6 100644 --- a/Src/java/engine-fhir/src/test/java/org/opencds/cqf/cql/engine/fhir/model/TestDstu2ModelResolver.java +++ b/Src/java/engine-fhir/src/test/java/org/opencds/cqf/cql/engine/fhir/model/TestDstu2ModelResolver.java @@ -1,8 +1,6 @@ package org.opencds.cqf.cql.engine.fhir.model; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertNull; -import static org.testng.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.*; import ca.uhn.fhir.context.FhirContext; import ca.uhn.fhir.context.FhirVersionEnum; @@ -30,9 +28,9 @@ import org.hl7.fhir.dstu2.model.Enumerations.ResourceType; import org.hl7.fhir.dstu2.model.Enumerations.SearchParamType; import org.hl7.fhir.dstu2.model.Enumerations.SpecialValues; +import org.junit.jupiter.api.Test; import org.opencds.cqf.cql.engine.fhir.exception.UnknownType; import org.opencds.cqf.cql.engine.model.ModelResolver; -import org.testng.annotations.Test; public class TestDstu2ModelResolver { @@ -57,14 +55,16 @@ public class TestDstu2ModelResolver { } }; - @Test(expectedExceptions = UnknownType.class) - public void resolverThrowsExceptionForUnknownType() { + @Test + void resolverThrowsExceptionForUnknownType() { ModelResolver resolver = new Dstu2FhirModelResolver(FhirContext.forCached(FhirVersionEnum.DSTU2)); - resolver.resolveType("ImpossibleTypeThatDoesntExistAndShouldBlowUp"); + assertThrows(UnknownType.class, () -> { + resolver.resolveType("ImpossibleTypeThatDoesn'tExistAndShouldBlowUp"); + }); } @Test - public void resolveModelInfoTests() { + void resolveModelInfoTests() { ModelResolver resolver = new Dstu2FhirModelResolver(); ModelManager mm = new ModelManager(); Model m = mm.resolveModel(new ModelIdentifier().withId("FHIR").withVersion("1.0.2")); @@ -92,7 +92,7 @@ public void resolveModelInfoTests() { } @Test - public void resolveTypeTests() { + void resolveTypeTests() { ModelResolver resolver = new Dstu2FhirModelResolver(FhirContext.forCached(FhirVersionEnum.DSTU2)); for (DataType type : DataType.values()) { @@ -126,7 +126,7 @@ public void resolveTypeTests() { } @Test - public void createInstanceTests() { + void createInstanceTests() { ModelResolver resolver = new Dstu2FhirModelResolver(FhirContext.forCached(FhirVersionEnum.DSTU2)); for (DataType type : DataType.values()) { @@ -171,10 +171,7 @@ public void createInstanceTests() { enumFactory.setAccessible(true); EnumFactory factory = (EnumFactory) enumFactory.get(instance); - assertTrue(factory.getClass() - .getSimpleName() - .replace("EnumFactory", "") - .equals(enumType.getSimpleName())); + assertEquals(factory.getClass().getSimpleName().replace("EnumFactory", ""), enumType.getSimpleName()); } catch (Exception e) { throw new AssertionError("error getting factory type. " + e.getMessage()); } @@ -182,12 +179,12 @@ public void createInstanceTests() { } @Test - public void contextPathTests() { + void contextPathTests() { ModelResolver resolver = new Dstu2FhirModelResolver(FhirContext.forCached(FhirVersionEnum.DSTU2)); String path = (String) resolver.getContextPath("Patient", "Patient"); assertNotNull(path); - assertTrue(path.equals("id")); + assertEquals("id", path); path = (String) resolver.getContextPath(null, "Encounter"); assertNull(path); @@ -199,22 +196,22 @@ public void contextPathTests() { path = (String) resolver.getContextPath("Patient", "Condition"); assertNotNull(path); - assertTrue(path.equals("patient")); + assertEquals("patient", path); path = (String) resolver.getContextPath("Patient", "Appointment"); assertNotNull(path); - assertTrue(path.equals("participant.actor")); + assertEquals("participant.actor", path); path = (String) resolver.getContextPath("Patient", "Observation"); assertNotNull(path); - assertTrue(path.equals("subject")); + assertEquals("subject", path); path = (String) resolver.getContextPath("Patient", "Encounter"); assertNotNull(path); - assertTrue(path.equals("patient")); + assertEquals("patient", path); path = (String) resolver.getContextPath("Patient", "MedicationStatement"); - assertTrue(path.equals("patient")); + assertEquals("patient", path); // Issue 527 - https://github.com/DBCG/cql_engine/issues/527 path = (String) resolver.getContextPath("Unfiltered", "MedicationStatement"); diff --git a/Src/java/engine-fhir/src/test/java/org/opencds/cqf/cql/engine/fhir/model/TestDstu3ModelResolver.java b/Src/java/engine-fhir/src/test/java/org/opencds/cqf/cql/engine/fhir/model/TestDstu3ModelResolver.java index a4728820b..8d78a00d1 100644 --- a/Src/java/engine-fhir/src/test/java/org/opencds/cqf/cql/engine/fhir/model/TestDstu3ModelResolver.java +++ b/Src/java/engine-fhir/src/test/java/org/opencds/cqf/cql/engine/fhir/model/TestDstu3ModelResolver.java @@ -1,9 +1,9 @@ package org.opencds.cqf.cql.engine.fhir.model; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertNull; -import static org.testng.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertThrows; import ca.uhn.fhir.context.FhirContext; import ca.uhn.fhir.context.FhirVersionEnum; @@ -39,11 +39,11 @@ import org.hl7.fhir.dstu3.model.Patient; import org.hl7.fhir.dstu3.model.Quantity; import org.hl7.fhir.dstu3.model.SimpleQuantity; +import org.junit.jupiter.api.Test; import org.opencds.cqf.cql.engine.fhir.exception.UnknownType; import org.opencds.cqf.cql.engine.model.ModelResolver; -import org.testng.annotations.Test; -public class TestDstu3ModelResolver { +class TestDstu3ModelResolver { // Couldn't find a way to automatically get the full list of enums. @SuppressWarnings("serial") @@ -69,15 +69,15 @@ public class TestDstu3ModelResolver { } }; - @Test(expectedExceptions = UnknownType.class) - public void resolverThrowsExceptionForUnknownType() { + @Test + void resolverThrowsExceptionForUnknownType() { ModelResolver resolver = new Dstu3FhirModelResolver(FhirContext.forCached(FhirVersionEnum.DSTU3)); - resolver.resolveType("ImpossibleTypeThatDoesntExistAndShouldBlowUp"); + assertThrows(UnknownType.class, () -> resolver.resolveType("ImpossibleTypeThatDoesn'tExistAndShouldBlowUp")); } - @Test // This tests all the top-level types HAPI knows about. - public void resolveTypeTests() { + @Test + void resolveTypeTests() { ModelResolver resolver = new Dstu3FhirModelResolver(FhirContext.forCached(FhirVersionEnum.DSTU3)); for (DataType type : DataType.values()) { @@ -110,9 +110,9 @@ public void resolveTypeTests() { } } - @Test // This tests all the types that are present in the ModelInfo. - public void resolveModelInfoTests() { + @Test + void resolveModelInfoTests() { ModelResolver resolver = new Dstu3FhirModelResolver(FhirContext.forCached(FhirVersionEnum.DSTU3)); ModelManager mm = new ModelManager(); Model m = mm.resolveModel(new ModelIdentifier().withId("FHIR").withVersion("3.0.0")); @@ -143,7 +143,7 @@ public void resolveModelInfoTests() { // Ideally, these would all disappear with either registering custom types // on the FhirContext or generalized logic, or fixed-up ModelInfos @Test - public void modelInfoSpecialCaseTests() { + void modelInfoSpecialCaseTests() { ModelResolver resolver = new Dstu3FhirModelResolver(FhirContext.forCached(FhirVersionEnum.DSTU3)); // This tests resolution of inner classes. They aren't registered directly. @@ -165,7 +165,7 @@ public void modelInfoSpecialCaseTests() { } @Test - public void createInstanceTests() { + void createInstanceTests() { ModelResolver resolver = new Dstu3FhirModelResolver(FhirContext.forCached(FhirVersionEnum.DSTU3)); for (DataType type : DataType.values()) { @@ -204,11 +204,9 @@ public void createInstanceTests() { Enumeration instance = (Enumeration) resolver.createInstance(enumType.getSimpleName()); assertNotNull(instance); - assertTrue(instance.getEnumFactory() - .getClass() - .getSimpleName() - .replace("EnumFactory", "") - .equals(enumType.getSimpleName())); + assertEquals( + instance.getEnumFactory().getClass().getSimpleName().replace("EnumFactory", ""), + enumType.getSimpleName()); } // These are some inner classes that don't appear in the enums above @@ -222,12 +220,12 @@ public void createInstanceTests() { } @Test - public void contextPathTests() { + void contextPathTests() { ModelResolver resolver = new Dstu3FhirModelResolver(FhirContext.forCached(FhirVersionEnum.DSTU3)); String path = (String) resolver.getContextPath("Patient", "Patient"); assertNotNull(path); - assertEquals(path, "id"); + assertEquals("id", path); path = (String) resolver.getContextPath(null, "Encounter"); assertNull(path); @@ -239,28 +237,28 @@ public void contextPathTests() { path = (String) resolver.getContextPath("Patient", "Condition"); assertNotNull(path); - assertEquals(path, "subject"); + assertEquals("subject", path); path = (String) resolver.getContextPath("Patient", "Appointment"); assertNotNull(path); - assertEquals(path, "participant.actor"); + assertEquals("participant.actor", path); path = (String) resolver.getContextPath("Patient", "Account"); assertNotNull(path); - assertEquals(path, "subject"); + assertEquals("subject", path); path = (String) resolver.getContextPath("Patient", "Encounter"); assertNotNull(path); - assertEquals(path, "subject"); + assertEquals("subject", path); path = (String) resolver.getContextPath("Patient", "MedicationStatement"); - assertEquals(path, "subject"); + assertEquals("subject", path); path = (String) resolver.getContextPath("Patient", "Task"); - assertEquals(path, "for"); + assertEquals("for", path); path = (String) resolver.getContextPath("Patient", "Coverage"); - assertEquals(path, "beneficiary"); + assertEquals("beneficiary", path); // Issue 527 - https://github.com/DBCG/cql_engine/issues/527 path = (String) resolver.getContextPath("Unfiltered", "MedicationStatement"); @@ -271,7 +269,7 @@ public void contextPathTests() { } @Test - public void resolveMissingPropertyReturnsNull() { + void resolveMissingPropertyReturnsNull() { ModelResolver resolver = new Dstu3FhirModelResolver(FhirContext.forCached(FhirVersionEnum.DSTU3)); Patient p = new Patient(); @@ -281,7 +279,7 @@ public void resolveMissingPropertyReturnsNull() { } @Test - public void resolveNullEnumerationReturnsNull() { + void resolveNullEnumerationReturnsNull() { FhirModelResolver resolver = new Dstu3FhirModelResolver(FhirContext.forCached(FhirVersionEnum.DSTU3)); @@ -295,7 +293,7 @@ public void resolveNullEnumerationReturnsNull() { } @Test - public void resolveNullPrimitiveReturnsNull() { + void resolveNullPrimitiveReturnsNull() { FhirModelResolver resolver = new Dstu3FhirModelResolver(FhirContext.forCached(FhirVersionEnum.DSTU3)); diff --git a/Src/java/engine-fhir/src/test/java/org/opencds/cqf/cql/engine/fhir/model/TestR4ModelResolver.java b/Src/java/engine-fhir/src/test/java/org/opencds/cqf/cql/engine/fhir/model/TestR4ModelResolver.java index 88e131910..13a1d8da5 100644 --- a/Src/java/engine-fhir/src/test/java/org/opencds/cqf/cql/engine/fhir/model/TestR4ModelResolver.java +++ b/Src/java/engine-fhir/src/test/java/org/opencds/cqf/cql/engine/fhir/model/TestR4ModelResolver.java @@ -2,10 +2,10 @@ import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.is; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertNull; -import static org.testng.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertThrows; import ca.uhn.fhir.context.FhirContext; import ca.uhn.fhir.context.FhirVersionEnum; @@ -42,11 +42,11 @@ import org.hl7.fhir.r4.model.Enumerations.ResourceType; import org.hl7.fhir.r4.model.Enumerations.SearchParamType; import org.hl7.fhir.r4.model.Enumerations.SpecialValues; +import org.junit.jupiter.api.Test; import org.opencds.cqf.cql.engine.fhir.exception.UnknownType; import org.opencds.cqf.cql.engine.model.ModelResolver; -import org.testng.annotations.Test; -public class TestR4ModelResolver { +class TestR4ModelResolver { // Couldn't find a way to automatically get the full list of enums. @SuppressWarnings("serial") @@ -77,14 +77,16 @@ public class TestR4ModelResolver { } }; - @Test(expectedExceptions = UnknownType.class) - public void resolverThrowsExceptionForUnknownType() { + @Test + void resolverThrowsExceptionForUnknownType() { ModelResolver resolver = new R4FhirModelResolver(FhirContext.forCached(FhirVersionEnum.R4)); - resolver.resolveType("ImpossibleTypeThatDoesntExistAndShouldBlowUp"); + assertThrows(UnknownType.class, () -> { + resolver.resolveType("ImpossibleTypeThatDoesn'tExistAndShouldBlowUp"); + }); } @Test - public void resolveTypeTests() { + void resolveTypeTests() { ModelResolver resolver = new R4FhirModelResolver(FhirContext.forCached(FhirVersionEnum.R4)); for (DataType type : DataType.values()) { @@ -119,7 +121,7 @@ public void resolveTypeTests() { } @Test - public void modelInfoSpecialCaseTests() { + void modelInfoSpecialCaseTests() { ModelResolver resolver = new R4FhirModelResolver(FhirContext.forCached(FhirVersionEnum.R4)); // This tests resolution of inner classes. They aren't registered directly. @@ -157,7 +159,7 @@ public void modelInfoSpecialCaseTests() { } @Test - public void modelInfo400Tests() { + void modelInfo400Tests() { ModelResolver resolver = new R4FhirModelResolver(FhirContext.forCached(FhirVersionEnum.R4)); ModelManager mm = new ModelManager(); Model m = mm.resolveModel(new ModelIdentifier().withId("FHIR").withVersion("4.0.1")); @@ -193,7 +195,7 @@ public void modelInfo400Tests() { } @Test - public void modelInfo401Tests() throws Exception { + void modelInfo401Tests() throws Exception { ModelResolver resolver = new R4FhirModelResolver(FhirContext.forCached(FhirVersionEnum.R4)); ModelManager mm = new ModelManager(); Model m = mm.resolveModel(new ModelIdentifier().withId("FHIR").withVersion("4.0.1")); @@ -242,7 +244,7 @@ public void modelInfo401Tests() throws Exception { } @Test - public void createInstanceTests() { + void createInstanceTests() { ModelResolver resolver = new R4FhirModelResolver(FhirContext.forCached(FhirVersionEnum.R4)); for (DataType type : DataType.values()) { @@ -280,11 +282,9 @@ public void createInstanceTests() { Enumeration instance = (Enumeration) resolver.createInstance(enumType.getSimpleName()); assertNotNull(instance); - assertTrue(instance.getEnumFactory() - .getClass() - .getSimpleName() - .replace("EnumFactory", "") - .equals(enumType.getSimpleName())); + assertEquals( + instance.getEnumFactory().getClass().getSimpleName().replace("EnumFactory", ""), + enumType.getSimpleName()); } // These are some inner classes that don't appear in the enums above @@ -297,12 +297,12 @@ public void createInstanceTests() { } @Test - public void contextPathTests() { + void contextPathTests() { ModelResolver resolver = new R4FhirModelResolver(FhirContext.forCached(FhirVersionEnum.R4)); String path = (String) resolver.getContextPath("Patient", "Patient"); assertNotNull(path); - assertTrue(path.equals("id")); + assertEquals("id", path); path = (String) resolver.getContextPath(null, "Encounter"); assertNull(path); @@ -314,31 +314,31 @@ public void contextPathTests() { path = (String) resolver.getContextPath("Patient", "Condition"); assertNotNull(path); - assertEquals(path, "subject"); + assertEquals("subject", path); path = (String) resolver.getContextPath("Patient", "Appointment"); assertNotNull(path); - assertEquals(path, "participant.actor"); + assertEquals("participant.actor", path); path = (String) resolver.getContextPath("Patient", "Account"); assertNotNull(path); - assertEquals(path, "subject"); + assertEquals("subject", path); path = (String) resolver.getContextPath("Patient", "Encounter"); assertNotNull(path); - assertEquals(path, "subject"); + assertEquals("subject", path); path = (String) resolver.getContextPath("Patient", "ValueSet"); assertNull(path); path = (String) resolver.getContextPath("Patient", "MedicationStatement"); - assertEquals(path, "subject"); + assertEquals("subject", path); path = (String) resolver.getContextPath("Patient", "Task"); - assertEquals(path, "for"); + assertEquals("for", path); path = (String) resolver.getContextPath("Patient", "Coverage"); - assertEquals(path, "beneficiary"); + assertEquals("beneficiary", path); // Issue 527 - https://github.com/DBCG/cql_engine/issues/527 path = (String) resolver.getContextPath("Unfiltered", "MedicationStatement"); @@ -349,7 +349,7 @@ public void contextPathTests() { } @Test - public void resolveMissingPropertyReturnsNull() { + void resolveMissingPropertyReturnsNull() { ModelResolver resolver = new R4FhirModelResolver(FhirContext.forCached(FhirVersionEnum.R4)); Patient p = new Patient(); @@ -359,7 +359,7 @@ public void resolveMissingPropertyReturnsNull() { } @Test - public void resolveIdPropertyReturnsString() { + void resolveIdPropertyReturnsString() { ModelResolver resolver = new R4FhirModelResolver(FhirContext.forCached(FhirVersionEnum.R4)); Patient p = new Patient(); @@ -376,7 +376,7 @@ public void resolveIdPropertyReturnsString() { } @Test - public void resolveDateTimeProviderReturnsDate() { + void resolveDateTimeProviderReturnsDate() { ModelResolver resolver = new R4FhirModelResolver(FhirContext.forCached(FhirVersionEnum.R4)); @@ -392,7 +392,7 @@ public void resolveDateTimeProviderReturnsDate() { } @Test - public void resolveNullEnumerationReturnsNull() { + void resolveNullEnumerationReturnsNull() { FhirModelResolver resolver = new R4FhirModelResolver(FhirContext.forCached(FhirVersionEnum.R4)); @@ -406,7 +406,7 @@ public void resolveNullEnumerationReturnsNull() { } @Test - public void resolveNullPrimitiveReturnsNull() { + void resolveNullPrimitiveReturnsNull() { FhirModelResolver resolver = new R4FhirModelResolver(FhirContext.forCached(FhirVersionEnum.R4)); @@ -417,7 +417,7 @@ public void resolveNullPrimitiveReturnsNull() { } @Test - public void resolveIdPatient() { + void resolveIdPatient() { final String expectedId = "123"; final FhirModelResolver resolver = new R4FhirModelResolver(FhirContext.forCached(FhirVersionEnum.R4)); @@ -429,7 +429,7 @@ public void resolveIdPatient() { } @Test - public void resolveIdProcedure() { + void resolveIdProcedure() { final String expectedId = "456"; final FhirModelResolver resolver = new R4FhirModelResolver(FhirContext.forCached(FhirVersionEnum.R4)); @@ -441,7 +441,7 @@ public void resolveIdProcedure() { } @Test - public void resolveIdStringReturnsNull() { + void resolveIdStringReturnsNull() { final FhirModelResolver resolver = new R4FhirModelResolver(FhirContext.forCached(FhirVersionEnum.R4)); @@ -449,7 +449,7 @@ public void resolveIdStringReturnsNull() { } @Test - public void resolveIdStringTypeReturnsNull() { + void resolveIdStringTypeReturnsNull() { final FhirModelResolver resolver = new R4FhirModelResolver(FhirContext.forCached(FhirVersionEnum.R4)); diff --git a/Src/java/engine-fhir/src/test/java/org/opencds/cqf/cql/engine/fhir/model/TestR5ModelResolver.java b/Src/java/engine-fhir/src/test/java/org/opencds/cqf/cql/engine/fhir/model/TestR5ModelResolver.java index 94b3f7464..b8594f166 100644 --- a/Src/java/engine-fhir/src/test/java/org/opencds/cqf/cql/engine/fhir/model/TestR5ModelResolver.java +++ b/Src/java/engine-fhir/src/test/java/org/opencds/cqf/cql/engine/fhir/model/TestR5ModelResolver.java @@ -2,10 +2,10 @@ import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.is; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertNull; -import static org.testng.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertThrows; import ca.uhn.fhir.context.FhirContext; import ca.uhn.fhir.context.FhirVersionEnum; @@ -29,11 +29,11 @@ import org.hl7.fhir.r5.model.Quantity; import org.hl7.fhir.r5.model.SimpleQuantity; import org.hl7.fhir.r5.model.VisionPrescription; +import org.junit.jupiter.api.Test; import org.opencds.cqf.cql.engine.fhir.exception.UnknownType; import org.opencds.cqf.cql.engine.model.ModelResolver; -import org.testng.annotations.Test; -public class TestR5ModelResolver { +class TestR5ModelResolver { // Couldn't find a way to automatically get the full list of enums. @SuppressWarnings("serial") @@ -48,14 +48,17 @@ public class TestR5ModelResolver { } }; - @Test(expectedExceptions = UnknownType.class) - public void resolverThrowsExceptionForUnknownType() { + @Test + void resolverThrowsExceptionForUnknownType() { ModelResolver resolver = new R5FhirModelResolver(FhirContext.forCached(FhirVersionEnum.R5)); - resolver.resolveType("ImpossibleTypeThatDoesntExistAndShouldBlowUp"); + + assertThrows(UnknownType.class, () -> { + resolver.resolveType("ImpossibleTypeThatDoesn'tExistAndShouldBlowUp"); + }); } @Test - public void resolveTypeTests() { + void resolveTypeTests() { ModelResolver resolver = new R5FhirModelResolver(FhirContext.forCached(FhirVersionEnum.R5)); for (FHIRTypes type : FHIRTypes.values()) { @@ -162,7 +165,7 @@ public void resolveTypeTests() { // } @Test - public void createInstanceTests() { + void createInstanceTests() { ModelResolver resolver = new R5FhirModelResolver(FhirContext.forCached(FhirVersionEnum.R5)); for (FHIRTypes type : FHIRTypes.values()) { @@ -193,11 +196,9 @@ public void createInstanceTests() { Enumeration instance = (Enumeration) resolver.createInstance(enumType.getSimpleName()); assertNotNull(instance); - assertTrue(instance.getEnumFactory() - .getClass() - .getSimpleName() - .replace("EnumFactory", "") - .equals(enumType.getSimpleName())); + assertEquals( + instance.getEnumFactory().getClass().getSimpleName().replace("EnumFactory", ""), + enumType.getSimpleName()); } // These are some inner classes that don't appear in the enums above @@ -210,12 +211,12 @@ public void createInstanceTests() { } @Test - public void contextPathTests() { + void contextPathTests() { ModelResolver resolver = new R5FhirModelResolver(FhirContext.forCached(FhirVersionEnum.R5)); String path = (String) resolver.getContextPath("Patient", "Patient"); assertNotNull(path); - assertTrue(path.equals("id")); + assertEquals("id", path); path = (String) resolver.getContextPath(null, "Encounter"); assertNull(path); @@ -227,31 +228,31 @@ public void contextPathTests() { path = (String) resolver.getContextPath("Patient", "Condition"); assertNotNull(path); - assertEquals(path, "subject"); + assertEquals("subject", path); path = (String) resolver.getContextPath("Patient", "Appointment"); assertNotNull(path); - assertEquals(path, "subject"); + assertEquals("subject", path); path = (String) resolver.getContextPath("Patient", "Account"); assertNotNull(path); - assertEquals(path, "subject"); + assertEquals("subject", path); path = (String) resolver.getContextPath("Patient", "Encounter"); assertNotNull(path); - assertEquals(path, "subject"); + assertEquals("subject", path); path = (String) resolver.getContextPath("Patient", "ValueSet"); assertNull(path); path = (String) resolver.getContextPath("Patient", "MedicationStatement"); - assertEquals(path, "subject"); + assertEquals("subject", path); path = (String) resolver.getContextPath("Patient", "Task"); - assertEquals(path, "for"); + assertEquals("for", path); path = (String) resolver.getContextPath("Patient", "Coverage"); - assertEquals(path, "beneficiary"); + assertEquals("beneficiary", path); // Issue 527 - https://github.com/DBCG/cql_engine/issues/527 path = (String) resolver.getContextPath("Unfiltered", "MedicationStatement"); @@ -262,7 +263,7 @@ public void contextPathTests() { } @Test - public void resolveMissingPropertyReturnsNull() { + void resolveMissingPropertyReturnsNull() { ModelResolver resolver = new R5FhirModelResolver(FhirContext.forCached(FhirVersionEnum.R5)); Patient p = new Patient(); @@ -272,7 +273,7 @@ public void resolveMissingPropertyReturnsNull() { } @Test - public void resolveIdPropertyReturnsString() { + void resolveIdPropertyReturnsString() { ModelResolver resolver = new R5FhirModelResolver(FhirContext.forCached(FhirVersionEnum.R5)); Patient p = new Patient(); @@ -289,7 +290,7 @@ public void resolveIdPropertyReturnsString() { } @Test - public void resolveDateTimeProviderReturnsDate() { + void resolveDateTimeProviderReturnsDate() { ModelResolver resolver = new R5FhirModelResolver(FhirContext.forCached(FhirVersionEnum.R5)); @@ -305,7 +306,7 @@ public void resolveDateTimeProviderReturnsDate() { } @Test - public void resolveNullEnumerationReturnsNull() { + void resolveNullEnumerationReturnsNull() { FhirModelResolver resolver = new R5FhirModelResolver(FhirContext.forCached(FhirVersionEnum.R5)); @@ -319,7 +320,7 @@ public void resolveNullEnumerationReturnsNull() { } @Test - public void resolveNullPrimitiveReturnsNull() { + void resolveNullPrimitiveReturnsNull() { FhirModelResolver resolver = new R5FhirModelResolver(FhirContext.forCached(FhirVersionEnum.R5)); diff --git a/Src/java/engine-fhir/src/test/java/org/opencds/cqf/cql/engine/fhir/retrieve/TestDstu3FhirQueryGenerator.java b/Src/java/engine-fhir/src/test/java/org/opencds/cqf/cql/engine/fhir/retrieve/TestDstu3FhirQueryGenerator.java index 4839cb1f5..a127e4696 100644 --- a/Src/java/engine-fhir/src/test/java/org/opencds/cqf/cql/engine/fhir/retrieve/TestDstu3FhirQueryGenerator.java +++ b/Src/java/engine-fhir/src/test/java/org/opencds/cqf/cql/engine/fhir/retrieve/TestDstu3FhirQueryGenerator.java @@ -1,6 +1,7 @@ package org.opencds.cqf.cql.engine.fhir.retrieve; -import static org.testng.Assert.*; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; import ca.uhn.fhir.context.FhirContext; import ca.uhn.fhir.context.FhirVersionEnum; @@ -14,6 +15,9 @@ import java.util.*; import org.apache.commons.lang3.tuple.Pair; import org.hl7.fhir.dstu3.model.*; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.opencds.cqf.cql.engine.fhir.Dstu3FhirTest; import org.opencds.cqf.cql.engine.fhir.exception.FhirVersionMisMatchException; import org.opencds.cqf.cql.engine.fhir.model.CachedDstu3FhirModelResolver; @@ -23,11 +27,8 @@ import org.opencds.cqf.cql.engine.runtime.DateTime; import org.opencds.cqf.cql.engine.runtime.Interval; import org.opencds.cqf.cql.engine.terminology.TerminologyProvider; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; -public class TestDstu3FhirQueryGenerator extends Dstu3FhirTest { +class TestDstu3FhirQueryGenerator extends Dstu3FhirTest { static IGenericClient CLIENT; Dstu3FhirQueryGenerator generator; @@ -36,13 +37,13 @@ public class TestDstu3FhirQueryGenerator extends Dstu3FhirTest { Map contextValues; Map parameters; - @BeforeClass - public void setUpBeforeClass() { + @BeforeAll + static void setUpBeforeAll() { CLIENT = newClient(); } - @BeforeMethod - public void setUp() throws FhirVersionMisMatchException { + @BeforeEach + void setUp() throws FhirVersionMisMatchException { SearchParameterResolver searchParameterResolver = new SearchParameterResolver(FhirContext.forCached(FhirVersionEnum.DSTU3)); TerminologyProvider terminologyProvider = new Dstu3FhirTerminologyProvider(CLIENT); @@ -92,7 +93,7 @@ private DataRequirement getCodeFilteredDataRequirement(String resourceType, Stri } @Test - void testGetFhirQueriesObservation() { + void getFhirQueriesObservation() { ValueSet valueSet = getTestValueSet("MyValueSet", 3); org.hl7.fhir.dstu3.model.Bundle valueSetBundle = new org.hl7.fhir.dstu3.model.Bundle(); @@ -102,6 +103,7 @@ void testGetFhirQueriesObservation() { entry.setResource(valueSet); valueSetBundle.addEntry(entry); + /* spell-checker: disable */ mockFhirRead("/ValueSet?url=http%3A%2F%2Fmyterm.com%2Ffhir%2FValueSet%2FMyValueSet", valueSetBundle); DataRequirement dataRequirement = getCodeFilteredDataRequirement("Observation", "category", valueSet); @@ -118,7 +120,7 @@ void testGetFhirQueriesObservation() { } @Test - void testGetFhirQueriesCodeInValueSet() { + void getFhirQueriesCodeInValueSet() { ValueSet valueSet = getTestValueSet("MyValueSet", 500); org.hl7.fhir.dstu3.model.Bundle valueSetBundle = new org.hl7.fhir.dstu3.model.Bundle(); @@ -128,6 +130,7 @@ void testGetFhirQueriesCodeInValueSet() { entry.setResource(valueSet); valueSetBundle.addEntry(entry); + /* spell-checker: disable */ mockFhirRead("/ValueSet?url=http%3A%2F%2Fmyterm.com%2Ffhir%2FValueSet%2FMyValueSet", valueSetBundle); DataRequirement dataRequirement = getCodeFilteredDataRequirement("Observation", "category", valueSet); @@ -145,7 +148,7 @@ void testGetFhirQueriesCodeInValueSet() { } @Test - void testGetFhirQueriesAppointment() { + void getFhirQueriesAppointment() { DataRequirement dataRequirement = new DataRequirement(); dataRequirement.setType("Appointment"); @@ -160,7 +163,7 @@ void testGetFhirQueriesAppointment() { } @Test - void testGetFhirQueriesAppointmentWithDate() { + void getFhirQueriesAppointmentWithDate() { DataRequirement dataRequirement = new DataRequirement(); dataRequirement.setType("Appointment"); DataRequirement.DataRequirementDateFilterComponent dateFilterComponent = @@ -189,7 +192,7 @@ void testGetFhirQueriesAppointmentWithDate() { } @Test - void testGetFhirQueriesObservationWithDuration() { + void getFhirQueriesObservationWithDuration() { DataRequirement dataRequirement = new DataRequirement(); dataRequirement.setType("Observation"); DataRequirement.DataRequirementDateFilterComponent dateFilterComponent = @@ -225,7 +228,7 @@ void testGetFhirQueriesObservationWithDuration() { } @Test - void testCodesExceedMaxCodesPerQuery() { + void codesExceedMaxCodesPerQuery() { ValueSet valueSet = getTestValueSet("MyValueSet", 8); org.hl7.fhir.dstu3.model.Bundle valueSetBundle = new org.hl7.fhir.dstu3.model.Bundle(); @@ -235,6 +238,7 @@ void testCodesExceedMaxCodesPerQuery() { entry.setResource(valueSet); valueSetBundle.addEntry(entry); + /* spell-checker: disable */ mockFhirRead("/ValueSet?url=http%3A%2F%2Fmyterm.com%2Ffhir%2FValueSet%2FMyValueSet", valueSetBundle); mockFhirRead("/ValueSet/MyValueSet/$expand", valueSet); @@ -252,13 +256,13 @@ void testCodesExceedMaxCodesPerQuery() { "Observation?category=http://myterm.com/fhir/CodeSystem/MyValueSet|code4,http://myterm.com/fhir/CodeSystem/MyValueSet|code5,http://myterm.com/fhir/CodeSystem/MyValueSet|code6,http://myterm.com/fhir/CodeSystem/MyValueSet|code7&patient=Patient/{{context.patientId}}"; assertNotNull(actual); - assertEquals(actual.size(), 2); + assertEquals(2, actual.size()); assertEquals(actual.get(0), expectedQuery1); assertEquals(actual.get(1), expectedQuery2); } @Test - void testMaxQueryThresholdExceeded() { + void maxQueryThresholdExceeded() { ValueSet valueSet = getTestValueSet("MyValueSet", 21); Bundle valueSetBundle = new Bundle(); @@ -281,11 +285,11 @@ void testMaxQueryThresholdExceeded() { dataRequirement, this.evaluationDateTime, this.contextValues, this.parameters, null); assertNotNull(actual); - assertEquals(actual.size(), 1); + assertEquals(1, actual.size()); } @Test - void testMaxQueryThreshold() { + void maxQueryThreshold() { ValueSet valueSet = getTestValueSet("MyValueSet", 21); Bundle valueSetBundle = new Bundle(); @@ -295,6 +299,7 @@ void testMaxQueryThreshold() { entry.setResource(valueSet); valueSetBundle.addEntry(entry); + /* spell-checker: disable */ mockFhirRead("/ValueSet?url=http%3A%2F%2Fmyterm.com%2Ffhir%2FValueSet%2FMyValueSet", valueSetBundle); mockFhirRead("/ValueSet/MyValueSet/$expand", valueSet); @@ -319,7 +324,7 @@ void testMaxQueryThreshold() { "Observation?category=http://myterm.com/fhir/CodeSystem/MyValueSet|code20&patient=Patient/{{context.patientId}}"; assertNotNull(actual); - assertEquals(actual.size(), 5); + assertEquals(5, actual.size()); assertEquals(actual.get(0), expectedQuery1); assertEquals(actual.get(1), expectedQuery2); assertEquals(actual.get(2), expectedQuery3); @@ -328,7 +333,7 @@ void testMaxQueryThreshold() { } @Test - void testGetDateRangeParamWithDateInterval() throws ParseException { + void getDateRangeParamWithDateInterval() throws ParseException { SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd", Locale.ENGLISH); Date low = formatter.parse("2023-01-01"); @@ -339,12 +344,12 @@ void testGetDateRangeParamWithDateInterval() throws ParseException { this.generator.getDateRangeParam("Condition", "onset", "valueDate", "valueDate", interval); assertNotNull(rangeParam); - assertTrue(rangeParam.getValue().getLowerBound().getValue().equals(low)); - assertTrue(rangeParam.getValue().getUpperBound().getValue().equals(high)); + assertEquals(rangeParam.getValue().getLowerBound().getValue(), low); + assertEquals(rangeParam.getValue().getUpperBound().getValue(), high); } @Test - void testGetDateRangeParamWithDateTimeInterval() throws ParseException { + void getDateRangeParamWithDateTimeInterval() throws ParseException { SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ", Locale.ENGLISH); Date low = formatter.parse("2023-01-01T12:01:02-0700"); @@ -355,7 +360,7 @@ void testGetDateRangeParamWithDateTimeInterval() throws ParseException { this.generator.getDateRangeParam("Condition", "onset", "valueDate", "valueDate", interval); assertNotNull(rangeParam); - assertTrue(rangeParam.getValue().getLowerBound().getValue().equals(low)); - assertTrue(rangeParam.getValue().getUpperBound().getValue().equals(high)); + assertEquals(rangeParam.getValue().getLowerBound().getValue(), low); + assertEquals(rangeParam.getValue().getUpperBound().getValue(), high); } } diff --git a/Src/java/engine-fhir/src/test/java/org/opencds/cqf/cql/engine/fhir/retrieve/TestR4FhirQueryGenerator.java b/Src/java/engine-fhir/src/test/java/org/opencds/cqf/cql/engine/fhir/retrieve/TestR4FhirQueryGenerator.java index 51121ad63..7a1aa6551 100644 --- a/Src/java/engine-fhir/src/test/java/org/opencds/cqf/cql/engine/fhir/retrieve/TestR4FhirQueryGenerator.java +++ b/Src/java/engine-fhir/src/test/java/org/opencds/cqf/cql/engine/fhir/retrieve/TestR4FhirQueryGenerator.java @@ -1,6 +1,7 @@ package org.opencds.cqf.cql.engine.fhir.retrieve; -import static org.testng.Assert.*; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; import ca.uhn.fhir.context.FhirContext; import ca.uhn.fhir.context.FhirVersionEnum; @@ -14,6 +15,9 @@ import java.util.*; import org.apache.commons.lang3.tuple.Pair; import org.hl7.fhir.r4.model.*; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.opencds.cqf.cql.engine.fhir.R4FhirTest; import org.opencds.cqf.cql.engine.fhir.exception.FhirVersionMisMatchException; import org.opencds.cqf.cql.engine.fhir.model.CachedR4FhirModelResolver; @@ -23,11 +27,8 @@ import org.opencds.cqf.cql.engine.runtime.DateTime; import org.opencds.cqf.cql.engine.runtime.Interval; import org.opencds.cqf.cql.engine.terminology.TerminologyProvider; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; -public class TestR4FhirQueryGenerator extends R4FhirTest { +class TestR4FhirQueryGenerator extends R4FhirTest { static IGenericClient CLIENT; R4FhirQueryGenerator generator; @@ -36,13 +37,13 @@ public class TestR4FhirQueryGenerator extends R4FhirTest { Map contextValues; Map parameters; - @BeforeClass - public void setUpBeforeClass() { + @BeforeAll + static void setUpBeforeAll() { CLIENT = newClient(); } - @BeforeMethod - public void setUp() throws FhirVersionMisMatchException { + @BeforeEach + void setUp() throws FhirVersionMisMatchException { SearchParameterResolver searchParameterResolver = new SearchParameterResolver(FhirContext.forCached(FhirVersionEnum.R4)); TerminologyProvider terminologyProvider = new R4FhirTerminologyProvider(CLIENT); @@ -55,7 +56,7 @@ public void setUp() throws FhirVersionMisMatchException { } @Test - public void Test() { + void test() { DateTime evaluationDateTime = new DateTime(evaluationOffsetDateTime); OffsetDateTime evaluationDateTimeAsLocal = OffsetDateTime.ofInstant( evaluationOffsetDateTime.toInstant(), @@ -63,7 +64,8 @@ public void Test() { Date expectedRangeStartDateTime = Date.from(evaluationDateTimeAsLocal.minusDays(90).toInstant()); - SimpleDateFormat simpleDateFormatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSXXX"); + /* spell-checker: disable */ + SimpleDateFormat simpleDateFormatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss."); String expectedQuery = String.format("date=%s", simpleDateFormatter.format(expectedRangeStartDateTime)); } @@ -105,7 +107,7 @@ private DataRequirement getCodeFilteredDataRequirement(String resourceType, Stri } @Test - void testGetFhirQueriesPatientWithNoFilters() { + void getFhirQueriesPatientWithNoFilters() { DataRequirement dataRequirement = new DataRequirement(); dataRequirement.setType("Patient"); @@ -121,7 +123,7 @@ void testGetFhirQueriesPatientWithNoFilters() { } @Test - void testGetFhirQueriesConditionWithNoFilters() { + void getFhirQueriesConditionWithNoFilters() { DataRequirement dataRequirement = new DataRequirement(); dataRequirement.setType("Condition"); @@ -137,7 +139,7 @@ void testGetFhirQueriesConditionWithNoFilters() { } @Test - void testGetFhirQueriesObservation() { + void getFhirQueriesObservation() { ValueSet valueSet = getTestValueSet("MyValueSet", 3); org.hl7.fhir.r4.model.Bundle valueSetBundle = new org.hl7.fhir.r4.model.Bundle(); @@ -147,6 +149,7 @@ void testGetFhirQueriesObservation() { entry.setResource(valueSet); valueSetBundle.addEntry(entry); + /* spell-checker: disable */ mockFhirRead("/ValueSet?url=http%3A%2F%2Fmyterm.com%2Ffhir%2FValueSet%2FMyValueSet", valueSetBundle); DataRequirement dataRequirement = getCodeFilteredDataRequirement("Observation", "category", valueSet); @@ -163,7 +166,7 @@ void testGetFhirQueriesObservation() { } @Test - void testGetFhirQueriesCodeInValueSet() { + void getFhirQueriesCodeInValueSet() { ValueSet valueSet = getTestValueSet("MyValueSet", 500); org.hl7.fhir.r4.model.Bundle valueSetBundle = new org.hl7.fhir.r4.model.Bundle(); @@ -190,7 +193,7 @@ void testGetFhirQueriesCodeInValueSet() { } @Test - void testGetFhirQueriesAppointment() { + void getFhirQueriesAppointment() { DataRequirement dataRequirement = new DataRequirement(); dataRequirement.setType("Appointment"); this.contextValues.put("Patient", "{{context.patientId}}"); @@ -204,7 +207,7 @@ void testGetFhirQueriesAppointment() { } @Test - void testGetFhirQueriesAppointmentWithDate() { + void getFhirQueriesAppointmentWithDate() { DataRequirement dataRequirement = new DataRequirement(); dataRequirement.setType("Appointment"); DataRequirement.DataRequirementDateFilterComponent dateFilterComponent = @@ -233,7 +236,7 @@ void testGetFhirQueriesAppointmentWithDate() { } @Test - void testGetFhirQueriesObservationWithDuration() { + void getFhirQueriesObservationWithDuration() { DataRequirement dataRequirement = new DataRequirement(); dataRequirement.setType("Observation"); DataRequirement.DataRequirementDateFilterComponent dateFilterComponent = @@ -268,7 +271,7 @@ void testGetFhirQueriesObservationWithDuration() { } @Test - void testCodesExceedMaxCodesPerQuery() { + void codesExceedMaxCodesPerQuery() { ValueSet valueSet = getTestValueSet("MyValueSet", 8); org.hl7.fhir.r4.model.Bundle valueSetBundle = new org.hl7.fhir.r4.model.Bundle(); @@ -295,13 +298,13 @@ void testCodesExceedMaxCodesPerQuery() { "Observation?category=http://myterm.com/fhir/CodeSystem/MyValueSet|code4,http://myterm.com/fhir/CodeSystem/MyValueSet|code5,http://myterm.com/fhir/CodeSystem/MyValueSet|code6,http://myterm.com/fhir/CodeSystem/MyValueSet|code7&subject=Patient/{{context.patientId}}"; assertNotNull(actual); - assertEquals(actual.size(), 2); + assertEquals(2, actual.size()); assertEquals(actual.get(0), expectedQuery1); assertEquals(actual.get(1), expectedQuery2); } @Test - void testQueryBatchThresholdExceeded() { + void queryBatchThresholdExceeded() { ValueSet valueSet = getTestValueSet("MyValueSet", 21); org.hl7.fhir.r4.model.Bundle valueSetBundle = new org.hl7.fhir.r4.model.Bundle(); @@ -324,11 +327,11 @@ void testQueryBatchThresholdExceeded() { dataRequirement, this.evaluationDateTime, this.contextValues, this.parameters, null); assertNotNull(actual); - assertEquals(actual.size(), 1); + assertEquals(1, actual.size()); } @Test - void testQueryBatchThreshold() { + void queryBatchThreshold() { ValueSet valueSet = getTestValueSet("MyValueSet", 21); org.hl7.fhir.r4.model.Bundle valueSetBundle = new org.hl7.fhir.r4.model.Bundle(); @@ -362,7 +365,7 @@ void testQueryBatchThreshold() { "Observation?category=http://myterm.com/fhir/CodeSystem/MyValueSet|code20&subject=Patient/{{context.patientId}}"; assertNotNull(actual); - assertEquals(actual.size(), 5); + assertEquals(5, actual.size()); assertEquals(actual.get(0), expectedQuery1); assertEquals(actual.get(1), expectedQuery2); assertEquals(actual.get(2), expectedQuery3); @@ -371,7 +374,7 @@ void testQueryBatchThreshold() { } @Test - void testMaxCodesPerQueryNull() { + void maxCodesPerQueryNull() { ValueSet valueSet = getTestValueSet("MyValueSet", 21); org.hl7.fhir.r4.model.Bundle valueSetBundle = new org.hl7.fhir.r4.model.Bundle(); @@ -396,12 +399,12 @@ void testMaxCodesPerQueryNull() { "Observation?category=http://myterm.com/fhir/CodeSystem/MyValueSet|code0,http://myterm.com/fhir/CodeSystem/MyValueSet|code1,http://myterm.com/fhir/CodeSystem/MyValueSet|code10,http://myterm.com/fhir/CodeSystem/MyValueSet|code11,http://myterm.com/fhir/CodeSystem/MyValueSet|code12,http://myterm.com/fhir/CodeSystem/MyValueSet|code13,http://myterm.com/fhir/CodeSystem/MyValueSet|code14,http://myterm.com/fhir/CodeSystem/MyValueSet|code15,http://myterm.com/fhir/CodeSystem/MyValueSet|code16,http://myterm.com/fhir/CodeSystem/MyValueSet|code17,http://myterm.com/fhir/CodeSystem/MyValueSet|code18,http://myterm.com/fhir/CodeSystem/MyValueSet|code19,http://myterm.com/fhir/CodeSystem/MyValueSet|code2,http://myterm.com/fhir/CodeSystem/MyValueSet|code20,http://myterm.com/fhir/CodeSystem/MyValueSet|code3,http://myterm.com/fhir/CodeSystem/MyValueSet|code4,http://myterm.com/fhir/CodeSystem/MyValueSet|code5,http://myterm.com/fhir/CodeSystem/MyValueSet|code6,http://myterm.com/fhir/CodeSystem/MyValueSet|code7,http://myterm.com/fhir/CodeSystem/MyValueSet|code8,http://myterm.com/fhir/CodeSystem/MyValueSet|code9&subject=Patient/{{context.patientId}}"; assertNotNull(actual); - assertEquals(actual.size(), 1); + assertEquals(1, actual.size()); assertEquals(actual.get(0), expectedQuery1); } @Test - void testBatchQueryThresholdNull() { + void batchQueryThresholdNull() { ValueSet valueSet = getTestValueSet("MyValueSet", 21); org.hl7.fhir.r4.model.Bundle valueSetBundle = new org.hl7.fhir.r4.model.Bundle(); @@ -424,11 +427,11 @@ void testBatchQueryThresholdNull() { dataRequirement, this.evaluationDateTime, this.contextValues, this.parameters, null); assertNotNull(actual); - assertEquals(actual.size(), 11); + assertEquals(11, actual.size()); } @Test - void testGetDateRangeParamWithDateType() throws ParseException { + void getDateRangeParamWithDateType() throws ParseException { SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd", Locale.ENGLISH); Date low = formatter.parse("2023-01-01"); @@ -439,12 +442,12 @@ void testGetDateRangeParamWithDateType() throws ParseException { this.generator.getDateRangeParam("Condition", "onset", "valueDate", "valueDate", interval); assertNotNull(rangeParam); - assertTrue(rangeParam.getValue().getLowerBound().getValue().equals(low)); - assertTrue(rangeParam.getValue().getUpperBound().getValue().equals(high)); + assertEquals(rangeParam.getValue().getLowerBound().getValue(), low); + assertEquals(rangeParam.getValue().getUpperBound().getValue(), high); } @Test - void testGetDateRangeParamWithDateTimeType() throws ParseException { + void getDateRangeParamWithDateTimeType() throws ParseException { DateTime low = new DateTime(OffsetDateTime.parse("2023-01-01T12:01:56-07:00")); DateTime high = new DateTime(OffsetDateTime.parse("2023-02-06T12:08:56-07:00")); Interval interval = new Interval(low, true, high, true); @@ -453,7 +456,7 @@ void testGetDateRangeParamWithDateTimeType() throws ParseException { this.generator.getDateRangeParam("Condition", "onset", "valueDateTime", "valueDateTime", interval); assertNotNull(rangeParam); - assertTrue(rangeParam.getValue().getLowerBound().getValue().equals(low.toJavaDate())); - assertTrue(rangeParam.getValue().getUpperBound().getValue().equals(high.toJavaDate())); + assertEquals(rangeParam.getValue().getLowerBound().getValue(), low.toJavaDate()); + assertEquals(rangeParam.getValue().getUpperBound().getValue(), high.toJavaDate()); } } diff --git a/Src/java/engine-fhir/src/test/java/org/opencds/cqf/cql/engine/fhir/retrieve/TestRestFhirRetrieveProvider.java b/Src/java/engine-fhir/src/test/java/org/opencds/cqf/cql/engine/fhir/retrieve/TestRestFhirRetrieveProvider.java index f1d8c9f4c..1b2f60672 100644 --- a/Src/java/engine-fhir/src/test/java/org/opencds/cqf/cql/engine/fhir/retrieve/TestRestFhirRetrieveProvider.java +++ b/Src/java/engine-fhir/src/test/java/org/opencds/cqf/cql/engine/fhir/retrieve/TestRestFhirRetrieveProvider.java @@ -3,8 +3,8 @@ import static ca.uhn.fhir.util.UrlUtil.escapeUrlParam; import static com.github.tomakehurst.wiremock.client.WireMock.get; import static com.github.tomakehurst.wiremock.client.WireMock.urlMatching; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNull; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNull; import ca.uhn.fhir.context.FhirVersionEnum; import ca.uhn.fhir.rest.client.api.IGenericClient; @@ -13,6 +13,9 @@ import java.util.Collections; import java.util.List; import org.hl7.fhir.r4.model.Patient; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.opencds.cqf.cql.engine.fhir.R4FhirTest; import org.opencds.cqf.cql.engine.fhir.exception.FhirVersionMisMatchException; import org.opencds.cqf.cql.engine.fhir.model.*; @@ -21,11 +24,8 @@ import org.opencds.cqf.cql.engine.runtime.Code; import org.opencds.cqf.cql.engine.runtime.DateTime; import org.opencds.cqf.cql.engine.runtime.Interval; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; -public class TestRestFhirRetrieveProvider extends R4FhirTest { +class TestRestFhirRetrieveProvider extends R4FhirTest { static SearchParameterResolver RESOLVER; static IGenericClient CLIENT; @@ -33,14 +33,14 @@ public class TestRestFhirRetrieveProvider extends R4FhirTest { RestFhirRetrieveProvider provider; FhirModelResolver modelResolver; - @BeforeClass - public void setUpBeforeClass() { + @BeforeAll + static void setUpBeforeAll() { CLIENT = newClient(); RESOLVER = new SearchParameterResolver(CLIENT.getFhirContext()); } - @BeforeMethod - public void setUp() { + @BeforeEach + void setUp() { modelResolver = getModelResolver(CLIENT.getFhirContext().getVersion().getVersion()); this.provider = new RestFhirRetrieveProvider(RESOLVER, modelResolver, CLIENT); } @@ -55,7 +55,7 @@ public void setUp() { } @Test - public void noUserSpecifiedPageSizeUsesDefault() throws FhirVersionMisMatchException { + void noUserSpecifiedPageSizeUsesDefault() throws FhirVersionMisMatchException { BaseFhirQueryGenerator fhirQueryGenerator = FhirQueryGeneratorFactory.create( modelResolver, provider.searchParameterResolver, provider.getTerminologyProvider()); @@ -64,7 +64,7 @@ public void noUserSpecifiedPageSizeUsesDefault() throws FhirVersionMisMatchExcep } @Test - public void userSpecifiedPageSizeIsUsed() throws FhirVersionMisMatchException { + void userSpecifiedPageSizeIsUsed() throws FhirVersionMisMatchException { Integer expected = 100; provider.setPageSize(expected); BaseFhirQueryGenerator fhirQueryGenerator = FhirQueryGeneratorFactory.create( @@ -81,8 +81,8 @@ public void userSpecifiedPageSizeIsUsed() throws FhirVersionMisMatchException { } @Test - public void userSpecifiedPageSizeIsUsedWhenCodeBasedQuery() { - Code code = new Code().withSystem("http://mysystem.com").withCode("mycode"); + void userSpecifiedPageSizeIsUsedWhenCodeBasedQuery() { + Code code = new Code().withSystem("http://mysystem.com").withCode("myCode"); List codes = Collections.singletonList(code); mockFhirSearch("/Condition?code=" + escapeUrlParam(code.getSystem() + "|" + code.getCode()) + "&subject=" @@ -93,7 +93,7 @@ public void userSpecifiedPageSizeIsUsedWhenCodeBasedQuery() { } @Test - public void userSpecifiedPageSizeIsUsedWhenValueSetQuery() { + void userSpecifiedPageSizeIsUsedWhenValueSetQuery() { String valueSetUrl = "http://myterm.com/fhir/ValueSet/MyValueSet"; @@ -117,7 +117,7 @@ public void userSpecifiedPageSizeIsUsedWhenValueSetQuery() { } @Test - public void userSpecifiedPageSizeIsUsedWhenDateQuery() { + void userSpecifiedPageSizeIsUsedWhenDateQuery() { /* * As best as I can tell, the date range optimized queries are * broken right now. See https://github.com/DBCG/cql_engine/issues/467. @@ -145,7 +145,7 @@ public void userSpecifiedPageSizeIsUsedWhenDateQuery() { } @Test - public void userSpecifiedPageSizeNotUsedWhenIDQuery() { + void userSpecifiedPageSizeNotUsedWhenIDQuery() { mockFhirRead("/Patient/123", new Patient()); provider.setPageSize(500); @@ -165,8 +165,8 @@ public void userSpecifiedPageSizeNotUsedWhenIDQuery() { } @Test - public void noUserSpecifiedPageSizeSpecifiedNoCountInURL() { - Code code = new Code().withSystem("http://mysystem.com").withCode("mycode"); + void noUserSpecifiedPageSizeSpecifiedNoCountInURL() { + Code code = new Code().withSystem("http://mysystem.com").withCode("myCode"); List codes = Collections.singletonList(code); mockFhirSearch("/Condition?code=" + escapeUrlParam(code.getSystem() + "|" + code.getCode()) + "&subject=" diff --git a/Src/java/engine-fhir/src/test/java/org/opencds/cqf/cql/engine/fhir/searchparam/TestSearchParameterResolver.java b/Src/java/engine-fhir/src/test/java/org/opencds/cqf/cql/engine/fhir/searchparam/TestSearchParameterResolver.java index 7632d1084..273ffef43 100644 --- a/Src/java/engine-fhir/src/test/java/org/opencds/cqf/cql/engine/fhir/searchparam/TestSearchParameterResolver.java +++ b/Src/java/engine-fhir/src/test/java/org/opencds/cqf/cql/engine/fhir/searchparam/TestSearchParameterResolver.java @@ -1,8 +1,8 @@ package org.opencds.cqf.cql.engine.fhir.searchparam; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertNull; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; import ca.uhn.fhir.context.FhirContext; import ca.uhn.fhir.context.FhirVersionEnum; @@ -10,11 +10,11 @@ import ca.uhn.fhir.model.api.IQueryParameterType; import ca.uhn.fhir.rest.api.RestSearchParameterTypeEnum; import org.apache.commons.lang3.tuple.Pair; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Test; -public class TestSearchParameterResolver { +class TestSearchParameterResolver { @Test - public void testReturnsNullPathReturnsNull() { + void returnsNullPathReturnsNull() { SearchParameterResolver resolver = new SearchParameterResolver(FhirContext.forCached(FhirVersionEnum.DSTU3)); RuntimeSearchParam param = resolver.getSearchParameterDefinition("Patient", null); @@ -22,7 +22,7 @@ public void testReturnsNullPathReturnsNull() { } @Test - public void testNullDataTypeReturnsNull() { + void nullDataTypeReturnsNull() { SearchParameterResolver resolver = new SearchParameterResolver(FhirContext.forCached(FhirVersionEnum.DSTU3)); RuntimeSearchParam param = resolver.getSearchParameterDefinition(null, "code"); @@ -30,7 +30,7 @@ public void testNullDataTypeReturnsNull() { } @Test - void testDstu3SearchParams() { + void dstu3SearchParams() { SearchParameterResolver resolver = new SearchParameterResolver(FhirContext.forCached(FhirVersionEnum.DSTU3)); RuntimeSearchParam param = resolver.getSearchParameterDefinition("Patient", "id"); @@ -65,7 +65,7 @@ void testDstu3SearchParams() { } @Test - void testDstu3DateSearchParams() { + void dstu3DateSearchParams() { SearchParameterResolver resolver = new SearchParameterResolver(FhirContext.forCached(FhirVersionEnum.DSTU3)); RuntimeSearchParam param = resolver.getSearchParameterDefinition( @@ -75,7 +75,7 @@ void testDstu3DateSearchParams() { } @Test - void testR4SearchParams() { + void r4SearchParams() { SearchParameterResolver resolver = new SearchParameterResolver(FhirContext.forCached(FhirVersionEnum.R4)); RuntimeSearchParam param = resolver.getSearchParameterDefinition("Patient", "id"); @@ -118,7 +118,7 @@ void testR4SearchParams() { } @Test - void testR4DateSearchParams() { + void r4DateSearchParams() { SearchParameterResolver resolver = new SearchParameterResolver(FhirContext.forCached(FhirVersionEnum.R4)); RuntimeSearchParam param = @@ -144,7 +144,7 @@ void testR4DateSearchParams() { } @Test - void testR4ReferenceParameter() { + void r4ReferenceParameter() { FhirContext context = FhirContext.forCached(FhirVersionEnum.R4); SearchParameterResolver resolver = new SearchParameterResolver(context); Pair actual = @@ -154,7 +154,7 @@ void testR4ReferenceParameter() { } @Test - void testR4TokenParameter() { + void r4TokenParameter() { FhirContext context = FhirContext.forCached(FhirVersionEnum.R4); SearchParameterResolver resolver = new SearchParameterResolver(context); Pair actual = diff --git a/Src/java/engine-fhir/src/test/java/org/opencds/cqf/cql/engine/fhir/terminology/TestR4FhirTerminologyProvider.java b/Src/java/engine-fhir/src/test/java/org/opencds/cqf/cql/engine/fhir/terminology/TestR4FhirTerminologyProvider.java index 8fb4eeb51..898108efb 100644 --- a/Src/java/engine-fhir/src/test/java/org/opencds/cqf/cql/engine/fhir/terminology/TestR4FhirTerminologyProvider.java +++ b/Src/java/engine-fhir/src/test/java/org/opencds/cqf/cql/engine/fhir/terminology/TestR4FhirTerminologyProvider.java @@ -1,9 +1,6 @@ package org.opencds.cqf.cql.engine.fhir.terminology; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertFalse; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.*; import java.io.UnsupportedEncodingException; import java.net.URLEncoder; @@ -14,15 +11,15 @@ import org.hl7.fhir.r4.model.Parameters; import org.hl7.fhir.r4.model.StringType; import org.hl7.fhir.r4.model.ValueSet; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.opencds.cqf.cql.engine.exception.TerminologyProviderException; import org.opencds.cqf.cql.engine.fhir.R4FhirTest; import org.opencds.cqf.cql.engine.runtime.Code; import org.opencds.cqf.cql.engine.terminology.CodeSystemInfo; import org.opencds.cqf.cql.engine.terminology.ValueSetInfo; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; -public class TestR4FhirTerminologyProvider extends R4FhirTest { +class TestR4FhirTerminologyProvider extends R4FhirTest { private static final String TEST_DISPLAY = "Display"; private static final String TEST_CODE = "425178004"; @@ -30,13 +27,13 @@ public class TestR4FhirTerminologyProvider extends R4FhirTest { private static final String TEST_SYSTEM_VERSION = "2013-09"; R4FhirTerminologyProvider provider; - @BeforeMethod - public void initializeProvider() { + @BeforeEach + void initializeProvider() { provider = new R4FhirTerminologyProvider(newClient()); } @Test - public void resolveByUrlUsingUrlSucceeds() throws Exception { + void resolveByUrlUsingUrlSucceeds() throws Exception { ValueSetInfo info = new ValueSetInfo().withId("https://cts.nlm.nih.gov/fhir/ValueSet/1.2.3.4"); ValueSet response = new ValueSet(); @@ -51,7 +48,7 @@ public void resolveByUrlUsingUrlSucceeds() throws Exception { } @Test - public void resolveByUrlUsingIdentifierSucceeds() throws Exception { + void resolveByUrlUsingIdentifierSucceeds() throws Exception { ValueSetInfo info = new ValueSetInfo().withId("urn:oid:1.2.3.4"); ValueSet response = new ValueSet(); @@ -66,7 +63,7 @@ public void resolveByUrlUsingIdentifierSucceeds() throws Exception { } @Test - public void resolveByUrlUsingResourceIdSucceeds() throws Exception { + void resolveByUrlUsingResourceIdSucceeds() throws Exception { ValueSetInfo info = new ValueSetInfo().withId("1.2.3.4"); ValueSet response = new ValueSet(); @@ -79,35 +76,35 @@ public void resolveByUrlUsingResourceIdSucceeds() throws Exception { assertEquals(id, response.getId()); } - @Test(expectedExceptions = IllegalArgumentException.class) - public void resolveByUrlNoMatchesThrowsException() throws Exception { + @Test + void resolveByUrlNoMatchesThrowsException() throws Exception { ValueSetInfo info = new ValueSetInfo().withId("urn:oid:1.2.3.4"); mockResolveSearchPath(info, null); - provider.resolveValueSetId(info); + assertThrows(IllegalArgumentException.class, () -> provider.resolveValueSetId(info)); } - @Test(expectedExceptions = TerminologyProviderException.class) - public void expandByUrlNoMatchesThrowsException() throws Exception { + @Test + void expandByUrlNoMatchesThrowsException() throws Exception { ValueSetInfo info = new ValueSetInfo().withId("urn:oid:1.2.3.4"); mockResolveSearchPath(info, null); - provider.expand(info); + assertThrows(TerminologyProviderException.class, () -> provider.expand(info)); } - @Test(expectedExceptions = UnsupportedOperationException.class) - public void nonNullVersionUnsupported() { + @Test + void nonNullVersionUnsupported() { ValueSetInfo info = new ValueSetInfo(); info.setId("urn:oid:Test"); info.setVersion("1.0.0."); - provider.resolveValueSetId(info); + assertThrows(UnsupportedOperationException.class, () -> provider.resolveValueSetId(info)); } - @Test(expectedExceptions = UnsupportedOperationException.class) - public void nonNullCodesystemsUnsupported() { + @Test + void nonNullCodesystemsUnsupported() { CodeSystemInfo codeSystem = new CodeSystemInfo(); codeSystem.setId("SNOMED-CT"); codeSystem.setVersion("2013-09"); @@ -116,11 +113,11 @@ public void nonNullCodesystemsUnsupported() { info.setId("urn:oid:Test"); info.getCodeSystems().add(codeSystem); - provider.resolveValueSetId(info); + assertThrows(UnsupportedOperationException.class, () -> provider.resolveValueSetId(info)); } @Test - public void urnOidPrefixIsStripped() throws Exception { + void urnOidPrefixIsStripped() throws Exception { ValueSetInfo info = new ValueSetInfo(); info.setId("urn:oid:Test"); @@ -131,11 +128,11 @@ public void urnOidPrefixIsStripped() throws Exception { mockResolveSearchPath(info, valueSet); String id = provider.resolveValueSetId(info); - assertEquals(id, "Test"); + assertEquals("Test", id); } - @Test(expectedExceptions = IllegalArgumentException.class) - public void moreThanOneURLSearchResultIsError() throws Exception { + @Test + void moreThanOneURLSearchResultIsError() throws Exception { ValueSetInfo info = new ValueSetInfo(); info.setId("http://localhost/fhir/ValueSet/1.2.3.4"); @@ -147,23 +144,23 @@ public void moreThanOneURLSearchResultIsError() throws Exception { secondSet.setId("1"); secondSet.setUrl(info.getId()); - mockFhirSearch("/ValueSet?url=" + urlencode(info.getId()), firstSet, secondSet); + mockFhirSearch("/ValueSet?url=" + urlEncode(info.getId()), firstSet, secondSet); - provider.resolveValueSetId(info); + assertThrows(IllegalArgumentException.class, () -> provider.resolveValueSetId(info)); } - @Test(expectedExceptions = IllegalArgumentException.class) - public void zeroURLSearchResultIsError() throws Exception { + @Test + void zeroURLSearchResultIsError() throws Exception { ValueSetInfo info = new ValueSetInfo(); info.setId("http://localhost/fhir/ValueSet/1.2.3.4"); mockResolveSearchPath(info, null); - provider.resolveValueSetId(info); + assertThrows(IllegalArgumentException.class, () -> provider.resolveValueSetId(info)); } @Test - public void expandOperationReturnsCorrectCodesMoreThanZero() throws Exception { + void expandOperationReturnsCorrectCodesMoreThanZero() throws Exception { ValueSetInfo info = new ValueSetInfo(); info.setId("urn:oid:Test"); @@ -181,13 +178,13 @@ public void expandOperationReturnsCorrectCodesMoreThanZero() throws Exception { Iterable codes = provider.expand(info); List list = StreamSupport.stream(codes.spliterator(), false).collect(Collectors.toList()); - assertEquals(list.size(), 1); - assertEquals(list.get(0).getSystem(), TEST_SYSTEM); - assertEquals(list.get(0).getCode(), TEST_CODE); + assertEquals(1, list.size()); + assertEquals(TEST_SYSTEM, list.get(0).getSystem()); + assertEquals(TEST_CODE, list.get(0).getCode()); } @Test - public void inOperationReturnsTrueWhenFhirReturnsTrue() throws Exception { + void inOperationReturnsTrueWhenFhirReturnsTrue() throws Exception { ValueSetInfo info = new ValueSetInfo(); info.setId("urn:oid:Test"); @@ -206,8 +203,8 @@ public void inOperationReturnsTrueWhenFhirReturnsTrue() throws Exception { parameters.getParameterFirstRep().setName("result").setValue(new BooleanType(true)); mockFhirRead( - "/ValueSet/Test/$validate-code?code=" + urlencode(code.getCode()) + "&system=" - + urlencode(code.getSystem()), + "/ValueSet/Test/$validate-code?code=" + urlEncode(code.getCode()) + "&system=" + + urlEncode(code.getSystem()), parameters); boolean result = provider.in(code, info); @@ -215,7 +212,7 @@ public void inOperationReturnsTrueWhenFhirReturnsTrue() throws Exception { } @Test - public void inOperationReturnsFalseWhenFhirReturnsFalse() throws Exception { + void inOperationReturnsFalseWhenFhirReturnsFalse() throws Exception { ValueSetInfo info = new ValueSetInfo(); info.setId("urn:oid:Test"); @@ -233,8 +230,8 @@ public void inOperationReturnsFalseWhenFhirReturnsFalse() throws Exception { parameters.getParameterFirstRep().setName("result").setValue(new BooleanType(false)); mockFhirRead( - "/ValueSet/Test/$validate-code?code=" + urlencode(code.getCode()) + "&system=" - + urlencode(code.getSystem()), + "/ValueSet/Test/$validate-code?code=" + urlEncode(code.getCode()) + "&system=" + + urlEncode(code.getSystem()), parameters); boolean result = provider.in(code, info); @@ -242,7 +239,7 @@ public void inOperationReturnsFalseWhenFhirReturnsFalse() throws Exception { } @Test - public void inOperationHandlesNullSystem() throws Exception { + void inOperationHandlesNullSystem() throws Exception { ValueSetInfo info = new ValueSetInfo(); info.setId("urn:oid:Test"); @@ -258,14 +255,14 @@ public void inOperationHandlesNullSystem() throws Exception { Parameters parameters = new Parameters(); parameters.getParameterFirstRep().setName("result").setValue(new BooleanType(true)); - mockFhirRead("/ValueSet/Test/$validate-code?code=" + urlencode(code.getCode()), parameters); + mockFhirRead("/ValueSet/Test/$validate-code?code=" + urlEncode(code.getCode()), parameters); boolean result = provider.in(code, info); assertTrue(result); } @Test - public void lookupOperationSuccess() throws Exception { + void lookupOperationSuccess() throws Exception { CodeSystemInfo info = new CodeSystemInfo(); info.setId(TEST_SYSTEM); info.setVersion(TEST_SYSTEM_VERSION); @@ -289,21 +286,21 @@ public void lookupOperationSuccess() throws Exception { assertEquals(result.getDisplay(), code.getDisplay()); } - protected String urlencode(String value) throws UnsupportedEncodingException { + protected String urlEncode(String value) throws UnsupportedEncodingException { return URLEncoder.encode(value, "utf-8"); } protected void mockResolveSearchPath(ValueSetInfo info, ValueSet valueSet) throws UnsupportedEncodingException { if (valueSet != null && valueSet.getUrl() != null) { - mockFhirSearch("/ValueSet?url=" + urlencode(info.getId()), valueSet); + mockFhirSearch("/ValueSet?url=" + urlEncode(info.getId()), valueSet); } else { - mockFhirSearch("/ValueSet?url=" + urlencode(info.getId())); + mockFhirSearch("/ValueSet?url=" + urlEncode(info.getId())); } if (valueSet != null && valueSet.getIdentifier().size() > 0) { - mockFhirSearch("/ValueSet?identifier=" + urlencode(info.getId()), valueSet); + mockFhirSearch("/ValueSet?identifier=" + urlEncode(info.getId()), valueSet); } else { - mockFhirSearch("/ValueSet?identifier=" + urlencode(info.getId())); + mockFhirSearch("/ValueSet?identifier=" + urlEncode(info.getId())); } if (valueSet != null) { diff --git a/Src/java/engine-fhir/src/test/resources/org/hl7/fhirpath/stu3/schema/fhir-single.xsd b/Src/java/engine-fhir/src/test/resources/org/hl7/fhirpath/stu3/schema/fhir-single.xsd index 4dfe30b51..62d63c087 100644 --- a/Src/java/engine-fhir/src/test/resources/org/hl7/fhirpath/stu3/schema/fhir-single.xsd +++ b/Src/java/engine-fhir/src/test/resources/org/hl7/fhirpath/stu3/schema/fhir-single.xsd @@ -3432,7 +3432,7 @@ - Indicates the period of time over which the account is allowed to have transactions posted to it. + Indicates the period of time over which the account is allowed to have transactions posted to it. This period may be different to the coveragePeriod which is the duration of time that services may occur. @@ -3448,8 +3448,8 @@ This period may be different to the coveragePeriod which is the duration of time - The party(s) that are responsible for payment (or part of) of charges applied to this account (including self-pay). - + The party(s) that are responsible for payment (or part of) of charges applied to this account (including self-pay). + A coverage may only be resposible for specific types of charges, and the sequence of the coverages in the account could be important when processing billing. @@ -5098,8 +5098,8 @@ A coverage may only be resposible for specific types of charges, and the sequenc - The Absolute URL for the resource. The fullUrl SHALL not disagree with the id in the resource. The fullUrl is a version independent reference to the resource. The fullUrl element SHALL have a value except that: -* fullUrl can be empty on a POST (although it does not need to when specifying a temporary id for reference in the bundle) + The Absolute URL for the resource. The fullUrl SHALL not disagree with the id in the resource. The fullUrl is a version independent reference to the resource. The fullUrl element SHALL have a value except that: +* fullUrl can be empty on a POST (although it does not need to when specifying a temporary id for reference in the bundle) * Results from operations might involve resources that are not identified. @@ -18787,7 +18787,9 @@ A coverage may only be resposible for specific types of charges, and the sequenc - Free text dosage can be used for cases where the dosage administered is too complex to code. When coded dosage is present, the free text dosage may still be present for display to humans. The dosage instructions should reflect the dosage of the medication that was administered. + Free text dosage can be used for cases where the dosage administered is too complex to code. When coded dosage is present, the free text dosage may still be present for display to humans. + +The dosage instructions should reflect the dosage of the medication that was administered. @@ -19274,12 +19276,16 @@ A coverage may only be resposible for specific types of charges, and the sequenc - A record of a medication that is being consumed by a patient. A MedicationStatement may indicate that the patient may be taking the medication now, or has taken the medication in the past or will be taking the medication in the future. The source of this information can be the patient, significant other (such as a family member or spouse), or a clinician. A common scenario where this information is captured is during the history taking process during a patient visit or stay. The medication information may come from e.g. the patient's memory, from a prescription bottle, or from a list of medications the patient, clinician or other party maintains The primary difference between a medication statement and a medication administration is that the medication administration has complete administration information and is based on actual administration information from the person who administered the medication. A medication statement is often, if not always, less specific. There is no required date/time when the medication was administered, in fact we only know that a source has reported the patient is taking this medication, where details such as time, quantity, or rate or even medication product may be incomplete or missing or less precise. As stated earlier, the medication statement information may come from the patient's memory, from a prescription bottle or from a list of medications the patient, clinician or other party maintains. Medication administration is more formal and is not missing detailed information. + A record of a medication that is being consumed by a patient. A MedicationStatement may indicate that the patient may be taking the medication now, or has taken the medication in the past or will be taking the medication in the future. The source of this information can be the patient, significant other (such as a family member or spouse), or a clinician. A common scenario where this information is captured is during the history taking process during a patient visit or stay. The medication information may come from e.g. the patient's memory, from a prescription bottle, or from a list of medications the patient, clinician or other party maintains + +The primary difference between a medication statement and a medication administration is that the medication administration has complete administration information and is based on actual administration information from the person who administered the medication. A medication statement is often, if not always, less specific. There is no required date/time when the medication was administered, in fact we only know that a source has reported the patient is taking this medication, where details such as time, quantity, or rate or even medication product may be incomplete or missing or less precise. As stated earlier, the medication statement information may come from the patient's memory, from a prescription bottle or from a list of medications the patient, clinician or other party maintains. Medication administration is more formal and is not missing detailed information. - A record of a medication that is being consumed by a patient. A MedicationStatement may indicate that the patient may be taking the medication now, or has taken the medication in the past or will be taking the medication in the future. The source of this information can be the patient, significant other (such as a family member or spouse), or a clinician. A common scenario where this information is captured is during the history taking process during a patient visit or stay. The medication information may come from e.g. the patient's memory, from a prescription bottle, or from a list of medications the patient, clinician or other party maintains The primary difference between a medication statement and a medication administration is that the medication administration has complete administration information and is based on actual administration information from the person who administered the medication. A medication statement is often, if not always, less specific. There is no required date/time when the medication was administered, in fact we only know that a source has reported the patient is taking this medication, where details such as time, quantity, or rate or even medication product may be incomplete or missing or less precise. As stated earlier, the medication statement information may come from the patient's memory, from a prescription bottle or from a list of medications the patient, clinician or other party maintains. Medication administration is more formal and is not missing detailed information. + A record of a medication that is being consumed by a patient. A MedicationStatement may indicate that the patient may be taking the medication now, or has taken the medication in the past or will be taking the medication in the future. The source of this information can be the patient, significant other (such as a family member or spouse), or a clinician. A common scenario where this information is captured is during the history taking process during a patient visit or stay. The medication information may come from e.g. the patient's memory, from a prescription bottle, or from a list of medications the patient, clinician or other party maintains + +The primary difference between a medication statement and a medication administration is that the medication administration has complete administration information and is based on actual administration information from the person who administered the medication. A medication statement is often, if not always, less specific. There is no required date/time when the medication was administered, in fact we only know that a source has reported the patient is taking this medication, where details such as time, quantity, or rate or even medication product may be incomplete or missing or less precise. As stated earlier, the medication statement information may come from the patient's memory, from a prescription bottle or from a list of medications the patient, clinician or other party maintains. Medication administration is more formal and is not missing detailed information. If the element is present, it must have either a @value, an @id, or extensions @@ -22711,7 +22717,8 @@ A coverage may only be resposible for specific types of charges, and the sequenc - Address(es) of the practitioner that are not role specific (typically home address). Work addresses are not typically entered in this property as they are usually role dependent. + Address(es) of the practitioner that are not role specific (typically home address). +Work addresses are not typically entered in this property as they are usually role dependent. @@ -23899,15 +23906,15 @@ A coverage may only be resposible for specific types of charges, and the sequenc - A reference to an [[[ElementDefinition]]] that provides the details for the item. If a definition is provided, then the following element values can be inferred from the definition: - -* concept (ElementDefinition.code) -* type (ElementDefinition.type) -* required (ElementDefinition.min) -* repeats (ElementDefinition.max) -* maxLength (ElementDefinition.maxLength) -* options (ElementDefinition.binding) - + A reference to an [[[ElementDefinition]]] that provides the details for the item. If a definition is provided, then the following element values can be inferred from the definition: + +* concept (ElementDefinition.code) +* type (ElementDefinition.type) +* required (ElementDefinition.min) +* repeats (ElementDefinition.max) +* maxLength (ElementDefinition.maxLength) +* options (ElementDefinition.binding) + Any information provided in these elements overrides the information from the definition. @@ -29464,7 +29471,7 @@ Any information provided in these elements overrides the information from the de The ID of a fixture. Asserts that the response contains at a minimum the fixture specified by minimumId. - + Assertions. Whether or not the test execution performs validation on the bundle navigation links. @@ -29519,7 +29526,7 @@ Any information provided in these elements overrides the information from the de The ID of the Profile to validate against. - + Assertions. The value to compare to. diff --git a/Src/java/engine/src/main/java/org/opencds/cqf/cql/engine/data/SystemDataProvider.java b/Src/java/engine/src/main/java/org/opencds/cqf/cql/engine/data/SystemDataProvider.java index 69dbe9239..6cd2ff9d1 100644 --- a/Src/java/engine/src/main/java/org/opencds/cqf/cql/engine/data/SystemDataProvider.java +++ b/Src/java/engine/src/main/java/org/opencds/cqf/cql/engine/data/SystemDataProvider.java @@ -33,13 +33,11 @@ public Iterable retrieve( throw new IllegalArgumentException("SystemDataProvider does not support retrieval."); } - @SuppressWarnings("deprecation") @Override public String getPackageName() { return "org.opencds.cqf.cql.engine.runtime"; } - @SuppressWarnings("deprecation") @Override public void setPackageName(String packageName) {} diff --git a/Src/java/engine/src/main/java/org/opencds/cqf/cql/engine/elm/executing/RetrieveEvaluator.java b/Src/java/engine/src/main/java/org/opencds/cqf/cql/engine/elm/executing/RetrieveEvaluator.java index d08be4852..5bd429513 100644 --- a/Src/java/engine/src/main/java/org/opencds/cqf/cql/engine/elm/executing/RetrieveEvaluator.java +++ b/Src/java/engine/src/main/java/org/opencds/cqf/cql/engine/elm/executing/RetrieveEvaluator.java @@ -12,11 +12,8 @@ import org.opencds.cqf.cql.engine.runtime.Concept; import org.opencds.cqf.cql.engine.runtime.Interval; import org.opencds.cqf.cql.engine.runtime.ValueSet; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; public class RetrieveEvaluator { - private static final Logger logger = LoggerFactory.getLogger(RetrieveEvaluator.class); @SuppressWarnings("unchecked") public static Object internalEvaluate(Retrieve elm, State state, ElmLibraryVisitor visitor) { @@ -27,7 +24,7 @@ public static Object internalEvaluate(Retrieve elm, State state, ElmLibraryVisit if (context != null) { /* - This whole block is a bit a hack in the sense that we need to the context (ex Practitioner) identifies itself in a non-domain specific way3 + This whole block is a bit a hack in the sense that the need to switch to the context (e.g. Practitioner) identifies itself in a non-domain specific way */ final Object contextValue = visitor.visitExpression(context, state); final String name = contextValue.getClass().getPackage().getName(); @@ -107,25 +104,4 @@ This whole block is a bit a hack in the sense that we need to the context (ex Pr return result; } - - // TODO: LD: Consider adding this to some sort of Library class - /** - * Do an instanceof on the class in question and then cast the parameter if it passes the test - *

- * Note this method is not recommended for use with generic types. - * - * @param superType The variable typed as the supertype of the type being tested to cast - * @param clazz The {@link Class} to which we are instance of checking for and attempting to cast - * @return The variable casted to the new subclass after a successful instanceof check. - * @param The supertype from which we aim to cast - * @param The subtype to which we aim to cast. - * @throws IllegalArgumentException if the first parameter fails the instanceof check - */ - private static S instanceOfCast(T superType, Class clazz) { - if (clazz.isInstance(superType)) { - return clazz.cast(superType); - } - - throw new IllegalArgumentException(String.format("Subtype of %s is not as expected", superType)); - } } diff --git a/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/data/CompositeDataProviderTest.java b/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/data/CompositeDataProviderTest.java index 12f71d556..3112a7a9f 100644 --- a/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/data/CompositeDataProviderTest.java +++ b/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/data/CompositeDataProviderTest.java @@ -1,18 +1,18 @@ package org.opencds.cqf.cql.engine.data; +import static org.junit.jupiter.api.Assertions.assertEquals; import static org.mockito.Mockito.*; -import static org.testng.Assert.*; import java.util.Date; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.mockito.Mock; import org.mockito.MockitoAnnotations; import org.opencds.cqf.cql.engine.model.ModelResolver; import org.opencds.cqf.cql.engine.retrieve.RetrieveProvider; -import org.testng.annotations.AfterMethod; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; -public class CompositeDataProviderTest { +class CompositeDataProviderTest { @Mock private ModelResolver mockModelResolver; @@ -21,18 +21,18 @@ public class CompositeDataProviderTest { private AutoCloseable mocks; - @BeforeMethod + @BeforeEach void before() { mocks = MockitoAnnotations.openMocks(this); } - @AfterMethod + @AfterEach void after() throws Exception { mocks.close(); } @Test - void testResolveIdString() { + void resolveIdString() { final String object = "object"; final String id = "text"; @@ -46,7 +46,7 @@ void testResolveIdString() { } @Test - void testResolveIdIntLong() { + void resolveIdIntLong() { final long object = 1L; final String id = "oneL"; @@ -60,7 +60,7 @@ void testResolveIdIntLong() { } @Test - void testResolveIdDate() { + void resolveIdDate() { final Date object = new Date(); final String id = "now"; diff --git a/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/data/SystemDataProviderTest.java b/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/data/SystemDataProviderTest.java index 3bb3690e3..e0759cc01 100644 --- a/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/data/SystemDataProviderTest.java +++ b/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/data/SystemDataProviderTest.java @@ -1,15 +1,15 @@ package org.opencds.cqf.cql.engine.data; -import static org.testng.Assert.assertNull; +import static org.junit.jupiter.api.Assertions.assertNull; import java.time.Month; +import org.junit.jupiter.api.Test; import org.opencds.cqf.cql.engine.runtime.Date; -import org.testng.annotations.Test; -public class SystemDataProviderTest { +class SystemDataProviderTest { @Test - public void resolveMissingPropertyReturnsNull() { + void resolveMissingPropertyReturnsNull() { SystemDataProvider provider = new SystemDataProvider(); Date date = new Date(2019, Month.JANUARY.getValue(), 1); @@ -19,7 +19,7 @@ public void resolveMissingPropertyReturnsNull() { } @Test - public void resolveIdAlwaysReturnsNull() { + void resolveIdAlwaysReturnsNull() { final SystemDataProvider provider = new SystemDataProvider(); assertNull(provider.resolveId("someObject")); diff --git a/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/execution/CqlAggregateFunctionsTest.java b/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/execution/CqlAggregateFunctionsTest.java index da9dfdb3a..a80380903 100644 --- a/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/execution/CqlAggregateFunctionsTest.java +++ b/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/execution/CqlAggregateFunctionsTest.java @@ -2,9 +2,11 @@ import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.is; +import static org.junit.jupiter.api.Assertions.*; import java.math.BigDecimal; import java.util.Arrays; +import org.junit.jupiter.api.Test; import org.opencds.cqf.cql.engine.elm.executing.AnyTrueEvaluator; import org.opencds.cqf.cql.engine.elm.executing.AvgEvaluator; import org.opencds.cqf.cql.engine.elm.executing.EquivalentEvaluator; @@ -12,13 +14,11 @@ import org.opencds.cqf.cql.engine.runtime.DateTime; import org.opencds.cqf.cql.engine.runtime.Quantity; import org.opencds.cqf.cql.engine.runtime.Time; -import org.testng.Assert; -import org.testng.annotations.Test; -public class CqlAggregateFunctionsTest extends CqlTestBase { +class CqlAggregateFunctionsTest extends CqlTestBase { @Test - public void test_all_aggregate_function_tests() { + void all_aggregate_function_tests() { final BigDecimal bigDecimalZoneOffset = getBigDecimalZoneOffset(); var results = engine.evaluate(toElmIdentifier("CqlAggregateFunctionsTest")); @@ -72,14 +72,14 @@ public void test_all_aggregate_function_tests() { try { value = AnyTrueEvaluator.anyTrue(Arrays.asList("this", "is", "error")); - Assert.fail(); + fail(); } catch (InvalidOperatorArgument e) { // pass } try { value = AvgEvaluator.avg(Arrays.asList("this", "is", "error"), engine.getState()); - Assert.fail(); + fail(); } catch (InvalidOperatorArgument e) { // pass } @@ -112,10 +112,10 @@ public void test_all_aggregate_function_tests() { assertThat(value, is("zebra")); value = results.forExpression("MaxTestDateTime").value(); - Assert.assertTrue(EquivalentEvaluator.equivalent(value, new DateTime(bigDecimalZoneOffset, 2012, 10, 6))); + assertTrue(EquivalentEvaluator.equivalent(value, new DateTime(bigDecimalZoneOffset, 2012, 10, 6))); value = results.forExpression("MaxTestTime").value(); - Assert.assertTrue(EquivalentEvaluator.equivalent(value, new Time(20, 59, 59, 999))); + assertTrue(EquivalentEvaluator.equivalent(value, new Time(20, 59, 59, 999))); value = results.forExpression("MedianTestDecimal").value(); assertThat(value, is(new BigDecimal("3.5"))); @@ -130,32 +130,36 @@ public void test_all_aggregate_function_tests() { assertThat(value, is("bye")); value = results.forExpression("MinTestDateTime").value(); - Assert.assertTrue(EquivalentEvaluator.equivalent(value, new DateTime(bigDecimalZoneOffset, 2012, 9, 5))); + assertTrue(EquivalentEvaluator.equivalent(value, new DateTime(bigDecimalZoneOffset, 2012, 9, 5))); value = results.forExpression("MinTestTime").value(); - Assert.assertTrue(EquivalentEvaluator.equivalent(value, new Time(5, 59, 59, 999))); + assertTrue(EquivalentEvaluator.equivalent(value, new Time(5, 59, 59, 999))); value = results.forExpression("ModeTestInteger").value(); assertThat(value, is(9)); value = results.forExpression("ModeTestDateTime2").value(); - Assert.assertTrue(EquivalentEvaluator.equivalent(value, new DateTime(bigDecimalZoneOffset, 2012, 10, 5))); + assertTrue(EquivalentEvaluator.equivalent(value, new DateTime(bigDecimalZoneOffset, 2012, 10, 5))); value = results.forExpression("ModeTestTime").value(); - Assert.assertTrue(EquivalentEvaluator.equivalent(value, new Time(5, 59, 59, 999))); + assertTrue(EquivalentEvaluator.equivalent(value, new Time(5, 59, 59, 999))); value = results.forExpression("ModeTestDateTime").value(); - Assert.assertTrue(((DateTime) value).equal(new DateTime(bigDecimalZoneOffset, 2012, 9, 5))); + assertTrue(((DateTime) value).equal(new DateTime(bigDecimalZoneOffset, 2012, 9, 5))); value = results.forExpression("PopStdDevTest1").value(); - Assert.assertTrue(((BigDecimal) value).compareTo(new BigDecimal("1.41421356")) - == 0); // 23730951454746218587388284504413604736328125 + assertEquals( + 0, + ((BigDecimal) value) + .compareTo(new BigDecimal("1.41421356"))); // 23730951454746218587388284504413604736328125 value = results.forExpression("PopVarianceTest1").value(); - Assert.assertTrue(((BigDecimal) value).compareTo(new BigDecimal("2.0")) == 0); + assertEquals(0, ((BigDecimal) value).compareTo(new BigDecimal("2.0"))); value = results.forExpression("StdDevTest1").value(); - Assert.assertTrue(((BigDecimal) value).compareTo(new BigDecimal("1.58113883")) - == 0); // 00841897613935316257993690669536590576171875 + assertEquals( + 0, + ((BigDecimal) value) + .compareTo(new BigDecimal("1.58113883"))); // 00841897613935316257993690669536590576171875 value = results.forExpression("SumTest1").value(); assertThat(value, is(new BigDecimal("20.0"))); @@ -164,13 +168,13 @@ public void test_all_aggregate_function_tests() { assertThat(value, is(20L)); value = results.forExpression("SumTestQuantity").value(); - Assert.assertTrue(((Quantity) value) + assertTrue(((Quantity) value) .equal(new Quantity().withValue(new BigDecimal("15.0")).withUnit("ml"))); value = results.forExpression("SumTestNull").value(); assertThat(value, is(1)); value = results.forExpression("VarianceTest1").value(); - Assert.assertTrue(((BigDecimal) value).compareTo(new BigDecimal("2.5")) == 0); + assertEquals(0, ((BigDecimal) value).compareTo(new BigDecimal("2.5"))); } } diff --git a/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/execution/CqlAggregateQueryTest.java b/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/execution/CqlAggregateQueryTest.java index 24dca5e1c..f1cc2b6f9 100644 --- a/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/execution/CqlAggregateQueryTest.java +++ b/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/execution/CqlAggregateQueryTest.java @@ -3,11 +3,11 @@ import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.is; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Test; -public class CqlAggregateQueryTest extends CqlTestBase { +class CqlAggregateQueryTest extends CqlTestBase { @Test - void test_all_aggregate_clause_tests() { + void all_aggregate_clause_tests() { var results = engine.evaluate(toElmIdentifier("CqlAggregateQueryTest")); var value = results.forExpression("AggregateSumWithStart").value(); assertThat(value, is(16)); diff --git a/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/execution/CqlArithmeticFunctionsTest.java b/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/execution/CqlArithmeticFunctionsTest.java index e4b27bf88..55ce4310e 100644 --- a/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/execution/CqlArithmeticFunctionsTest.java +++ b/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/execution/CqlArithmeticFunctionsTest.java @@ -2,23 +2,23 @@ import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.*; +import static org.junit.jupiter.api.Assertions.*; import java.math.BigDecimal; import org.hl7.elm.r1.VersionedIdentifier; +import org.junit.jupiter.api.Test; import org.opencds.cqf.cql.engine.elm.executing.*; import org.opencds.cqf.cql.engine.exception.CqlException; import org.opencds.cqf.cql.engine.exception.UndefinedResult; import org.opencds.cqf.cql.engine.runtime.*; -import org.testng.Assert; -import org.testng.annotations.Test; @SuppressWarnings("removal") -public class CqlArithmeticFunctionsTest extends CqlTestBase { +class CqlArithmeticFunctionsTest extends CqlTestBase { private static final VersionedIdentifier library = new VersionedIdentifier().withId("CqlArithmeticFunctionsTest"); @Test - public void testAbs() { + void abs() { var value = engine.expression(library, "AbsNull").value(); assertThat(value, is(nullValue())); @@ -39,15 +39,16 @@ public void testAbs() { assertThat((BigDecimal) value, comparesEqualTo(BigDecimal.valueOf(0.0))); value = engine.expression(library, "Abs1cm").value(); - Assert.assertTrue(((Quantity) value) + assertEquals( + 0, + ((Quantity) value) .compareTo( - new Quantity().withValue(new BigDecimal("1.0")).withUnit("cm")) - == 0); + new Quantity().withValue(new BigDecimal("1.0")).withUnit("cm"))); // error testing try { value = AbsEvaluator.abs("This is an error"); - Assert.fail(); + fail(); } catch (CqlException e) { // pass } @@ -57,7 +58,7 @@ public void testAbs() { * {@link org.opencds.cqf.cql.engine.elm.execution.AddEvaluator#evaluate(Context)} */ @Test - public void testAdd() { + void add() { var value = engine.expression(library, "AddNull").value(); assertThat(value, is(nullValue())); @@ -72,8 +73,8 @@ public void testAdd() { assertThat(value, is(new BigDecimal("2.0"))); value = engine.expression(library, "Add1Q1Q").value(); - Assert.assertEquals(((Quantity) value).getValue(), new BigDecimal("2")); - Assert.assertEquals(((Quantity) value).getUnit(), "g/cm3"); + assertEquals(((Quantity) value).getValue(), new BigDecimal("2")); + assertEquals("g/cm3", ((Quantity) value).getUnit()); value = engine.expression(library, "AddIAndD").value(); assertThat(value, is(new BigDecimal("3.0"))); @@ -81,7 +82,7 @@ public void testAdd() { // error testing try { value = AddEvaluator.add("This is an error", 404); - Assert.fail(); + fail(); } catch (CqlException e) { // pass } @@ -91,7 +92,7 @@ public void testAdd() { * {@link org.opencds.cqf.cql.engine.elm.execution.CeilingEvaluator#evaluate(Context)} */ @Test - public void testCeiling() { + void ceiling() { var value = engine.expression(library, "CeilingNull").value(); assertThat(value, is(nullValue())); @@ -119,7 +120,7 @@ public void testCeiling() { * {@link org.opencds.cqf.cql.engine.elm.execution.DivideEvaluator#evaluate(Context)} */ @Test - public void testDivide() { + void divide() { var value = engine.expression(library, "DivideNull").value(); assertThat(value, is(nullValue())); @@ -143,14 +144,14 @@ public void testDivide() { assertThat((BigDecimal) value, comparesEqualTo(new BigDecimal("3.33333333"))); value = engine.expression(library, "Divide1Q1").value(); - Assert.assertEquals(((Quantity) value).getValue(), new BigDecimal("1")); - Assert.assertEquals(((Quantity) value).getUnit(), "g/cm3"); + assertEquals(((Quantity) value).getValue(), new BigDecimal("1")); + assertEquals("g/cm3", ((Quantity) value).getUnit()); // TODO: The asserted "correct" answer 1.0'g/cm3' is wrong; // the true correct answer is just 1.0 with no units or empty string unit. // value = engine.expression(arithmetic, "Divide1Q1Q").value(); - // Assert.assertEquals(((Quantity) value).getValue(), new BigDecimal("1.0")); - // Assert.assertEquals("g/cm3", ((Quantity) value).getUnit()); + // Assertions.assertEquals(((Quantity) value).getValue(), new BigDecimal("1.0")); + // Assertions.assertEquals("g/cm3", ((Quantity) value).getUnit()); value = engine.expression(library, "Divide10I5D").value(); assertThat((BigDecimal) value, comparesEqualTo(new BigDecimal("2.0"))); @@ -159,15 +160,15 @@ public void testDivide() { assertThat((BigDecimal) value, comparesEqualTo(new BigDecimal("2.0"))); value = engine.expression(library, "Divide10Q5I").value(); - Assert.assertEquals(new BigDecimal("2.0"), ((Quantity) value).getValue()); - Assert.assertEquals(((Quantity) value).getUnit(), "g"); + assertEquals(new BigDecimal("2.0"), ((Quantity) value).getValue()); + assertEquals("g", ((Quantity) value).getUnit()); } /** * {@link org.opencds.cqf.cql.engine.elm.execution.FloorEvaluator#evaluate(Context)} */ @Test - public void testFloor() { + void floor() { var value = engine.expression(library, "FloorNull").value(); assertThat(value, is(nullValue())); @@ -198,7 +199,7 @@ public void testFloor() { * {@link org.opencds.cqf.cql.engine.elm.execution.ExpEvaluator#evaluate(Context)} */ @Test - public void testExp() { + void exp() { var value = engine.expression(library, "ExpNull").value(); assertThat(value, is(nullValue())); @@ -220,14 +221,14 @@ public void testExp() { try { value = engine.expression(library, "Exp1000").value(); - Assert.fail(); + fail(); } catch (UndefinedResult ae) { assertThat(ae.getMessage(), is("Results in positive infinity")); } try { value = engine.expression(library, "Exp1000D").value(); - Assert.fail(); + fail(); } catch (UndefinedResult ae) { assertThat(ae.getMessage(), is("Results in positive infinity")); } @@ -237,33 +238,33 @@ public void testExp() { * {@link org.opencds.cqf.cql.engine.elm.execution.HighBoundaryEvaluator#evaluate(Context)} */ @Test - public void testHighBoundary() { + void highBoundary() { var value = engine.expression(library, "HighBoundaryDec").value(); - Assert.assertEquals(((BigDecimal) value).compareTo(new BigDecimal("1.58799999")), 0); + assertEquals(0, ((BigDecimal) value).compareTo(new BigDecimal("1.58799999"))); value = engine.expression(library, "HighBoundaryDate").value(); - Assert.assertTrue(EquivalentEvaluator.equivalent(value, new Date(2014, 12))); + assertTrue(EquivalentEvaluator.equivalent(value, new Date(2014, 12))); value = engine.expression(library, "HighBoundaryDateTime").value(); final DateTime expectedDateTime = new DateTime(getBigDecimalZoneOffset(), 2014, 1, 1, 8, 59, 59, 999); - Assert.assertTrue(EquivalentEvaluator.equivalent(value, expectedDateTime)); + assertTrue(EquivalentEvaluator.equivalent(value, expectedDateTime)); value = engine.expression(library, "HighBoundaryTime").value(); - Assert.assertTrue(EquivalentEvaluator.equivalent(value, new Time(10, 30, 59, 999))); + assertTrue(EquivalentEvaluator.equivalent(value, new Time(10, 30, 59, 999))); value = engine.expression(library, "HighBoundaryNull").value(); - Assert.assertNull(value); + assertNull(value); value = engine.expression(library, "HighBoundaryNullPrecision").value(); - Assert.assertEquals(((BigDecimal) value).compareTo(new BigDecimal("1.58888999")), 0); + assertEquals(0, ((BigDecimal) value).compareTo(new BigDecimal("1.58888999"))); } /** * {@link org.opencds.cqf.cql.engine.elm.execution.LogEvaluator#evaluate(Context)} */ @Test - public void testLog() { + void log() { var value = engine.expression(library, "LogNullNull").value(); assertThat(value, is(nullValue())); @@ -293,20 +294,20 @@ public void testLog() { * {@link org.opencds.cqf.cql.engine.elm.execution.LnEvaluator#evaluate(Context)} */ @Test - public void testLn() { + void ln() { var value = engine.expression(library, "LnNull").value(); assertThat(value, is(nullValue())); try { value = engine.expression(library, "Ln0").value(); - Assert.fail(); + fail(); } catch (UndefinedResult ae) { assertThat(ae.getMessage(), is("Results in negative infinity")); } try { value = engine.expression(library, "LnNeg0").value(); - Assert.fail(); + fail(); } catch (UndefinedResult ae) { assertThat(ae.getMessage(), is("Results in negative infinity")); } @@ -331,33 +332,33 @@ public void testLn() { * {@link org.opencds.cqf.cql.engine.elm.execution.LowBoundaryEvaluator#evaluate(Context)} */ @Test - public void testLowBoundary() { + void lowBoundary() { var value = engine.expression(library, "LowBoundaryDec").value(); - Assert.assertEquals(((BigDecimal) value).compareTo(new BigDecimal("1.58700000")), 0); + assertEquals(0, ((BigDecimal) value).compareTo(new BigDecimal("1.58700000"))); value = engine.expression(library, "LowBoundaryDate").value(); - Assert.assertTrue(EquivalentEvaluator.equivalent(value, new Date(2014, 1))); + assertTrue(EquivalentEvaluator.equivalent(value, new Date(2014, 1))); value = engine.expression(library, "LowBoundaryDateTime").value(); final DateTime expectedDateTime = new DateTime(getBigDecimalZoneOffset(), 2014, 1, 1, 8, 0, 0, 0); - Assert.assertTrue(EquivalentEvaluator.equivalent(value, expectedDateTime)); + assertTrue(EquivalentEvaluator.equivalent(value, expectedDateTime)); value = engine.expression(library, "LowBoundaryTime").value(); - Assert.assertTrue(EquivalentEvaluator.equivalent(value, new Time(10, 30, 0, 0))); + assertTrue(EquivalentEvaluator.equivalent(value, new Time(10, 30, 0, 0))); value = engine.expression(library, "LowBoundaryNull").value(); - Assert.assertNull(value); + assertNull(value); value = engine.expression(library, "LowBoundaryNullPrecision").value(); - Assert.assertEquals(((BigDecimal) value).compareTo(new BigDecimal("1.58888000")), 0); + assertEquals(0, ((BigDecimal) value).compareTo(new BigDecimal("1.58888000"))); } /** * {@link org.opencds.cqf.cql.engine.elm.execution.MaxEvaluator#evaluate(Context)} */ @Test - public void testMaximum() { + void maximum() { var value = engine.expression(library, "IntegerMaxValue").value(); assertThat(value, is(Integer.MAX_VALUE)); @@ -366,21 +367,20 @@ public void testMaximum() { assertThat(value, is(Long.MAX_VALUE)); value = engine.expression(library, "DecimalMaxValue").value(); - Assert.assertEquals(((BigDecimal) value).compareTo(new BigDecimal("9999999999999999999999999999.99999999")), 0); + assertEquals(0, ((BigDecimal) value).compareTo(new BigDecimal("9999999999999999999999999999.99999999"))); value = engine.expression(library, "DateTimeMaxValue").value(); - Assert.assertTrue( - EquivalentEvaluator.equivalent(value, new DateTime(BigDecimal.ZERO, 9999, 12, 31, 23, 59, 59, 999))); + assertTrue(EquivalentEvaluator.equivalent(value, new DateTime(BigDecimal.ZERO, 9999, 12, 31, 23, 59, 59, 999))); value = engine.expression(library, "TimeMaxValue").value(); - Assert.assertTrue(EquivalentEvaluator.equivalent(value, new Time(23, 59, 59, 999))); + assertTrue(EquivalentEvaluator.equivalent(value, new Time(23, 59, 59, 999))); } /** * {@link org.opencds.cqf.cql.engine.elm.execution.MinEvaluator#evaluate(Context)} */ @Test - public void testMinimum() { + void minimum() { var value = engine.expression(library, "IntegerMinValue").value(); assertThat(value, is(Integer.MIN_VALUE)); @@ -389,21 +389,20 @@ public void testMinimum() { assertThat(value, is(Long.MIN_VALUE)); value = engine.expression(library, "DecimalMinValue").value(); - Assert.assertTrue( - ((BigDecimal) value).compareTo(new BigDecimal("-9999999999999999999999999999.99999999")) == 0); + assertEquals(0, ((BigDecimal) value).compareTo(new BigDecimal("-9999999999999999999999999999.99999999"))); value = engine.expression(library, "DateTimeMinValue").value(); - Assert.assertTrue(EquivalentEvaluator.equivalent(value, new DateTime(BigDecimal.ZERO, 1, 1, 1, 0, 0, 0, 0))); + assertTrue(EquivalentEvaluator.equivalent(value, new DateTime(BigDecimal.ZERO, 1, 1, 1, 0, 0, 0, 0))); value = engine.expression(library, "TimeMinValue").value(); - Assert.assertTrue(EquivalentEvaluator.equivalent(value, new Time(0, 0, 0, 0))); + assertTrue(EquivalentEvaluator.equivalent(value, new Time(0, 0, 0, 0))); } /** * {@link org.opencds.cqf.cql.engine.elm.execution.ModuloEvaluator#evaluate(Context)} */ @Test - public void testModulo() { + void modulo() { var value = engine.expression(library, "ModuloNull").value(); assertThat(value, is(nullValue())); @@ -444,7 +443,7 @@ public void testModulo() { * {@link org.opencds.cqf.cql.engine.elm.execution.MultiplyEvaluator#evaluate(Context)} */ @Test - public void testMultiply() { + void multiply() { var value = engine.expression(library, "MultiplyNull").value(); assertThat(value, is(nullValue())); @@ -463,15 +462,15 @@ public void testMultiply() { // TODO: should return multiplied units i.e. cm2 // value = engine.expression(arithmetic, "Multiply1CMBy2CM").value(); - // Assert.assertTrue(new BigDecimal("2.0").compareTo(((Quantity) value).getValue()) == 0); - // Assert.assertEquals("cm", ((Quantity) value).getUnit()); + // Assertions.assertTrue(new BigDecimal("2.0").compareTo(((Quantity) value).getValue()) == 0); + // Assertions.assertEquals("cm", ((Quantity) value).getUnit()); } /** * {@link org.opencds.cqf.cql.engine.elm.execution.NegateEvaluator#evaluate(Context)} */ @Test - public void testNegate() { + void negate() { var value = engine.expression(library, "NegateNull").value(); assertThat(value, is(nullValue())); @@ -506,15 +505,15 @@ public void testNegate() { assertThat((BigDecimal) value, comparesEqualTo(new BigDecimal("1.0"))); value = engine.expression(library, "Negate1CM").value(); - Assert.assertTrue(new BigDecimal("-1.0").compareTo(((Quantity) value).getValue()) == 0); - Assert.assertEquals(((Quantity) value).getUnit(), "cm"); + assertEquals(0, new BigDecimal("-1.0").compareTo(((Quantity) value).getValue())); + assertEquals("cm", ((Quantity) value).getUnit()); } /** * {@link org.opencds.cqf.cql.engine.elm.execution.PredecessorEvaluator#evaluate(Context)} */ @Test - public void testPredecessor() { + void predecessor() { var value = engine.expression(library, "PredecessorNull").value(); assertThat(value, is(nullValue())); @@ -534,26 +533,26 @@ public void testPredecessor() { assertThat((BigDecimal) value, comparesEqualTo(new BigDecimal("1.00999999"))); // value = engine.expression(arithmetic, "PredecessorOf1QCM").value(); - // Assert.assertTrue(new BigDecimal("0.99999999").compareTo(((Quantity) value).getValue()) == 0); - // Assert.assertEquals("cm", ((Quantity) value).getUnit()); + // Assertions.assertTrue(new BigDecimal("0.99999999").compareTo(((Quantity) value).getValue()) == 0); + // Assertions.assertEquals("cm", ((Quantity) value).getUnit()); value = engine.expression(library, "PredecessorOfJan12000").value(); final DateTime expectedDateTime = new DateTime(getBigDecimalZoneOffset(), 1999, 12, 31); - Assert.assertTrue(EquivalentEvaluator.equivalent(value, expectedDateTime)); + assertTrue(EquivalentEvaluator.equivalent(value, expectedDateTime)); value = engine.expression(library, "PredecessorOfNoon").value(); - Assert.assertTrue(EquivalentEvaluator.equivalent(value, new Time(11, 59, 59, 999))); + assertTrue(EquivalentEvaluator.equivalent(value, new Time(11, 59, 59, 999))); try { value = engine.expression(library, "PredecessorUnderflowDt").value(); - Assert.fail(); + fail(); } catch (RuntimeException re) { assertThat(re.getMessage(), is("The year: 0 falls below the accepted bounds of 0001-9999.")); } try { value = engine.expression(library, "PredecessorUnderflowT").value(); - Assert.fail(); + fail(); } catch (RuntimeException re) { assertThat( re.getMessage(), @@ -565,28 +564,28 @@ public void testPredecessor() { * {@link org.opencds.cqf.cql.engine.elm.execution.PrecisionEvaluator#evaluate(Context)} */ @Test - public void testPrecision() { + void precision() { var value = engine.expression(library, "PrecisionDecimal5").value(); - Assert.assertEquals(value, 5); + assertEquals(5, value); value = engine.expression(library, "PrecisionDateYear").value(); - Assert.assertEquals(value, 4); + assertEquals(4, value); value = engine.expression(library, "PrecisionDateTimeMs").value(); - Assert.assertEquals(value, 17); + assertEquals(17, value); value = engine.expression(library, "PrecisionTimeMinute").value(); - Assert.assertEquals(value, 4); + assertEquals(4, value); value = engine.expression(library, "PrecisionTimeMs").value(); - Assert.assertEquals(value, 9); + assertEquals(9, value); } /** * {@link org.opencds.cqf.cql.engine.elm.execution.PowerEvaluator#evaluate(Context)} */ @Test - public void testPower() { + void power() { var value = engine.expression(library, "PowerNullToNull").value(); assertThat(value, is(nullValue())); @@ -637,7 +636,7 @@ public void testPower() { * {@link org.opencds.cqf.cql.engine.elm.execution.RoundEvaluator#evaluate(Context)} */ @Test - public void testRound() { + void round() { var value = engine.expression(library, "RoundNull").value(); assertThat(value, is(nullValue())); @@ -676,7 +675,7 @@ public void testRound() { * {@link org.opencds.cqf.cql.engine.elm.execution.SubtractEvaluator#evaluate(Context)} */ @Test - public void testSubtract() { + void subtract() { var value = engine.expression(library, "SubtractNull").value(); assertThat(value, is(nullValue())); @@ -690,8 +689,8 @@ public void testSubtract() { assertThat((BigDecimal) value, comparesEqualTo(BigDecimal.valueOf(-1.0))); value = engine.expression(library, "Subtract1CMAnd2CM").value(); - Assert.assertTrue(new BigDecimal("-1.0").compareTo(((Quantity) value).getValue()) == 0); - Assert.assertEquals(((Quantity) value).getUnit(), "cm"); + assertEquals(0, new BigDecimal("-1.0").compareTo(((Quantity) value).getValue())); + assertEquals("cm", ((Quantity) value).getUnit()); value = engine.expression(library, "Subtract2And11D").value(); assertThat((BigDecimal) value, comparesEqualTo(new BigDecimal("0.9"))); @@ -701,7 +700,7 @@ public void testSubtract() { * {@link org.opencds.cqf.cql.engine.elm.execution.SuccessorEvaluator#evaluate(Context)} */ @Test - public void testSuccessor() { + void successor() { var value = engine.expression(library, "SuccessorNull").value(); assertThat(value, is(nullValue())); @@ -722,21 +721,21 @@ public void testSuccessor() { value = engine.expression(library, "SuccessorOfJan12000").value(); final DateTime expectedDateTime = new DateTime(getBigDecimalZoneOffset(), 2000, 1, 2); - Assert.assertTrue(EquivalentEvaluator.equivalent(value, expectedDateTime)); + assertTrue(EquivalentEvaluator.equivalent(value, expectedDateTime)); value = engine.expression(library, "SuccessorOfNoon").value(); - Assert.assertTrue(EquivalentEvaluator.equivalent(value, new Time(12, 0, 0, 1))); + assertTrue(EquivalentEvaluator.equivalent(value, new Time(12, 0, 0, 1))); try { value = engine.expression(library, "SuccessorOverflowDt").value(); - Assert.fail(); + fail(); } catch (RuntimeException re) { assertThat(re.getMessage(), is("The year: 10000 falls above the accepted bounds of 0001-9999.")); } try { value = engine.expression(library, "SuccessorOverflowT").value(); - Assert.fail(); + fail(); } catch (RuntimeException re) { assertThat( re.getMessage(), @@ -748,7 +747,7 @@ public void testSuccessor() { * {@link org.opencds.cqf.cql.engine.elm.execution.TruncateEvaluator#evaluate(Context)} */ @Test - public void testTruncate() { + void truncate() { var value = engine.expression(library, "TruncateNull").value(); assertThat(value, is(nullValue())); @@ -790,7 +789,7 @@ public void testTruncate() { * {@link org.opencds.cqf.cql.engine.elm.execution.TruncatedDivideEvaluator#evaluate(Context)} */ @Test - public void testTruncatedDivide() { + void truncatedDivide() { var value = engine.expression(library, "TruncatedDivideNull").value(); assertThat(value, is(nullValue())); diff --git a/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/execution/CqlClinicalOperatorsTest.java b/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/execution/CqlClinicalOperatorsTest.java index f0a591910..0f6d896f9 100644 --- a/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/execution/CqlClinicalOperatorsTest.java +++ b/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/execution/CqlClinicalOperatorsTest.java @@ -3,17 +3,17 @@ import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.is; import static org.hamcrest.Matchers.nullValue; +import static org.junit.jupiter.api.Assertions.assertEquals; import java.time.ZonedDateTime; import java.util.TimeZone; +import org.junit.jupiter.api.Test; import org.opencds.cqf.cql.engine.runtime.Interval; -import org.testng.Assert; -import org.testng.annotations.Test; -public class CqlClinicalOperatorsTest extends CqlTestBase { +class CqlClinicalOperatorsTest extends CqlTestBase { @Test - public void test_all_clinical_operators_tests() { + void all_clinical_operators_tests() { var results = engine.evaluate( toElmIdentifier("CqlClinicalOperatorsTest"), ZonedDateTime.of(2016, 1, 1, 0, 0, 0, 0, TimeZone.getDefault().toZoneId())); @@ -68,8 +68,8 @@ public void test_all_clinical_operators_tests() { assertThat(value, is((27 * 60 + 10) * 60 + 15)); value = results.forExpression("CalculateAgeAtUncertain").value(); - Assert.assertTrue(((Interval) value).getStart().equals(187)); - Assert.assertTrue(((Interval) value).getEnd().equals(198)); + assertEquals(187, ((Interval) value).getStart()); + assertEquals(198, ((Interval) value).getEnd()); value = results.forExpression("Issue70A").value(); assertThat(value, is(false)); diff --git a/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/execution/CqlComparisonOperatorsTest.java b/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/execution/CqlComparisonOperatorsTest.java index e0ea78894..2c71fa782 100644 --- a/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/execution/CqlComparisonOperatorsTest.java +++ b/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/execution/CqlComparisonOperatorsTest.java @@ -3,21 +3,21 @@ import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.is; import static org.hamcrest.Matchers.nullValue; -import static org.testng.Assert.assertFalse; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.fail; import java.util.ArrayList; import java.util.List; import org.cqframework.cql.cql2elm.CqlCompilerException; import org.cqframework.cql.cql2elm.CqlCompilerOptions; +import org.junit.jupiter.api.Test; import org.opencds.cqf.cql.engine.elm.executing.GreaterEvaluator; import org.opencds.cqf.cql.engine.exception.CqlException; -import org.testng.Assert; -import org.testng.annotations.Test; -public class CqlComparisonOperatorsTest extends CqlTestBase { +class CqlComparisonOperatorsTest extends CqlTestBase { @Test - public void test_cql_comparison_test_suite_compiles() { + void cql_comparison_test_suite_compiles() { var errors = new ArrayList(); this.getLibrary(toElmIdentifier("CqlComparisonOperatorsTest"), errors, testCompilerOptions()); assertFalse( @@ -26,7 +26,7 @@ public void test_cql_comparison_test_suite_compiles() { } @Test - public void test_all_comparison_operators_tests() { + void all_comparison_operators_tests() { var eng = getEngine(testCompilerOptions()); var results = eng.evaluate(toElmIdentifier("CqlComparisonOperatorsTest")); @@ -237,7 +237,7 @@ public void test_all_comparison_operators_tests() { try { GreaterEvaluator.greater(1, "one", engine.getState()); - Assert.fail(); + fail(); } catch (CqlException e) { // pass } diff --git a/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/execution/CqlConceptTest.java b/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/execution/CqlConceptTest.java index 76b918981..559db05f2 100644 --- a/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/execution/CqlConceptTest.java +++ b/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/execution/CqlConceptTest.java @@ -1,20 +1,19 @@ package org.opencds.cqf.cql.engine.execution; +import static org.junit.jupiter.api.Assertions.fail; + import java.io.IOException; import java.util.*; +import org.junit.jupiter.api.Test; import org.opencds.cqf.cql.engine.runtime.*; -import org.testng.Assert; -import org.testng.annotations.Test; -public class CqlConceptTest extends CqlTestBase { +class CqlConceptTest extends CqlTestBase { @Test - public void test_all_cql_concept_tests() throws IOException { + void all_cql_concept_tests() throws IOException { Environment environment = new Environment(getLibraryManager()); CqlEngine engine = new CqlEngine(environment); - Set set = new HashSet<>(); - var results = engine.evaluate(toElmIdentifier("CqlConceptTest")); List codes = Arrays.asList(createCode("123", "1"), createCode("234", "1"), createCode("abc", "a")); @@ -36,7 +35,7 @@ private static Code createCode(String prefix, String systemVal) { static void assertEqual(CqlType expected, CqlType actual) { if (!expected.equal(actual)) { String message = "Expected " + expected + " but got " + actual; - Assert.fail(message); + fail(message); } } } diff --git a/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/execution/CqlConditionalOperatorsTest.java b/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/execution/CqlConditionalOperatorsTest.java index a20fe130c..344246947 100644 --- a/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/execution/CqlConditionalOperatorsTest.java +++ b/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/execution/CqlConditionalOperatorsTest.java @@ -5,15 +5,15 @@ import java.io.IOException; import org.hl7.elm.r1.VersionedIdentifier; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Test; @SuppressWarnings("removal") -public class CqlConditionalOperatorsTest extends CqlTestBase { +class CqlConditionalOperatorsTest extends CqlTestBase { private static final VersionedIdentifier library = new VersionedIdentifier().withId("CqlConditionalOperatorsTest"); @Test - public void test_all_conditional_operators_tests() throws IOException { + void all_conditional_operators_tests() throws IOException { var value = engine.expression(library, "IfTrue1").value(); assertThat(value, is(5)); diff --git a/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/execution/CqlDateTimeOperatorsTest.java b/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/execution/CqlDateTimeOperatorsTest.java index f5beed591..8a9b5e3f9 100644 --- a/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/execution/CqlDateTimeOperatorsTest.java +++ b/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/execution/CqlDateTimeOperatorsTest.java @@ -3,19 +3,19 @@ import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.is; import static org.hamcrest.Matchers.nullValue; +import static org.junit.jupiter.api.Assertions.*; import java.math.BigDecimal; import org.hl7.elm.r1.VersionedIdentifier; +import org.junit.jupiter.api.Test; import org.opencds.cqf.cql.engine.elm.executing.AfterEvaluator; import org.opencds.cqf.cql.engine.elm.executing.EquivalentEvaluator; import org.opencds.cqf.cql.engine.exception.CqlException; import org.opencds.cqf.cql.engine.exception.InvalidDateTime; import org.opencds.cqf.cql.engine.runtime.*; -import org.testng.Assert; -import org.testng.annotations.Test; @SuppressWarnings("removal") -public class CqlDateTimeOperatorsTest extends CqlTestBase { +class CqlDateTimeOperatorsTest extends CqlTestBase { private static final VersionedIdentifier library = new VersionedIdentifier().withId("CqlDateTimeOperatorsTest"); @@ -23,131 +23,125 @@ public class CqlDateTimeOperatorsTest extends CqlTestBase { * {@link org.opencds.cqf.cql.engine.elm.execution.AddEvaluator#evaluate(Context)} */ @Test - public void testAdd() { + void add() { final BigDecimal bigDecimalZoneOffset = getBigDecimalZoneOffset(); var value = engine.expression(library, "DateTimeAdd5Years").value(); - Assert.assertTrue(EquivalentEvaluator.equivalent(value, new DateTime(bigDecimalZoneOffset, 2010, 10, 10))); + assertTrue(EquivalentEvaluator.equivalent(value, new DateTime(bigDecimalZoneOffset, 2010, 10, 10))); try { engine.expression(library, "DateTimeAddInvalidYears").value(); - Assert.fail(); + fail(); } catch (InvalidDateTime ae) { // pass } value = engine.expression(library, "DateTimeAdd5Months").value(); - Assert.assertTrue(EquivalentEvaluator.equivalent(value, new DateTime(bigDecimalZoneOffset, 2005, 10, 10))); + assertTrue(EquivalentEvaluator.equivalent(value, new DateTime(bigDecimalZoneOffset, 2005, 10, 10))); value = engine.expression(library, "DateTimeAddMonthsOverflow").value(); - Assert.assertTrue(EquivalentEvaluator.equivalent(value, new DateTime(bigDecimalZoneOffset, 2006, 3, 10))); + assertTrue(EquivalentEvaluator.equivalent(value, new DateTime(bigDecimalZoneOffset, 2006, 3, 10))); value = engine.expression(library, "DateTimeAddThreeWeeks").value(); - Assert.assertTrue(EquivalentEvaluator.equivalent(value, new DateTime(bigDecimalZoneOffset, 2018, 5, 23))); + assertTrue(EquivalentEvaluator.equivalent(value, new DateTime(bigDecimalZoneOffset, 2018, 5, 23))); value = engine.expression(library, "DateTimeAddYearInWeeks").value(); - Assert.assertTrue(EquivalentEvaluator.equivalent(value, new DateTime(bigDecimalZoneOffset, 2019, 5, 23))); + assertTrue(EquivalentEvaluator.equivalent(value, new DateTime(bigDecimalZoneOffset, 2019, 5, 23))); value = engine.expression(library, "DateTimeAdd5Days").value(); - Assert.assertTrue(EquivalentEvaluator.equivalent(value, new DateTime(bigDecimalZoneOffset, 2005, 5, 15))); + assertTrue(EquivalentEvaluator.equivalent(value, new DateTime(bigDecimalZoneOffset, 2005, 5, 15))); value = engine.expression(library, "DateTimeAddDaysOverflow").value(); - Assert.assertTrue(EquivalentEvaluator.equivalent(value, new DateTime(bigDecimalZoneOffset, 2016, 7, 1))); + assertTrue(EquivalentEvaluator.equivalent(value, new DateTime(bigDecimalZoneOffset, 2016, 7, 1))); value = engine.expression(library, "DateTimeAdd5Hours").value(); - Assert.assertTrue(EquivalentEvaluator.equivalent(value, new DateTime(bigDecimalZoneOffset, 2005, 5, 10, 10))); + assertTrue(EquivalentEvaluator.equivalent(value, new DateTime(bigDecimalZoneOffset, 2005, 5, 10, 10))); value = engine.expression(library, "DateTimeAdd5HoursWithLeftMinPrecisionSecond") .value(); - Assert.assertTrue( - EquivalentEvaluator.equivalent(value, new DateTime(bigDecimalZoneOffset, 2005, 5, 10, 10, 20, 30))); + assertTrue(EquivalentEvaluator.equivalent(value, new DateTime(bigDecimalZoneOffset, 2005, 5, 10, 10, 20, 30))); value = engine.expression(library, "DateTimeAdd5HoursWithLeftMinPrecisionDay") .value(); - Assert.assertTrue(EquivalentEvaluator.equivalent(value, new DateTime(bigDecimalZoneOffset, 2005, 5, 10))); + assertTrue(EquivalentEvaluator.equivalent(value, new DateTime(bigDecimalZoneOffset, 2005, 5, 10))); value = engine.expression(library, "DateTimeAdd5HoursWithLeftMinPrecisionDayOverflow") .value(); - Assert.assertTrue(EquivalentEvaluator.equivalent(value, new DateTime(bigDecimalZoneOffset, 2005, 5, 11))); + assertTrue(EquivalentEvaluator.equivalent(value, new DateTime(bigDecimalZoneOffset, 2005, 5, 11))); value = engine.expression(library, "DateAdd2YearsAsMonths").value(); - Assert.assertTrue(EquivalentEvaluator.equivalent(value, new Date(2016))); + assertTrue(EquivalentEvaluator.equivalent(value, new Date(2016))); value = engine.expression(library, "DateAdd2YearsAsMonthsRem1").value(); - Assert.assertTrue(EquivalentEvaluator.equivalent(value, new Date(2016))); + assertTrue(EquivalentEvaluator.equivalent(value, new Date(2016))); value = engine.expression(library, "DateAdd33Days").value(); - Assert.assertTrue(EquivalentEvaluator.equivalent(value, new Date(2014, 7))); + assertTrue(EquivalentEvaluator.equivalent(value, new Date(2014, 7))); value = engine.expression(library, "DateAdd1Year").value(); - Assert.assertTrue(EquivalentEvaluator.equivalent(value, new Date(2015, 6))); + assertTrue(EquivalentEvaluator.equivalent(value, new Date(2015, 6))); value = engine.expression(library, "DateTimeAddHoursOverflow").value(); - Assert.assertTrue(EquivalentEvaluator.equivalent(value, new DateTime(bigDecimalZoneOffset, 2016, 6, 11, 0))); + assertTrue(EquivalentEvaluator.equivalent(value, new DateTime(bigDecimalZoneOffset, 2016, 6, 11, 0))); value = engine.expression(library, "DateTimeAdd5Minutes").value(); - Assert.assertTrue( - EquivalentEvaluator.equivalent(value, new DateTime(bigDecimalZoneOffset, 2005, 5, 10, 5, 10))); + assertTrue(EquivalentEvaluator.equivalent(value, new DateTime(bigDecimalZoneOffset, 2005, 5, 10, 5, 10))); value = engine.expression(library, "DateTimeAddMinutesOverflow").value(); - Assert.assertTrue(EquivalentEvaluator.equivalent(value, new DateTime(bigDecimalZoneOffset, 2016, 6, 10, 6, 0))); + assertTrue(EquivalentEvaluator.equivalent(value, new DateTime(bigDecimalZoneOffset, 2016, 6, 10, 6, 0))); value = engine.expression(library, "DateTimeAdd5Seconds").value(); - Assert.assertTrue( - EquivalentEvaluator.equivalent(value, new DateTime(bigDecimalZoneOffset, 2005, 5, 10, 5, 5, 10))); + assertTrue(EquivalentEvaluator.equivalent(value, new DateTime(bigDecimalZoneOffset, 2005, 5, 10, 5, 5, 10))); value = engine.expression(library, "DateTimeAddSecondsOverflow").value(); - Assert.assertTrue( - EquivalentEvaluator.equivalent(value, new DateTime(bigDecimalZoneOffset, 2016, 6, 10, 5, 6, 0))); + assertTrue(EquivalentEvaluator.equivalent(value, new DateTime(bigDecimalZoneOffset, 2016, 6, 10, 5, 6, 0))); value = engine.expression(library, "DateTimeAdd5Milliseconds").value(); - Assert.assertTrue( - EquivalentEvaluator.equivalent(value, new DateTime(bigDecimalZoneOffset, 2005, 5, 10, 5, 5, 5, 10))); + assertTrue(EquivalentEvaluator.equivalent(value, new DateTime(bigDecimalZoneOffset, 2005, 5, 10, 5, 5, 5, 10))); value = engine.expression(library, "DateTimeAddMillisecondsOverflow").value(); - Assert.assertTrue( - EquivalentEvaluator.equivalent(value, new DateTime(bigDecimalZoneOffset, 2016, 6, 10, 5, 5, 6, 0))); + assertTrue(EquivalentEvaluator.equivalent(value, new DateTime(bigDecimalZoneOffset, 2016, 6, 10, 5, 5, 6, 0))); value = engine.expression(library, "DateTimeAddLeapYear").value(); - Assert.assertTrue(EquivalentEvaluator.equivalent(value, new DateTime(bigDecimalZoneOffset, 2013, 2, 28))); + assertTrue(EquivalentEvaluator.equivalent(value, new DateTime(bigDecimalZoneOffset, 2013, 2, 28))); value = engine.expression(library, "DateTimeAdd2YearsByMonths").value(); - Assert.assertTrue(EquivalentEvaluator.equivalent(value, new DateTime(bigDecimalZoneOffset, 2016))); + assertTrue(EquivalentEvaluator.equivalent(value, new DateTime(bigDecimalZoneOffset, 2016))); value = engine.expression(library, "DateTimeAdd2YearsByDays").value(); - Assert.assertTrue(EquivalentEvaluator.equivalent(value, new DateTime(bigDecimalZoneOffset, 2016))); + assertTrue(EquivalentEvaluator.equivalent(value, new DateTime(bigDecimalZoneOffset, 2016))); value = engine.expression(library, "DateTimeAdd2YearsByDaysRem5Days").value(); - Assert.assertTrue(EquivalentEvaluator.equivalent(value, new DateTime(bigDecimalZoneOffset, 2016))); + assertTrue(EquivalentEvaluator.equivalent(value, new DateTime(bigDecimalZoneOffset, 2016))); value = engine.expression(library, "TimeAdd5Hours").value(); - Assert.assertTrue(EquivalentEvaluator.equivalent(value, new Time(20, 59, 59, 999))); + assertTrue(EquivalentEvaluator.equivalent(value, new Time(20, 59, 59, 999))); value = engine.expression(library, "TimeAdd1Minute").value(); - Assert.assertTrue(EquivalentEvaluator.equivalent(value, new Time(16, 0, 59, 999))); + assertTrue(EquivalentEvaluator.equivalent(value, new Time(16, 0, 59, 999))); value = engine.expression(library, "TimeAdd1Second").value(); - Assert.assertTrue(EquivalentEvaluator.equivalent(value, new Time(16, 0, 0, 999))); + assertTrue(EquivalentEvaluator.equivalent(value, new Time(16, 0, 0, 999))); value = engine.expression(library, "TimeAdd1Millisecond").value(); - Assert.assertTrue(EquivalentEvaluator.equivalent(value, new Time(16, 0, 0, 0))); + assertTrue(EquivalentEvaluator.equivalent(value, new Time(16, 0, 0, 0))); value = engine.expression(library, "TimeAdd5Hours1Minute").value(); - Assert.assertTrue(EquivalentEvaluator.equivalent(value, new Time(21, 0, 59, 999))); + assertTrue(EquivalentEvaluator.equivalent(value, new Time(21, 0, 59, 999))); // checking access ordering and returning correct result value = engine.expression(library, "TimeAdd1Second").value(); - Assert.assertTrue(EquivalentEvaluator.equivalent(value, new Time(16, 0, 0, 999))); + assertTrue(EquivalentEvaluator.equivalent(value, new Time(16, 0, 0, 999))); value = engine.expression(library, "TimeAdd5hoursByMinute").value(); - Assert.assertTrue(EquivalentEvaluator.equivalent(value, new Time(20, 59, 59, 999))); + assertTrue(EquivalentEvaluator.equivalent(value, new Time(20, 59, 59, 999))); } /** * {@link org.opencds.cqf.cql.engine.elm.execution.AfterEvaluator#evaluate(Context)} */ @Test - public void testAfter() { + void after() { final BigDecimal bigDecimalZoneOffset = getBigDecimalZoneOffset(); var value = engine.expression(library, "DateTimeAfterYearTrue").value(); @@ -226,7 +220,7 @@ public void testAfter() { assertThat(value, is(true)); try { AfterEvaluator.after(12, "This is an error", null, engine.getState()); - Assert.fail(); + fail(); } catch (CqlException e) { // pass } @@ -236,7 +230,7 @@ public void testAfter() { * {@link org.opencds.cqf.cql.engine.elm.execution.BeforeEvaluator#evaluate(Context)} */ @Test - public void testBefore() { + void before() { var value = engine.expression(library, "DateTimeBeforeYearTrue").value(); assertThat(value, is(true)); @@ -318,31 +312,29 @@ public void testBefore() { * {@link org.opencds.cqf.cql.engine.elm.execution.DateTimeEvaluator#evaluate(Context)} */ @Test - public void testDateTime() { + void dateTime() { final BigDecimal bigDecimalZoneOffset = getBigDecimalZoneOffset(); var value = engine.expression(library, "DateTimeYear").value(); - Assert.assertTrue(EquivalentEvaluator.equivalent(value, new DateTime(bigDecimalZoneOffset, 2003))); + assertTrue(EquivalentEvaluator.equivalent(value, new DateTime(bigDecimalZoneOffset, 2003))); value = engine.expression(library, "DateTimeMonth").value(); - Assert.assertTrue(EquivalentEvaluator.equivalent(value, new DateTime(bigDecimalZoneOffset, 2003, 10))); + assertTrue(EquivalentEvaluator.equivalent(value, new DateTime(bigDecimalZoneOffset, 2003, 10))); value = engine.expression(library, "DateTimeDay").value(); - Assert.assertTrue(EquivalentEvaluator.equivalent(value, new DateTime(bigDecimalZoneOffset, 2003, 10, 29))); + assertTrue(EquivalentEvaluator.equivalent(value, new DateTime(bigDecimalZoneOffset, 2003, 10, 29))); value = engine.expression(library, "DateTimeHour").value(); - Assert.assertTrue(EquivalentEvaluator.equivalent(value, new DateTime(bigDecimalZoneOffset, 2003, 10, 29, 20))); + assertTrue(EquivalentEvaluator.equivalent(value, new DateTime(bigDecimalZoneOffset, 2003, 10, 29, 20))); value = engine.expression(library, "DateTimeMinute").value(); - Assert.assertTrue( - EquivalentEvaluator.equivalent(value, new DateTime(bigDecimalZoneOffset, 2003, 10, 29, 20, 50))); + assertTrue(EquivalentEvaluator.equivalent(value, new DateTime(bigDecimalZoneOffset, 2003, 10, 29, 20, 50))); value = engine.expression(library, "DateTimeSecond").value(); - Assert.assertTrue( - EquivalentEvaluator.equivalent(value, new DateTime(bigDecimalZoneOffset, 2003, 10, 29, 20, 50, 33))); + assertTrue(EquivalentEvaluator.equivalent(value, new DateTime(bigDecimalZoneOffset, 2003, 10, 29, 20, 50, 33))); value = engine.expression(library, "DateTimeMillisecond").value(); - Assert.assertTrue(EquivalentEvaluator.equivalent( + assertTrue(EquivalentEvaluator.equivalent( value, new DateTime(bigDecimalZoneOffset, 2003, 10, 29, 20, 50, 33, 955))); } @@ -350,7 +342,7 @@ public void testDateTime() { * {@link org.opencds.cqf.cql.engine.elm.execution.DateTimeComponentFromEvaluator#evaluate(Context)} */ @Test - public void testDateTimeComponentFrom() { + void dateTimeComponentFrom() { var value = engine.expression(library, "DateTimeComponentFromYear").value(); assertThat(value, is(2003)); @@ -381,7 +373,7 @@ public void testDateTimeComponentFrom() { assertThat(value, is(new BigDecimal("1.0"))); value = engine.expression(library, "DateTimeComponentFromDate").value(); - Assert.assertTrue(EquivalentEvaluator.equivalent(value, new Date(2003, 10, 29))); + assertTrue(EquivalentEvaluator.equivalent(value, new Date(2003, 10, 29))); value = engine.expression(library, "TimeComponentFromHour").value(); assertThat(value, is(23)); @@ -400,7 +392,7 @@ public void testDateTimeComponentFrom() { * {@link org.opencds.cqf.cql.engine.elm.execution.DifferenceBetweenEvaluator#evaluate(Context)} */ @Test - public void testDifference() { + void difference() { var value = engine.expression(library, "DateTimeDifferenceYear").value(); assertThat(value, is(5)); @@ -473,7 +465,7 @@ public void testDifference() { * {@link org.opencds.cqf.cql.engine.elm.execution.DurationBetweenEvaluator#evaluate(Context)} */ @Test - public void testDuration() { + void duration() { var value = engine.expression(library, "DateTimeDurationBetweenYear").value(); assertThat(value, is(5)); @@ -499,34 +491,34 @@ public void testDuration() { value = engine.expression(library, "DateTimeDurationBetweenUncertainInterval") .value(); - Assert.assertTrue(((Interval) value).getStart().equals(17)); - Assert.assertTrue(((Interval) value).getEnd().equals(44)); + assertEquals(17, ((Interval) value).getStart()); + assertEquals(44, ((Interval) value).getEnd()); value = engine.expression(library, "DateTimeDurationBetweenUncertainInterval2") .value(); - Assert.assertTrue(((Interval) value).getStart().equals(5)); - Assert.assertTrue(((Interval) value).getEnd().equals(16)); + assertEquals(5, ((Interval) value).getStart()); + assertEquals(16, ((Interval) value).getEnd()); // assertThat(((Uncertainty)result).getUncertaintyInterval(), is(new Interval(5, true, 17, true))); value = engine.expression(library, "DateTimeDurationBetweenUncertainAdd") .value(); - Assert.assertTrue(((Interval) value).getStart().equals(34)); - Assert.assertTrue(((Interval) value).getEnd().equals(88)); + assertEquals(34, ((Interval) value).getStart()); + assertEquals(88, ((Interval) value).getEnd()); value = engine.expression(library, "DateTimeDurationBetweenUncertainSubtract") .value(); - Assert.assertTrue(((Interval) value).getStart().equals(12)); - Assert.assertTrue(((Interval) value).getEnd().equals(28)); + assertEquals(12, ((Interval) value).getStart()); + assertEquals(28, ((Interval) value).getEnd()); value = engine.expression(library, "DateTimeDurationBetweenUncertainMultiply") .value(); - Assert.assertTrue(((Interval) value).getStart().equals(289)); - Assert.assertTrue(((Interval) value).getEnd().equals(1936)); + assertEquals(289, ((Interval) value).getStart()); + assertEquals(1936, ((Interval) value).getEnd()); try { value = engine.expression(library, "DateTimeDurationBetweenUncertainDiv") .value(); - Assert.fail(); + fail(); } catch (RuntimeException re) { // pass } @@ -601,7 +593,7 @@ public void testDuration() { * {@link org.opencds.cqf.cql.engine.elm.execution.NowEvaluator#evaluate(Context)} */ @Test - public void testNow() { + void now() { var value = engine.expression(library, "DateTimeNow").value(); assertThat(value, is(true)); @@ -609,18 +601,17 @@ public void testNow() { value = engine.expression( library, "Issue34A", evaluationDateTime.getDateTime().toZonedDateTime()) .value(); - Assert.assertTrue(EquivalentEvaluator.equivalent(value, evaluationDateTime)); - Assert.assertTrue(((DateTime) value) - .getDateTime() - .getOffset() - .equals(evaluationDateTime.getDateTime().getOffset())); + assertTrue(EquivalentEvaluator.equivalent(value, evaluationDateTime)); + assertEquals( + ((DateTime) value).getDateTime().getOffset(), + evaluationDateTime.getDateTime().getOffset()); } /** * {@link org.opencds.cqf.cql.engine.elm.execution.SameAsEvaluator#evaluate(Context)} */ @Test - public void testSameAs() { + void sameAs() { var value = engine.expression(library, "DateTimeSameAsYearTrue").value(); assertThat(value, is(true)); @@ -702,7 +693,7 @@ public void testSameAs() { * {@link org.opencds.cqf.cql.engine.elm.execution.SameOrAfterEvaluator#evaluate(Context)} */ @Test - public void testSameOrAfter() { + void sameOrAfter() { var value = engine.expression(library, "DateTimeSameOrAfterYearTrue1").value(); assertThat(value, is(true)); @@ -825,7 +816,7 @@ public void testSameOrAfter() { * {@link org.opencds.cqf.cql.engine.elm.execution.SameOrBeforeEvaluator#evaluate(Context)} */ @Test - public void testSameOrBefore() { + void sameOrBefore() { var value = engine.expression(library, "DateTimeSameOrBeforeYearTrue1").value(); assertThat(value, is(true)); @@ -942,127 +933,122 @@ public void testSameOrBefore() { * {@link org.opencds.cqf.cql.engine.elm.execution.SubtractEvaluator#evaluate(Context)} */ @Test - public void testSubtract() { + void subtract() { final BigDecimal bigDecimalZoneOffset = getBigDecimalZoneOffset(); var value = engine.expression(library, "DateTimeSubtract5Years").value(); - Assert.assertTrue(EquivalentEvaluator.equivalent(value, new DateTime(bigDecimalZoneOffset, 2000, 10, 10))); + assertTrue(EquivalentEvaluator.equivalent(value, new DateTime(bigDecimalZoneOffset, 2000, 10, 10))); try { engine.expression(library, "DateTimeSubtractInvalidYears").value(); - Assert.fail(); + fail(); } catch (InvalidDateTime ae) { // pass } value = engine.expression(library, "DateTimeSubtract5Months").value(); - Assert.assertTrue(EquivalentEvaluator.equivalent(value, new DateTime(bigDecimalZoneOffset, 2005, 1, 10))); + assertTrue(EquivalentEvaluator.equivalent(value, new DateTime(bigDecimalZoneOffset, 2005, 1, 10))); value = engine.expression(library, "DateTimeSubtractMonthsUnderflow").value(); - Assert.assertTrue(EquivalentEvaluator.equivalent(value, new DateTime(bigDecimalZoneOffset, 2004, 11, 10))); + assertTrue(EquivalentEvaluator.equivalent(value, new DateTime(bigDecimalZoneOffset, 2004, 11, 10))); value = engine.expression(library, "DateTimeSubtractThreeWeeks").value(); - Assert.assertTrue(EquivalentEvaluator.equivalent(value, new DateTime(bigDecimalZoneOffset, 2018, 5, 2))); + assertTrue(EquivalentEvaluator.equivalent(value, new DateTime(bigDecimalZoneOffset, 2018, 5, 2))); value = engine.expression(library, "DateTimeSubtractYearInWeeks").value(); - Assert.assertTrue(EquivalentEvaluator.equivalent(value, new DateTime(bigDecimalZoneOffset, 2017, 5, 23))); + assertTrue(EquivalentEvaluator.equivalent(value, new DateTime(bigDecimalZoneOffset, 2017, 5, 23))); value = engine.expression(library, "DateTimeSubtract5Days").value(); - Assert.assertTrue(EquivalentEvaluator.equivalent(value, new DateTime(bigDecimalZoneOffset, 2005, 5, 5))); + assertTrue(EquivalentEvaluator.equivalent(value, new DateTime(bigDecimalZoneOffset, 2005, 5, 5))); value = engine.expression(library, "DateTimeSubtractDaysUnderflow").value(); - Assert.assertTrue(EquivalentEvaluator.equivalent(value, new DateTime(bigDecimalZoneOffset, 2016, 5, 30))); + assertTrue(EquivalentEvaluator.equivalent(value, new DateTime(bigDecimalZoneOffset, 2016, 5, 30))); value = engine.expression(library, "DateTimeSubtract5Hours").value(); - Assert.assertTrue(EquivalentEvaluator.equivalent(value, new DateTime(bigDecimalZoneOffset, 2005, 5, 10, 5))); + assertTrue(EquivalentEvaluator.equivalent(value, new DateTime(bigDecimalZoneOffset, 2005, 5, 10, 5))); value = engine.expression(library, "DateTimeSubtractHoursUnderflow").value(); - Assert.assertTrue(EquivalentEvaluator.equivalent(value, new DateTime(bigDecimalZoneOffset, 2016, 6, 9, 23))); + assertTrue(EquivalentEvaluator.equivalent(value, new DateTime(bigDecimalZoneOffset, 2016, 6, 9, 23))); value = engine.expression(library, "DateTimeSubtract5Minutes").value(); - Assert.assertTrue(EquivalentEvaluator.equivalent(value, new DateTime(bigDecimalZoneOffset, 2005, 5, 10, 5, 5))); + assertTrue(EquivalentEvaluator.equivalent(value, new DateTime(bigDecimalZoneOffset, 2005, 5, 10, 5, 5))); value = engine.expression(library, "DateTimeSubtractMinutesUnderflow").value(); - Assert.assertTrue( - EquivalentEvaluator.equivalent(value, new DateTime(bigDecimalZoneOffset, 2016, 6, 10, 4, 59))); + assertTrue(EquivalentEvaluator.equivalent(value, new DateTime(bigDecimalZoneOffset, 2016, 6, 10, 4, 59))); value = engine.expression(library, "DateTimeSubtract5Seconds").value(); - Assert.assertTrue( - EquivalentEvaluator.equivalent(value, new DateTime(bigDecimalZoneOffset, 2005, 5, 10, 5, 5, 5))); + assertTrue(EquivalentEvaluator.equivalent(value, new DateTime(bigDecimalZoneOffset, 2005, 5, 10, 5, 5, 5))); value = engine.expression(library, "DateTimeSubtract1YearInSeconds").value(); - Assert.assertTrue(EquivalentEvaluator.equivalent(value, new DateTime(bigDecimalZoneOffset, 2015, 5))); + assertTrue(EquivalentEvaluator.equivalent(value, new DateTime(bigDecimalZoneOffset, 2015, 5))); value = engine.expression(library, "DateTimeSubtract15HourPrecisionSecond") .value(); - Assert.assertTrue( - EquivalentEvaluator.equivalent(value, new DateTime(bigDecimalZoneOffset, 2016, 9, 30, 19, 20, 30))); + assertTrue(EquivalentEvaluator.equivalent(value, new DateTime(bigDecimalZoneOffset, 2016, 9, 30, 19, 20, 30))); value = engine.expression(library, "DateTimeSubtractSecondsUnderflow").value(); - Assert.assertTrue( - EquivalentEvaluator.equivalent(value, new DateTime(bigDecimalZoneOffset, 2016, 6, 10, 5, 4, 59))); + assertTrue(EquivalentEvaluator.equivalent(value, new DateTime(bigDecimalZoneOffset, 2016, 6, 10, 5, 4, 59))); value = engine.expression(library, "DateTimeSubtract5Milliseconds").value(); - Assert.assertTrue( - EquivalentEvaluator.equivalent(value, new DateTime(bigDecimalZoneOffset, 2005, 5, 10, 5, 5, 5, 5))); + assertTrue(EquivalentEvaluator.equivalent(value, new DateTime(bigDecimalZoneOffset, 2005, 5, 10, 5, 5, 5, 5))); value = engine.expression(library, "DateTimeSubtractMillisecondsUnderflow") .value(); - Assert.assertTrue( + assertTrue( EquivalentEvaluator.equivalent(value, new DateTime(bigDecimalZoneOffset, 2016, 6, 10, 5, 5, 4, 999))); value = engine.expression(library, "DateTimeSubtract2YearsAsMonths").value(); - Assert.assertTrue(EquivalentEvaluator.equivalent(value, new DateTime(bigDecimalZoneOffset, 2012))); + assertTrue(EquivalentEvaluator.equivalent(value, new DateTime(bigDecimalZoneOffset, 2012))); value = engine.expression(library, "DateTimeSubtract2YearsAsMonthsRem1").value(); - Assert.assertTrue(EquivalentEvaluator.equivalent(value, new DateTime(bigDecimalZoneOffset, 2012))); + assertTrue(EquivalentEvaluator.equivalent(value, new DateTime(bigDecimalZoneOffset, 2012))); value = engine.expression(library, "DateSubtract2YearsAsMonthsRem1").value(); - Assert.assertTrue(EquivalentEvaluator.equivalent(value, new Date(2012))); + assertTrue(EquivalentEvaluator.equivalent(value, new Date(2012))); value = engine.expression(library, "DateSubtract2YearsAsMonths").value(); - Assert.assertTrue(EquivalentEvaluator.equivalent(value, new Date(2012))); + assertTrue(EquivalentEvaluator.equivalent(value, new Date(2012))); value = engine.expression(library, "DateSubtract33Days").value(); - Assert.assertTrue(EquivalentEvaluator.equivalent(value, new Date(2014, 5))); + assertTrue(EquivalentEvaluator.equivalent(value, new Date(2014, 5))); value = engine.expression(library, "DateSubtract1Year").value(); - Assert.assertTrue(EquivalentEvaluator.equivalent(value, new Date(2013, 6))); + assertTrue(EquivalentEvaluator.equivalent(value, new Date(2013, 6))); value = engine.expression(library, "TimeSubtract5Hours").value(); - Assert.assertTrue(EquivalentEvaluator.equivalent(value, new Time(10, 59, 59, 999))); + assertTrue(EquivalentEvaluator.equivalent(value, new Time(10, 59, 59, 999))); value = engine.expression(library, "TimeSubtract1Minute").value(); - Assert.assertTrue(EquivalentEvaluator.equivalent(value, new Time(15, 58, 59, 999))); + assertTrue(EquivalentEvaluator.equivalent(value, new Time(15, 58, 59, 999))); value = engine.expression(library, "TimeSubtract1Second").value(); - Assert.assertTrue(EquivalentEvaluator.equivalent(value, new Time(15, 59, 58, 999))); + assertTrue(EquivalentEvaluator.equivalent(value, new Time(15, 59, 58, 999))); value = engine.expression(library, "TimeSubtract1Millisecond").value(); - Assert.assertTrue(EquivalentEvaluator.equivalent(value, new Time(15, 59, 58, 999))); + assertTrue(EquivalentEvaluator.equivalent(value, new Time(15, 59, 58, 999))); value = engine.expression(library, "TimeSubtract5Hours1Minute").value(); - Assert.assertTrue(EquivalentEvaluator.equivalent(value, new Time(10, 58, 59, 999))); + assertTrue(EquivalentEvaluator.equivalent(value, new Time(10, 58, 59, 999))); value = engine.expression(library, "TimeSubtract5hoursByMinute").value(); - Assert.assertTrue(EquivalentEvaluator.equivalent(value, new Time(10, 59, 59, 999))); + assertTrue(EquivalentEvaluator.equivalent(value, new Time(10, 59, 59, 999))); } /** * {@link org.opencds.cqf.cql.engine.elm.execution.TimeEvaluator#evaluate(Context)} */ @Test - public void testTime() { + void time() { var value = engine.expression(library, "TimeTest2").value(); - Assert.assertTrue(EquivalentEvaluator.equivalent(value, new Time(23, 59, 59, 999))); + assertTrue(EquivalentEvaluator.equivalent(value, new Time(23, 59, 59, 999))); } /** * {@link org.opencds.cqf.cql.engine.elm.execution.TimeOfDayEvaluator#evaluate(Context)} */ @Test - public void testTimeOfDay() { + void timeOfDay() { // TODO: uncomment once Time(x,x,x,x,x) format is fixed // Context context = new Context(library); // var value = engine.expression(library, "TimeOfDayTest").value(); @@ -1073,7 +1059,7 @@ public void testTimeOfDay() { * {@link org.opencds.cqf.cql.engine.elm.execution.TodayEvaluator#evaluate(Context)} */ @Test - public void testToday() { + void today() { var value = engine.expression(library, "DateTimeSameOrBeforeTodayTrue1").value(); assertThat(value, is(true)); @@ -1090,8 +1076,8 @@ public void testToday() { // context = new Context(library, new DateTime(TemporalHelper.getDefaultOffset(), 2016, 6, 10, 5, 5, 4, // 999)); // value = engine.expression(library, "Issue34B").value(); - // Assert.assertTrue(EquivalentEvaluator.equivalent(value, new DateTime(null, 2016, 6, 10))); - // Assert.assertTrue(((DateTime) + // Assertions.assertTrue(EquivalentEvaluator.equivalent(value, new DateTime(null, 2016, 6, 10))); + // Assertions.assertTrue(((DateTime) // result).getDateTime().getOffset().equals(TemporalHelper.getDefaultZoneOffset())); } } diff --git a/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/execution/CqlEngineTest.java b/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/execution/CqlEngineTest.java index 6f95dda5b..ec1e3a19f 100644 --- a/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/execution/CqlEngineTest.java +++ b/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/execution/CqlEngineTest.java @@ -1,16 +1,16 @@ package org.opencds.cqf.cql.engine.execution; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; +import org.junit.jupiter.api.Test; import org.opencds.cqf.cql.engine.debug.DebugMap; -import org.testng.annotations.Test; class CqlEngineTest extends CqlTestBase { @Test - void testDebugMap() { + void debugMap() { // The specific library isn't important, just that it has a debug map var debugMap = new DebugMap(); diff --git a/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/execution/CqlErrorsAndMessagingOperatorsTest.java b/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/execution/CqlErrorsAndMessagingOperatorsTest.java index a64d1f103..ace07ebb6 100644 --- a/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/execution/CqlErrorsAndMessagingOperatorsTest.java +++ b/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/execution/CqlErrorsAndMessagingOperatorsTest.java @@ -2,41 +2,41 @@ import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.is; +import static org.junit.jupiter.api.Assertions.assertEquals; import java.util.*; import java.util.function.Supplier; import org.hl7.elm.r1.VersionedIdentifier; +import org.junit.jupiter.api.Test; import org.opencds.cqf.cql.engine.data.DataProvider; import org.opencds.cqf.cql.engine.data.SystemDataProvider; import org.opencds.cqf.cql.engine.elm.executing.obfuscate.PHIObfuscator; import org.opencds.cqf.cql.engine.elm.executing.obfuscate.RedactingPHIObfuscator; -import org.testng.Assert; -import org.testng.annotations.Test; @SuppressWarnings("removal") -public class CqlErrorsAndMessagingOperatorsTest extends CqlTestBase { +class CqlErrorsAndMessagingOperatorsTest extends CqlTestBase { private static final VersionedIdentifier library = new VersionedIdentifier().withId("CqlErrorsAndMessagingOperatorsTest"); @Test - public void test_message() { + void message() { var value = engine.expression(library, "TestMessageInfo").value(); assertThat(value, is(1)); - // Assert.assertEquals(result.toString(), "100: Test Message"); + // Assertions.assertEquals(result.toString(), "100: Test Message"); value = engine.expression(library, "TestMessageWarn").value(); assertThat(value, is(2)); - // Assert.assertEquals(result.toString(), "200: You have been warned!"); + // Assertions.assertEquals(result.toString(), "200: You have been warned!"); value = engine.expression(library, "TestMessageTrace").value(); assertThat(value, is(new ArrayList(Arrays.asList(3, 4, 5)))); - // Assert.assertEquals(result.toString(), "300: This is a trace\n[3, 4, 5]"); + // Assertions.assertEquals(result.toString(), "300: This is a trace\n[3, 4, 5]"); try { value = engine.expression(library, "TestMessageError").value(); } catch (RuntimeException re) { - Assert.assertEquals(re.getMessage(), String.format("400: This is an error!%n")); + assertEquals(re.getMessage(), String.format("400: This is an error!%n")); } value = engine.expression(library, "TestMessageWithNullSeverity").value(); @@ -82,33 +82,33 @@ public void test_message() { value = engine.expression(library, "TestErrorWithNullSource").value(); assertThat(value == null, is(true)); } catch (RuntimeException re) { - Assert.assertEquals(re.getMessage(), String.format("1: This is a message%nnull")); + assertEquals(re.getMessage(), String.format("1: This is a message%nnull")); } try { value = engine.expression(library, "TestErrorWithNullCondition").value(); assertThat(value, is(1)); } catch (RuntimeException re) { - Assert.assertEquals(re.getMessage(), String.format("1: This is a message%n")); + assertEquals(re.getMessage(), String.format("1: This is a message%n")); } try { value = engine.expression(library, "TestErrorWithNullCode").value(); assertThat(value, is(1)); } catch (RuntimeException re) { - Assert.assertEquals(re.getMessage(), String.format("This is a message%n")); + assertEquals(re.getMessage(), String.format("This is a message%n")); } try { value = engine.expression(library, "TestErrorWithNullMessage").value(); assertThat(value, is(1)); } catch (RuntimeException re) { - Assert.assertEquals(re.getMessage(), String.format("1: null%n")); + assertEquals(re.getMessage(), String.format("1: null%n")); } } @Test - public void test_obfuscation() { + void obfuscation() { Map dataProviders = new HashMap<>(); dataProviders.put("urn:hl7-org:elm-types:r1", new CustomSystemDataProvider()); Environment environment = new Environment(getLibraryManager(), dataProviders, null); @@ -117,7 +117,7 @@ public void test_obfuscation() { try { e.expression(library, "TestMessageObfuscation").value(); } catch (RuntimeException result) { - Assert.assertEquals( + assertEquals( result.getMessage(), String.format("400: This source should be redacted%n%s", RedactingPHIObfuscator.REDACTED_MESSAGE)); } diff --git a/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/execution/CqlExternalFunctionsTest.java b/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/execution/CqlExternalFunctionsTest.java index 2244f70de..92ef74bb9 100644 --- a/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/execution/CqlExternalFunctionsTest.java +++ b/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/execution/CqlExternalFunctionsTest.java @@ -5,14 +5,14 @@ import java.util.Arrays; import org.hl7.elm.r1.VersionedIdentifier; +import org.junit.jupiter.api.Test; import org.opencds.cqf.cql.engine.data.SystemExternalFunctionProvider; import org.opencds.cqf.cql.engine.execution.external.MyMath; -import org.testng.annotations.Test; -public class CqlExternalFunctionsTest extends CqlTestBase { +class CqlExternalFunctionsTest extends CqlTestBase { @Test - public void testExternalFunctions() { + void externalFunctions() { VersionedIdentifier identifier = toElmIdentifier("CqlExternalFunctionsTest"); engine.getState() diff --git a/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/execution/CqlExternalFunctionsTest2.java b/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/execution/CqlExternalFunctionsTest2.java index 08aa4ef6f..9d42d2801 100644 --- a/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/execution/CqlExternalFunctionsTest2.java +++ b/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/execution/CqlExternalFunctionsTest2.java @@ -5,14 +5,14 @@ import java.util.Arrays; import org.hl7.elm.r1.VersionedIdentifier; +import org.junit.jupiter.api.Test; import org.opencds.cqf.cql.engine.data.SystemExternalFunctionProvider; import org.opencds.cqf.cql.engine.execution.external.MyMath2; -import org.testng.annotations.Test; -public class CqlExternalFunctionsTest2 extends CqlTestBase { +class CqlExternalFunctionsTest2 extends CqlTestBase { @Test - public void testExternalFunctions() { + void externalFunctions() { VersionedIdentifier identifier = toElmIdentifier("CqlExternalFunctionsTest2"); engine.getEnvironment() diff --git a/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/execution/CqlFunctionOverloadTest.java b/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/execution/CqlFunctionOverloadTest.java index fc293e761..abb80d36f 100644 --- a/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/execution/CqlFunctionOverloadTest.java +++ b/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/execution/CqlFunctionOverloadTest.java @@ -4,12 +4,12 @@ import static org.hamcrest.Matchers.is; import java.math.BigDecimal; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Test; -public class CqlFunctionOverloadTest extends CqlTestBase { +class CqlFunctionOverloadTest extends CqlTestBase { @Test - public void test_function_overloads() { + void function_overloads() { var results = engine.evaluate(toElmIdentifier("FunctionOverloadTest")); var value = results.forExpression("TestAnyFunctionWithInteger").value(); assertThat(value, is(1)); diff --git a/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/execution/CqlFunctionTest.java b/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/execution/CqlFunctionTest.java index 59dda215f..2305e176f 100644 --- a/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/execution/CqlFunctionTest.java +++ b/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/execution/CqlFunctionTest.java @@ -4,12 +4,12 @@ import static org.hamcrest.Matchers.is; import static org.hamcrest.Matchers.nullValue; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Test; -public class CqlFunctionTest extends CqlTestBase { +class CqlFunctionTest extends CqlTestBase { @Test - public void test_all_function_tests() { + void all_function_tests() { var results = engine.evaluate(toElmIdentifier("CqlFunctionTests")); var value = results.forExpression("FunctionTestStringArg").value(); assertThat(value, is("hello")); diff --git a/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/execution/CqlInternalTypeRepresentationSuiteTest.java b/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/execution/CqlInternalTypeRepresentationSuiteTest.java index 5e1c2e8c0..c5cab373a 100644 --- a/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/execution/CqlInternalTypeRepresentationSuiteTest.java +++ b/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/execution/CqlInternalTypeRepresentationSuiteTest.java @@ -1,5 +1,7 @@ package org.opencds.cqf.cql.engine.execution; +import static org.junit.jupiter.api.Assertions.*; + import java.math.BigDecimal; import java.time.LocalDateTime; import java.time.Month; @@ -8,14 +10,13 @@ import java.util.Arrays; import java.util.Collections; import java.util.LinkedHashMap; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import org.opencds.cqf.cql.engine.runtime.*; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.testng.Assert; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; -public class CqlInternalTypeRepresentationSuiteTest extends CqlTestBase { +class CqlInternalTypeRepresentationSuiteTest extends CqlTestBase { private static final Logger logger = LoggerFactory.getLogger(CqlInternalTypeRepresentationSuiteTest.class); private static final ZoneId UTC = ZoneId.of("UTC"); @@ -26,7 +27,6 @@ public class CqlInternalTypeRepresentationSuiteTest extends CqlTestBase { private static final LocalDateTime NON_DST_2023_11_13 = LocalDateTime.of(2023, Month.NOVEMBER, 13, 0, 0, 0); private static final LocalDateTime NON_DST_2018_01_01 = LocalDateTime.of(2018, Month.JANUARY, 1, 7, 0, 0); - @DataProvider private static Object[][] timeZones() { return new Object[][] { {UTC, DST_2023_11_01}, {MONTREAL, DST_2023_11_01}, {REGINA, DST_2023_11_01}, @@ -35,106 +35,107 @@ private static Object[][] timeZones() { }; } - @Test(dataProvider = "timeZones") - public void test_all_internal_type_representation(ZoneId zoneId, LocalDateTime now) { + @ParameterizedTest + @MethodSource("timeZones") + void all_internal_type_representation(ZoneId zoneId, LocalDateTime now) { var results = engine.evaluate(toElmIdentifier("CqlInternalTypeRepresentationSuite"), ZonedDateTime.of(now, zoneId)); final BigDecimal bigDecimalZoneOffset = getBigDecimalZoneOffset(); var value = results.forExpression("BoolTrue").value(); - Assert.assertTrue(value instanceof Boolean); - Assert.assertTrue((Boolean) value); + assertTrue(value instanceof Boolean); + assertTrue((Boolean) value); value = results.forExpression("BoolFalse").value(); - Assert.assertTrue(value instanceof Boolean); - Assert.assertTrue(!(Boolean) value); + assertTrue(value instanceof Boolean); + assertFalse((Boolean) value); value = results.forExpression("IntOne").value(); - Assert.assertTrue(value instanceof Integer); - Assert.assertTrue((Integer) value == 1); + assertTrue(value instanceof Integer); + assertTrue((Integer) value == 1); value = results.forExpression("DecimalTenth").value(); - Assert.assertTrue(value instanceof BigDecimal); - Assert.assertTrue(((BigDecimal) value).compareTo(new BigDecimal("0.1")) == 0); + assertTrue(value instanceof BigDecimal); + assertEquals(0, ((BigDecimal) value).compareTo(new BigDecimal("0.1"))); value = results.forExpression("StringTrue").value(); - Assert.assertTrue(value instanceof String); - Assert.assertTrue(value.equals("true")); + assertTrue(value instanceof String); + assertEquals("true", value); value = results.forExpression("DateTimeX").value(); - Assert.assertTrue(value instanceof DateTime); - Assert.assertTrue(((DateTime) value).equal(new DateTime(new BigDecimal("0.0"), 2012, 2, 15, 12, 10, 59, 456))); + assertTrue(value instanceof DateTime); + assertTrue(((DateTime) value).equal(new DateTime(new BigDecimal("0.0"), 2012, 2, 15, 12, 10, 59, 456))); value = results.forExpression("DateTimeFX").value(); - Assert.assertTrue(value instanceof DateTime); - Assert.assertTrue(((DateTime) value).equal(new DateTime(new BigDecimal("0.0"), 2012, 2, 15, 12, 10, 59, 456))); + assertTrue(value instanceof DateTime); + assertTrue(((DateTime) value).equal(new DateTime(new BigDecimal("0.0"), 2012, 2, 15, 12, 10, 59, 456))); value = results.forExpression("TimeX").value(); - Assert.assertTrue(value instanceof Time); - Assert.assertTrue(((Time) value).equal(new Time(12, 10, 59, 456))); + assertTrue(value instanceof Time); + assertTrue(((Time) value).equal(new Time(12, 10, 59, 456))); value = results.expressionResults.get("DateTime_Year").value(); - Assert.assertTrue(value instanceof DateTime); - Assert.assertTrue(((DateTime) value).equal(new DateTime(bigDecimalZoneOffset, 2012))); + assertTrue(value instanceof DateTime); + assertTrue(((DateTime) value).equal(new DateTime(bigDecimalZoneOffset, 2012))); value = results.expressionResults.get("DateTime_Month").value(); - Assert.assertTrue(value instanceof DateTime); - Assert.assertTrue(((DateTime) value).equal(new DateTime(bigDecimalZoneOffset, 2012, 2))); + assertTrue(value instanceof DateTime); + assertTrue(((DateTime) value).equal(new DateTime(bigDecimalZoneOffset, 2012, 2))); value = results.expressionResults.get("DateTime_Day").value(); - Assert.assertTrue(value instanceof DateTime); - Assert.assertTrue(((DateTime) value).equal(new DateTime(bigDecimalZoneOffset, 2012, 2, 15))); + assertTrue(value instanceof DateTime); + assertTrue(((DateTime) value).equal(new DateTime(bigDecimalZoneOffset, 2012, 2, 15))); value = results.expressionResults.get("DateTime_Hour").value(); - Assert.assertTrue(value instanceof DateTime); - Assert.assertTrue(((DateTime) value).equal(new DateTime(bigDecimalZoneOffset, 2012, 2, 15, 12))); + assertTrue(value instanceof DateTime); + assertTrue(((DateTime) value).equal(new DateTime(bigDecimalZoneOffset, 2012, 2, 15, 12))); value = results.expressionResults.get("DateTime_Minute").value(); - Assert.assertTrue(value instanceof DateTime); - Assert.assertTrue(((DateTime) value).equal(new DateTime(bigDecimalZoneOffset, 2012, 2, 15, 12, 10))); + assertTrue(value instanceof DateTime); + assertTrue(((DateTime) value).equal(new DateTime(bigDecimalZoneOffset, 2012, 2, 15, 12, 10))); value = results.expressionResults.get("DateTime_Second").value(); - Assert.assertTrue(value instanceof DateTime); - Assert.assertTrue(((DateTime) value).equal(new DateTime(bigDecimalZoneOffset, 2012, 2, 15, 12, 10, 59))); + assertTrue(value instanceof DateTime); + assertTrue(((DateTime) value).equal(new DateTime(bigDecimalZoneOffset, 2012, 2, 15, 12, 10, 59))); value = results.expressionResults.get("DateTime_Millisecond").value(); - Assert.assertTrue(value instanceof DateTime); - Assert.assertTrue(((DateTime) value).equal(new DateTime(bigDecimalZoneOffset, 2012, 2, 15, 12, 10, 59, 456))); + assertTrue(value instanceof DateTime); + assertTrue(((DateTime) value).equal(new DateTime(bigDecimalZoneOffset, 2012, 2, 15, 12, 10, 59, 456))); value = results.expressionResults.get("DateTime_TimezoneOffset").value(); - Assert.assertTrue(value instanceof DateTime); - Assert.assertTrue(((DateTime) value).equal(new DateTime(new BigDecimal("-8.0"), 2012, 2, 15, 12, 10, 59, 456))); + assertTrue(value instanceof DateTime); + assertTrue(((DateTime) value).equal(new DateTime(new BigDecimal("-8.0"), 2012, 2, 15, 12, 10, 59, 456))); value = results.expressionResults.get("Time_Hour").value(); - Assert.assertTrue(value instanceof Time); - Assert.assertTrue(((Time) value).equal(new Time(12))); + assertTrue(value instanceof Time); + assertTrue(((Time) value).equal(new Time(12))); value = results.expressionResults.get("Time_Minute").value(); - Assert.assertTrue(value instanceof Time); - Assert.assertTrue(((Time) value).equal(new Time(12, 10))); + assertTrue(value instanceof Time); + assertTrue(((Time) value).equal(new Time(12, 10))); value = results.expressionResults.get("Time_Second").value(); - Assert.assertTrue(value instanceof Time); - Assert.assertTrue(((Time) value).equal(new Time(12, 10, 59))); + assertTrue(value instanceof Time); + assertTrue(((Time) value).equal(new Time(12, 10, 59))); value = results.expressionResults.get("Time_Millisecond").value(); - Assert.assertTrue(value instanceof Time); - Assert.assertTrue(((Time) value).equal(new Time(12, 10, 59, 456))); + assertTrue(value instanceof Time); + assertTrue(((Time) value).equal(new Time(12, 10, 59, 456))); value = results.expressionResults.get("Clinical_quantity").value(); - Assert.assertTrue(value instanceof Quantity); - Assert.assertTrue(((Quantity) value) + assertTrue(value instanceof Quantity); + assertTrue(((Quantity) value) .equal(new Quantity().withValue(new BigDecimal(12)).withUnit("a"))); value = results.expressionResults.get("Clinical_QuantityA").value(); - Assert.assertTrue(value instanceof Quantity); - Assert.assertTrue(((Quantity) value) + assertTrue(value instanceof Quantity); + assertTrue(((Quantity) value) .equal(new Quantity().withValue(new BigDecimal(12)).withUnit("a"))); value = results.expressionResults.get("Clinical_CodeA").value(); - Assert.assertTrue(value instanceof Code); - Assert.assertTrue(((Code) value) + assertTrue(value instanceof Code); + assertTrue(((Code) value) .equal(new Code() .withCode("12345") .withSystem("http://loinc.org") @@ -142,8 +143,8 @@ public void test_all_internal_type_representation(ZoneId zoneId, LocalDateTime n .withDisplay("Test Code"))); value = results.expressionResults.get("Clinical_ConceptA").value(); - Assert.assertTrue(value instanceof Concept); - Assert.assertTrue(((Concept) value) + assertTrue(value instanceof Concept); + assertTrue(((Concept) value) .equal(new Concept() .withCode(new Code() .withCode("12345") @@ -156,8 +157,8 @@ public void test_all_internal_type_representation(ZoneId zoneId, LocalDateTime n elements.put("a", 1); elements.put("b", 2); value = results.expressionResults.get("Structured_tuple").value(); - Assert.assertTrue(value instanceof Tuple); - Assert.assertTrue(((Tuple) value).equal(new Tuple(engine.getState()).withElements(elements))); + assertTrue(value instanceof Tuple); + assertTrue(((Tuple) value).equal(new Tuple(engine.getState()).withElements(elements))); elements.clear(); elements.put("class", "Portable CQL Test Suite"); @@ -166,62 +167,62 @@ public void test_all_internal_type_representation(ZoneId zoneId, LocalDateTime n elements.put("developer", "Christopher Schuler"); value = results.expressionResults.get("Structured_TupleA").value(); - Assert.assertTrue(value instanceof Tuple); - Assert.assertTrue(((Tuple) value).equal(new Tuple(engine.getState()).withElements(elements))); + assertTrue(value instanceof Tuple); + assertTrue(((Tuple) value).equal(new Tuple(engine.getState()).withElements(elements))); value = results.expressionResults.get("Interval_Open").value(); - Assert.assertTrue(value instanceof Interval); - Assert.assertTrue(((Interval) value) + assertTrue(value instanceof Interval); + assertTrue(((Interval) value) .equal(new Interval( new DateTime(bigDecimalZoneOffset, 2012, 1, 1), false, new DateTime(bigDecimalZoneOffset, 2013, 1, 1), false))); value = results.expressionResults.get("Interval_LeftOpen").value(); - Assert.assertTrue(value instanceof Interval); - Assert.assertTrue(((Interval) value) + assertTrue(value instanceof Interval); + assertTrue(((Interval) value) .equal(new Interval( new DateTime(bigDecimalZoneOffset, 2012, 1, 1), false, new DateTime(bigDecimalZoneOffset, 2013, 1, 1), true))); value = results.expressionResults.get("Interval_RightOpen").value(); - Assert.assertTrue(value instanceof Interval); - Assert.assertTrue(((Interval) value) + assertTrue(value instanceof Interval); + assertTrue(((Interval) value) .equal(new Interval( new DateTime(bigDecimalZoneOffset, 2012, 1, 1), true, new DateTime(bigDecimalZoneOffset, 2013, 1, 1), false))); value = results.expressionResults.get("Interval_Closed").value(); - Assert.assertTrue(value instanceof Interval); - Assert.assertTrue(((Interval) value) + assertTrue(value instanceof Interval); + assertTrue(((Interval) value) .equal(new Interval( new DateTime(bigDecimalZoneOffset, 2012, 1, 1), true, new DateTime(bigDecimalZoneOffset, 2013, 1, 1), true))); value = results.expressionResults.get("List_BoolList").value(); - Assert.assertTrue(value instanceof Iterable); + assertTrue(value instanceof Iterable); Boolean listComp = CqlList.equal((Iterable) value, Arrays.asList(true, false, true), engine.getState()); - Assert.assertTrue(listComp != null && listComp); + assertTrue(listComp != null && listComp); value = results.expressionResults.get("List_IntList").value(); - Assert.assertTrue(value instanceof Iterable); + assertTrue(value instanceof Iterable); listComp = CqlList.equal((Iterable) value, Arrays.asList(9, 7, 8), engine.getState()); - Assert.assertTrue(listComp != null && listComp); + assertTrue(listComp != null && listComp); value = results.expressionResults.get("List_DecimalList").value(); - Assert.assertTrue(value instanceof Iterable); + assertTrue(value instanceof Iterable); listComp = CqlList.equal( (Iterable) value, Arrays.asList(new BigDecimal("1.0"), new BigDecimal("2.1"), new BigDecimal("3.2")), engine.getState()); - Assert.assertTrue(listComp != null && listComp); + assertTrue(listComp != null && listComp); value = results.expressionResults.get("List_StringList").value(); - Assert.assertTrue(value instanceof Iterable); + assertTrue(value instanceof Iterable); listComp = CqlList.equal((Iterable) value, Arrays.asList("a", "bee", "see"), engine.getState()); - Assert.assertTrue(listComp != null && listComp); + assertTrue(listComp != null && listComp); value = results.expressionResults.get("List_DateTimeList").value(); - Assert.assertTrue(value instanceof Iterable); + assertTrue(value instanceof Iterable); listComp = CqlList.equal( (Iterable) value, Arrays.asList( @@ -229,18 +230,18 @@ public void test_all_internal_type_representation(ZoneId zoneId, LocalDateTime n new DateTime(new BigDecimal("0.0"), 2012, 3, 15, 12, 10, 59, 456), new DateTime(new BigDecimal("0.0"), 2012, 4, 15, 12, 10, 59, 456)), engine.getState()); - Assert.assertTrue(listComp != null && listComp); + assertTrue(listComp != null && listComp); value = results.expressionResults.get("List_TimeList").value(); - Assert.assertTrue(value instanceof Iterable); + assertTrue(value instanceof Iterable); listComp = CqlList.equal( (Iterable) value, Arrays.asList(new Time(12, 10, 59, 456), new Time(13, 10, 59, 456), new Time(14, 10, 59, 456)), engine.getState()); - Assert.assertTrue(listComp != null && listComp); + assertTrue(listComp != null && listComp); value = results.expressionResults.get("List_QuantityList").value(); - Assert.assertTrue(value instanceof Iterable); + assertTrue(value instanceof Iterable); listComp = CqlList.equal( (Iterable) value, Arrays.asList( @@ -248,10 +249,10 @@ public void test_all_internal_type_representation(ZoneId zoneId, LocalDateTime n new Quantity().withValue(new BigDecimal("2.1")).withUnit("m"), new Quantity().withValue(new BigDecimal("3.2")).withUnit("m")), engine.getState()); - Assert.assertTrue(listComp != null && listComp); + assertTrue(listComp != null && listComp); value = results.expressionResults.get("List_CodeList").value(); - Assert.assertTrue(value instanceof Iterable); + assertTrue(value instanceof Iterable); listComp = CqlList.equal( (Iterable) value, Arrays.asList( @@ -266,10 +267,10 @@ public void test_all_internal_type_representation(ZoneId zoneId, LocalDateTime n .withVersion("1") .withDisplay("Another Test Code")), engine.getState()); - Assert.assertTrue(listComp != null && listComp); + assertTrue(listComp != null && listComp); value = results.expressionResults.get("List_ConceptList").value(); - Assert.assertTrue(value instanceof Iterable); + assertTrue(value instanceof Iterable); listComp = CqlList.equal( (Iterable) value, Arrays.asList( @@ -288,7 +289,7 @@ public void test_all_internal_type_representation(ZoneId zoneId, LocalDateTime n .withDisplay("Another Test Code")) .withDisplay("Another Test Concept")), engine.getState()); - Assert.assertTrue(listComp != null && listComp); + assertTrue(listComp != null && listComp); elements.clear(); elements.put("a", 1); @@ -297,25 +298,25 @@ public void test_all_internal_type_representation(ZoneId zoneId, LocalDateTime n elements2.put("x", 2); elements2.put("z", "3"); value = results.expressionResults.get("List_TupleList").value(); - Assert.assertTrue(value instanceof Iterable); + assertTrue(value instanceof Iterable); listComp = CqlList.equal( (Iterable) value, Arrays.asList( new Tuple(engine.getState()).withElements(elements), new Tuple(engine.getState()).withElements(elements2)), engine.getState()); - Assert.assertTrue(listComp != null && listComp); + assertTrue(listComp != null && listComp); value = results.expressionResults.get("List_ListList").value(); - Assert.assertTrue(value instanceof Iterable); + assertTrue(value instanceof Iterable); listComp = CqlList.equal( (Iterable) value, Arrays.asList(Arrays.asList(1, 2, 3), Arrays.asList("a", "b", "c")), engine.getState()); - Assert.assertTrue(listComp != null && listComp); + assertTrue(listComp != null && listComp); value = results.expressionResults.get("List_IntervalList").value(); - Assert.assertTrue(value instanceof Iterable); + assertTrue(value instanceof Iterable); listComp = CqlList.equal( (Iterable) value, Arrays.asList( @@ -323,16 +324,16 @@ public void test_all_internal_type_representation(ZoneId zoneId, LocalDateTime n new Interval(5, false, 9, false), new Interval(8, true, 10, false)), engine.getState()); - Assert.assertTrue(listComp != null && listComp); + assertTrue(listComp != null && listComp); value = results.expressionResults.get("List_MixedList").value(); - Assert.assertTrue(value instanceof Iterable); + assertTrue(value instanceof Iterable); listComp = CqlList.equal((Iterable) value, Arrays.asList(1, "two", 3), engine.getState()); - Assert.assertTrue(listComp != null && listComp); + assertTrue(listComp != null && listComp); value = results.expressionResults.get("List_EmptyList").value(); - Assert.assertTrue(value instanceof Iterable); + assertTrue(value instanceof Iterable); listComp = CqlList.equal((Iterable) value, Collections.EMPTY_LIST, engine.getState()); - Assert.assertTrue(listComp != null && listComp); + assertTrue(listComp != null && listComp); } } diff --git a/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/execution/CqlLibraryLoadingTest.java b/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/execution/CqlLibraryLoadingTest.java index 413a39036..cc304644b 100644 --- a/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/execution/CqlLibraryLoadingTest.java +++ b/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/execution/CqlLibraryLoadingTest.java @@ -2,35 +2,38 @@ import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.containsString; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.fail; import org.cqframework.cql.cql2elm.CqlIncludeException; import org.hl7.elm.r1.VersionedIdentifier; +import org.junit.jupiter.api.Test; import org.opencds.cqf.cql.engine.exception.CqlException; -import org.testng.Assert; -import org.testng.annotations.Test; -public class CqlLibraryLoadingTest extends CqlTestBase { +class CqlLibraryLoadingTest extends CqlTestBase { - @Test(expectedExceptions = IllegalArgumentException.class) - public void missing_identifier_throws_error() { - engine.evaluate((VersionedIdentifier) null); + @Test + void missing_identifier_throws_error() { + assertThrows(IllegalArgumentException.class, () -> { + engine.evaluate((VersionedIdentifier) null); + }); } @Test - public void missing_library_throws_error() { + void missing_library_throws_error() { try { engine.evaluate(new VersionedIdentifier().withId("Not a library")); - Assert.fail(); + fail(); } catch (CqlIncludeException e) { assertThat(e.getMessage(), containsString("not load source")); } } @Test - public void bad_library_throws_error() { + void bad_library_throws_error() { try { engine.evaluate(new VersionedIdentifier().withId("CqlLibraryLoadingTest")); - Assert.fail(); + fail(); } catch (CqlException e) { assertThat(e.getMessage(), containsString("loaded, but had errors")); } diff --git a/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/execution/CqlListDistinguishedOverloadsTest.java b/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/execution/CqlListDistinguishedOverloadsTest.java index f7a93ca64..67f86cfb9 100644 --- a/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/execution/CqlListDistinguishedOverloadsTest.java +++ b/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/execution/CqlListDistinguishedOverloadsTest.java @@ -1,21 +1,21 @@ package org.opencds.cqf.cql.engine.execution; -import static org.testng.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import org.hl7.elm.r1.VersionedIdentifier; -import org.testng.annotations.Ignore; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; @SuppressWarnings("removal") -public class CqlListDistinguishedOverloadsTest extends CqlTestBase { +class CqlListDistinguishedOverloadsTest extends CqlTestBase { private static final VersionedIdentifier library = new VersionedIdentifier().withId("CqlListDistinguishedOverloads"); @Test - @Ignore("There's a bug in the cql engine that is causing it to select the wrong function overload at runtime") - public void test_list_overload() { + @Disabled("There's a bug in the cql engine that is causing it to select the wrong function overload at runtime") + void list_overload() { var value = engine.expression(library, "Test").value(); - assertEquals(value, "1, 2, 3, 4, 5"); + assertEquals("1, 2, 3, 4, 5", value); } } diff --git a/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/execution/CqlLogicalOperatorsTest.java b/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/execution/CqlLogicalOperatorsTest.java index 05e18ed3e..f75f4abf7 100644 --- a/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/execution/CqlLogicalOperatorsTest.java +++ b/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/execution/CqlLogicalOperatorsTest.java @@ -4,12 +4,12 @@ import static org.hamcrest.Matchers.is; import static org.hamcrest.Matchers.nullValue; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Test; -public class CqlLogicalOperatorsTest extends CqlTestBase { +class CqlLogicalOperatorsTest extends CqlTestBase { @Test - public void test_all_logical_operators() { + void all_logical_operators() { var results = engine.evaluate(toElmIdentifier("CqlLogicalOperatorsTest")); var value = results.forExpression("TrueAndTrue").value(); assertThat(value, is(true)); diff --git a/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/execution/CqlMainSuiteTest.java b/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/execution/CqlMainSuiteTest.java index 26769f527..42024405e 100644 --- a/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/execution/CqlMainSuiteTest.java +++ b/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/execution/CqlMainSuiteTest.java @@ -1,21 +1,21 @@ package org.opencds.cqf.cql.engine.execution; -import static org.testng.Assert.assertFalse; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; import java.time.ZonedDateTime; import java.util.*; import org.cqframework.cql.cql2elm.CqlCompilerException; import org.cqframework.cql.cql2elm.CqlCompilerOptions; -import org.testng.Assert; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Test; -public class CqlMainSuiteTest extends CqlTestBase { +class CqlMainSuiteTest extends CqlTestBase { private static final ZonedDateTime evalTime = ZonedDateTime.of(2018, 1, 1, 7, 0, 0, 0, TimeZone.getDefault().toZoneId()); @Test - public void test_cql_main_test_suite_compiles() { + void cql_main_test_suite_compiles() { var errors = new ArrayList(); this.getLibrary(toElmIdentifier("CqlTestSuite"), errors, testCompilerOptions()); assertFalse( @@ -24,7 +24,7 @@ public void test_cql_main_test_suite_compiles() { } @Test - public void test_all_portable_cql_engine_tests() { + void all_portable_cql_engine_tests() { var e = getEngine(testCompilerOptions()); // TODO: It'd be interesting to be able to inspect the // possible set of expressions from the CQL engine API @@ -34,7 +34,7 @@ public void test_all_portable_cql_engine_tests() { for (var entry : result.expressionResults.entrySet()) { if (entry.getKey().toString().startsWith("test")) { if (((ExpressionResult) entry.getValue()).value() != null) { - Assert.assertEquals( + assertEquals( (String) ((ExpressionResult) entry.getValue()).value(), entry.getKey().toString().replaceAll("test_", "") + " TEST PASSED"); } @@ -43,7 +43,7 @@ public void test_all_portable_cql_engine_tests() { } @Test - public void test_cql_timezone_tests() { + void cql_timezone_tests() { var e = getEngine(testCompilerOptions()); // TODO: It'd be interesting to be able to inspect the // possible set of expressions from the CQL engine API @@ -54,7 +54,7 @@ public void test_cql_timezone_tests() { for (var entry : result.expressionResults.entrySet()) { if (entry.getKey().toString().startsWith("test")) { if (((ExpressionResult) entry.getValue()).value() != null) { - Assert.assertEquals( + assertEquals( (String) ((ExpressionResult) entry.getValue()).value(), entry.getKey().toString().replaceAll("test_", "") + " TEST PASSED"); } diff --git a/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/execution/CqlNulLogicalOperatorsTest.java b/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/execution/CqlNulLogicalOperatorsTest.java index 0267f4078..e9b75ebed 100644 --- a/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/execution/CqlNulLogicalOperatorsTest.java +++ b/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/execution/CqlNulLogicalOperatorsTest.java @@ -3,19 +3,19 @@ import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.is; import static org.hamcrest.Matchers.nullValue; +import static org.junit.jupiter.api.Assertions.assertTrue; import java.math.BigDecimal; import java.util.Collections; +import org.junit.jupiter.api.Test; import org.opencds.cqf.cql.engine.elm.executing.EquivalentEvaluator; import org.opencds.cqf.cql.engine.runtime.DateTime; import org.opencds.cqf.cql.engine.runtime.Time; -import org.testng.Assert; -import org.testng.annotations.Test; -public class CqlNulLogicalOperatorsTest extends CqlTestBase { +class CqlNulLogicalOperatorsTest extends CqlTestBase { @Test - public void test_all_null_logical_operators() { + void all_null_logical_operators() { final BigDecimal bigDecimalZoneOffset = getBigDecimalZoneOffset(); var results = engine.evaluate(toElmIdentifier("CqlNullologicalOperatorsTest")); var value = results.forExpression("CoalesceANull").value(); @@ -40,16 +40,16 @@ public void test_all_null_logical_operators() { assertThat(value, is(Collections.singletonList("a"))); value = results.forExpression("DateTimeCoalesce").value(); - Assert.assertTrue(EquivalentEvaluator.equivalent(value, new DateTime(bigDecimalZoneOffset, 2012, 5, 18))); + assertTrue(EquivalentEvaluator.equivalent(value, new DateTime(bigDecimalZoneOffset, 2012, 5, 18))); value = results.forExpression("DateTimeListCoalesce").value(); - Assert.assertTrue(EquivalentEvaluator.equivalent(value, new DateTime(bigDecimalZoneOffset, 2012, 5, 18))); + assertTrue(EquivalentEvaluator.equivalent(value, new DateTime(bigDecimalZoneOffset, 2012, 5, 18))); value = results.forExpression("TimeCoalesce").value(); - Assert.assertTrue(EquivalentEvaluator.equivalent(value, new Time(5, 15, 33, 556))); + assertTrue(EquivalentEvaluator.equivalent(value, new Time(5, 15, 33, 556))); value = results.forExpression("TimeListCoalesce").value(); - Assert.assertTrue(EquivalentEvaluator.equivalent(value, new Time(5, 15, 33, 556))); + assertTrue(EquivalentEvaluator.equivalent(value, new Time(5, 15, 33, 556))); value = results.forExpression("IsNullTrue").value(); assertThat(value, is(true)); diff --git a/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/execution/CqlPerformanceIT.java b/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/execution/CqlPerformanceIT.java index 3fde727ec..1bc182602 100644 --- a/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/execution/CqlPerformanceIT.java +++ b/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/execution/CqlPerformanceIT.java @@ -1,6 +1,6 @@ package org.opencds.cqf.cql.engine.execution; -import static org.testng.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertTrue; import java.io.IOException; import java.time.Duration; @@ -10,9 +10,9 @@ import org.cqframework.cql.cql2elm.CqlCompilerOptions; import org.fhir.ucum.UcumException; import org.hl7.elm.r1.VersionedIdentifier; +import org.junit.jupiter.api.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.testng.annotations.Test; public class CqlPerformanceIT extends CqlTestBase { @@ -23,14 +23,14 @@ public class CqlPerformanceIT extends CqlTestBase { // This test is a basically empty library that tests how long the engine // initialization takes. @Test - public void testEngineInit() throws IOException, UcumException { + void engineInit() throws IOException, UcumException { VersionedIdentifier libraryId = toElmIdentifier("Test"); runPerformanceTest(libraryId, 1.0, null); } // This test is for the various CQL operators @Test - public void testMainSuite() throws IOException, UcumException { + void mainSuite() throws IOException, UcumException { VersionedIdentifier libraryId = toElmIdentifier("CqlPerformanceTest", "1"); ZonedDateTime date = ZonedDateTime.of(2018, 1, 1, 7, 0, 0, 0, TimeZone.getDefault().toZoneId()); @@ -50,7 +50,7 @@ public void testErrorSuite() throws IOException, UcumException { // This test is to check the validity of the internal representation of the CQL // types (OPTIONAL) @Test - public void testInternalTypeRepresentationSuite() throws IOException, UcumException { + void internalTypeRepresentationSuite() throws IOException, UcumException { VersionedIdentifier libraryId = toElmIdentifier("CqlInternalTypeRepresentationSuite", "1"); runPerformanceTest(libraryId, 10.0, null); } diff --git a/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/execution/CqlQueryTest.java b/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/execution/CqlQueryTest.java index 6e349b5ba..762ae4361 100644 --- a/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/execution/CqlQueryTest.java +++ b/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/execution/CqlQueryTest.java @@ -1,55 +1,57 @@ package org.opencds.cqf.cql.engine.execution; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; + import java.util.*; +import org.junit.jupiter.api.Test; import org.opencds.cqf.cql.engine.elm.executing.EquivalentEvaluator; import org.opencds.cqf.cql.engine.runtime.Tuple; -import org.testng.Assert; -import org.testng.annotations.Test; -public class CqlQueryTest extends CqlTestBase { +class CqlQueryTest extends CqlTestBase { @Test - public void test_all_query_operators() { + void all_query_operators() { var results = engine.evaluate(toElmIdentifier("CqlQueryTests")); var value = results.forExpression("RightShift").value(); - Assert.assertEquals(value, Arrays.asList(null, "A", "B", "C")); + assertEquals(value, Arrays.asList(null, "A", "B", "C")); value = results.forExpression("LeftShift").value(); - Assert.assertEquals(value, Arrays.asList("B", "C", "D", null)); + assertEquals(value, Arrays.asList("B", "C", "D", null)); value = results.forExpression("LeftShift2").value(); - Assert.assertEquals(value, Arrays.asList("B", "C", "D", null)); + assertEquals(value, Arrays.asList("B", "C", "D", null)); value = results.forExpression("Multisource").value(); - Assert.assertTrue(value instanceof List); + assertTrue(value instanceof List); List list = (List) value; - Assert.assertTrue(list.size() == 1); - Assert.assertTrue(list.get(0) instanceof Tuple); + assertEquals(1, list.size()); + assertTrue(list.get(0) instanceof Tuple); Tuple resultTuple = (Tuple) list.get(0); - Assert.assertTrue(resultTuple.getElements().containsKey("A") + assertTrue(resultTuple.getElements().containsKey("A") && resultTuple.getElements().containsKey("B")); value = results.forExpression("Complex Multisource").value(); - Assert.assertTrue(value instanceof List); + assertTrue(value instanceof List); list = (List) value; - Assert.assertTrue(list.size() == 4); + assertEquals(4, list.size()); value = results.forExpression("Let Test Fails").value(); value = results.forExpression("Triple Source Query").value(); - Assert.assertTrue(value instanceof List); + assertTrue(value instanceof List); list = (List) value; - Assert.assertTrue(list.size() == 27); + assertEquals(27, list.size()); value = results.forExpression("Let Expression in Multi Source Query").value(); - Assert.assertTrue(value instanceof List); + assertTrue(value instanceof List); list = (List) value; - Assert.assertTrue(list.size() == 1); - Assert.assertTrue(EquivalentEvaluator.equivalent(list.get(0), 3)); + assertEquals(1, list.size()); + assertTrue(EquivalentEvaluator.equivalent(list.get(0), 3)); value = results.forExpression("Accessing Third Element of Triple Source Query") .value(); - Assert.assertTrue(value instanceof List); + assertTrue(value instanceof List); list = (List) value; - Assert.assertTrue(list.size() == 1); - Assert.assertTrue(EquivalentEvaluator.equivalent(list.get(0), 3)); + assertEquals(1, list.size()); + assertTrue(EquivalentEvaluator.equivalent(list.get(0), 3)); } } diff --git a/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/execution/CqlStringOperatorsTest.java b/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/execution/CqlStringOperatorsTest.java index 070019fe3..2c48ced35 100644 --- a/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/execution/CqlStringOperatorsTest.java +++ b/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/execution/CqlStringOperatorsTest.java @@ -3,15 +3,16 @@ import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.is; import static org.hamcrest.Matchers.nullValue; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; import java.util.*; -import org.testng.Assert; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Test; -public class CqlStringOperatorsTest extends CqlTestBase { +class CqlStringOperatorsTest extends CqlTestBase { @Test - public void test_all_string_operators() { + void all_string_operators() { var results = engine.evaluate(toElmIdentifier("CqlStringOperatorsTest")); var value = results.forExpression("CombineNull").value(); assertThat(value, is(nullValue())); @@ -95,19 +96,19 @@ public void test_all_string_operators() { assertThat(value, is(true)); value = results.forExpression("LastPositionOfNull").value(); - Assert.assertTrue(value == null); + assertTrue(value == null); value = results.forExpression("LastPositionOfNull1").value(); - Assert.assertTrue(value == null); + assertTrue(value == null); value = results.forExpression("LastPositionOfNull2").value(); - Assert.assertTrue(value == null); + assertTrue(value == null); value = results.forExpression("LastPositionOf1").value(); - Assert.assertTrue((Integer) value == 1); + assertTrue((Integer) value == 1); value = results.forExpression("LastPositionOf2").value(); - Assert.assertTrue((Integer) value == 11); + assertTrue((Integer) value == 11); value = results.forExpression("LengthNullString").value(); assertThat(value, is(nullValue())); @@ -200,19 +201,19 @@ public void test_all_string_operators() { assertThat(value, is(new ArrayList(Arrays.asList("a", "b")))); value = results.forExpression("StartsWithNull").value(); - Assert.assertTrue(value == null); + assertTrue(value == null); value = results.forExpression("StartsWithNull1").value(); - Assert.assertTrue(value == null); + assertTrue(value == null); value = results.forExpression("StartsWithNull2").value(); - Assert.assertTrue(value == null); + assertTrue(value == null); value = results.forExpression("StartsWithTrue1").value(); - Assert.assertTrue((Boolean) value); + assertTrue((Boolean) value); value = results.forExpression("StartsWithFalse1").value(); - Assert.assertTrue(!(Boolean) value); + assertFalse((Boolean) value); value = results.forExpression("SubstringNullNull").value(); assertThat(value, is(nullValue())); diff --git a/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/execution/CqlTestBase.java b/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/execution/CqlTestBase.java index ee04bb943..517c6b713 100644 --- a/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/execution/CqlTestBase.java +++ b/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/execution/CqlTestBase.java @@ -7,9 +7,8 @@ import java.util.List; import org.cqframework.cql.cql2elm.*; import org.hl7.elm.r1.Library; +import org.junit.jupiter.api.BeforeEach; import org.opencds.cqf.cql.engine.runtime.TemporalHelper; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.DataProvider; public class CqlTestBase { static final String NORTH_AMERICA_MOUNTAIN = @@ -24,7 +23,6 @@ public class CqlTestBase { static final String INDIAN_COCOS = "Indian/Cocos"; static final String PACIFIC_CHATHAM = "Pacific/Chatham"; - @DataProvider static Object[][] timezones() { return new Object[][] { {NORTH_AMERICA_MOUNTAIN}, @@ -101,7 +99,7 @@ public static CqlEngine getEngine(CqlCompilerOptions cqlCompilerOptions) { Environment environment; CqlEngine engine; - @BeforeMethod + @BeforeEach protected void beforeEachMethod() { environment = new Environment(getLibraryManager()); engine = new CqlEngine(environment); diff --git a/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/execution/CqlTimezoneTests.java b/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/execution/CqlTimezoneTests.java index 5e7221c69..10548cba4 100644 --- a/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/execution/CqlTimezoneTests.java +++ b/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/execution/CqlTimezoneTests.java @@ -1,50 +1,47 @@ package org.opencds.cqf.cql.engine.execution; +import static org.junit.jupiter.api.Assertions.assertEquals; + import java.time.ZonedDateTime; import java.util.TimeZone; import org.hl7.elm.r1.VersionedIdentifier; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.testng.annotations.*; -import org.testng.asserts.SoftAssert; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; @SuppressWarnings("removal") -public class CqlTimezoneTests extends CqlTestBase { - private static final Logger logger = LoggerFactory.getLogger(CqlTimezoneTests.class); - +class CqlTimezoneTests extends CqlTestBase { private static final VersionedIdentifier library = new VersionedIdentifier().withId("CqlTimezoneTests"); - @Test(dataProvider = "timezones") - public void testExpressionsProblematicForWeirdTimezones(String timezone) { + @MethodSource("timezones") + @ParameterizedTest + void expressionsProblematicForWeirdTimezones(String timezone) { final String oldTz = System.getProperty("user.timezone"); + /* spell-checker: disable */ // This is the ONLY thing that will work. System.setProperty() and -Duser.timezone do NOT work TimeZone.setDefault(TimeZone.getTimeZone(timezone)); engine.getState().setEvaluationDateTime(ZonedDateTime.now()); try { - final SoftAssert softAssert = new SoftAssert(); - evaluateExpression("in interval 1", true, softAssert); - evaluateExpression("in interval 2", true, softAssert); - evaluateExpression("in interval 3", true, softAssert); - evaluateExpression("in interval 4", true, softAssert); + evaluateExpression("in interval 1", true); + evaluateExpression("in interval 2", true); + evaluateExpression("in interval 3", true); + evaluateExpression("in interval 4", true); // This is a DateTime compared to an Interval - evaluateExpression("in interval 5", true, softAssert); - evaluateExpression("in interval 6", true, softAssert); - - evaluateExpression("After_SameHour", false, softAssert); - evaluateExpression("SameAs_SameHour", true, softAssert); - evaluateExpression("SameOrAfter_HourBefore", false, softAssert); - evaluateExpression("SameOrBefore_SameHour", true, softAssert); + evaluateExpression("in interval 5", true); + evaluateExpression("in interval 6", true); - softAssert.assertAll(); + evaluateExpression("After_SameHour", false); + evaluateExpression("SameAs_SameHour", true); + evaluateExpression("SameOrAfter_HourBefore", false); + evaluateExpression("SameOrBefore_SameHour", true); } finally { TimeZone.setDefault(TimeZone.getTimeZone(oldTz)); } } - private void evaluateExpression(String functionName, boolean expectedResult, SoftAssert softAssert) { + private void evaluateExpression(String functionName, boolean expectedResult) { var value = engine.expression(library, functionName).value(); - softAssert.assertEquals(value, expectedResult, functionName); + assertEquals(value, expectedResult, functionName); } } diff --git a/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/execution/CqlTypesOperatorsTest.java b/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/execution/CqlTypesOperatorsTest.java index 6447c681d..adc9687c4 100644 --- a/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/execution/CqlTypesOperatorsTest.java +++ b/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/execution/CqlTypesOperatorsTest.java @@ -1,17 +1,24 @@ package org.opencds.cqf.cql.engine.execution; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertTrue; + import java.math.BigDecimal; import java.time.ZoneId; import java.time.ZonedDateTime; import java.util.*; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import org.opencds.cqf.cql.engine.elm.executing.EquivalentEvaluator; import org.opencds.cqf.cql.engine.runtime.*; -import org.testng.annotations.Test; -import org.testng.asserts.SoftAssert; -public class CqlTypesOperatorsTest extends CqlTestBase { - @Test(dataProvider = "timezones") - public void test_all_types_operators(String timezone) { +class CqlTypesOperatorsTest extends CqlTestBase { + + @ParameterizedTest + @MethodSource("timezones") + void all_types_operators(String timezone) { final String oldTz = System.getProperty("user.timezone"); // This is the ONLY thing that will work. System.setProperty() and -Duser.timezone do NOT work TimeZone.setDefault(TimeZone.getTimeZone(timezone)); @@ -20,298 +27,290 @@ public void test_all_types_operators(String timezone) { try { final BigDecimal bigDecimalZoneOffset = getBigDecimalZoneOffset(); - final SoftAssert softAssert = new SoftAssert(); - var results = engine.evaluate(toElmIdentifier("CqlTypeOperatorsTest")); var value = results.forExpression("AsQuantity").value(); - softAssert.assertTrue(((Quantity) value) + assertTrue(((Quantity) value) .equal(new Quantity().withValue(new BigDecimal("45.5")).withUnit("g"))); value = results.forExpression("CastAsQuantity").value(); - softAssert.assertTrue(((Quantity) value) + assertTrue(((Quantity) value) .equal(new Quantity().withValue(new BigDecimal("45.5")).withUnit("g"))); value = results.forExpression("AsDateTime").value(); - softAssert.assertTrue( - EquivalentEvaluator.equivalent(value, new DateTime(bigDecimalZoneOffset, 2014, 1, 1))); + assertTrue(EquivalentEvaluator.equivalent(value, new DateTime(bigDecimalZoneOffset, 2014, 1, 1))); value = results.forExpression("IntegerToDecimal").value(); - softAssert.assertEquals(value, new BigDecimal(5)); + assertEquals(value, new BigDecimal(5)); value = results.forExpression("IntegerToString").value(); - softAssert.assertEquals(value, "5"); + assertEquals("5", value); value = results.forExpression("StringToDateTime").value(); - softAssert.assertTrue( - EquivalentEvaluator.equivalent(value, new DateTime(bigDecimalZoneOffset, 2014, 1, 1))); + assertTrue(EquivalentEvaluator.equivalent(value, new DateTime(bigDecimalZoneOffset, 2014, 1, 1))); value = results.forExpression("StringToTime").value(); - softAssert.assertTrue(EquivalentEvaluator.equivalent(value, new Time(14, 30, 0, 0))); + assertTrue(EquivalentEvaluator.equivalent(value, new Time(14, 30, 0, 0))); value = results.forExpression("ConvertQuantity").value(); - softAssert.assertTrue(EquivalentEvaluator.equivalent( + assertTrue(EquivalentEvaluator.equivalent( value, new Quantity().withValue(new BigDecimal("0.005")).withUnit("g"))); value = results.forExpression("ConvertSyntax").value(); - softAssert.assertTrue(EquivalentEvaluator.equivalent( + assertTrue(EquivalentEvaluator.equivalent( value, new Quantity().withValue(new BigDecimal("0.005")).withUnit("g"))); value = results.forExpression("ConvertsToBooleanTrue").value(); - softAssert.assertTrue((Boolean) value); + assertTrue((Boolean) value); value = results.forExpression("ConvertsToBooleanFalse").value(); - softAssert.assertFalse((Boolean) value); + assertFalse((Boolean) value); value = results.forExpression("ConvertsToBooleanNull").value(); - softAssert.assertNull(value); + assertNull(value); value = results.forExpression("ConvertsToDateTrue").value(); - softAssert.assertTrue((Boolean) value); + assertTrue((Boolean) value); value = results.forExpression("ConvertsToDateFalse").value(); - softAssert.assertFalse((Boolean) value); + assertFalse((Boolean) value); value = results.forExpression("ConvertsToDateNull").value(); - softAssert.assertNull(value); + assertNull(value); value = results.forExpression("ConvertsToDateTimeStringTrue").value(); - softAssert.assertTrue((Boolean) value); + assertTrue((Boolean) value); value = results.forExpression("ConvertsToDateTimeDateTrue").value(); - softAssert.assertTrue((Boolean) value); + assertTrue((Boolean) value); value = results.forExpression("ConvertsToDateTimeFalse").value(); - softAssert.assertFalse((Boolean) value); + assertFalse((Boolean) value); value = results.forExpression("ConvertsToDateTimeNull").value(); - softAssert.assertNull(value); + assertNull(value); value = results.forExpression("ConvertsToDecimalTrue").value(); - softAssert.assertTrue((Boolean) value); + assertTrue((Boolean) value); value = results.forExpression("ConvertsToDecimalFalse").value(); - softAssert.assertFalse((Boolean) value); + assertFalse((Boolean) value); value = results.forExpression("ConvertsToDecimalNull").value(); - softAssert.assertNull(value); + assertNull(value); value = results.forExpression("ConvertsToIntegerTrue").value(); - softAssert.assertTrue((Boolean) value); + assertTrue((Boolean) value); value = results.forExpression("ConvertsToIntegerLong").value(); - softAssert.assertTrue((Boolean) value); + assertTrue((Boolean) value); value = results.forExpression("ConvertsToIntegerFalse").value(); - softAssert.assertFalse((Boolean) value); + assertFalse((Boolean) value); value = results.forExpression("ConvertsToIntegerNull").value(); - softAssert.assertNull(value); + assertNull(value); value = results.forExpression("ConvertsToLongTrue").value(); - softAssert.assertTrue((Boolean) value); + assertTrue((Boolean) value); value = results.forExpression("ConvertsToLongFalse").value(); - softAssert.assertFalse((Boolean) value); + assertFalse((Boolean) value); value = results.forExpression("ConvertsToLongNull").value(); - softAssert.assertNull(value); + assertNull(value); value = results.forExpression("ConvertsToQuantityStringTrue").value(); - softAssert.assertTrue((Boolean) value); + assertTrue((Boolean) value); value = results.forExpression("ConvertsToQuantityStringFalse").value(); - softAssert.assertFalse((Boolean) value); + assertFalse((Boolean) value); value = results.forExpression("ConvertsToQuantityIntegerTrue").value(); - softAssert.assertTrue((Boolean) value); + assertTrue((Boolean) value); value = results.forExpression("ConvertsToQuantityDecimalTrue").value(); - softAssert.assertTrue((Boolean) value); + assertTrue((Boolean) value); value = results.forExpression("ConvertsToQuantityRatioTrue").value(); - softAssert.assertTrue((Boolean) value); + assertTrue((Boolean) value); value = results.forExpression("ConvertsToQuantityNull").value(); - softAssert.assertNull(value); + assertNull(value); value = results.forExpression("ConvertsToStringBoolean").value(); - softAssert.assertTrue((Boolean) value); + assertTrue((Boolean) value); value = results.forExpression("ConvertsToStringInteger").value(); - softAssert.assertTrue((Boolean) value); + assertTrue((Boolean) value); value = results.forExpression("ConvertsToStringLong").value(); - softAssert.assertTrue((Boolean) value); + assertTrue((Boolean) value); value = results.forExpression("ConvertsToStringDecimal").value(); - softAssert.assertTrue((Boolean) value); + assertTrue((Boolean) value); value = results.forExpression("ConvertsToStringQuantity").value(); - softAssert.assertTrue((Boolean) value); + assertTrue((Boolean) value); value = results.forExpression("ConvertsToStringRatio").value(); - softAssert.assertTrue((Boolean) value); + assertTrue((Boolean) value); value = results.forExpression("ConvertsToStringDate").value(); - softAssert.assertTrue((Boolean) value); + assertTrue((Boolean) value); value = results.forExpression("ConvertsToStringDateTime").value(); - softAssert.assertTrue((Boolean) value); + assertTrue((Boolean) value); value = results.forExpression("ConvertsToStringTime").value(); - softAssert.assertTrue((Boolean) value); + assertTrue((Boolean) value); value = results.forExpression("ConvertsToStringNull").value(); - softAssert.assertNull(value); + assertNull(value); value = results.forExpression("ConvertsToTimeTrue").value(); - softAssert.assertTrue((Boolean) value); + assertTrue((Boolean) value); value = results.forExpression("ConvertsToTimeFalse").value(); - softAssert.assertFalse((Boolean) value); + assertFalse((Boolean) value); value = results.forExpression("ConvertsToTimeNull").value(); - softAssert.assertNull(value); + assertNull(value); value = results.forExpression("IntegerIsInteger").value(); - softAssert.assertEquals(value, true); + assertTrue((Boolean) value); value = results.forExpression("StringIsInteger").value(); - softAssert.assertEquals(value, false); + assertFalse((Boolean) value); value = results.forExpression("StringNoToBoolean").value(); - softAssert.assertEquals(value, false); + assertFalse((Boolean) value); value = results.forExpression("CodeToConcept1").value(); - softAssert.assertTrue(((Concept) value).equivalent(new Concept().withCode(new Code().withCode("8480-6")))); + assertTrue(((Concept) value).equivalent(new Concept().withCode(new Code().withCode("8480-6")))); value = results.forExpression("ToDateTime0").value(); - softAssert.assertTrue(EquivalentEvaluator.equivalent(value, new DateTime(bigDecimalZoneOffset, 2014, 1))); + assertTrue(EquivalentEvaluator.equivalent(value, new DateTime(bigDecimalZoneOffset, 2014, 1))); value = results.forExpression("ToDateTime1").value(); - softAssert.assertTrue( - EquivalentEvaluator.equivalent(value, new DateTime(bigDecimalZoneOffset, 2014, 1, 1))); + assertTrue(EquivalentEvaluator.equivalent(value, new DateTime(bigDecimalZoneOffset, 2014, 1, 1))); value = results.forExpression("ToDateTime2").value(); - softAssert.assertTrue( - EquivalentEvaluator.equivalent(value, new DateTime(bigDecimalZoneOffset, 2014, 1, 1, 12, 5))); + assertTrue(EquivalentEvaluator.equivalent(value, new DateTime(bigDecimalZoneOffset, 2014, 1, 1, 12, 5))); value = results.forExpression("ToDateTime3").value(); - softAssert.assertTrue(EquivalentEvaluator.equivalent( + assertTrue(EquivalentEvaluator.equivalent( value, new DateTime(bigDecimalZoneOffset, 2014, 1, 1, 12, 5, 5, 955))); value = results.forExpression("ToDateTime4").value(); - softAssert.assertTrue( + assertTrue( EquivalentEvaluator.equivalent( value, new DateTime(new BigDecimal("1.5"), 2014, 1, 1, 12, 5, 5, 955)), "ToDateTime4 vs. new DateTime(-1.5)"); value = results.forExpression("ToDateTime5").value(); - softAssert.assertTrue( + assertTrue( EquivalentEvaluator.equivalent( value, new DateTime(new BigDecimal("-1.25"), 2014, 1, 1, 12, 5, 5, 955)), "ToDateTime5 vs. new DateTime(-1.25)"); value = results.forExpression("ToDateTime6").value(); final BigDecimal bigDecimalOffsetForUtc = getBigDecimalZoneOffset(ZoneId.of("UTC")); - softAssert.assertTrue(EquivalentEvaluator.equivalent( + assertTrue(EquivalentEvaluator.equivalent( value, new DateTime(bigDecimalOffsetForUtc, 2014, 1, 1, 12, 5, 5, 955))); value = results.forExpression("ToDateTimeMalformed").value(); - softAssert.assertNull(value); + assertNull(value); value = results.forExpression("String25D5ToDecimal").value(); - softAssert.assertEquals(value, new BigDecimal("25.5")); + assertEquals(value, new BigDecimal("25.5")); value = results.forExpression("StringNeg25ToInteger").value(); - softAssert.assertEquals(value, -25); + assertEquals(-25, value); value = results.forExpression("String123ToLong").value(); - softAssert.assertEquals(value, 123L); + assertEquals(123L, value); value = results.forExpression("String5D5CMToQuantity").value(); - softAssert.assertTrue(((Quantity) value) + assertTrue(((Quantity) value) .equal(new Quantity().withValue(new BigDecimal("5.5")).withUnit("cm"))); value = results.forExpression("StringInvalidToQuantityNull").value(); - softAssert.assertNull(value); + assertNull(value); value = results.forExpression("String100PerMinPerSqMeterToQuantity").value(); - softAssert.assertTrue(((Quantity) value) + assertTrue(((Quantity) value) .equal(new Quantity().withValue(new BigDecimal("100")).withUnit("daL/min/m2"))); value = results.forExpression("String100UnitPer10BillionToQuantity").value(); - softAssert.assertTrue(((Quantity) value) + assertTrue(((Quantity) value) .equal(new Quantity().withValue(new BigDecimal("100")).withUnit("U/10*10{cells}"))); value = results.forExpression("String60DayPer7DayToQuantity").value(); - softAssert.assertTrue(((Quantity) value) + assertTrue(((Quantity) value) .equal(new Quantity().withValue(new BigDecimal("60")).withUnit("d/(7.d)"))); value = results.forExpression("String60EhrlichPer100gmToQuantity").value(); - softAssert.assertTrue(((Quantity) value) + assertTrue(((Quantity) value) .equal(new Quantity().withValue(new BigDecimal("60")).withUnit("{EhrlichU}/100.g"))); value = results.forExpression("StringPercentToQuantity").value(); - softAssert.assertTrue(((Quantity) value) + assertTrue(((Quantity) value) .equal(new Quantity().withValue(new BigDecimal("60")).withUnit("%"))); value = results.forExpression("StringPercentWithoutQuoteToQuantity").value(); - softAssert.assertTrue(((Quantity) value) + assertTrue(((Quantity) value) .equal(new Quantity().withValue(new BigDecimal("70")).withUnit("%"))); value = results.forExpression("StringPercentWithTabToQuantity").value(); - softAssert.assertTrue(((Quantity) value) + assertTrue(((Quantity) value) .equal(new Quantity().withValue(new BigDecimal("80")).withUnit("%"))); value = results.forExpression("StringPercentWithMultiSpacesToQuantity") .value(); - softAssert.assertTrue(((Quantity) value) + assertTrue(((Quantity) value) .equal(new Quantity().withValue(new BigDecimal("90")).withUnit("%"))); value = results.forExpression("StringPercentWithSpacesUnitToQuantity") .value(); - softAssert.assertTrue(((Quantity) value) + assertTrue(((Quantity) value) .equal(new Quantity().withValue(new BigDecimal("10")).withUnit("ml"))); value = results.forExpression("StringPercentWithQuoteUnitToQuantity") .value(); - softAssert.assertTrue(((Quantity) value) + assertTrue(((Quantity) value) .equal(new Quantity().withValue(new BigDecimal("20")).withUnit("ml"))); value = results.forExpression("ToRatioIsValid").value(); - softAssert.assertTrue(((Ratio) value) + assertTrue(((Ratio) value) .getNumerator() .equal(new Quantity().withValue(new BigDecimal("1.0")).withUnit("mg"))); - softAssert.assertTrue(((Ratio) value) + assertTrue(((Ratio) value) .getDenominator() .equal(new Quantity().withValue(new BigDecimal("2.0")).withUnit("mg"))); value = results.forExpression("ToRatioIsNull").value(); - softAssert.assertNull(value); + assertNull(value); value = results.forExpression("IntegerNeg5ToString").value(); - softAssert.assertEquals(value, "-5"); + assertEquals("-5", value); value = results.forExpression("LongNeg5ToString").value(); - softAssert.assertEquals(value, "-5"); + assertEquals("-5", value); value = results.forExpression("Decimal18D55ToString").value(); - softAssert.assertEquals(value, "18.55"); + assertEquals("18.55", value); value = results.forExpression("Quantity5D5CMToString").value(); - softAssert.assertEquals(value, "5.5 'cm'"); + assertEquals("5.5 'cm'", value); value = results.forExpression("BooleanTrueToString").value(); - softAssert.assertEquals(value, "true"); + assertEquals("true", value); value = results.forExpression("ToTime1").value(); - softAssert.assertTrue(EquivalentEvaluator.equivalent(value, new Time(14, 30, 0, 0))); + assertTrue(EquivalentEvaluator.equivalent(value, new Time(14, 30, 0, 0))); value = results.forExpression("ToTimeMalformed").value(); - softAssert.assertNull(value); - - softAssert.assertAll(); + assertNull(value); } finally { TimeZone.setDefault(TimeZone.getTimeZone(oldTz)); } diff --git a/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/execution/CqlTypesTest.java b/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/execution/CqlTypesTest.java index c0194b7d9..e42ae5039 100644 --- a/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/execution/CqlTypesTest.java +++ b/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/execution/CqlTypesTest.java @@ -1,55 +1,55 @@ package org.opencds.cqf.cql.engine.execution; +import static org.junit.jupiter.api.Assertions.*; + import java.math.BigDecimal; import java.time.OffsetDateTime; import java.util.*; +import org.junit.jupiter.api.Test; import org.opencds.cqf.cql.engine.elm.executing.EquivalentEvaluator; import org.opencds.cqf.cql.engine.runtime.*; -import org.testng.annotations.Test; -import org.testng.asserts.SoftAssert; // import static org.hamcrest.MatcherAssert.assertThat; // import static org.hamcrest.Matchers.is; // import static org.hamcrest.Matchers.nullValue; -public class CqlTypesTest extends CqlTestBase { +class CqlTypesTest extends CqlTestBase { @Test - public void test_all_types() { + void all_types() { final BigDecimal bigDecimalZoneOffset = getBigDecimalZoneOffset(); - final SoftAssert softAssert = new SoftAssert(); var results = engine.evaluate(toElmIdentifier("CqlTypesTest")); var value = results.forExpression("AnyInteger").value(); - softAssert.assertEquals(value, 5, "AnyInteger"); + assertEquals(5, value, "AnyInteger"); value = results.forExpression("AnyLong").value(); - softAssert.assertEquals(value, Long.valueOf("12"), "AnyLong"); + assertEquals(value, Long.valueOf("12"), "AnyLong"); value = results.forExpression("AnyDecimal").value(); - softAssert.assertEquals(value, new BigDecimal("5.0"), "AnyDecimal"); + assertEquals(value, new BigDecimal("5.0"), "AnyDecimal"); value = results.forExpression("AnyQuantity").value(); - softAssert.assertTrue( + assertTrue( ((Quantity) value) .equal(new Quantity().withValue(new BigDecimal("5.0")).withUnit("g")), "AnyQuantity"); value = results.forExpression("AnyDateTime").value(); - softAssert.assertTrue( + assertTrue( EquivalentEvaluator.equivalent(value, new DateTime(bigDecimalZoneOffset, 2012, 4, 4)), "AnyDateTime"); value = results.forExpression("AnyTime").value(); - softAssert.assertTrue(EquivalentEvaluator.equivalent(value, new Time(9, 0, 0, 0)), "AnyTime"); + assertTrue(EquivalentEvaluator.equivalent(value, new Time(9, 0, 0, 0)), "AnyTime"); value = results.forExpression("AnyInterval").value(); - softAssert.assertEquals(((Interval) value), new Interval(2, true, 7, true), "AnyInterval"); + assertEquals(((Interval) value), new Interval(2, true, 7, true), "AnyInterval"); value = results.forExpression("AnyList").value(); - softAssert.assertEquals(value, Arrays.asList(1, 2, 3), "AnyList"); + assertEquals(value, Arrays.asList(1, 2, 3), "AnyList"); value = results.forExpression("AnyTuple").value(); - softAssert.assertEquals( + assertEquals( ((Tuple) value).getElements(), new HashMap() { { @@ -60,15 +60,15 @@ public void test_all_types() { "AnyTuple"); value = results.forExpression("BooleanTestTrue").value(); - softAssert.assertEquals(value.getClass().getSimpleName(), "Boolean", "BooleanTestTrue"); - softAssert.assertEquals(value, true, "BooleanTestTrue"); + assertEquals("Boolean", value.getClass().getSimpleName(), "BooleanTestTrue"); + assertTrue((Boolean) value, "BooleanTestTrue"); value = results.forExpression("BooleanTestFalse").value(); - softAssert.assertEquals(value.getClass().getSimpleName(), "Boolean", "BooleanTestFalse"); - softAssert.assertEquals(value, false, "BooleanTestFalse"); + assertEquals("Boolean", value.getClass().getSimpleName(), "BooleanTestFalse"); + assertFalse((Boolean) value, "BooleanTestFalse"); value = results.forExpression("CodeLiteral").value(); - softAssert.assertTrue( + assertTrue( ((Code) value) .equal(new Code() .withCode("8480-6") @@ -78,7 +78,7 @@ public void test_all_types() { "CodeLiteral"); value = results.forExpression("CodeLiteral2").value(); - softAssert.assertTrue( + assertTrue( ((Code) value) .equal(new Code() .withCode("1234-5") @@ -88,7 +88,7 @@ public void test_all_types() { "CodeLiteral2"); value = results.forExpression("ConceptTest").value(); - softAssert.assertTrue( + assertTrue( ((Concept) value) .equal(new Concept() .withCodes(Arrays.asList( @@ -106,84 +106,79 @@ public void test_all_types() { "ConceptTest"); value = results.forExpression("DateTimeNull").value(); - softAssert.assertNull(value, "DateTimeNull"); + assertNull(value, "DateTimeNull"); value = results.forExpression("DateTimeProper").value(); - softAssert.assertTrue( + assertTrue( EquivalentEvaluator.equivalent(value, new DateTime(bigDecimalZoneOffset, 2016, 7, 7, 6, 25, 33, 910)), "DateTimeProper"); value = results.forExpression("DateTimeIncomplete").value(); - softAssert.assertTrue( + assertTrue( EquivalentEvaluator.equivalent(value, new DateTime(bigDecimalZoneOffset, 2015, 2, 10)), "DateTimeIncomplete"); value = results.forExpression("DateTimeUncertain").value(); - softAssert.assertEquals(((Interval) value).getStart(), 19, "DateTimeUncertain"); - softAssert.assertEquals(((Interval) value).getEnd(), 49, "DateTimeUncertain"); + assertEquals(19, ((Interval) value).getStart(), "DateTimeUncertain"); + assertEquals(49, ((Interval) value).getEnd(), "DateTimeUncertain"); value = results.forExpression("DateTimeMin").value(); - softAssert.assertTrue(EquivalentEvaluator.equivalent( + assertTrue(EquivalentEvaluator.equivalent( value, new DateTime(OffsetDateTime.of( 1, 1, 1, 0, 0, 0, 0, OffsetDateTime.now().getOffset())))); value = results.forExpression("DateTimeMax").value(); - softAssert.assertTrue(EquivalentEvaluator.equivalent( + assertTrue(EquivalentEvaluator.equivalent( value, new DateTime(bigDecimalZoneOffset, 9999, 12, 31, 23, 59, 59, 999))); value = results.forExpression("DecimalUpperBoundExcept").value(); - softAssert.assertEquals( - value, new BigDecimal("10000000000000000000000000000000000.00000000"), "DecimalUpperBoundExcept"); + assertEquals(value, new BigDecimal("10000000000000000000000000000000000.00000000"), "DecimalUpperBoundExcept"); value = results.forExpression("DecimalLowerBoundExcept").value(); - softAssert.assertEquals( - value, new BigDecimal("-10000000000000000000000000000000000.00000000"), "DecimalLowerBoundExcept"); + assertEquals(value, new BigDecimal("-10000000000000000000000000000000000.00000000"), "DecimalLowerBoundExcept"); // NOTE: This should also return an error as the fractional precision is greater than 8 value = results.forExpression("DecimalFractionalTooBig").value(); - softAssert.assertEquals(value, new BigDecimal("5.999999999"), "DecimalFractionalTooBig"); + assertEquals(value, new BigDecimal("5.999999999"), "DecimalFractionalTooBig"); value = results.forExpression("DecimalPi").value(); - softAssert.assertEquals(value, new BigDecimal("3.14159265"), "DecimalPi"); + assertEquals(value, new BigDecimal("3.14159265"), "DecimalPi"); value = results.forExpression("IntegerProper").value(); - softAssert.assertEquals(value, 5000, "IntegerProper"); + assertEquals(5000, value, "IntegerProper"); value = results.forExpression("QuantityTest").value(); - softAssert.assertTrue(((Quantity) value) + assertTrue(((Quantity) value) .equal(new Quantity().withValue(new BigDecimal("150.2")).withUnit("[lb_av]"))); value = results.forExpression("QuantityTest2").value(); - softAssert.assertTrue(((Quantity) value) + assertTrue(((Quantity) value) .equal(new Quantity().withValue(new BigDecimal("2.5589")).withUnit("{eskimo kisses}"))); // NOTE: This should also return an error as the fractional precision is greater than 8 value = results.forExpression("QuantityFractionalTooBig").value(); - softAssert.assertTrue(((Quantity) value) + assertTrue(((Quantity) value) .equal(new Quantity().withValue(new BigDecimal("5.99999999")).withUnit("g"))); value = results.forExpression("RatioTest").value(); - softAssert.assertTrue(((Ratio) value) + assertTrue(((Ratio) value) .getNumerator() .equal(new Quantity().withValue(new BigDecimal("150.2")).withUnit("[lb_av]"))); - softAssert.assertTrue(((Ratio) value) + assertTrue(((Ratio) value) .getDenominator() .equal(new Quantity().withValue(new BigDecimal("2.5589")).withUnit("{eskimo kisses}"))); value = results.forExpression("StringTestEscapeQuotes").value(); - softAssert.assertEquals( - value, "\'I start with a single quote and end with a double quote\"", "StringTestEscapeQuotes"); + assertEquals("\'I start with a single quote and end with a double quote\"", value, "StringTestEscapeQuotes"); value = results.forExpression("TimeProper").value(); - softAssert.assertTrue(EquivalentEvaluator.equivalent(value, new Time(10, 25, 12, 863)), "TimeProper"); + assertTrue(EquivalentEvaluator.equivalent(value, new Time(10, 25, 12, 863)), "TimeProper"); value = results.forExpression("TimeAllMax").value(); - softAssert.assertTrue(EquivalentEvaluator.equivalent(value, new Time(23, 59, 59, 999)), "TimeAllMax"); + assertTrue(EquivalentEvaluator.equivalent(value, new Time(23, 59, 59, 999)), "TimeAllMax"); value = results.forExpression("TimeAllMin").value(); - softAssert.assertTrue(EquivalentEvaluator.equivalent(value, new Time(0, 0, 0, 0)), "TimeAllMin"); - - softAssert.assertAll(); + assertTrue(EquivalentEvaluator.equivalent(value, new Time(0, 0, 0, 0)), "TimeAllMin"); } } diff --git a/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/execution/CqlValueLiteralsAndSelectorsTest.java b/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/execution/CqlValueLiteralsAndSelectorsTest.java index 3c08e98d1..ee5397349 100644 --- a/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/execution/CqlValueLiteralsAndSelectorsTest.java +++ b/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/execution/CqlValueLiteralsAndSelectorsTest.java @@ -5,20 +5,20 @@ import static org.hamcrest.Matchers.instanceOf; import static org.hamcrest.Matchers.is; import static org.hamcrest.Matchers.nullValue; +import static org.junit.jupiter.api.Assertions.assertNull; import java.math.BigDecimal; import java.math.RoundingMode; +import org.junit.jupiter.api.Test; import org.opencds.cqf.cql.engine.runtime.*; -import org.testng.Assert; -import org.testng.annotations.Test; -public class CqlValueLiteralsAndSelectorsTest extends CqlTestBase { +class CqlValueLiteralsAndSelectorsTest extends CqlTestBase { @Test - public void test_all_ValueLiteralsAndSelectors() { + void all_value_literals_and_selectors() { var results = engine.evaluate(toElmIdentifier("CqlValueLiteralsAndSelectorsTest")); var value = results.forExpression("Null").value(); - Assert.assertNull(value); + assertNull(value); assertThat(value, is(nullValue())); value = results.forExpression("BooleanFalse").value(); diff --git a/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/execution/DateComparatorTest.java b/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/execution/DateComparatorTest.java index c361b3311..6972df5b6 100644 --- a/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/execution/DateComparatorTest.java +++ b/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/execution/DateComparatorTest.java @@ -3,12 +3,12 @@ import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.is; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Test; -public class DateComparatorTest extends CqlTestBase { +class DateComparatorTest extends CqlTestBase { @Test - public void test_date_comparator() { + void date_comparator() { var results = engine.evaluate(toElmIdentifier("DateComparatorTest")); var value = results.forExpression("Date Comparator Test").value(); assertThat(value, is(true)); diff --git a/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/execution/EmptyStringsTest.java b/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/execution/EmptyStringsTest.java index 0e1626bb5..08d0086de 100644 --- a/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/execution/EmptyStringsTest.java +++ b/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/execution/EmptyStringsTest.java @@ -4,12 +4,12 @@ import static org.hamcrest.Matchers.is; import static org.hamcrest.Matchers.nullValue; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Test; -public class EmptyStringsTest extends CqlTestBase { +class EmptyStringsTest extends CqlTestBase { @Test - public void test_all_empty_string() { + void all_empty_string() { var results = engine.evaluate(toElmIdentifier("EmptyStringsTest")); var value = results.forExpression("Null").value(); assertThat(value, is(nullValue())); diff --git a/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/execution/ExpandValueSetTest.java b/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/execution/ExpandValueSetTest.java index cf600db85..c95d17686 100644 --- a/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/execution/ExpandValueSetTest.java +++ b/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/execution/ExpandValueSetTest.java @@ -1,23 +1,23 @@ package org.opencds.cqf.cql.engine.execution; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.opencds.cqf.cql.engine.execution.CqlConceptTest.assertEqual; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; import java.util.Collections; import java.util.List; import org.cqframework.cql.cql2elm.LibraryManager; import org.cqframework.cql.cql2elm.ModelManager; +import org.junit.jupiter.api.Test; import org.opencds.cqf.cql.engine.runtime.Code; import org.opencds.cqf.cql.engine.terminology.CodeSystemInfo; import org.opencds.cqf.cql.engine.terminology.TerminologyProvider; import org.opencds.cqf.cql.engine.terminology.ValueSetInfo; -import org.testng.annotations.Test; -public class ExpandValueSetTest { +class ExpandValueSetTest { @Test - public void test_all_expand_valueset() { + void all_expand_valueset() { LibraryManager libraryManager = new LibraryManager(new ModelManager()); libraryManager.getLibrarySourceLoader().registerProvider(new TestLibrarySourceProvider()); @@ -44,7 +44,7 @@ public Code lookup(Code code, CodeSystemInfo codeSystem) { @SuppressWarnings("unchecked") List actual = (List) results.forExpression("ExpandValueSet").value(); assertNotNull(actual); - assertEquals(actual.size(), 1); + assertEquals(1, actual.size()); assertEqual(expected, actual.get(0)); } diff --git a/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/execution/ExpressionCacheTest.java b/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/execution/ExpressionCacheTest.java index 360b74c0a..c66effaf6 100644 --- a/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/execution/ExpressionCacheTest.java +++ b/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/execution/ExpressionCacheTest.java @@ -2,17 +2,17 @@ import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.is; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; import org.hl7.elm.r1.VersionedIdentifier; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Test; @SuppressWarnings("removal") -public class ExpressionCacheTest extends CqlTestBase { +class ExpressionCacheTest extends CqlTestBase { @Test - public void test_expression_cache() { + void expression_cache() { engine.getCache().setExpressionCaching(true); diff --git a/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/execution/IncludedCodeRefTest.java b/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/execution/IncludedCodeRefTest.java index aa875aeae..32e904c20 100644 --- a/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/execution/IncludedCodeRefTest.java +++ b/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/execution/IncludedCodeRefTest.java @@ -3,15 +3,15 @@ import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.instanceOf; import static org.hamcrest.Matchers.is; -import static org.testng.Assert.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import org.junit.jupiter.api.Test; import org.opencds.cqf.cql.engine.runtime.Code; -import org.testng.annotations.Test; -public class IncludedCodeRefTest extends CqlTestBase { +class IncludedCodeRefTest extends CqlTestBase { @Test - public void test_included_code_ref() { + void included_code_ref() { var results = engine.evaluate(toElmIdentifier("IncludedCodeRefTest")); var value = results.forExpression("IncludedCode").value(); assertNotNull(value); diff --git a/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/execution/IncludedConceptRefTest.java b/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/execution/IncludedConceptRefTest.java index 5a0146461..147f2129c 100644 --- a/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/execution/IncludedConceptRefTest.java +++ b/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/execution/IncludedConceptRefTest.java @@ -3,15 +3,15 @@ import static org.opencds.cqf.cql.engine.execution.CqlConceptTest.assertEqual; import java.util.Collections; +import org.junit.jupiter.api.Test; import org.opencds.cqf.cql.engine.runtime.Code; import org.opencds.cqf.cql.engine.runtime.Concept; import org.opencds.cqf.cql.engine.runtime.CqlType; -import org.testng.annotations.Test; -public class IncludedConceptRefTest extends CqlTestBase { +class IncludedConceptRefTest extends CqlTestBase { @Test - public void test_included_concept_ref() { + void included_concept_ref() { Code code = new Code() .withCode("code-value") diff --git a/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/execution/IncludedParameterTest.java b/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/execution/IncludedParameterTest.java index b23229be1..37b3ac4e0 100644 --- a/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/execution/IncludedParameterTest.java +++ b/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/execution/IncludedParameterTest.java @@ -1,19 +1,19 @@ package org.opencds.cqf.cql.engine.execution; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNull; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNull; import java.util.HashMap; import java.util.HashSet; import org.hl7.elm.r1.VersionedIdentifier; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Test; -public class IncludedParameterTest extends CqlTestBase { +class IncludedParameterTest extends CqlTestBase { private static final VersionedIdentifier library = new VersionedIdentifier().withId("IncludedParameterTest"); @Test - public void test_gets_global_param_value() { + void gets_global_param_value() { var expressions = new HashSet(); expressions.add("Included Parameter"); expressions.add("Local Parameter"); @@ -23,12 +23,12 @@ public void test_gets_global_param_value() { var result = engine.evaluate(library, expressions, params); // Parameter added as a global should affect all expressions - assertEquals(result.forExpression("Included Parameter").value(), 1); - assertEquals(result.forExpression("Local Parameter").value(), 1); + assertEquals(1, result.forExpression("Included Parameter").value()); + assertEquals(1, result.forExpression("Local Parameter").value()); } @Test - public void test_local_param_value() { + void local_param_value() { var expressions = new HashSet(); expressions.add("Included Parameter"); expressions.add("Local Parameter"); @@ -39,11 +39,11 @@ public void test_local_param_value() { var result = engine.evaluate(library, expressions, params); // Parameter added as a local should only impact the local value assertNull(result.forExpression("Included Parameter").value()); - assertEquals(result.forExpression("Local Parameter").value(), 1); + assertEquals(1, result.forExpression("Local Parameter").value()); } @Test - public void test_include_param_value() { + void include_param_value() { var expressions = new HashSet(); expressions.add("Included Parameter"); expressions.add("Local Parameter"); @@ -54,11 +54,11 @@ public void test_include_param_value() { var result = engine.evaluate(library, expressions, params); // Parameter added as a local should only impact the local value assertNull(result.forExpression("Local Parameter").value()); - assertEquals(result.forExpression("Included Parameter").value(), 1); + assertEquals(1, result.forExpression("Included Parameter").value()); } @Test - public void test_local_override_param_value() { + void local_override_param_value() { var expressions = new HashSet(); expressions.add("Included Parameter"); @@ -71,7 +71,7 @@ public void test_local_override_param_value() { var result = engine.evaluate(library, expressions, params); // If a library-specific parameter is not specified, the global // value should be used - assertEquals(result.forExpression("Local Parameter").value(), 2); - assertEquals(result.forExpression("Included Parameter").value(), 1); + assertEquals(2, result.forExpression("Local Parameter").value()); + assertEquals(1, result.forExpression("Included Parameter").value()); } } diff --git a/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/execution/IncludedSignatureOutputTests.java b/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/execution/IncludedSignatureOutputTests.java index 30f818278..46a02ceb1 100644 --- a/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/execution/IncludedSignatureOutputTests.java +++ b/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/execution/IncludedSignatureOutputTests.java @@ -4,12 +4,12 @@ import static org.hamcrest.Matchers.is; import java.math.BigDecimal; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Test; -public class IncludedSignatureOutputTests extends CqlTestBase { +class IncludedSignatureOutputTests extends CqlTestBase { @Test - public void testEvaluate() { + void evaluate() { var results = engine.evaluate(toElmIdentifier("IncludedSignatureOutputTests")); Object value = results.forExpression("TestOverload").value(); diff --git a/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/execution/IncludedSignatureWithAliasOutputTests.java b/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/execution/IncludedSignatureWithAliasOutputTests.java index f4117620c..ce5b779e5 100644 --- a/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/execution/IncludedSignatureWithAliasOutputTests.java +++ b/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/execution/IncludedSignatureWithAliasOutputTests.java @@ -4,12 +4,12 @@ import static org.hamcrest.Matchers.is; import java.math.BigDecimal; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Test; -public class IncludedSignatureWithAliasOutputTests extends CqlTestBase { +class IncludedSignatureWithAliasOutputTests extends CqlTestBase { @Test - public void testEvaluate() { + void evaluate() { var results = engine.evaluate(toElmIdentifier("IncludedSignatureWithAliasOutputTests")); Object value = results.forExpression("TestOverload").value(); diff --git a/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/execution/IncludedValueSetRefTest.java b/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/execution/IncludedValueSetRefTest.java index 73fde267c..e9c7a66a5 100644 --- a/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/execution/IncludedValueSetRefTest.java +++ b/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/execution/IncludedValueSetRefTest.java @@ -1,23 +1,23 @@ package org.opencds.cqf.cql.engine.execution; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.opencds.cqf.cql.engine.execution.CqlConceptTest.assertEqual; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; import java.util.Collections; import java.util.List; import org.cqframework.cql.cql2elm.LibraryManager; import org.cqframework.cql.cql2elm.ModelManager; +import org.junit.jupiter.api.Test; import org.opencds.cqf.cql.engine.runtime.Code; import org.opencds.cqf.cql.engine.terminology.CodeSystemInfo; import org.opencds.cqf.cql.engine.terminology.TerminologyProvider; import org.opencds.cqf.cql.engine.terminology.ValueSetInfo; -import org.testng.annotations.Test; -public class IncludedValueSetRefTest { +class IncludedValueSetRefTest { @Test - public void test_all_included_valueset() { + void all_included_valueset() { LibraryManager libraryManager = new LibraryManager(new ModelManager()); libraryManager.getLibrarySourceLoader().registerProvider(new TestLibrarySourceProvider()); @@ -46,7 +46,7 @@ public Code lookup(Code code, CodeSystemInfo codeSystem) { List actual = (List) results.forExpression("IncludedValueSet").value(); assertNotNull(actual); - assertEquals(actual.size(), 1); + assertEquals(1, actual.size()); assertEqual(expected, actual.get(0)); } diff --git a/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/execution/IntervalOperatorsTest.java b/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/execution/IntervalOperatorsTest.java index 351c9599c..7935bf9e2 100644 --- a/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/execution/IntervalOperatorsTest.java +++ b/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/execution/IntervalOperatorsTest.java @@ -2,16 +2,18 @@ import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.*; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertTrue; import java.math.BigDecimal; import java.util.*; +import org.junit.jupiter.api.Test; import org.opencds.cqf.cql.engine.elm.executing.EquivalentEvaluator; import org.opencds.cqf.cql.engine.runtime.*; import org.opencds.cqf.cql.engine.runtime.Date; -import org.testng.Assert; -import org.testng.annotations.Test; -public class IntervalOperatorsTest extends CqlTestBase { +class IntervalOperatorsTest extends CqlTestBase { // @Test // public void test_fail() { // @@ -22,7 +24,7 @@ public class IntervalOperatorsTest extends CqlTestBase { // results = engine.evaluate(toElmIdentifier("CqlIntervalOperatorsTest"), set, null, null, null, // null); // Object value = results.forExpression("InvalidIntegerIntervalA").value(); - // Assert.fail(); + // Assertions.fail(); // // // } catch (Exception e) { @@ -32,7 +34,7 @@ public class IntervalOperatorsTest extends CqlTestBase { // } @Test - public void test_all_interval_operators() { + void all_interval_operators() { final BigDecimal bigDecimalZoneOffset = getBigDecimalZoneOffset(); var results = engine.evaluate(toElmIdentifier("CqlIntervalOperatorsTest")); @@ -178,37 +180,37 @@ public void test_all_interval_operators() { assertThat(value, is(nullValue())); value = results.forExpression("IntegerIntervalCollapse").value(); - Assert.assertTrue(((Interval) ((List) value).get(0)).equal(new Interval(1, true, 10, true))); - Assert.assertTrue(((Interval) ((List) value).get(1)).equal(new Interval(12, true, 19, true))); + assertTrue(((Interval) ((List) value).get(0)).equal(new Interval(1, true, 10, true))); + assertTrue(((Interval) ((List) value).get(1)).equal(new Interval(12, true, 19, true))); value = results.forExpression("IntegerIntervalCollapse2").value(); - Assert.assertTrue(((Interval) ((List) value).get(0)).equal(new Interval(1, true, 19, true))); + assertTrue(((Interval) ((List) value).get(0)).equal(new Interval(1, true, 19, true))); value = results.forExpression("IntegerIntervalCollapse3").value(); - Assert.assertTrue(((Interval) ((List) value).get(0)).equal(new Interval(4, true, 8, true))); + assertTrue(((Interval) ((List) value).get(0)).equal(new Interval(4, true, 8, true))); value = results.forExpression("IntegerIntervalCollapse4").value(); - Assert.assertTrue(((Interval) ((List) value).get(0)).equal(new Interval(4, true, 6, true))); - Assert.assertTrue(((Interval) ((List) value).get(1)).equal(new Interval(8, true, 10, true))); + assertTrue(((Interval) ((List) value).get(0)).equal(new Interval(4, true, 6, true))); + assertTrue(((Interval) ((List) value).get(1)).equal(new Interval(8, true, 10, true))); value = results.forExpression("DecimalIntervalCollapse").value(); - Assert.assertTrue(((Interval) ((List) value).get(0)) + assertTrue(((Interval) ((List) value).get(0)) .equal(new Interval(new BigDecimal("1.0"), true, new BigDecimal("10.0"), true))); - Assert.assertTrue(((Interval) ((List) value).get(1)) + assertTrue(((Interval) ((List) value).get(1)) .equal(new Interval(new BigDecimal("12.0"), true, new BigDecimal("19.0"), true))); value = results.forExpression("DecimalIntervalCollapse2").value(); - Assert.assertTrue(((Interval) ((List) value).get(0)) + assertTrue(((Interval) ((List) value).get(0)) .equal(new Interval(new BigDecimal("4.0"), true, new BigDecimal("8.0"), true))); value = results.forExpression("QuantityIntervalCollapse").value(); - Assert.assertTrue(((Interval) ((List) value).get(0)) + assertTrue(((Interval) ((List) value).get(0)) .equal(new Interval( new Quantity().withValue(new BigDecimal("1.0")).withUnit("g"), true, new Quantity().withValue(new BigDecimal("10.0")).withUnit("g"), true))); - Assert.assertTrue(((Interval) ((List) value).get(1)) + assertTrue(((Interval) ((List) value).get(1)) .equal(new Interval( new Quantity().withValue(new BigDecimal("12.0")).withUnit("g"), true, @@ -216,77 +218,77 @@ public void test_all_interval_operators() { true))); value = results.forExpression("DateTimeCollapse").value(); - Assert.assertTrue(EquivalentEvaluator.equivalent( + assertTrue(EquivalentEvaluator.equivalent( ((Interval) ((List) value).get(0)).getStart(), new DateTime(bigDecimalZoneOffset, 2012, 1, 1))); - Assert.assertTrue(EquivalentEvaluator.equivalent( + assertTrue(EquivalentEvaluator.equivalent( ((Interval) ((List) value).get(0)).getEnd(), new DateTime(bigDecimalZoneOffset, 2012, 1, 25))); - Assert.assertTrue(EquivalentEvaluator.equivalent( + assertTrue(EquivalentEvaluator.equivalent( ((Interval) ((List) value).get(1)).getStart(), new DateTime(bigDecimalZoneOffset, 2012, 5, 10))); - Assert.assertTrue(EquivalentEvaluator.equivalent( + assertTrue(EquivalentEvaluator.equivalent( ((Interval) ((List) value).get(1)).getEnd(), new DateTime(bigDecimalZoneOffset, 2012, 5, 30))); assertThat(((List) value).size(), is(2)); value = results.forExpression("DateTimeCollapse2").value(); - Assert.assertTrue(EquivalentEvaluator.equivalent( + assertTrue(EquivalentEvaluator.equivalent( ((Interval) ((List) value).get(0)).getStart(), new DateTime(bigDecimalZoneOffset, 2012, 1, 1))); - Assert.assertTrue(EquivalentEvaluator.equivalent( + assertTrue(EquivalentEvaluator.equivalent( ((Interval) ((List) value).get(0)).getEnd(), new DateTime(bigDecimalZoneOffset, 2012, 5, 25))); assertThat(((List) value).size(), is(1)); value = results.forExpression("DateTimeCollapse3").value(); - Assert.assertTrue(EquivalentEvaluator.equivalent( + assertTrue(EquivalentEvaluator.equivalent( ((Interval) ((List) value).get(0)).getStart(), new DateTime(bigDecimalZoneOffset, 2018, 1, 1))); - Assert.assertTrue(EquivalentEvaluator.equivalent( + assertTrue(EquivalentEvaluator.equivalent( ((Interval) ((List) value).get(0)).getEnd(), new DateTime(bigDecimalZoneOffset, 2018, 8, 28))); - Assert.assertTrue(EquivalentEvaluator.equivalent( + assertTrue(EquivalentEvaluator.equivalent( ((Interval) ((List) value).get(1)).getStart(), new DateTime(bigDecimalZoneOffset, 2018, 8, 30))); - Assert.assertTrue(EquivalentEvaluator.equivalent( + assertTrue(EquivalentEvaluator.equivalent( ((Interval) ((List) value).get(1)).getEnd(), new DateTime(bigDecimalZoneOffset, 2018, 10, 15))); assertThat(((List) value).size(), is(2)); value = results.forExpression("DateTimeCollapse4").value(); - Assert.assertTrue( + assertTrue( EquivalentEvaluator.equivalent(((Interval) ((List) value).get(0)).getStart(), new Date(2018, 1, 1))); - Assert.assertTrue( + assertTrue( EquivalentEvaluator.equivalent(((Interval) ((List) value).get(0)).getEnd(), new Date(2018, 8, 28))); - Assert.assertTrue(EquivalentEvaluator.equivalent( + assertTrue(EquivalentEvaluator.equivalent( ((Interval) ((List) value).get(1)).getStart(), new Date(2018, 8, 30))); - Assert.assertTrue( + assertTrue( EquivalentEvaluator.equivalent(((Interval) ((List) value).get(1)).getEnd(), new Date(2018, 10, 15))); value = results.forExpression("DateTimeCollapse5").value(); System.out.println(value); - Assert.assertTrue( + assertTrue( EquivalentEvaluator.equivalent(((Interval) ((List) value).get(0)).getStart(), new Date(2018, 1, 1))); - Assert.assertTrue( + assertTrue( EquivalentEvaluator.equivalent(((Interval) ((List) value).get(0)).getEnd(), new Date(2018, 8, 28))); - Assert.assertTrue(EquivalentEvaluator.equivalent( + assertTrue(EquivalentEvaluator.equivalent( ((Interval) ((List) value).get(1)).getStart(), new Date(2018, 8, 30))); - Assert.assertTrue( + assertTrue( EquivalentEvaluator.equivalent(((Interval) ((List) value).get(1)).getEnd(), new Date(2018, 10, 15))); value = results.forExpression("DateTimeCollapse6").value(); - Assert.assertTrue( + assertTrue( EquivalentEvaluator.equivalent(((Interval) ((List) value).get(0)).getStart(), new Date(2018, 1, 1))); - Assert.assertTrue( + assertTrue( EquivalentEvaluator.equivalent(((Interval) ((List) value).get(0)).getEnd(), new Date(2018, 10, 15))); value = results.forExpression("TimeCollapse").value(); - Assert.assertTrue(EquivalentEvaluator.equivalent( + assertTrue(EquivalentEvaluator.equivalent( ((Interval) ((List) value).get(0)).getStart(), new Time(1, 59, 59, 999))); - Assert.assertTrue(EquivalentEvaluator.equivalent( + assertTrue(EquivalentEvaluator.equivalent( ((Interval) ((List) value).get(0)).getEnd(), new Time(15, 59, 59, 999))); - Assert.assertTrue(EquivalentEvaluator.equivalent( + assertTrue(EquivalentEvaluator.equivalent( ((Interval) ((List) value).get(1)).getStart(), new Time(17, 59, 59, 999))); - Assert.assertTrue(EquivalentEvaluator.equivalent( + assertTrue(EquivalentEvaluator.equivalent( ((Interval) ((List) value).get(1)).getEnd(), new Time(22, 59, 59, 999))); assertThat(((List) value).size(), is(2)); value = results.forExpression("TimeCollapse2").value(); - Assert.assertTrue(EquivalentEvaluator.equivalent( + assertTrue(EquivalentEvaluator.equivalent( ((Interval) ((List) value).get(0)).getStart(), new Time(1, 59, 59, 999))); - Assert.assertTrue(EquivalentEvaluator.equivalent( + assertTrue(EquivalentEvaluator.equivalent( ((Interval) ((List) value).get(0)).getEnd(), new Time(15, 59, 59, 999))); assertThat(((List) value).size(), is(1)); value = results.forExpression("TestContainsNull").value(); @@ -344,15 +346,14 @@ public void test_all_interval_operators() { assertThat(value, is(new BigDecimal("10.0"))); value = results.forExpression("QuantityIntervalEnd").value(); - Assert.assertTrue(((Quantity) value) + assertTrue(((Quantity) value) .equal(new Quantity().withValue(new BigDecimal("10.0")).withUnit("g"))); value = results.forExpression("DateTimeIntervalEnd").value(); - Assert.assertTrue( - EquivalentEvaluator.equivalent(value, new DateTime(bigDecimalZoneOffset, 2016, 5, 2, 0, 0, 0, 0))); + assertTrue(EquivalentEvaluator.equivalent(value, new DateTime(bigDecimalZoneOffset, 2016, 5, 2, 0, 0, 0, 0))); value = results.forExpression("TimeIntervalEnd").value(); - Assert.assertTrue(EquivalentEvaluator.equivalent(value, new Time(23, 59, 59, 599))); + assertTrue(EquivalentEvaluator.equivalent(value, new Time(23, 59, 59, 599))); // value = results.forExpression("TestEndsNull").value(); // assertThat(value, is(nullValue())); @@ -427,10 +428,10 @@ public void test_all_interval_operators() { // assertThat(value, is(nullValue())); value = results.forExpression("IntegerIntervalExcept1to3").value(); - Assert.assertTrue(((Interval) value).equal(new Interval(1, true, 3, true))); + assertTrue(((Interval) value).equal(new Interval(1, true, 3, true))); value = results.forExpression("IntegerIntervalExcept4to6").value(); - Assert.assertTrue(((Interval) value).equal(new Interval(-4, false, 6, false))); + assertTrue(((Interval) value).equal(new Interval(-4, false, 6, false))); value = results.forExpression("IntegerIntervalExceptNullOutNull").value(); assertThat(value, is(nullValue())); @@ -439,14 +440,14 @@ public void test_all_interval_operators() { assertThat(value, is(nullValue())); value = results.forExpression("DecimalIntervalExcept1to3").value(); - Assert.assertTrue(((Interval) value) + assertTrue(((Interval) value) .equal(new Interval(new BigDecimal("1.0"), true, new BigDecimal("3.99999999"), true))); value = results.forExpression("DecimalIntervalExceptNull").value(); assertThat(value, is(nullValue())); value = results.forExpression("QuantityIntervalExcept1to4").value(); - Assert.assertTrue(((Interval) value) + assertTrue(((Interval) value) .equal(new Interval( new Quantity().withValue(new BigDecimal("1.0")).withUnit("g"), true, @@ -454,27 +455,27 @@ public void test_all_interval_operators() { true))); value = results.forExpression("Except12").value(); - Assert.assertTrue(((Interval) value).equal(new Interval(1, true, 2, true))); + assertTrue(((Interval) value).equal(new Interval(1, true, 2, true))); value = results.forExpression("ExceptDateTimeInterval").value(); - Assert.assertTrue(EquivalentEvaluator.equivalent( + assertTrue(EquivalentEvaluator.equivalent( ((Interval) value).getStart(), new DateTime(bigDecimalZoneOffset, 2012, 1, 5))); - Assert.assertTrue(EquivalentEvaluator.equivalent( + assertTrue(EquivalentEvaluator.equivalent( ((Interval) value).getEnd(), new DateTime(bigDecimalZoneOffset, 2012, 1, 6))); value = results.forExpression("ExceptDateTime2").value(); - Assert.assertTrue(EquivalentEvaluator.equivalent( + assertTrue(EquivalentEvaluator.equivalent( ((Interval) value).getStart(), new DateTime(bigDecimalZoneOffset, 2012, 1, 13))); - Assert.assertTrue(EquivalentEvaluator.equivalent( + assertTrue(EquivalentEvaluator.equivalent( ((Interval) value).getEnd(), new DateTime(bigDecimalZoneOffset, 2012, 1, 16))); value = results.forExpression("ExceptTimeInterval").value(); - Assert.assertTrue(EquivalentEvaluator.equivalent(((Interval) value).getStart(), new Time(5, 59, 59, 999))); - Assert.assertTrue(EquivalentEvaluator.equivalent(((Interval) value).getEnd(), new Time(8, 59, 59, 998))); + assertTrue(EquivalentEvaluator.equivalent(((Interval) value).getStart(), new Time(5, 59, 59, 999))); + assertTrue(EquivalentEvaluator.equivalent(((Interval) value).getEnd(), new Time(8, 59, 59, 998))); value = results.forExpression("ExceptTime2").value(); - Assert.assertTrue(EquivalentEvaluator.equivalent(((Interval) value).getStart(), new Time(11, 0, 0, 0))); - Assert.assertTrue(EquivalentEvaluator.equivalent(((Interval) value).getEnd(), new Time(11, 59, 59, 999))); + assertTrue(EquivalentEvaluator.equivalent(((Interval) value).getStart(), new Time(11, 0, 0, 0))); + assertTrue(EquivalentEvaluator.equivalent(((Interval) value).getEnd(), new Time(11, 59, 59, 999))); value = results.forExpression("TestInNull").value(); assertThat(value, is(false)); @@ -598,20 +599,19 @@ public void test_all_interval_operators() { assertThat(value, is(nullValue())); value = results.forExpression("IntegerIntervalIntersectTest4to10").value(); - Assert.assertTrue(((Interval) value).equal(new Interval(4, true, 10, true))); + assertTrue(((Interval) value).equal(new Interval(4, true, 10, true))); value = results.forExpression("IntegerIntervalIntersectTestNull").value(); assertThat(value, is(nullValue())); value = results.forExpression("DecimalIntervalIntersectTest4to10").value(); - Assert.assertTrue( - ((Interval) value).equal(new Interval(new BigDecimal("4.0"), true, new BigDecimal("10.0"), true))); + assertTrue(((Interval) value).equal(new Interval(new BigDecimal("4.0"), true, new BigDecimal("10.0"), true))); value = results.forExpression("IntegerIntervalIntersectTestNull").value(); assertThat(value, is(nullValue())); value = results.forExpression("QuantityIntervalIntersectTest5to10").value(); - Assert.assertTrue(((Interval) value) + assertTrue(((Interval) value) .equal(new Interval( new Quantity().withValue(new BigDecimal("5.0")).withUnit("g"), true, @@ -622,14 +622,14 @@ public void test_all_interval_operators() { assertThat(value, is(nullValue())); value = results.forExpression("DateTimeIntersect").value(); - Assert.assertTrue(EquivalentEvaluator.equivalent( + assertTrue(EquivalentEvaluator.equivalent( ((Interval) value).getStart(), new DateTime(bigDecimalZoneOffset, 2012, 1, 7))); - Assert.assertTrue(EquivalentEvaluator.equivalent( + assertTrue(EquivalentEvaluator.equivalent( ((Interval) value).getEnd(), new DateTime(bigDecimalZoneOffset, 2012, 1, 10))); value = results.forExpression("TimeIntersect").value(); - Assert.assertTrue(EquivalentEvaluator.equivalent(((Interval) value).getStart(), new Time(4, 59, 59, 999))); - Assert.assertTrue(EquivalentEvaluator.equivalent(((Interval) value).getEnd(), new Time(6, 59, 59, 999))); + assertTrue(EquivalentEvaluator.equivalent(((Interval) value).getStart(), new Time(4, 59, 59, 999))); + assertTrue(EquivalentEvaluator.equivalent(((Interval) value).getEnd(), new Time(6, 59, 59, 999))); value = results.forExpression("IntegerIntervalEquivalentTrue").value(); assertThat(value, is(true)); @@ -956,16 +956,16 @@ public void test_all_interval_operators() { assertThat(value, is(false)); value = results.forExpression("TestPointFromNull").value(); - Assert.assertTrue(value == null); + assertTrue(value == null); value = results.forExpression("TestPointFromInteger").value(); - Assert.assertTrue((Integer) value == 1); + assertTrue((Integer) value == 1); value = results.forExpression("TestPointFromDecimal").value(); - Assert.assertTrue(((BigDecimal) value).compareTo(new BigDecimal("1.0")) == 0); + assertEquals(0, ((BigDecimal) value).compareTo(new BigDecimal("1.0"))); value = results.forExpression("TestPointFromQuantity").value(); - Assert.assertTrue(((Quantity) value) + assertTrue(((Quantity) value) .equal(new Quantity().withValue(new BigDecimal("1.0")).withUnit("cm"))); value = results.forExpression("TestProperlyIncludesNull").value(); @@ -1077,7 +1077,7 @@ public void test_all_interval_operators() { assertThat(value, is(5)); value = results.forExpression("SizeIsNull").value(); - Assert.assertNull(value); + assertNull(value); value = results.forExpression("IntegerIntervalStart").value(); assertThat(value, is(1)); @@ -1086,15 +1086,14 @@ public void test_all_interval_operators() { assertThat(value, is(new BigDecimal("1.0"))); value = results.forExpression("QuantityIntervalStart").value(); - Assert.assertTrue(((Quantity) value) + assertTrue(((Quantity) value) .equal(new Quantity().withValue(new BigDecimal("1.0")).withUnit("g"))); value = results.forExpression("DateTimeIntervalStart").value(); - Assert.assertTrue( - EquivalentEvaluator.equivalent(value, new DateTime(bigDecimalZoneOffset, 2016, 5, 1, 0, 0, 0, 0))); + assertTrue(EquivalentEvaluator.equivalent(value, new DateTime(bigDecimalZoneOffset, 2016, 5, 1, 0, 0, 0, 0))); value = results.forExpression("TimeIntervalStart").value(); - Assert.assertTrue(EquivalentEvaluator.equivalent(value, new Time(0, 0, 0, 0))); + assertTrue(EquivalentEvaluator.equivalent(value, new Time(0, 0, 0, 0))); value = results.forExpression("TestStartsNull").value(); assertThat(value, is(nullValue())); @@ -1136,20 +1135,19 @@ public void test_all_interval_operators() { assertThat(value, is(nullValue())); value = results.forExpression("IntegerIntervalUnion1To15").value(); - Assert.assertTrue(((Interval) value).equal(new Interval(1, true, 15, true))); + assertTrue(((Interval) value).equal(new Interval(1, true, 15, true))); value = results.forExpression("IntegerIntervalUnionNull").value(); assertThat(value, is(nullValue())); value = results.forExpression("DecimalIntervalUnion1To15").value(); - Assert.assertTrue( - ((Interval) value).equal(new Interval(new BigDecimal("1.0"), true, new BigDecimal("15.0"), true))); + assertTrue(((Interval) value).equal(new Interval(new BigDecimal("1.0"), true, new BigDecimal("15.0"), true))); value = results.forExpression("DecimalIntervalUnionNull").value(); assertThat(value, is(nullValue())); value = results.forExpression("QuantityIntervalUnion1To15").value(); - Assert.assertTrue(((Interval) value) + assertTrue(((Interval) value) .equal(new Interval( new Quantity().withValue(new BigDecimal("1.0")).withUnit("g"), true, @@ -1160,17 +1158,17 @@ public void test_all_interval_operators() { assertThat(value, is(nullValue())); value = results.forExpression("DateTimeUnion").value(); - Assert.assertTrue(EquivalentEvaluator.equivalent( + assertTrue(EquivalentEvaluator.equivalent( ((Interval) value).getStart(), new DateTime(bigDecimalZoneOffset, 2012, 1, 5))); - Assert.assertTrue(EquivalentEvaluator.equivalent( + assertTrue(EquivalentEvaluator.equivalent( ((Interval) value).getEnd(), new DateTime(bigDecimalZoneOffset, 2012, 1, 28))); value = results.forExpression("DateTimeUnionNull").value(); assertThat(value, is(nullValue())); value = results.forExpression("TimeUnion").value(); - Assert.assertTrue(EquivalentEvaluator.equivalent(((Interval) value).getStart(), new Time(5, 59, 59, 999))); - Assert.assertTrue(EquivalentEvaluator.equivalent(((Interval) value).getEnd(), new Time(20, 59, 59, 999))); + assertTrue(EquivalentEvaluator.equivalent(((Interval) value).getStart(), new Time(5, 59, 59, 999))); + assertTrue(EquivalentEvaluator.equivalent(((Interval) value).getEnd(), new Time(20, 59, 59, 999))); value = results.forExpression("TimeUnionNull").value(); assertThat(value, is(nullValue())); diff --git a/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/execution/Issue208.java b/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/execution/Issue208.java index 75d154c50..c1eda834f 100644 --- a/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/execution/Issue208.java +++ b/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/execution/Issue208.java @@ -1,31 +1,32 @@ package org.opencds.cqf.cql.engine.execution; +import static org.junit.jupiter.api.Assertions.assertTrue; + import java.util.List; +import org.junit.jupiter.api.Test; import org.opencds.cqf.cql.engine.elm.executing.EquivalentEvaluator; -import org.testng.Assert; -import org.testng.annotations.Test; -public class Issue208 extends CqlTestBase { +class Issue208 extends CqlTestBase { @Test - public void testInterval() { + void interval() { var results = engine.evaluate(toElmIdentifier("Issue208")); var value = results.forExpression("Let Test 1").value(); - Assert.assertTrue(EquivalentEvaluator.equivalent(((List) (((List) value).get(0))).get(0), 1)); - Assert.assertTrue(EquivalentEvaluator.equivalent(((List) (((List) value).get(0))).get(1), 2)); - Assert.assertTrue(EquivalentEvaluator.equivalent(((List) (((List) value).get(0))).get(2), 3)); + assertTrue(EquivalentEvaluator.equivalent(((List) (((List) value).get(0))).get(0), 1)); + assertTrue(EquivalentEvaluator.equivalent(((List) (((List) value).get(0))).get(1), 2)); + assertTrue(EquivalentEvaluator.equivalent(((List) (((List) value).get(0))).get(2), 3)); - Assert.assertTrue(EquivalentEvaluator.equivalent(((List) (((List) value).get(1))).get(0), 4)); - Assert.assertTrue(EquivalentEvaluator.equivalent(((List) (((List) value).get(1))).get(1), 5)); - Assert.assertTrue(EquivalentEvaluator.equivalent(((List) (((List) value).get(1))).get(2), 6)); + assertTrue(EquivalentEvaluator.equivalent(((List) (((List) value).get(1))).get(0), 4)); + assertTrue(EquivalentEvaluator.equivalent(((List) (((List) value).get(1))).get(1), 5)); + assertTrue(EquivalentEvaluator.equivalent(((List) (((List) value).get(1))).get(2), 6)); value = results.forExpression("Let Test 2").value(); - Assert.assertTrue(EquivalentEvaluator.equivalent(((List) (((List) value).get(0))).get(0), 1)); - Assert.assertTrue(EquivalentEvaluator.equivalent(((List) (((List) value).get(0))).get(1), 2)); - Assert.assertTrue(EquivalentEvaluator.equivalent(((List) (((List) value).get(0))).get(2), 3)); + assertTrue(EquivalentEvaluator.equivalent(((List) (((List) value).get(0))).get(0), 1)); + assertTrue(EquivalentEvaluator.equivalent(((List) (((List) value).get(0))).get(1), 2)); + assertTrue(EquivalentEvaluator.equivalent(((List) (((List) value).get(0))).get(2), 3)); - Assert.assertTrue(EquivalentEvaluator.equivalent(((List) (((List) value).get(1))).get(0), 4)); - Assert.assertTrue(EquivalentEvaluator.equivalent(((List) (((List) value).get(1))).get(1), 5)); - Assert.assertTrue(EquivalentEvaluator.equivalent(((List) (((List) value).get(1))).get(2), 6)); + assertTrue(EquivalentEvaluator.equivalent(((List) (((List) value).get(1))).get(0), 4)); + assertTrue(EquivalentEvaluator.equivalent(((List) (((List) value).get(1))).get(1), 5)); + assertTrue(EquivalentEvaluator.equivalent(((List) (((List) value).get(1))).get(2), 6)); } } diff --git a/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/execution/Issue213.java b/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/execution/Issue213.java index 8886f8c4a..5c41a06fc 100644 --- a/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/execution/Issue213.java +++ b/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/execution/Issue213.java @@ -1,23 +1,25 @@ package org.opencds.cqf.cql.engine.execution; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Test; -public class Issue213 extends CqlTestBase { +class Issue213 extends CqlTestBase { @Test - public void testInterval() { + void interval() { // // // results = engine.evaluate(toElmIdentifier("Issue213"), null, null, null, null, null); // Object value = results.forExpression("Collapsed Treatment Intervals").value(); - // Assert.assertTrue(EquivalentEvaluator.equivalent(((Interval) ((List) value).get(0)).getStart(), new + // Assertions.assertTrue(EquivalentEvaluator.equivalent(((Interval) ((List) value).get(0)).getStart(), + // new // DateTime(null, 2018, 1, 1))); - // Assert.assertTrue(EquivalentEvaluator.equivalent(((Interval) ((List) value).get(0)).getEnd(), new + // Assertions.assertTrue(EquivalentEvaluator.equivalent(((Interval) ((List) value).get(0)).getEnd(), new // DateTime(null, 2018, 8, 28))); - // Assert.assertTrue(EquivalentEvaluator.equivalent(((Interval) ((List) value).get(1)).getStart(), new + // Assertions.assertTrue(EquivalentEvaluator.equivalent(((Interval) ((List) value).get(1)).getStart(), + // new // DateTime(null, 2018, 8, 30))); - // Assert.assertTrue(EquivalentEvaluator.equivalent(((Interval) ((List) value).get(1)).getEnd(), new + // Assertions.assertTrue(EquivalentEvaluator.equivalent(((Interval) ((List) value).get(1)).getEnd(), new // DateTime(null, 2018, 10, 15))); // assertTrue(((List) value).size() == 2); } diff --git a/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/execution/Issue223.java b/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/execution/Issue223.java index 8512e0e47..6b62f5369 100644 --- a/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/execution/Issue223.java +++ b/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/execution/Issue223.java @@ -4,12 +4,12 @@ import static org.hamcrest.Matchers.is; import java.util.List; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Test; -public class Issue223 extends CqlTestBase { +class Issue223 extends CqlTestBase { @Test - public void testInterval() { + void interval() { var results = engine.evaluate(toElmIdentifier("Issue223")); var value = results.forExpression("Access Flattened List of List Items").value(); List list = (List) value; diff --git a/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/execution/Issue33.java b/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/execution/Issue33.java index 65f864226..29e90734f 100644 --- a/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/execution/Issue33.java +++ b/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/execution/Issue33.java @@ -1,23 +1,24 @@ package org.opencds.cqf.cql.engine.execution; +import static org.junit.jupiter.api.Assertions.assertTrue; + import java.math.BigDecimal; +import org.junit.jupiter.api.Test; import org.opencds.cqf.cql.engine.elm.executing.EquivalentEvaluator; import org.opencds.cqf.cql.engine.runtime.DateTime; import org.opencds.cqf.cql.engine.runtime.Interval; -import org.testng.Assert; -import org.testng.annotations.Test; -public class Issue33 extends CqlTestBase { +class Issue33 extends CqlTestBase { @Test - public void testInterval() { + void interval() { final BigDecimal bigDecimalZoneOffset = getBigDecimalZoneOffset(); var results = engine.evaluate(toElmIdentifier("Issue33")); Object value = results.forExpression("Issue33").value(); - Assert.assertTrue(EquivalentEvaluator.equivalent( + assertTrue(EquivalentEvaluator.equivalent( ((Interval) value).getStart(), new DateTime(bigDecimalZoneOffset, 2017, 12, 20, 11, 0, 0))); - Assert.assertTrue(EquivalentEvaluator.equivalent( + assertTrue(EquivalentEvaluator.equivalent( ((Interval) value).getEnd(), new DateTime(bigDecimalZoneOffset, 2017, 12, 20, 23, 59, 59, 999))); } } diff --git a/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/execution/Issue39.java b/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/execution/Issue39.java index 63f370eef..aa6bbd23a 100644 --- a/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/execution/Issue39.java +++ b/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/execution/Issue39.java @@ -3,12 +3,12 @@ import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.is; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Test; -public class Issue39 extends CqlTestBase { +class Issue39 extends CqlTestBase { @Test - public void testInterval() { + void interval() { var results = engine.evaluate(toElmIdentifier("Issue39")); Object value = results.forExpression("EquivalentIntervals").value(); assertThat(value, is(true)); diff --git a/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/execution/Issue458.java b/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/execution/Issue458.java index 8964115d6..83feb7a56 100644 --- a/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/execution/Issue458.java +++ b/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/execution/Issue458.java @@ -1,17 +1,17 @@ package org.opencds.cqf.cql.engine.execution; -import static org.testng.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; +import org.junit.jupiter.api.Test; import org.opencds.cqf.cql.engine.runtime.Interval; -import org.testng.annotations.Test; -public class Issue458 extends CqlTestBase { +class Issue458 extends CqlTestBase { @Test - public void testInterval() { + void interval() { var results = engine.evaluate(toElmIdentifier("Issue458")); var value = results.forExpression("Closed-Open Interval").value(); Interval interval = (Interval) value; - assertEquals(interval.toString(), "Interval[3, 5)"); + assertEquals("Interval[3, 5)", interval.toString()); } } diff --git a/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/execution/LetClauseOutsideQueryContextTest.java b/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/execution/LetClauseOutsideQueryContextTest.java index b02851265..2af696886 100644 --- a/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/execution/LetClauseOutsideQueryContextTest.java +++ b/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/execution/LetClauseOutsideQueryContextTest.java @@ -1,20 +1,21 @@ package org.opencds.cqf.cql.engine.execution; +import static org.junit.jupiter.api.Assertions.assertTrue; + import java.util.List; +import org.junit.jupiter.api.Test; import org.opencds.cqf.cql.engine.elm.executing.EquivalentEvaluator; -import org.testng.Assert; -import org.testng.annotations.Test; -public class LetClauseOutsideQueryContextTest extends CqlTestBase { +class LetClauseOutsideQueryContextTest extends CqlTestBase { @Test - public void testEvaluate() { + void evaluate() { var results = engine.evaluate(toElmIdentifier("LetClauseOutsideQueryContextTest")); var value = results.forExpression("First Position of list").value(); - Assert.assertTrue(EquivalentEvaluator.equivalent(((List) value).get(0), 1)); + assertTrue(EquivalentEvaluator.equivalent(((List) value).get(0), 1)); value = results.forExpression("Third Position of list With Same Name of Let As First") .value(); - Assert.assertTrue(EquivalentEvaluator.equivalent(((List) value).get(0), 3)); + assertTrue(EquivalentEvaluator.equivalent(((List) value).get(0), 3)); } } diff --git a/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/execution/ListOperatorsTest.java b/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/execution/ListOperatorsTest.java index dfafdfb95..193bd8faa 100644 --- a/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/execution/ListOperatorsTest.java +++ b/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/execution/ListOperatorsTest.java @@ -2,9 +2,9 @@ import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.*; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; import static org.opencds.cqf.cql.engine.elm.executing.EquivalentEvaluator.equivalent; -import static org.testng.Assert.assertFalse; -import static org.testng.Assert.assertTrue; import java.math.BigDecimal; import java.util.ArrayList; @@ -13,13 +13,13 @@ import java.util.List; import org.cqframework.cql.cql2elm.CqlCompilerException; import org.cqframework.cql.cql2elm.CqlCompilerOptions; +import org.junit.jupiter.api.Test; import org.opencds.cqf.cql.engine.runtime.*; -import org.testng.annotations.Test; -public class ListOperatorsTest extends CqlTestBase { +class ListOperatorsTest extends CqlTestBase { @Test - public void test_cql_list_test_suite_compiles() { + void cql_list_test_suite_compiles() { var errors = new ArrayList(); this.getLibrary(toElmIdentifier("CqlListOperatorsTest"), errors, testCompilerOptions()); assertFalse( @@ -28,7 +28,7 @@ public void test_cql_list_test_suite_compiles() { } @Test - public void test_all_interval_operators() { + void all_interval_operators() { final BigDecimal bigDecimalZoneOffset = getBigDecimalZoneOffset(); var eng = getEngine(testCompilerOptions()); @@ -696,7 +696,7 @@ public void test_all_interval_operators() { } @Test - public void test_union_operator() { + void union_operator() { final BigDecimal bigDecimalZoneOffset = getBigDecimalZoneOffset(); var eng = getEngine(testCompilerOptions()); var results = eng.evaluate(toElmIdentifier("CqlListOperatorsTest")); diff --git a/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/execution/RuntimeTests.java b/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/execution/RuntimeTests.java index 01f45cc31..b50a5204d 100644 --- a/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/execution/RuntimeTests.java +++ b/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/execution/RuntimeTests.java @@ -2,19 +2,20 @@ import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.is; +import static org.junit.jupiter.api.Assertions.assertThrows; import java.math.BigDecimal; +import org.junit.jupiter.api.Test; import org.opencds.cqf.cql.engine.debug.Location; import org.opencds.cqf.cql.engine.debug.SourceLocator; import org.opencds.cqf.cql.engine.exception.InvalidInterval; import org.opencds.cqf.cql.engine.runtime.Interval; import org.opencds.cqf.cql.engine.runtime.Quantity; import org.opencds.cqf.cql.engine.runtime.Tuple; -import org.testng.annotations.Test; -public class RuntimeTests { +class RuntimeTests { @Test - public void testQuantityToString() { + void quantityToString() { Quantity q = new Quantity().withValue(null).withUnit(null); assertThat(q.toString(), is("null 'null'")); @@ -28,15 +29,18 @@ public void testQuantityToString() { assertThat(q.toString(), is("0.05 'mg'")); } - @Test(expectedExceptions = InvalidInterval.class) - public void testIntervalOfQuantityWithDifferentUOM() { + @Test + void intervalOfQuantityWithDifferentUOM() { Quantity s = new Quantity().withValue(new BigDecimal(10)).withUnit("mg/mL"); Quantity e = new Quantity().withValue(new BigDecimal(10)).withUnit("kg/m3"); - new Interval(s, true, e, true); + + assertThrows(InvalidInterval.class, () -> { + new Interval(s, true, e, true); + }); } @Test - public void testTupleToString() { + void tupleToString() { Tuple t = new Tuple(); assertThat(t.toString(), is("Tuple { : }")); @@ -48,7 +52,7 @@ public void testTupleToString() { } @Test - public void testSourceLocation() { + void sourceLocation() { SourceLocator sourceLocator = new SourceLocator( "http://cql.hl7.org/Library/Example", "Example", diff --git a/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/execution/SignatureOutputTests.java b/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/execution/SignatureOutputTests.java index 596823ca4..b9f132bb6 100644 --- a/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/execution/SignatureOutputTests.java +++ b/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/execution/SignatureOutputTests.java @@ -4,12 +4,12 @@ import static org.hamcrest.Matchers.is; import java.math.BigDecimal; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Test; -public class SignatureOutputTests extends CqlTestBase { +class SignatureOutputTests extends CqlTestBase { @Test - public void testEvaluate() { + void evaluate() { var results = engine.evaluate(toElmIdentifier("SignatureOutputTests")); var value = results.forExpression("TestIntegerOverload").value(); assertThat(value, is(new BigDecimal("1"))); diff --git a/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/execution/SortDescendingTest.java b/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/execution/SortDescendingTest.java index aadd3f08d..4b5ca580a 100644 --- a/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/execution/SortDescendingTest.java +++ b/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/execution/SortDescendingTest.java @@ -1,19 +1,20 @@ package org.opencds.cqf.cql.engine.execution; +import static org.junit.jupiter.api.Assertions.assertTrue; + import java.util.List; +import org.junit.jupiter.api.Test; import org.opencds.cqf.cql.engine.elm.executing.EquivalentEvaluator; -import org.testng.Assert; -import org.testng.annotations.Test; -public class SortDescendingTest extends CqlTestBase { +class SortDescendingTest extends CqlTestBase { @Test - public void testEvaluate() { + void evaluate() { var results = engine.evaluate(toElmIdentifier("SortDescendingTest")); var value = results.forExpression("sorted list of numbers descending").value(); - Assert.assertTrue(EquivalentEvaluator.equivalent(((List) value).get(0), 9)); - Assert.assertTrue(EquivalentEvaluator.equivalent(((List) value).get(1), 4)); - Assert.assertTrue(EquivalentEvaluator.equivalent(((List) value).get(2), 2)); - Assert.assertTrue(EquivalentEvaluator.equivalent(((List) value).get(3), 1)); + assertTrue(EquivalentEvaluator.equivalent(((List) value).get(0), 9)); + assertTrue(EquivalentEvaluator.equivalent(((List) value).get(1), 4)); + assertTrue(EquivalentEvaluator.equivalent(((List) value).get(2), 2)); + assertTrue(EquivalentEvaluator.equivalent(((List) value).get(3), 1)); } } diff --git a/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/execution/TestUnion.java b/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/execution/TestUnion.java index d56d1de1d..c24361bdb 100644 --- a/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/execution/TestUnion.java +++ b/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/execution/TestUnion.java @@ -1,16 +1,16 @@ package org.opencds.cqf.cql.engine.execution; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; import java.util.List; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Test; -public class TestUnion extends CqlTestBase { +class TestUnion extends CqlTestBase { @Test - public void testUnion() { + void union() { var results = engine.evaluate(toElmIdentifier("TestUnion")); var value = results.forExpression("NullAndNull").value(); assertNotNull(value); diff --git a/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/model/CachingModelResolverDecoratorTest.java b/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/model/CachingModelResolverDecoratorTest.java index 9c9ef8cea..493b85437 100644 --- a/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/model/CachingModelResolverDecoratorTest.java +++ b/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/model/CachingModelResolverDecoratorTest.java @@ -1,24 +1,23 @@ package org.opencds.cqf.cql.engine.model; +import static org.junit.jupiter.api.Assertions.assertEquals; import static org.mockito.ArgumentMatchers.isA; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; -import static org.testng.Assert.assertEquals; import java.util.Date; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.mockito.Mock; import org.mockito.MockitoAnnotations; import org.opencds.cqf.cql.engine.data.CompositeDataProvider; import org.opencds.cqf.cql.engine.retrieve.RetrieveProvider; -import org.testng.Assert; -import org.testng.annotations.AfterMethod; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; // TODO: Extend testing to cover more of the CachedModelResolver -public class CachingModelResolverDecoratorTest { +class CachingModelResolverDecoratorTest { @Mock private ModelResolver mockModelResolver; @@ -27,19 +26,19 @@ public class CachingModelResolverDecoratorTest { private AutoCloseable mocks; - @BeforeMethod + @BeforeEach void before() { mocks = MockitoAnnotations.openMocks(this); } - @AfterMethod + @AfterEach void after() throws Exception { mocks.close(); } @Test @SuppressWarnings("deprecation") - public void context_path_resolved_only_once() { + void context_path_resolved_only_once() { var m = mock(ModelResolver.class); when(m.getPackageName()).thenReturn("test.package"); when(m.getContextPath("Patient", "Patient")).thenReturn("id"); @@ -54,7 +53,7 @@ public void context_path_resolved_only_once() { @Test @SuppressWarnings({"unchecked", "deprecation"}) - public void type_resolved_only_once() { + void type_resolved_only_once() { var m = mock(ModelResolver.class); when(m.getPackageName()).thenReturn("test.package"); when(m.resolveType(isA(Integer.class))).thenReturn((Class) Integer.class); @@ -69,7 +68,7 @@ public void type_resolved_only_once() { } @Test - void testResolveIdString() { + void resolveIdString() { final String object = "object"; final String id = "text"; @@ -78,12 +77,12 @@ void testResolveIdString() { final CompositeDataProvider compositeDataProvider = new CompositeDataProvider(mockModelResolver, mockRetrieveProvider); - Assert.assertEquals(id, compositeDataProvider.resolveId(object)); + assertEquals(id, compositeDataProvider.resolveId(object)); verify(mockModelResolver, times(1)).resolveId(object); } @Test - void testResolveIdIntLong() { + void resolveIdIntLong() { final long object = 1L; final String id = "oneL"; @@ -92,12 +91,12 @@ void testResolveIdIntLong() { final CompositeDataProvider compositeDataProvider = new CompositeDataProvider(mockModelResolver, mockRetrieveProvider); - Assert.assertEquals(id, compositeDataProvider.resolveId(object)); + assertEquals(id, compositeDataProvider.resolveId(object)); verify(mockModelResolver, times(1)).resolveId(object); } @Test - void testResolveIdDate() { + void resolveIdDate() { final Date object = new Date(); final String id = "now"; @@ -106,7 +105,7 @@ void testResolveIdDate() { final CompositeDataProvider compositeDataProvider = new CompositeDataProvider(mockModelResolver, mockRetrieveProvider); - Assert.assertEquals(id, compositeDataProvider.resolveId(object)); + assertEquals(id, compositeDataProvider.resolveId(object)); verify(mockModelResolver, times(1)).resolveId(object); } } diff --git a/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/runtime/DateTimeTest.java b/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/runtime/DateTimeTest.java index 3d85703c5..f05388a83 100644 --- a/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/runtime/DateTimeTest.java +++ b/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/runtime/DateTimeTest.java @@ -1,6 +1,6 @@ package org.opencds.cqf.cql.engine.runtime; -import static org.testng.Assert.*; +import static org.junit.jupiter.api.Assertions.*; import java.math.BigDecimal; import java.math.RoundingMode; @@ -8,13 +8,14 @@ import java.time.format.DateTimeFormatter; import java.time.temporal.ChronoField; import java.util.List; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import org.opencds.cqf.cql.engine.exception.CqlException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; -public class DateTimeTest { +class DateTimeTest { private static final Logger logger = LoggerFactory.getLogger(DateTimeTest.class); private static final LocalDateTime DST_2023_10_26_22_12_0 = LocalDateTime.of(2023, Month.OCTOBER, 26, 22, 12, 0); @@ -75,7 +76,6 @@ private static List toList(LocalDateTime localDateTime) { localDateTime.getSecond()); } - @DataProvider private static Object[][] dateStrings() { return new Object[][] { {DST_2023_10_26_22_12_0_STRING, ZoneOffset.UTC, Precision.HOUR}, @@ -97,8 +97,9 @@ private static Object[][] dateStrings() { }; } - @Test(dataProvider = "dateStrings") - void testDateStrings(String dateString, ZoneOffset zoneOffset, Precision precision) { + @ParameterizedTest + @MethodSource("dateStrings") + void dateStrings(String dateString, ZoneOffset zoneOffset, Precision precision) { final DateTime dateTime = new DateTime(dateString, zoneOffset); final OffsetDateTime normalizedDateTime = dateTime.getNormalized(precision); @@ -106,12 +107,12 @@ void testDateStrings(String dateString, ZoneOffset zoneOffset, Precision precisi assertEquals(normalizedDateTime, dateTime.getDateTime()); } - @Test(expectedExceptions = CqlException.class) - void testDateStringsNullOffsets() { - new DateTime(DST_2023_10_26_22_12_0_STRING, null); + @Test + void dateStringsNullOffsets() { + assertThrows(CqlException.class, () -> new DateTime(DST_2023_10_26_22_12_0_STRING, null)); + ; } - @DataProvider private static Object[][] dateStringsOtherZoneId() { return new Object[][] { {DST_2023_10_26_22_12_0, DST_OFFSET_NORTH_AMERICA_EASTERN, DST_OFFSET_NORTH_AMERICA_MOUNTAIN, Precision.HOUR @@ -209,8 +210,9 @@ private static Object[][] dateStringsOtherZoneId() { }; } - @Test(dataProvider = "dateStringsOtherZoneId") - void testDateStringsOtherZoneId( + @ParameterizedTest + @MethodSource("dateStringsOtherZoneId") + void dateStringsOtherZoneId( LocalDateTime localDateTime, ZoneOffset zoneOffsetInit, ZoneOffset zonedOffsetGetNormalized, @@ -226,7 +228,6 @@ void testDateStringsOtherZoneId( assertEquals(normalizedDateTime, expectedOffsetDateTime); } - @DataProvider private static Object[][] offsetPrecisions() { return new Object[][] { {DST_2023_10_26_22_12_0, ZoneOffset.UTC, Precision.HOUR}, @@ -248,8 +249,9 @@ private static Object[][] offsetPrecisions() { }; } - @Test(dataProvider = "offsetPrecisions") - void testOffsetPrecisions(LocalDateTime localDateTime, ZoneOffset zoneOffset, Precision precision) { + @ParameterizedTest + @MethodSource("offsetPrecisions") + void offsetPrecisions(LocalDateTime localDateTime, ZoneOffset zoneOffset, Precision precision) { final OffsetDateTime offsetDateTime = OffsetDateTime.of(localDateTime, zoneOffset); final DateTime dateTimeNoPrecision = new DateTime(offsetDateTime); final DateTime dateTimePrecision = new DateTime(offsetDateTime, precision); @@ -261,7 +263,6 @@ void testOffsetPrecisions(LocalDateTime localDateTime, ZoneOffset zoneOffset, Pr assertEquals(normalizedDateTimePrecision, dateTimePrecision.getDateTime()); } - @DataProvider private static Object[][] bigDecimals() { return new Object[][] { {BigDecimal.ZERO, Precision.HOUR, DST_2023_10_26_22_12_0_INTS}, @@ -283,8 +284,9 @@ private static Object[][] bigDecimals() { }; } - @Test(dataProvider = "bigDecimals") - void testBigDecimal(BigDecimal offset, Precision precision, List dateElements) { + @ParameterizedTest + @MethodSource("bigDecimals") + void bigDecimal(BigDecimal offset, Precision precision, List dateElements) { final int[] dateElementsArray = dateElements.stream().mapToInt(anInt -> anInt).toArray(); final DateTime dateTime = new DateTime(offset, dateElementsArray); @@ -303,11 +305,11 @@ void testBigDecimal(BigDecimal offset, Precision precision, List dateEl assertEquals(normalizedDateTime, dateTime.getDateTime()); } - @Test(expectedExceptions = CqlException.class) - void testNullBigDecimalOffset() { - new DateTime( - null, - DST_2023_10_26_22_12_0_INTS.stream().mapToInt(anInt -> anInt).toArray()); + @Test + void nullBigDecimalOffset() { + var digits = + DST_2023_10_26_22_12_0_INTS.stream().mapToInt(anInt -> anInt).toArray(); + assertThrows(CqlException.class, () -> new DateTime(null, digits)); } private static final ZoneId UTC = ZoneId.of("UTC"); @@ -317,7 +319,6 @@ void testNullBigDecimalOffset() { private static final LocalDateTime DST_2023_11_01 = LocalDateTime.of(2023, Month.NOVEMBER, 1, 0, 0, 0); private static final LocalDateTime NON_DST_2023_11_13 = LocalDateTime.of(2023, Month.NOVEMBER, 13, 0, 0, 0); - @DataProvider private static Object[][] timeZones() { return new Object[][] { {UTC, DST_2023_11_01}, {MONTREAL, DST_2023_11_01}, {REGINA, DST_2023_11_01}, @@ -325,8 +326,9 @@ private static Object[][] timeZones() { }; } - @Test(dataProvider = "timeZones") - void testBigDecimalWithCustomTimezoneAndNow(ZoneId zoneId, LocalDateTime now) { + @ParameterizedTest + @MethodSource("timeZones") + void bigDecimalWithCustomTimezoneAndNow(ZoneId zoneId, LocalDateTime now) { final ZoneOffset currentOffsetForMyZone = zoneId.getRules().getOffset(now); final BigDecimal offset = TemporalHelper.zoneToOffset(currentOffsetForMyZone); @@ -340,12 +342,12 @@ void testBigDecimalWithCustomTimezoneAndNow(ZoneId zoneId, LocalDateTime now) { } @Test - void testDateTimeEquals() { + void dateTimeEquals() { var dateTime = new DateTime(BigDecimal.ONE, 2020); - assertTrue(dateTime.equals(dateTime)); - assertFalse(dateTime.equals(null)); - assertFalse(dateTime.equals(1)); + assertEquals(dateTime, dateTime); + assertNotEquals(null, dateTime); + assertNotEquals(1, dateTime); var dateTime2 = new DateTime(BigDecimal.ONE, 2020); diff --git a/Src/java/model-jackson/src/test/java/org/hl7/elm_modelinfo/r1/serializing/jackson/JacksonModelInfoLoadingTests.java b/Src/java/model-jackson/src/test/java/org/hl7/elm_modelinfo/r1/serializing/jackson/JacksonModelInfoLoadingTests.java index db80642a3..3211164f4 100644 --- a/Src/java/model-jackson/src/test/java/org/hl7/elm_modelinfo/r1/serializing/jackson/JacksonModelInfoLoadingTests.java +++ b/Src/java/model-jackson/src/test/java/org/hl7/elm_modelinfo/r1/serializing/jackson/JacksonModelInfoLoadingTests.java @@ -7,180 +7,180 @@ import org.cqframework.cql.cql2elm.quick.QuickFhirModelInfoProvider; import org.cqframework.cql.cql2elm.quick.QuickModelInfoProvider; import org.hl7.cql.model.SystemModelInfoProvider; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Test; -public class JacksonModelInfoLoadingTests { +class JacksonModelInfoLoadingTests { @Test - public void testSystem() throws IOException { + void system() throws IOException { new org.hl7.elm_modelinfo.r1.serializing.jackson.XmlModelInfoReader() .read(SystemModelInfoProvider.class.getResourceAsStream("/org/hl7/elm/r1/system-modelinfo.xml")); } @Test - public void testUSCore310() throws IOException { + void uSCore310() throws IOException { new org.hl7.elm_modelinfo.r1.serializing.jackson.XmlModelInfoReader() .read(QuickModelInfoProvider.class.getResourceAsStream("/org/hl7/fhir/uscore-modelinfo-3.1.0.xml")); } @Test - public void testUSCore311() throws IOException { + void uSCore311() throws IOException { new org.hl7.elm_modelinfo.r1.serializing.jackson.XmlModelInfoReader() .read(QuickModelInfoProvider.class.getResourceAsStream("/org/hl7/fhir/uscore-modelinfo-3.1.1.xml")); } @Test - public void testQuickFhir301() throws IOException { + void quickFhir301() throws IOException { new org.hl7.elm_modelinfo.r1.serializing.jackson.XmlModelInfoReader() .read(QuickFhirModelInfoProvider.class.getResourceAsStream( "/org/hl7/fhir/quickfhir-modelinfo-3.0.1.xml")); } @Test - public void testQuick330() throws IOException { + void quick330() throws IOException { new org.hl7.elm_modelinfo.r1.serializing.jackson.XmlModelInfoReader() .read(QuickModelInfoProvider.class.getResourceAsStream("/org/hl7/fhir/quick-modelinfo-3.3.0.xml")); } @Test - public void testQuick300() throws IOException { + void quick300() throws IOException { new org.hl7.elm_modelinfo.r1.serializing.jackson.XmlModelInfoReader() .read(QuickModelInfoProvider.class.getResourceAsStream("/org/hl7/fhir/quick-modelinfo-3.0.0.xml")); } @Test - public void testQuick() throws IOException { + void quick() throws IOException { new org.hl7.elm_modelinfo.r1.serializing.jackson.XmlModelInfoReader() .read(QuickModelInfoProvider.class.getResourceAsStream("/org/hl7/fhir/quick-modelinfo.xml")); } @Test - public void testQICore400() throws IOException { + void qICore400() throws IOException { new org.hl7.elm_modelinfo.r1.serializing.jackson.XmlModelInfoReader() .read(QICoreModelInfoProvider.class.getResourceAsStream("/org/hl7/fhir/qicore-modelinfo-4.0.0.xml")); } @Test - public void testQICore410() throws IOException { + void qICore410() throws IOException { new org.hl7.elm_modelinfo.r1.serializing.jackson.XmlModelInfoReader() .read(QICoreModelInfoProvider.class.getResourceAsStream("/org/hl7/fhir/qicore-modelinfo-4.1.0.xml")); } @Test - public void testQICore411() throws IOException { + void qICore411() throws IOException { new org.hl7.elm_modelinfo.r1.serializing.jackson.XmlModelInfoReader() .read(QICoreModelInfoProvider.class.getResourceAsStream("/org/hl7/fhir/qicore-modelinfo-4.1.1.xml")); } @Test - public void testQDM() throws IOException { + void qdm() throws IOException { new org.hl7.elm_modelinfo.r1.serializing.jackson.XmlModelInfoReader() .read(QdmModelInfoProvider.class.getResourceAsStream("/gov/healthit/qdm/qdm-modelinfo.xml")); } @Test - public void testQDM420() throws IOException { + void qdm420() throws IOException { new org.hl7.elm_modelinfo.r1.serializing.jackson.XmlModelInfoReader() .read(QdmModelInfoProvider.class.getResourceAsStream("/gov/healthit/qdm/qdm-modelinfo-4.2.xml")); } @Test - public void testQDM430() throws IOException { + void qdm430() throws IOException { new org.hl7.elm_modelinfo.r1.serializing.jackson.XmlModelInfoReader() .read(QdmModelInfoProvider.class.getResourceAsStream("/gov/healthit/qdm/qdm-modelinfo-4.3.xml")); } @Test - public void testQDM500() throws IOException { + void qdm500() throws IOException { new org.hl7.elm_modelinfo.r1.serializing.jackson.XmlModelInfoReader() .read(QdmModelInfoProvider.class.getResourceAsStream("/gov/healthit/qdm/qdm-modelinfo-5.0.xml")); } @Test - public void testQDM501() throws IOException { + void qdm501() throws IOException { new org.hl7.elm_modelinfo.r1.serializing.jackson.XmlModelInfoReader() .read(QdmModelInfoProvider.class.getResourceAsStream("/gov/healthit/qdm/qdm-modelinfo-5.0.1.xml")); } @Test - public void testQDM502() throws IOException { + void qdm502() throws IOException { new org.hl7.elm_modelinfo.r1.serializing.jackson.XmlModelInfoReader() .read(QdmModelInfoProvider.class.getResourceAsStream("/gov/healthit/qdm/qdm-modelinfo-5.0.2.xml")); } @Test - public void testQDM530() throws IOException { + void qdm530() throws IOException { new org.hl7.elm_modelinfo.r1.serializing.jackson.XmlModelInfoReader() .read(QdmModelInfoProvider.class.getResourceAsStream("/gov/healthit/qdm/qdm-modelinfo-5.3.xml")); } @Test - public void testQDM540() throws IOException { + void qdm540() throws IOException { new org.hl7.elm_modelinfo.r1.serializing.jackson.XmlModelInfoReader() .read(QdmModelInfoProvider.class.getResourceAsStream("/gov/healthit/qdm/qdm-modelinfo-5.4.xml")); } @Test - public void testQDM550() throws IOException { + void qdm550() throws IOException { new org.hl7.elm_modelinfo.r1.serializing.jackson.XmlModelInfoReader() .read(QdmModelInfoProvider.class.getResourceAsStream("/gov/healthit/qdm/qdm-modelinfo-5.5.xml")); } @Test - public void testQDM560() throws IOException { + void qdm560() throws IOException { new org.hl7.elm_modelinfo.r1.serializing.jackson.XmlModelInfoReader() .read(QdmModelInfoProvider.class.getResourceAsStream("/gov/healthit/qdm/qdm-modelinfo-5.6.xml")); } @Test - public void testFhirModelInfo102() throws IOException { + void fhirModelInfo102() throws IOException { new org.hl7.elm_modelinfo.r1.serializing.jackson.XmlModelInfoReader() .read(FhirModelInfoProvider.class.getResourceAsStream("/org/hl7/fhir/fhir-modelinfo-1.0.2.xml")); } @Test - public void testFhirModelInfo140() throws IOException { + void fhirModelInfo140() throws IOException { new org.hl7.elm_modelinfo.r1.serializing.jackson.XmlModelInfoReader() .read(FhirModelInfoProvider.class.getResourceAsStream("/org/hl7/fhir/fhir-modelinfo-1.4.xml")); } @Test - public void testFhirModelInfo160() throws IOException { + void fhirModelInfo160() throws IOException { new org.hl7.elm_modelinfo.r1.serializing.jackson.XmlModelInfoReader() .read(FhirModelInfoProvider.class.getResourceAsStream("/org/hl7/fhir/fhir-modelinfo-1.6.xml")); } @Test - public void testFhirModelInfo180() throws IOException { + void fhirModelInfo180() throws IOException { new org.hl7.elm_modelinfo.r1.serializing.jackson.XmlModelInfoReader() .read(FhirModelInfoProvider.class.getResourceAsStream("/org/hl7/fhir/fhir-modelinfo-1.8.xml")); } @Test - public void testFhirModelInfo300() throws IOException { + void fhirModelInfo300() throws IOException { new org.hl7.elm_modelinfo.r1.serializing.jackson.XmlModelInfoReader() .read(FhirModelInfoProvider.class.getResourceAsStream("/org/hl7/fhir/fhir-modelinfo-3.0.0.xml")); } @Test - public void testFhirModelInfo301() throws IOException { + void fhirModelInfo301() throws IOException { new org.hl7.elm_modelinfo.r1.serializing.jackson.XmlModelInfoReader() .read(FhirModelInfoProvider.class.getResourceAsStream("/org/hl7/fhir/fhir-modelinfo-3.0.1.xml")); } @Test - public void testFhirModelInfo320() throws IOException { + void fhirModelInfo320() throws IOException { new org.hl7.elm_modelinfo.r1.serializing.jackson.XmlModelInfoReader() .read(FhirModelInfoProvider.class.getResourceAsStream("/org/hl7/fhir/fhir-modelinfo-3.2.0.xml")); } @Test - public void testFhirModelInfo400() throws IOException { + void fhirModelInfo400() throws IOException { new org.hl7.elm_modelinfo.r1.serializing.jackson.XmlModelInfoReader() .read(FhirModelInfoProvider.class.getResourceAsStream("/org/hl7/fhir/fhir-modelinfo-4.0.0.xml")); } @Test - public void testFhirModelInfo401() throws IOException { + void fhirModelInfo401() throws IOException { new org.hl7.elm_modelinfo.r1.serializing.jackson.XmlModelInfoReader() .read(FhirModelInfoProvider.class.getResourceAsStream("/org/hl7/fhir/fhir-modelinfo-4.0.1.xml")); } diff --git a/Src/java/model-jaxb/src/test/java/org/hl7/elm_modelinfo/r1/serializing/jaxb/XmlModelInfoReaderTest.java b/Src/java/model-jaxb/src/test/java/org/hl7/elm_modelinfo/r1/serializing/jaxb/XmlModelInfoReaderTest.java index 710d4a64d..eaab3abc2 100644 --- a/Src/java/model-jaxb/src/test/java/org/hl7/elm_modelinfo/r1/serializing/jaxb/XmlModelInfoReaderTest.java +++ b/Src/java/model-jaxb/src/test/java/org/hl7/elm_modelinfo/r1/serializing/jaxb/XmlModelInfoReaderTest.java @@ -1,15 +1,15 @@ package org.hl7.elm_modelinfo.r1.serializing.jaxb; -import static org.testng.Assert.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNotNull; import java.io.IOException; import org.hl7.elm_modelinfo.r1.ModelInfo; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Test; -public class XmlModelInfoReaderTest { +class XmlModelInfoReaderTest { @Test - public void testRead() throws IOException { + void read() throws IOException { var reader = new XmlModelInfoReader(); ModelInfo mi = reader.read( ""); diff --git a/Src/java/model/src/test/java/org/hl7/cql/model/ChoiceTypeTests.java b/Src/java/model/src/test/java/org/hl7/cql/model/ChoiceTypeTests.java index 31ef1d2ce..dbe861089 100644 --- a/Src/java/model/src/test/java/org/hl7/cql/model/ChoiceTypeTests.java +++ b/Src/java/model/src/test/java/org/hl7/cql/model/ChoiceTypeTests.java @@ -1,14 +1,15 @@ package org.hl7.cql.model; -import static org.testng.Assert.*; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; import java.util.Arrays; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Test; -public class ChoiceTypeTests { +class ChoiceTypeTests { @Test - public void testChoiceTypeIsCompatible() { + void choiceTypeIsCompatible() { ChoiceType first = new ChoiceType( Arrays.asList(new SimpleType("Period"), new SimpleType("Interval"), new SimpleType("DateTime"))); @@ -24,7 +25,7 @@ public void testChoiceTypeIsCompatible() { } @Test - public void testChoiceTypeIsNotCompatible() { + void choiceTypeIsNotCompatible() { ChoiceType first = new ChoiceType( Arrays.asList(new SimpleType("Period"), new SimpleType("Interval"), new SimpleType("DateTime"))); diff --git a/Src/java/model/src/test/java/org/hl7/cql/model/GenericClassSignatureParserTest.java b/Src/java/model/src/test/java/org/hl7/cql/model/GenericClassSignatureParserTest.java index 84c46f738..bead1b2bc 100644 --- a/Src/java/model/src/test/java/org/hl7/cql/model/GenericClassSignatureParserTest.java +++ b/Src/java/model/src/test/java/org/hl7/cql/model/GenericClassSignatureParserTest.java @@ -2,16 +2,16 @@ import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.is; -import static org.testng.Assert.fail; +import static org.junit.jupiter.api.Assertions.fail; import java.util.HashMap; import java.util.Map; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Test; -public class GenericClassSignatureParserTest { +class GenericClassSignatureParserTest { @Test - public void parseTest1() { + void parseTest1() { GenericClassSignatureParser genericClassSignatureParser = new GenericClassSignatureParser("MyType", null); if (genericClassSignatureParser.isValidGenericSignature()) { ClassType signature = genericClassSignatureParser.parseGenericSignature(); @@ -25,7 +25,7 @@ public void parseTest1() { } @Test - public void parseTest2() { + void parseTest2() { ClassType collectionType = new ClassType("Collection", null, null); Map resolvedTypes = new HashMap<>(); resolvedTypes.put("Collection", collectionType); @@ -49,7 +49,7 @@ public void parseTest2() { } @Test - public void parseTest3() { + void parseTest3() { ClassType collectionType = new ClassType("Collection", null, null); ClassType objectType = new ClassType("Object", null, null); Map resolvedTypes = new HashMap<>(); @@ -80,7 +80,7 @@ public void parseTest3() { } @Test - public void parseTest4() { + void parseTest4() { try { ClassType collectionType = new ClassType("Collection", null, null); Map resolvedTypes = new HashMap<>(); @@ -95,7 +95,7 @@ public void parseTest4() { } @Test - public void parseTest5() { + void parseTest5() { ClassType objectType = new ClassType("Object", null, null); ClassType listType = new ClassType("List", null, null); listType.addGenericParameter(new TypeParameter("T")); @@ -124,7 +124,7 @@ public void parseTest5() { } @Test - public void parseTest6() { + void parseTest6() { ClassType objectType = new ClassType("Object", null, null); SimpleType stringType = new SimpleType("String", null); ClassType listType = new ClassType("List", null, null); @@ -161,7 +161,7 @@ public void parseTest6() { } @Test - public void parseTest7() { + void parseTest7() { SimpleType integerType = new SimpleType("Integer", null); SimpleType stringType = new SimpleType("String", null); ClassType listType = new ClassType("List", null, null); diff --git a/Src/java/model/src/test/java/org/hl7/cql/model/ModelInfoComparerTest.java b/Src/java/model/src/test/java/org/hl7/cql/model/ModelInfoComparerTest.java index a5a9f71fa..c69fa1b24 100644 --- a/Src/java/model/src/test/java/org/hl7/cql/model/ModelInfoComparerTest.java +++ b/Src/java/model/src/test/java/org/hl7/cql/model/ModelInfoComparerTest.java @@ -7,12 +7,12 @@ import java.util.*; import java.util.stream.Collectors; import org.hl7.elm_modelinfo.r1.*; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Test; public class ModelInfoComparerTest { @Test - public void compareModelInfo() { + void compareModelInfo() { ModelInfo a = JAXB.unmarshal(ModelInfoComparerTest.class.getResourceAsStream("a-modelinfo.xml"), ModelInfo.class); ModelInfo b = @@ -47,7 +47,7 @@ public void compareMATModelInfo() { } @Test - public void compareNewModelInfo() { + void compareNewModelInfo() { ModelInfo a = JAXB.unmarshal( ModelInfoComparerTest.class.getResourceAsStream("fhir-modelinfo-4.0.1.xml"), ModelInfo.class); ModelInfo b = JAXB.unmarshal( @@ -68,7 +68,7 @@ public void compareNewModelInfo() { } @Test - public void compareMetadataModelInfo() { + void compareMetadataModelInfo() { ModelInfo a = JAXB.unmarshal( ModelInfoComparerTest.class.getResourceAsStream("fhir-modelinfo-4.0.1-1.5.1.xml"), ModelInfo.class); ModelInfo b = JAXB.unmarshal( diff --git a/Src/java/model/src/test/resources/org/hl7/cql/model/fhir-modelinfo-4.0.1-with-metadata.xml b/Src/java/model/src/test/resources/org/hl7/cql/model/fhir-modelinfo-4.0.1-with-metadata.xml index 95ceee49f..5105a4e70 100644 --- a/Src/java/model/src/test/resources/org/hl7/cql/model/fhir-modelinfo-4.0.1-with-metadata.xml +++ b/Src/java/model/src/test/resources/org/hl7/cql/model/fhir-modelinfo-4.0.1-with-metadata.xml @@ -27772,7 +27772,7 @@ - + @@ -27808,7 +27808,7 @@ - + @@ -27940,7 +27940,7 @@ - + @@ -27978,7 +27978,7 @@ - + @@ -27996,7 +27996,7 @@ - + @@ -28051,7 +28051,7 @@ - + diff --git a/Src/java/quick/schema/v1.4/fhir-single.xsd b/Src/java/quick/schema/v1.4/fhir-single.xsd index 9547b2f43..f6b95c69b 100644 --- a/Src/java/quick/schema/v1.4/fhir-single.xsd +++ b/Src/java/quick/schema/v1.4/fhir-single.xsd @@ -4305,8 +4305,8 @@ - The Absolute URL for the resource. The fullUrl SHALL not disagree with the id in the resource. The fullUrl is a version independent reference to the resource. The fullUrl element SHALL have a value except that: -* fullUrl can be empty on a POST (although it does not need to when specifying a temporary id for reference in the bundle) + The Absolute URL for the resource. The fullUrl SHALL not disagree with the id in the resource. The fullUrl is a version independent reference to the resource. The fullUrl element SHALL have a value except that: +* fullUrl can be empty on a POST (although it does not need to when specifying a temporary id for reference in the bundle) * Results from operations might involve resources that are not identified. @@ -16621,8 +16621,8 @@ - Indicates whether the Medication is only taken when needed within a specific dosing schedule (Boolean option), or it indicates the precondition for taking the Medication (CodeableConcept). - + Indicates whether the Medication is only taken when needed within a specific dosing schedule (Boolean option), or it indicates the precondition for taking the Medication (CodeableConcept). + Specifically if 'boolean' datatype is selected, then the following logic applies: If set to True, this indicates that the medication is only taken when needed, within the specified schedule. @@ -16954,12 +16954,16 @@ Specifically if 'boolean' datatype is selected, then the following logic applies - A record of a medication that is being consumed by a patient. A MedicationStatement may indicate that the patient may be taking the medication now, or has taken the medication in the past or will be taking the medication in the future. The source of this information can be the patient, significant other (such as a family member or spouse), or a clinician. A common scenario where this information is captured is during the history taking process during a patient visit or stay. The medication information may come from e.g. the patient's memory, from a prescription bottle, or from a list of medications the patient, clinician or other party maintains The primary difference between a medication statement and a medication administration is that the medication administration has complete administration information and is based on actual administration information from the person who administered the medication. A medication statement is often, if not always, less specific. There is no required date/time when the medication was administered, in fact we only know that a source has reported the patient is taking this medication, where details such as time, quantity, or rate or even medication product may be incomplete or missing or less precise. As stated earlier, the medication statement information may come from the patient's memory, from a prescription bottle or from a list of medications the patient, clinician or other party maintains. Medication administration is more formal and is not missing detailed information. + A record of a medication that is being consumed by a patient. A MedicationStatement may indicate that the patient may be taking the medication now, or has taken the medication in the past or will be taking the medication in the future. The source of this information can be the patient, significant other (such as a family member or spouse), or a clinician. A common scenario where this information is captured is during the history taking process during a patient visit or stay. The medication information may come from e.g. the patient's memory, from a prescription bottle, or from a list of medications the patient, clinician or other party maintains + +The primary difference between a medication statement and a medication administration is that the medication administration has complete administration information and is based on actual administration information from the person who administered the medication. A medication statement is often, if not always, less specific. There is no required date/time when the medication was administered, in fact we only know that a source has reported the patient is taking this medication, where details such as time, quantity, or rate or even medication product may be incomplete or missing or less precise. As stated earlier, the medication statement information may come from the patient's memory, from a prescription bottle or from a list of medications the patient, clinician or other party maintains. Medication administration is more formal and is not missing detailed information. - A record of a medication that is being consumed by a patient. A MedicationStatement may indicate that the patient may be taking the medication now, or has taken the medication in the past or will be taking the medication in the future. The source of this information can be the patient, significant other (such as a family member or spouse), or a clinician. A common scenario where this information is captured is during the history taking process during a patient visit or stay. The medication information may come from e.g. the patient's memory, from a prescription bottle, or from a list of medications the patient, clinician or other party maintains The primary difference between a medication statement and a medication administration is that the medication administration has complete administration information and is based on actual administration information from the person who administered the medication. A medication statement is often, if not always, less specific. There is no required date/time when the medication was administered, in fact we only know that a source has reported the patient is taking this medication, where details such as time, quantity, or rate or even medication product may be incomplete or missing or less precise. As stated earlier, the medication statement information may come from the patient's memory, from a prescription bottle or from a list of medications the patient, clinician or other party maintains. Medication administration is more formal and is not missing detailed information. + A record of a medication that is being consumed by a patient. A MedicationStatement may indicate that the patient may be taking the medication now, or has taken the medication in the past or will be taking the medication in the future. The source of this information can be the patient, significant other (such as a family member or spouse), or a clinician. A common scenario where this information is captured is during the history taking process during a patient visit or stay. The medication information may come from e.g. the patient's memory, from a prescription bottle, or from a list of medications the patient, clinician or other party maintains + +The primary difference between a medication statement and a medication administration is that the medication administration has complete administration information and is based on actual administration information from the person who administered the medication. A medication statement is often, if not always, less specific. There is no required date/time when the medication was administered, in fact we only know that a source has reported the patient is taking this medication, where details such as time, quantity, or rate or even medication product may be incomplete or missing or less precise. As stated earlier, the medication statement information may come from the patient's memory, from a prescription bottle or from a list of medications the patient, clinician or other party maintains. Medication administration is more formal and is not missing detailed information. If the element is present, it must have either a @value, an @id, or extensions @@ -17042,7 +17046,9 @@ Specifically if 'boolean' datatype is selected, then the following logic applies - A record of a medication that is being consumed by a patient. A MedicationStatement may indicate that the patient may be taking the medication now, or has taken the medication in the past or will be taking the medication in the future. The source of this information can be the patient, significant other (such as a family member or spouse), or a clinician. A common scenario where this information is captured is during the history taking process during a patient visit or stay. The medication information may come from e.g. the patient's memory, from a prescription bottle, or from a list of medications the patient, clinician or other party maintains The primary difference between a medication statement and a medication administration is that the medication administration has complete administration information and is based on actual administration information from the person who administered the medication. A medication statement is often, if not always, less specific. There is no required date/time when the medication was administered, in fact we only know that a source has reported the patient is taking this medication, where details such as time, quantity, or rate or even medication product may be incomplete or missing or less precise. As stated earlier, the medication statement information may come from the patient's memory, from a prescription bottle or from a list of medications the patient, clinician or other party maintains. Medication administration is more formal and is not missing detailed information. + A record of a medication that is being consumed by a patient. A MedicationStatement may indicate that the patient may be taking the medication now, or has taken the medication in the past or will be taking the medication in the future. The source of this information can be the patient, significant other (such as a family member or spouse), or a clinician. A common scenario where this information is captured is during the history taking process during a patient visit or stay. The medication information may come from e.g. the patient's memory, from a prescription bottle, or from a list of medications the patient, clinician or other party maintains + +The primary difference between a medication statement and a medication administration is that the medication administration has complete administration information and is based on actual administration information from the person who administered the medication. A medication statement is often, if not always, less specific. There is no required date/time when the medication was administered, in fact we only know that a source has reported the patient is taking this medication, where details such as time, quantity, or rate or even medication product may be incomplete or missing or less precise. As stated earlier, the medication statement information may come from the patient's memory, from a prescription bottle or from a list of medications the patient, clinician or other party maintains. Medication administration is more formal and is not missing detailed information. @@ -17059,8 +17065,8 @@ Specifically if 'boolean' datatype is selected, then the following logic applies - Indicates whether the Medication is only taken when needed within a specific dosing schedule (Boolean option), or it indicates the precondition for taking the Medication (CodeableConcept). - + Indicates whether the Medication is only taken when needed within a specific dosing schedule (Boolean option), or it indicates the precondition for taking the Medication (CodeableConcept). + Specifically if 'boolean' datatype is selected, then the following logic applies: If set to True, this indicates that the medication is only taken when needed, within the specified schedule. @@ -19643,7 +19649,7 @@ Specifically if 'boolean' datatype is selected, then the following logic applies - Address(es) of the practitioner that are not role specific (typically home address). + Address(es) of the practitioner that are not role specific (typically home address). Work addresses are not typically entered in this property as they are usually role dependent. @@ -24615,7 +24621,7 @@ Work addresses are not typically entered in this property as they are usually ro - + Assertions. The value to compare to. diff --git a/Src/java/quick/schema/v1.4/testscript.xsd b/Src/java/quick/schema/v1.4/testscript.xsd index c850f0e11..c470e7965 100644 --- a/Src/java/quick/schema/v1.4/testscript.xsd +++ b/Src/java/quick/schema/v1.4/testscript.xsd @@ -739,7 +739,7 @@ - Whether or not the test execution will produce a warning only on error for this assert. + Whether or not the test execution will produce a warning only on error for this Assertions. diff --git a/Src/java/quick/schema/v1.6/fhir-single.xsd b/Src/java/quick/schema/v1.6/fhir-single.xsd index 509d0be2a..332cdc5de 100644 --- a/Src/java/quick/schema/v1.6/fhir-single.xsd +++ b/Src/java/quick/schema/v1.6/fhir-single.xsd @@ -3298,7 +3298,7 @@ - Indicates the period of time over which the account is allowed to have transactions posted to it. + Indicates the period of time over which the account is allowed to have transactions posted to it. This period may be different to the coveragePeriod which is the duration of time that services may occur. @@ -3314,8 +3314,8 @@ This period may be different to the coveragePeriod which is the duration of time - The party(s) that are responsible for payment (or part of) of charges applied to this account (including self-pay). - + The party(s) that are responsible for payment (or part of) of charges applied to this account (including self-pay). + A coverage may only be resposible for specific types of charges, and the sequence of the coverages in the account could be important when processing billing. @@ -4863,8 +4863,8 @@ A coverage may only be resposible for specific types of charges, and the sequenc - The Absolute URL for the resource. The fullUrl SHALL not disagree with the id in the resource. The fullUrl is a version independent reference to the resource. The fullUrl element SHALL have a value except that: -* fullUrl can be empty on a POST (although it does not need to when specifying a temporary id for reference in the bundle) + The Absolute URL for the resource. The fullUrl SHALL not disagree with the id in the resource. The fullUrl is a version independent reference to the resource. The fullUrl element SHALL have a value except that: +* fullUrl can be empty on a POST (although it does not need to when specifying a temporary id for reference in the bundle) * Results from operations might involve resources that are not identified. @@ -19187,7 +19187,9 @@ A coverage may only be resposible for specific types of charges, and the sequenc - Free text dosage can be used for cases where the dosage administered is too complex to code. When coded dosage is present, the free text dosage may still be present for display to humans. The dosage instructions should reflect the dosage of the medication that was administered. + Free text dosage can be used for cases where the dosage administered is too complex to code. When coded dosage is present, the free text dosage may still be present for display to humans. + +The dosage instructions should reflect the dosage of the medication that was administered. @@ -19432,8 +19434,8 @@ A coverage may only be resposible for specific types of charges, and the sequenc - Indicates whether the Medication is only taken when needed within a specific dosing schedule (Boolean option), or it indicates the precondition for taking the Medication (CodeableConcept). - + Indicates whether the Medication is only taken when needed within a specific dosing schedule (Boolean option), or it indicates the precondition for taking the Medication (CodeableConcept). + Specifically if 'boolean' datatype is selected, then the following logic applies: If set to True, this indicates that the medication is only taken when needed, within the specified schedule. @@ -19926,12 +19928,16 @@ Specifically if 'boolean' datatype is selected, then the following logic applies - A record of a medication that is being consumed by a patient. A MedicationStatement may indicate that the patient may be taking the medication now, or has taken the medication in the past or will be taking the medication in the future. The source of this information can be the patient, significant other (such as a family member or spouse), or a clinician. A common scenario where this information is captured is during the history taking process during a patient visit or stay. The medication information may come from e.g. the patient's memory, from a prescription bottle, or from a list of medications the patient, clinician or other party maintains The primary difference between a medication statement and a medication administration is that the medication administration has complete administration information and is based on actual administration information from the person who administered the medication. A medication statement is often, if not always, less specific. There is no required date/time when the medication was administered, in fact we only know that a source has reported the patient is taking this medication, where details such as time, quantity, or rate or even medication product may be incomplete or missing or less precise. As stated earlier, the medication statement information may come from the patient's memory, from a prescription bottle or from a list of medications the patient, clinician or other party maintains. Medication administration is more formal and is not missing detailed information. + A record of a medication that is being consumed by a patient. A MedicationStatement may indicate that the patient may be taking the medication now, or has taken the medication in the past or will be taking the medication in the future. The source of this information can be the patient, significant other (such as a family member or spouse), or a clinician. A common scenario where this information is captured is during the history taking process during a patient visit or stay. The medication information may come from e.g. the patient's memory, from a prescription bottle, or from a list of medications the patient, clinician or other party maintains + +The primary difference between a medication statement and a medication administration is that the medication administration has complete administration information and is based on actual administration information from the person who administered the medication. A medication statement is often, if not always, less specific. There is no required date/time when the medication was administered, in fact we only know that a source has reported the patient is taking this medication, where details such as time, quantity, or rate or even medication product may be incomplete or missing or less precise. As stated earlier, the medication statement information may come from the patient's memory, from a prescription bottle or from a list of medications the patient, clinician or other party maintains. Medication administration is more formal and is not missing detailed information. - A record of a medication that is being consumed by a patient. A MedicationStatement may indicate that the patient may be taking the medication now, or has taken the medication in the past or will be taking the medication in the future. The source of this information can be the patient, significant other (such as a family member or spouse), or a clinician. A common scenario where this information is captured is during the history taking process during a patient visit or stay. The medication information may come from e.g. the patient's memory, from a prescription bottle, or from a list of medications the patient, clinician or other party maintains The primary difference between a medication statement and a medication administration is that the medication administration has complete administration information and is based on actual administration information from the person who administered the medication. A medication statement is often, if not always, less specific. There is no required date/time when the medication was administered, in fact we only know that a source has reported the patient is taking this medication, where details such as time, quantity, or rate or even medication product may be incomplete or missing or less precise. As stated earlier, the medication statement information may come from the patient's memory, from a prescription bottle or from a list of medications the patient, clinician or other party maintains. Medication administration is more formal and is not missing detailed information. + A record of a medication that is being consumed by a patient. A MedicationStatement may indicate that the patient may be taking the medication now, or has taken the medication in the past or will be taking the medication in the future. The source of this information can be the patient, significant other (such as a family member or spouse), or a clinician. A common scenario where this information is captured is during the history taking process during a patient visit or stay. The medication information may come from e.g. the patient's memory, from a prescription bottle, or from a list of medications the patient, clinician or other party maintains + +The primary difference between a medication statement and a medication administration is that the medication administration has complete administration information and is based on actual administration information from the person who administered the medication. A medication statement is often, if not always, less specific. There is no required date/time when the medication was administered, in fact we only know that a source has reported the patient is taking this medication, where details such as time, quantity, or rate or even medication product may be incomplete or missing or less precise. As stated earlier, the medication statement information may come from the patient's memory, from a prescription bottle or from a list of medications the patient, clinician or other party maintains. Medication administration is more formal and is not missing detailed information. If the element is present, it must have either a @value, an @id, or extensions @@ -20022,7 +20028,9 @@ Specifically if 'boolean' datatype is selected, then the following logic applies - A record of a medication that is being consumed by a patient. A MedicationStatement may indicate that the patient may be taking the medication now, or has taken the medication in the past or will be taking the medication in the future. The source of this information can be the patient, significant other (such as a family member or spouse), or a clinician. A common scenario where this information is captured is during the history taking process during a patient visit or stay. The medication information may come from e.g. the patient's memory, from a prescription bottle, or from a list of medications the patient, clinician or other party maintains The primary difference between a medication statement and a medication administration is that the medication administration has complete administration information and is based on actual administration information from the person who administered the medication. A medication statement is often, if not always, less specific. There is no required date/time when the medication was administered, in fact we only know that a source has reported the patient is taking this medication, where details such as time, quantity, or rate or even medication product may be incomplete or missing or less precise. As stated earlier, the medication statement information may come from the patient's memory, from a prescription bottle or from a list of medications the patient, clinician or other party maintains. Medication administration is more formal and is not missing detailed information. + A record of a medication that is being consumed by a patient. A MedicationStatement may indicate that the patient may be taking the medication now, or has taken the medication in the past or will be taking the medication in the future. The source of this information can be the patient, significant other (such as a family member or spouse), or a clinician. A common scenario where this information is captured is during the history taking process during a patient visit or stay. The medication information may come from e.g. the patient's memory, from a prescription bottle, or from a list of medications the patient, clinician or other party maintains + +The primary difference between a medication statement and a medication administration is that the medication administration has complete administration information and is based on actual administration information from the person who administered the medication. A medication statement is often, if not always, less specific. There is no required date/time when the medication was administered, in fact we only know that a source has reported the patient is taking this medication, where details such as time, quantity, or rate or even medication product may be incomplete or missing or less precise. As stated earlier, the medication statement information may come from the patient's memory, from a prescription bottle or from a list of medications the patient, clinician or other party maintains. Medication administration is more formal and is not missing detailed information. @@ -20044,7 +20052,9 @@ Specifically if 'boolean' datatype is selected, then the following logic applies - Indicates whether the Medication is only taken when needed within a specific dosing schedule (Boolean option), or it indicates the precondition for taking the Medication (CodeableConcept). Specifically if 'boolean' datatype is selected, then the following logic applies: If set to True, this indicates that the medication is only taken when needed, within the specified schedule. + Indicates whether the Medication is only taken when needed within a specific dosing schedule (Boolean option), or it indicates the precondition for taking the Medication (CodeableConcept). + +Specifically if 'boolean' datatype is selected, then the following logic applies: If set to True, this indicates that the medication is only taken when needed, within the specified schedule. @@ -23286,7 +23296,8 @@ Specifically if 'boolean' datatype is selected, then the following logic applies - Address(es) of the practitioner that are not role specific (typically home address). Work addresses are not typically entered in this property as they are usually role dependent. + Address(es) of the practitioner that are not role specific (typically home address). +Work addresses are not typically entered in this property as they are usually role dependent. @@ -28894,7 +28905,7 @@ Specifically if 'boolean' datatype is selected, then the following logic applies - + Assertions. The ID of the Profile to validate against. diff --git a/Src/java/quick/schema/v1.6/testscript.xsd b/Src/java/quick/schema/v1.6/testscript.xsd index f3eb05c69..34ca59154 100644 --- a/Src/java/quick/schema/v1.6/testscript.xsd +++ b/Src/java/quick/schema/v1.6/testscript.xsd @@ -744,7 +744,7 @@ - Whether or not the test execution will produce a warning only on error for this assert. + Whether or not the test execution will produce a warning only on error for this Assertions. diff --git a/Src/java/quick/schema/v1.8/fhir-single.xsd b/Src/java/quick/schema/v1.8/fhir-single.xsd index 4dfe30b51..62d63c087 100644 --- a/Src/java/quick/schema/v1.8/fhir-single.xsd +++ b/Src/java/quick/schema/v1.8/fhir-single.xsd @@ -3432,7 +3432,7 @@ - Indicates the period of time over which the account is allowed to have transactions posted to it. + Indicates the period of time over which the account is allowed to have transactions posted to it. This period may be different to the coveragePeriod which is the duration of time that services may occur. @@ -3448,8 +3448,8 @@ This period may be different to the coveragePeriod which is the duration of time - The party(s) that are responsible for payment (or part of) of charges applied to this account (including self-pay). - + The party(s) that are responsible for payment (or part of) of charges applied to this account (including self-pay). + A coverage may only be resposible for specific types of charges, and the sequence of the coverages in the account could be important when processing billing. @@ -5098,8 +5098,8 @@ A coverage may only be resposible for specific types of charges, and the sequenc - The Absolute URL for the resource. The fullUrl SHALL not disagree with the id in the resource. The fullUrl is a version independent reference to the resource. The fullUrl element SHALL have a value except that: -* fullUrl can be empty on a POST (although it does not need to when specifying a temporary id for reference in the bundle) + The Absolute URL for the resource. The fullUrl SHALL not disagree with the id in the resource. The fullUrl is a version independent reference to the resource. The fullUrl element SHALL have a value except that: +* fullUrl can be empty on a POST (although it does not need to when specifying a temporary id for reference in the bundle) * Results from operations might involve resources that are not identified. @@ -18787,7 +18787,9 @@ A coverage may only be resposible for specific types of charges, and the sequenc - Free text dosage can be used for cases where the dosage administered is too complex to code. When coded dosage is present, the free text dosage may still be present for display to humans. The dosage instructions should reflect the dosage of the medication that was administered. + Free text dosage can be used for cases where the dosage administered is too complex to code. When coded dosage is present, the free text dosage may still be present for display to humans. + +The dosage instructions should reflect the dosage of the medication that was administered. @@ -19274,12 +19276,16 @@ A coverage may only be resposible for specific types of charges, and the sequenc - A record of a medication that is being consumed by a patient. A MedicationStatement may indicate that the patient may be taking the medication now, or has taken the medication in the past or will be taking the medication in the future. The source of this information can be the patient, significant other (such as a family member or spouse), or a clinician. A common scenario where this information is captured is during the history taking process during a patient visit or stay. The medication information may come from e.g. the patient's memory, from a prescription bottle, or from a list of medications the patient, clinician or other party maintains The primary difference between a medication statement and a medication administration is that the medication administration has complete administration information and is based on actual administration information from the person who administered the medication. A medication statement is often, if not always, less specific. There is no required date/time when the medication was administered, in fact we only know that a source has reported the patient is taking this medication, where details such as time, quantity, or rate or even medication product may be incomplete or missing or less precise. As stated earlier, the medication statement information may come from the patient's memory, from a prescription bottle or from a list of medications the patient, clinician or other party maintains. Medication administration is more formal and is not missing detailed information. + A record of a medication that is being consumed by a patient. A MedicationStatement may indicate that the patient may be taking the medication now, or has taken the medication in the past or will be taking the medication in the future. The source of this information can be the patient, significant other (such as a family member or spouse), or a clinician. A common scenario where this information is captured is during the history taking process during a patient visit or stay. The medication information may come from e.g. the patient's memory, from a prescription bottle, or from a list of medications the patient, clinician or other party maintains + +The primary difference between a medication statement and a medication administration is that the medication administration has complete administration information and is based on actual administration information from the person who administered the medication. A medication statement is often, if not always, less specific. There is no required date/time when the medication was administered, in fact we only know that a source has reported the patient is taking this medication, where details such as time, quantity, or rate or even medication product may be incomplete or missing or less precise. As stated earlier, the medication statement information may come from the patient's memory, from a prescription bottle or from a list of medications the patient, clinician or other party maintains. Medication administration is more formal and is not missing detailed information. - A record of a medication that is being consumed by a patient. A MedicationStatement may indicate that the patient may be taking the medication now, or has taken the medication in the past or will be taking the medication in the future. The source of this information can be the patient, significant other (such as a family member or spouse), or a clinician. A common scenario where this information is captured is during the history taking process during a patient visit or stay. The medication information may come from e.g. the patient's memory, from a prescription bottle, or from a list of medications the patient, clinician or other party maintains The primary difference between a medication statement and a medication administration is that the medication administration has complete administration information and is based on actual administration information from the person who administered the medication. A medication statement is often, if not always, less specific. There is no required date/time when the medication was administered, in fact we only know that a source has reported the patient is taking this medication, where details such as time, quantity, or rate or even medication product may be incomplete or missing or less precise. As stated earlier, the medication statement information may come from the patient's memory, from a prescription bottle or from a list of medications the patient, clinician or other party maintains. Medication administration is more formal and is not missing detailed information. + A record of a medication that is being consumed by a patient. A MedicationStatement may indicate that the patient may be taking the medication now, or has taken the medication in the past or will be taking the medication in the future. The source of this information can be the patient, significant other (such as a family member or spouse), or a clinician. A common scenario where this information is captured is during the history taking process during a patient visit or stay. The medication information may come from e.g. the patient's memory, from a prescription bottle, or from a list of medications the patient, clinician or other party maintains + +The primary difference between a medication statement and a medication administration is that the medication administration has complete administration information and is based on actual administration information from the person who administered the medication. A medication statement is often, if not always, less specific. There is no required date/time when the medication was administered, in fact we only know that a source has reported the patient is taking this medication, where details such as time, quantity, or rate or even medication product may be incomplete or missing or less precise. As stated earlier, the medication statement information may come from the patient's memory, from a prescription bottle or from a list of medications the patient, clinician or other party maintains. Medication administration is more formal and is not missing detailed information. If the element is present, it must have either a @value, an @id, or extensions @@ -22711,7 +22717,8 @@ A coverage may only be resposible for specific types of charges, and the sequenc - Address(es) of the practitioner that are not role specific (typically home address). Work addresses are not typically entered in this property as they are usually role dependent. + Address(es) of the practitioner that are not role specific (typically home address). +Work addresses are not typically entered in this property as they are usually role dependent. @@ -23899,15 +23906,15 @@ A coverage may only be resposible for specific types of charges, and the sequenc - A reference to an [[[ElementDefinition]]] that provides the details for the item. If a definition is provided, then the following element values can be inferred from the definition: - -* concept (ElementDefinition.code) -* type (ElementDefinition.type) -* required (ElementDefinition.min) -* repeats (ElementDefinition.max) -* maxLength (ElementDefinition.maxLength) -* options (ElementDefinition.binding) - + A reference to an [[[ElementDefinition]]] that provides the details for the item. If a definition is provided, then the following element values can be inferred from the definition: + +* concept (ElementDefinition.code) +* type (ElementDefinition.type) +* required (ElementDefinition.min) +* repeats (ElementDefinition.max) +* maxLength (ElementDefinition.maxLength) +* options (ElementDefinition.binding) + Any information provided in these elements overrides the information from the definition. @@ -29464,7 +29471,7 @@ Any information provided in these elements overrides the information from the de The ID of a fixture. Asserts that the response contains at a minimum the fixture specified by minimumId. - + Assertions. Whether or not the test execution performs validation on the bundle navigation links. @@ -29519,7 +29526,7 @@ Any information provided in these elements overrides the information from the de The ID of the Profile to validate against. - + Assertions. The value to compare to. diff --git a/Src/java/quick/schema/v1.8/testscript.xsd b/Src/java/quick/schema/v1.8/testscript.xsd index 21ecd04f8..608027c03 100644 --- a/Src/java/quick/schema/v1.8/testscript.xsd +++ b/Src/java/quick/schema/v1.8/testscript.xsd @@ -708,7 +708,7 @@ - The operator type defines the conditional behavior of the assert. If not defined, the default is equals. + The operator type defines the conditional behavior of the Assertions. If not defined, the default is equals. @@ -763,7 +763,7 @@ - Whether or not the test execution will produce a warning only on error for this assert. + Whether or not the test execution will produce a warning only on error for this Assertions. diff --git a/Src/java/quick/src/main/resources/org/hl7/fhir/fhir-modelinfo-4.0.1.xml b/Src/java/quick/src/main/resources/org/hl7/fhir/fhir-modelinfo-4.0.1.xml index 41d244187..ecee11d55 100644 --- a/Src/java/quick/src/main/resources/org/hl7/fhir/fhir-modelinfo-4.0.1.xml +++ b/Src/java/quick/src/main/resources/org/hl7/fhir/fhir-modelinfo-4.0.1.xml @@ -27772,7 +27772,7 @@ - + @@ -27808,7 +27808,7 @@ - + @@ -27940,7 +27940,7 @@ - + @@ -27978,7 +27978,7 @@ - + @@ -27996,7 +27996,7 @@ - + @@ -28051,7 +28051,7 @@ - + diff --git a/Src/java/tools/cql-formatter/src/test/java/org/cqframework/cql/tools/formatter/CqlFormatterVisitorTest.java b/Src/java/tools/cql-formatter/src/test/java/org/cqframework/cql/tools/formatter/CqlFormatterVisitorTest.java index 49b677d77..1ce8d4bb9 100644 --- a/Src/java/tools/cql-formatter/src/test/java/org/cqframework/cql/tools/formatter/CqlFormatterVisitorTest.java +++ b/Src/java/tools/cql-formatter/src/test/java/org/cqframework/cql/tools/formatter/CqlFormatterVisitorTest.java @@ -1,17 +1,18 @@ package org.cqframework.cql.tools.formatter; import static org.cqframework.cql.tools.formatter.CqlFormatterVisitor.*; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; import java.io.IOException; import java.io.InputStream; import org.cqframework.cql.cql2elm.Cql2ElmVisitor; -import org.testng.Assert; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Test; /** * Created by Christopher on 7/20/2017. */ -public class CqlFormatterVisitorTest { +class CqlFormatterVisitorTest { boolean inError = false; @@ -19,11 +20,11 @@ private void runTest(String fileName) throws IOException { String input = getInputStreamAsString(getInput(fileName)); FormatResult result = getFormattedOutput(getInput(fileName)); inError = result.errors.size() > 0; - Assert.assertTrue(inputMatchesOutput(input, result.output)); + assertTrue(inputMatchesOutput(input, result.output)); } @Test - public void testFormatterSpecific() throws IOException { + void formatterSpecific() throws IOException { runTest("comments.cql"); // I commented these catches out because it seems to me that the formatter should not clobber input when these // errors occur... @@ -36,49 +37,49 @@ public void testFormatterSpecific() throws IOException { // this test has an extra "`", which is not ignored - causing a syntax error. runTest("git-issue-206-a.cql"); // } catch (AssertionError ae) { - // Assert.assertFalse(inError); + // Assertions.assertFalse(inError); // } // try { // this test has an extra """, which is not ignored - causing a syntax error. runTest("git-issue-206-b.cql"); // } catch (AssertionError ae) { - // Assert.assertTrue(inError); + // Assertions.assertTrue(inError); // } runTest("git-issue-210-a.cql"); - Assert.assertFalse(inError); + assertFalse(inError); runTest("git-issue-210-b.cql"); - Assert.assertFalse(inError); + assertFalse(inError); runTest("git-issue-210-c.cql"); - Assert.assertFalse(inError); + assertFalse(inError); runTest("git-issue-246.cql"); - Assert.assertFalse(inError); + assertFalse(inError); runTest("comment-after.cql"); - Assert.assertFalse(inError); + assertFalse(inError); runTest("comment-before.cql"); - Assert.assertFalse(inError); + assertFalse(inError); runTest("comment-first.cql"); - Assert.assertFalse(inError); + assertFalse(inError); runTest("comment-in-clause.cql"); - Assert.assertFalse(inError); + assertFalse(inError); runTest("comment-last.cql"); - Assert.assertFalse(inError); + assertFalse(inError); runTest("git-issue-349.cql"); - Assert.assertFalse(inError); + assertFalse(inError); runTest("git-issue-613.cql"); - Assert.assertFalse(inError); + assertFalse(inError); runTest("git-issue-437.cql"); - Assert.assertFalse(inError); + assertFalse(inError); runTest("git-issue-377.cql"); - Assert.assertFalse(inError); + assertFalse(inError); try { runTest("invalid-syntax.cql"); } catch (AssertionError ae) { - Assert.assertTrue(inError); + assertTrue(inError); } } @Test - public void runCql2ElmRegressionTestSuite() throws IOException { + void runCql2ElmRegressionTestSuite() throws IOException { runTest("CMS146v2_Test_CQM.cql"); runTest("CodeAndConceptTest.cql"); runTest("DateTimeLiteralTest.cql"); diff --git a/Src/java/tools/xsd-to-modelinfo/src/test/java/org/cqframework/cql/tools/xsd2modelinfo/TestTypes.java b/Src/java/tools/xsd-to-modelinfo/src/test/java/org/cqframework/cql/tools/xsd2modelinfo/TestTypes.java index 559ad578a..7bde34852 100644 --- a/Src/java/tools/xsd-to-modelinfo/src/test/java/org/cqframework/cql/tools/xsd2modelinfo/TestTypes.java +++ b/Src/java/tools/xsd-to-modelinfo/src/test/java/org/cqframework/cql/tools/xsd2modelinfo/TestTypes.java @@ -7,12 +7,12 @@ import javax.xml.transform.stream.StreamSource; import org.apache.ws.commons.schema.*; import org.hl7.elm_modelinfo.r1.ModelInfo; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Test; -public class TestTypes { +class TestTypes { @Test - public void testModelImporter() { + void modelImporter() { InputStream is = null; try { File f = new File(TestTypes.class.getResource("fhir-single.xsd").getFile());