diff --git a/tooling/src/test/java/org/opencds/cqf/tooling/acceleratorkit/ANCMiniContentTest.java b/tooling/src/test/java/org/opencds/cqf/tooling/acceleratorkit/ANCMiniContentTest.java index 687f1508a..716aa2d44 100644 --- a/tooling/src/test/java/org/opencds/cqf/tooling/acceleratorkit/ANCMiniContentTest.java +++ b/tooling/src/test/java/org/opencds/cqf/tooling/acceleratorkit/ANCMiniContentTest.java @@ -1,7 +1,6 @@ package org.opencds.cqf.tooling.acceleratorkit; import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertFalse; import static org.testng.Assert.assertTrue; import java.io.IOException; @@ -13,24 +12,22 @@ public class ANCMiniContentTest extends BaseContentTest { public ANCMiniContentTest() { - super(new Spreadsheet() { - { - path = "acceleratorkit/ANC Test Cases-mini.xlsx"; - scope = "ANCM"; - dataElementPages = "ANC.A. Registration,ANC.B5 Quick check,ANC.End End"; - } - }); + super(new Spreadsheet() + .path("acceleratorkit/WHO-ANC-mini.xlsx") + .testCases("acceleratorkit/ANC Test Cases-mini.xlsx") + .scope("ANCM") + .dataElementPages("ANC.A. Registration,ANC.B5 Quick check,ANC.End End")); } @Test public void validateContentCount() { - assertFalse(profilesPath().toFile().exists()); + assertEquals(profilesPath().toFile().listFiles().length, 12); assertEquals(cqlPath().toFile().listFiles().length, 4); - assertFalse(examplesPath().toFile().exists()); - assertFalse(extensionsPath().toFile().exists()); - assertFalse(resourcesPath().toFile().exists()); - assertFalse(testsPath().toFile().exists()); - assertEquals(vocabularyPath().resolve("codesystem").toFile().listFiles().length, 1); + assertEquals(examplesPath().toFile().listFiles().length, 12); + assertEquals(extensionsPath().toFile().listFiles().length, 2); + assertEquals(resourcesPath().resolve("questionnaire").toFile().listFiles().length, 3); + assertEquals(testsPath().toFile().listFiles().length, 14); + assertEquals(vocabularyPath().resolve("codesystem").toFile().listFiles().length, 2); } @Test diff --git a/tooling/src/test/java/org/opencds/cqf/tooling/acceleratorkit/BaseContentTest.java b/tooling/src/test/java/org/opencds/cqf/tooling/acceleratorkit/BaseContentTest.java index 14ea9d3ea..a27d401d7 100644 --- a/tooling/src/test/java/org/opencds/cqf/tooling/acceleratorkit/BaseContentTest.java +++ b/tooling/src/test/java/org/opencds/cqf/tooling/acceleratorkit/BaseContentTest.java @@ -1,11 +1,13 @@ package org.opencds.cqf.tooling.acceleratorkit; import java.io.BufferedReader; +import java.io.File; import java.io.FileReader; import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; import java.util.ArrayList; +import java.util.Comparator; import java.util.Objects; import org.hl7.fhir.instance.model.api.IBaseResource; @@ -53,7 +55,17 @@ protected void init() throws IOException { Files.createDirectories(p); } - var f = Files.createTempDirectory(p, "content-test-"); + var testPath = p.resolve("content-test-" + scope()); + + // Clean out any existing tests. + if (testPath.toFile().exists()) { + Files.walk(testPath) + .sorted(Comparator.reverseOrder()) + .map(Path::toFile) + .forEach(File::delete); + } + + var f = Files.createDirectory(testPath); outputPath = f.toAbsolutePath(); processor = new Processor(); processor.execute(args()); @@ -67,11 +79,55 @@ protected String command() { * Add new fields to this class to support additional command line arguments. */ protected static class Spreadsheet { - String path; - String encoding; - String scope; - String dataElementPages; - String testCases; + private String path; + public String path() { + return path; + } + + public Spreadsheet path(String path) { + this.path = path; + return this; + } + + private String encoding; + public String encoding() { + return encoding; + } + + public Spreadsheet encoding(String encoding) { + this.encoding = encoding; + return this; + } + + private String scope; + private String scope() { + return scope; + } + + public Spreadsheet scope(String scope) { + this.scope = scope; + return this; + } + + private String dataElementPages; + public String dataElementPages() { + return dataElementPages; + } + + public Spreadsheet dataElementPages(String dataElementPages) { + this.dataElementPages = dataElementPages; + return this; + } + + private String testCases; + public String testCases() { + return testCases; + } + + public Spreadsheet testCases(String testCases) { + this.testCases = testCases; + return this; + } } protected String[] params() { @@ -81,7 +137,8 @@ protected String[] params() { "-dep", dataElementPages(), "-op", outputPath().toAbsolutePath().toString(), "-e", encoding(), - "-tc", testCases()}; + "-tc", testCasesPath() != null ? testCasesPath().toAbsolutePath().toString() : null + }; }; protected String[] args() { @@ -106,25 +163,28 @@ protected String[] args() { } // Input params accessors + protected Path spreadsheetPath() { + return Path.of(resourcesPath, spreadsheet.path()); + } + + protected Path testCasesPath() { + if (spreadsheet.testCases() == null) { + return null; + } - protected String testCases() { - return spreadsheet.testCases; + return Path.of(resourcesPath, spreadsheet.testCases()); } protected String encoding() { - return spreadsheet.encoding; + return spreadsheet.encoding(); } protected String scope() { - return spreadsheet.scope; - } - - protected Path spreadsheetPath() { - return Path.of(resourcesPath, spreadsheet.path); + return spreadsheet.scope(); } protected String dataElementPages() { - return spreadsheet.dataElementPages; + return spreadsheet.dataElementPages(); } // FHIR context accessors diff --git a/tooling/src/test/java/org/opencds/cqf/tooling/acceleratorkit/DTRContentTest.java b/tooling/src/test/java/org/opencds/cqf/tooling/acceleratorkit/DTRContentTest.java index 32e117e99..cd564b1d4 100644 --- a/tooling/src/test/java/org/opencds/cqf/tooling/acceleratorkit/DTRContentTest.java +++ b/tooling/src/test/java/org/opencds/cqf/tooling/acceleratorkit/DTRContentTest.java @@ -8,13 +8,10 @@ public class DTRContentTest extends BaseContentTest { public DTRContentTest() { - super(new Spreadsheet() { - { - path = "acceleratorkit/DTR.xlsx"; - scope = "ASLP"; - dataElementPages = "ASLP.A1 Adult Sleep Studies"; - } - }); + super(new Spreadsheet() + .path("acceleratorkit/DTR.xlsx") + .scope("ASLP") + .dataElementPages("ASLP.A1 Adult Sleep Studies"));; } @Test diff --git a/tooling/src/test/resources/acceleratorkit/WHO-ANC-mini.xlsx b/tooling/src/test/resources/acceleratorkit/WHO-ANC-mini.xlsx new file mode 100644 index 000000000..32069ca82 Binary files /dev/null and b/tooling/src/test/resources/acceleratorkit/WHO-ANC-mini.xlsx differ