From 58cbd0b613a8bcedccd28ff188ae5ca46e3de16d Mon Sep 17 00:00:00 2001 From: daviddieppois Date: Tue, 7 May 2024 13:49:58 -0400 Subject: [PATCH 01/22] Added missing tests --- .../cqf/tooling/operation/ig/CqlRefresh.java | 23 ++++++ .../operation/RefreshIGOperationTest.java | 77 +++++++++++++++++-- 2 files changed, 95 insertions(+), 5 deletions(-) create mode 100644 tooling/src/main/java/org/opencds/cqf/tooling/operation/ig/CqlRefresh.java diff --git a/tooling/src/main/java/org/opencds/cqf/tooling/operation/ig/CqlRefresh.java b/tooling/src/main/java/org/opencds/cqf/tooling/operation/ig/CqlRefresh.java new file mode 100644 index 000000000..e326174e4 --- /dev/null +++ b/tooling/src/main/java/org/opencds/cqf/tooling/operation/ig/CqlRefresh.java @@ -0,0 +1,23 @@ +package org.opencds.cqf.tooling.operation.ig; + +import org.hl7.fhir.instance.model.api.IBaseResource; +import org.opencds.cqf.tooling.processor.argument.RefreshIGArgumentProcessor; + +import java.util.List; + +public class CqlRefresh extends Refresh { + + public CqlRefresh(IGInfo igInfo) { + super(igInfo); + } + + @Override + public List refresh() { + return List.of(); + } + + public void refreshCql(IGInfo igInfo, RefreshIGArgumentProcessor params) { + + } + +} diff --git a/tooling/src/test/java/org/opencds/cqf/tooling/operation/RefreshIGOperationTest.java b/tooling/src/test/java/org/opencds/cqf/tooling/operation/RefreshIGOperationTest.java index 6c861325b..629152f21 100644 --- a/tooling/src/test/java/org/opencds/cqf/tooling/operation/RefreshIGOperationTest.java +++ b/tooling/src/test/java/org/opencds/cqf/tooling/operation/RefreshIGOperationTest.java @@ -19,10 +19,12 @@ import java.util.List; import java.util.Map; +import com.google.gson.*; import org.apache.commons.io.FileUtils; import org.hl7.fhir.instance.model.api.IBaseResource; import org.hl7.fhir.utilities.IniFile; import org.opencds.cqf.tooling.RefreshTest; +import org.opencds.cqf.tooling.operation.ig.NewRefreshIGOperation; import org.opencds.cqf.tooling.parameter.RefreshIGParameters; import org.opencds.cqf.tooling.processor.IGProcessor; import org.opencds.cqf.tooling.processor.argument.RefreshIGArgumentProcessor; @@ -30,16 +32,12 @@ import org.opencds.cqf.tooling.utilities.ResourceUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.testng.annotations.AfterMethod; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; +import org.testng.annotations.*; import com.fasterxml.jackson.core.StreamReadConstraints; import com.github.tomakehurst.wiremock.WireMockServer; import com.github.tomakehurst.wiremock.client.WireMock; import com.github.tomakehurst.wiremock.common.Json; -import com.google.gson.Gson; import ca.uhn.fhir.context.FhirContext; import ca.uhn.fhir.context.FhirVersionEnum; @@ -64,6 +62,13 @@ public RefreshIGOperationTest() { private final String INI_LOC = Path.of("target","refreshIG","ig.ini").toString(); + private static final String[] NEW_REFRESH_IG_LIBRARY_FILE_NAMES = { + "GMTPInitialExpressions.json", "GMTPInitialExpressions.json", + "MBODAInitialExpressions.json", "USCoreCommon.json", "USCoreElements.json", "USCoreTests.json" + }; + + private static final String NEW_REFRESH_IG_FOLDER_PATH = "src/test/resources/NewRefreshIG"; + private static final String NEW_REFRESH_IG_LIBRARY_FOLDER_PATH = "src/test/resources/NewRefreshIG/input/resources/library"; // Store the original standard out before changing it. private final PrintStream originalStdOut = System.out; @@ -88,6 +93,68 @@ public void setUp() throws Exception { deleteTempINI(); } + @Test + public void testNewRefreshOperation() { + File folder = new File(NEW_REFRESH_IG_FOLDER_PATH); + assertTrue(folder.exists(), "Folder should be present"); + File jsonFile = new File(folder, "ig.ini"); + assertTrue(jsonFile.exists(), "ig.ini file should be present"); + + NewRefreshIGOperation newRefreshIGOperation = new NewRefreshIGOperation(); + String[] args = new String[]{ + "-NewRefreshIG", + "-ini=" + "src/test/resources/NewRefreshIG/ig.ini", + "-rd=" + "src/test/resources/NewRefreshIG", + "-uv=" + "1.0.1", + "-d", + "-p", + "-t" + }; + newRefreshIGOperation.execute(args); + + folder = new File(NEW_REFRESH_IG_LIBRARY_FOLDER_PATH); + assertTrue(folder.exists(), "Folder should be created"); + + for (String fileName : NEW_REFRESH_IG_LIBRARY_FILE_NAMES) { + // Check if the specific file exists + jsonFile = new File(folder, fileName); + assertTrue(jsonFile.exists(), "JSON file " + fileName + " should be created"); + } + + try (FileReader reader = new FileReader(NEW_REFRESH_IG_LIBRARY_FOLDER_PATH + separator + "GMTPInitialExpressions.json")) { + JsonObject jsonObject = JsonParser.parseReader(reader).getAsJsonObject(); + String version = jsonObject.get("version").getAsString(); + JsonArray relatedArtifacts = jsonObject.getAsJsonArray("relatedArtifact"); + + boolean foundFHIRHelpers = false; + for (JsonElement element : relatedArtifacts) { + JsonObject artifact = element.getAsJsonObject(); + if (artifact.has("display") && artifact.get("display").getAsString().equals("Library FHIRHelpers")) { + String resource = artifact.get("resource").getAsString(); + if (resource.equals("http://fhir.org/guides/cqf/common/Library/FHIRHelpers|4.0.1")) { + foundFHIRHelpers = true; + break; + } + } + } + assertTrue(foundFHIRHelpers, "Library FHIRHelpers not found with correct resource value"); + assertEquals("1.0.1", version, "Version parameter should be modified correctly"); + } catch (IOException e) { + fail("Error reading JSON file: " + e.getMessage()); + } + } + + @AfterSuite + public void cleanup() { + // Delete the generated files + File folder = new File(NEW_REFRESH_IG_LIBRARY_FOLDER_PATH); + for (String fileName : NEW_REFRESH_IG_LIBRARY_FILE_NAMES) { + File jsonFile = new File(folder, fileName); + if (jsonFile.exists()) { + jsonFile.delete(); + } + } + } /** * This test breaks down refreshIG's process and can verify multiple bundles From 4d48c41d52dbeaca54e73a41cdd149827c31abd3 Mon Sep 17 00:00:00 2001 From: daviddieppois Date: Mon, 13 May 2024 09:22:09 -0400 Subject: [PATCH 02/22] _Added CqlRefresh in order to update cql file before conversion. _Made sure that we have the cql data inside the json library and that it matches the udpated cql _Update tests to verify everything works as expected. --- .../cqf/tooling/operation/ig/CqlRefresh.java | 81 ++++++++++++++++++- .../operation/ig/NewRefreshIGOperation.java | 2 + .../cqf/tooling/processor/CqlProcessor.java | 2 + .../operation/RefreshIGOperationTest.java | 79 ++++++++++++++---- 4 files changed, 144 insertions(+), 20 deletions(-) diff --git a/tooling/src/main/java/org/opencds/cqf/tooling/operation/ig/CqlRefresh.java b/tooling/src/main/java/org/opencds/cqf/tooling/operation/ig/CqlRefresh.java index e326174e4..2d00e3c56 100644 --- a/tooling/src/main/java/org/opencds/cqf/tooling/operation/ig/CqlRefresh.java +++ b/tooling/src/main/java/org/opencds/cqf/tooling/operation/ig/CqlRefresh.java @@ -1,12 +1,26 @@ package org.opencds.cqf.tooling.operation.ig; import org.hl7.fhir.instance.model.api.IBaseResource; -import org.opencds.cqf.tooling.processor.argument.RefreshIGArgumentProcessor; +import org.opencds.cqf.tooling.parameter.RefreshIGParameters; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; -import java.util.List; +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.*; +import java.util.regex.Matcher; +import java.util.regex.Pattern; +import java.util.stream.Collectors; +import java.util.stream.Stream; public class CqlRefresh extends Refresh { + private static final Logger logger = LoggerFactory.getLogger(CqlRefresh.class); + private final Pattern VERSION_PATTERN = Pattern.compile("^(library\\s+(\\S+)\\s+version\\s+)'[0-9]+\\.[0-9]+\\.[0-9]+'"); + private final Pattern INCLUDE_PATTERN = Pattern.compile("^(include\\s+(\\S+)\\s+version\\s+)'([0-9]+\\.[0-9]+\\.[0-9]+)'(\\s+called\\s+(\\S+))?"); + public CqlRefresh(IGInfo igInfo) { super(igInfo); } @@ -16,8 +30,69 @@ public List refresh() { return List.of(); } - public void refreshCql(IGInfo igInfo, RefreshIGArgumentProcessor params) { + public void refreshCql(IGInfo igInfo, RefreshIGParameters params) { + Map updatedLibraries = refreshCqlFile(igInfo.getCqlBinaryPath(), params.updatedVersion); + updateCqlReferences(igInfo.getCqlBinaryPath(), updatedLibraries); + } + + private Map refreshCqlFile(String cqlBinaryPath, String updatedVersion) { + Map updatedLibraries = new HashMap<>(); + try (Stream paths = Files.walk(Paths.get(cqlBinaryPath))) { + List files = paths + .filter(Files::isRegularFile) + .filter(path -> path.toString().endsWith(".cql")) + .collect(Collectors.toList()); + + for (Path file : files) { + List lines = Files.readAllLines(file); + for (int i = 0; i < lines.size(); i++) { + Matcher matcher = VERSION_PATTERN.matcher(lines.get(i)); + if (matcher.matches()) { + String libraryName = matcher.group(2); + String updatedLine = matcher.replaceFirst("$1'" + updatedVersion + "'"); + lines.set(i, updatedLine); + Files.write(file, lines); + updatedLibraries.put(libraryName, updatedVersion); + break; + } + } + } + } catch (IOException e) { + logger.error("Error updating cql files: {}", e.getMessage()); + } + return updatedLibraries; + } + + private void updateCqlReferences(String cqlBinaryPath, Map updatedLibraries) { + try (Stream paths = Files.walk(Paths.get(cqlBinaryPath))) { + List files = paths + .filter(Files::isRegularFile) + .filter(path -> path.toString().endsWith(".cql")) + .collect(Collectors.toList()); + for (Path file : files) { + List lines = Files.readAllLines(file); + boolean fileUpdated = false; + for (int i = 0; i < lines.size(); i++) { + Matcher matcher = INCLUDE_PATTERN.matcher(lines.get(i)); + while (matcher.find()) { + String libraryName = matcher.group(2); + String newVersion = updatedLibraries.get(libraryName); + if (newVersion != null && !matcher.group(3).equals(newVersion)) { + String calledPart = matcher.group(4) != null ? matcher.group(4) : ""; + String newLine = matcher.replaceFirst("$1'" + newVersion + "'" + calledPart); + lines.set(i, newLine); + fileUpdated = true; + } + } + } + if (fileUpdated) { + Files.write(file, lines); + } + } + } catch (IOException e) { + logger.error("Error updating CQL references: {}", e.getMessage()); + } } } diff --git a/tooling/src/main/java/org/opencds/cqf/tooling/operation/ig/NewRefreshIGOperation.java b/tooling/src/main/java/org/opencds/cqf/tooling/operation/ig/NewRefreshIGOperation.java index 23e3c4678..8718c0a34 100644 --- a/tooling/src/main/java/org/opencds/cqf/tooling/operation/ig/NewRefreshIGOperation.java +++ b/tooling/src/main/java/org/opencds/cqf/tooling/operation/ig/NewRefreshIGOperation.java @@ -22,6 +22,8 @@ public void execute(String[] args) { try { this.params = new RefreshIGArgumentProcessor().parseAndConvert(args); IGInfo info = new IGInfo(null, params); + CqlRefresh cqlRefresh = new CqlRefresh(info); + cqlRefresh.refreshCql(info, params); LibraryRefresh libraryRefresh = new LibraryRefresh(info); publishLibraries(info, libraryRefresh.refresh(this.params)); PlanDefinitionRefresh planDefinitionRefresh = new PlanDefinitionRefresh(info, libraryRefresh.getCqlProcessor(), libraryRefresh.getLibraryPackages()); diff --git a/tooling/src/main/java/org/opencds/cqf/tooling/processor/CqlProcessor.java b/tooling/src/main/java/org/opencds/cqf/tooling/processor/CqlProcessor.java index 9f3c19ed2..4e5a6ac00 100644 --- a/tooling/src/main/java/org/opencds/cqf/tooling/processor/CqlProcessor.java +++ b/tooling/src/main/java/org/opencds/cqf/tooling/processor/CqlProcessor.java @@ -2,6 +2,7 @@ import java.io.File; import java.io.FilenameFilter; +import java.nio.file.Files; import java.nio.file.Paths; import java.util.*; import java.util.stream.Collectors; @@ -390,6 +391,7 @@ private void translateFile(LibraryManager libraryManager, File file, CqlCompiler result.setOptions(new CqlTranslatorOptions().withCqlCompilerOptions(options)); // convert to base64 bytes // NOTE: Publication tooling requires XML content + result.setCql(Files.readAllBytes(file.toPath())); result.setElm(translator.toXml().getBytes()); result.setIdentifier(translator.toELM().getIdentifier()); result.setJsonElm(translator.toJson().getBytes()); diff --git a/tooling/src/test/java/org/opencds/cqf/tooling/operation/RefreshIGOperationTest.java b/tooling/src/test/java/org/opencds/cqf/tooling/operation/RefreshIGOperationTest.java index 629152f21..be3d8bb72 100644 --- a/tooling/src/test/java/org/opencds/cqf/tooling/operation/RefreshIGOperationTest.java +++ b/tooling/src/test/java/org/opencds/cqf/tooling/operation/RefreshIGOperationTest.java @@ -67,8 +67,9 @@ public RefreshIGOperationTest() { "MBODAInitialExpressions.json", "USCoreCommon.json", "USCoreElements.json", "USCoreTests.json" }; - private static final String NEW_REFRESH_IG_FOLDER_PATH = "src/test/resources/NewRefreshIG"; - private static final String NEW_REFRESH_IG_LIBRARY_FOLDER_PATH = "src/test/resources/NewRefreshIG/input/resources/library"; + private static final String NEW_REFRESH_IG_FOLDER_PATH = "src" + separator + "test" + separator + "resources" + separator + "NewRefreshIG"; + private static final String NEW_REFRESH_IG_CQL_FOLDER_PATH = "src" + separator + "test" + separator + "resources" + separator + "NewRefreshIG" + separator + "input" + separator + "cql"; + private static final String NEW_REFRESH_IG_LIBRARY_FOLDER_PATH = "src" + separator + "test" + separator + "resources" + separator + "NewRefreshIG" + separator + "input" + separator + "resources" + separator + "library"; // Store the original standard out before changing it. private final PrintStream originalStdOut = System.out; @@ -93,6 +94,7 @@ public void setUp() throws Exception { deleteTempINI(); } + @Test public void testNewRefreshOperation() { File folder = new File(NEW_REFRESH_IG_FOLDER_PATH); @@ -112,36 +114,63 @@ public void testNewRefreshOperation() { }; newRefreshIGOperation.execute(args); + // Verify correct update of cql files following refresh + File cumulativeMedFile = new File(NEW_REFRESH_IG_CQL_FOLDER_PATH, "CumulativeMedicationDuration.cql"); + assertTrue(cumulativeMedFile.exists(), "CumulativeMedicationDuration.cql should exist"); + verifyFileContent(cumulativeMedFile, "library CumulativeMedicationDuration version '1.0.1'"); + + File mbodaFile = new File(NEW_REFRESH_IG_CQL_FOLDER_PATH, "MBODAInitialExpressions.cql"); + assertTrue(mbodaFile.exists(), "MBODAInitialExpressions.cql should exist"); + verifyFileContent(mbodaFile, "include CumulativeMedicationDuration version '1.0.1' called CMD"); + folder = new File(NEW_REFRESH_IG_LIBRARY_FOLDER_PATH); assertTrue(folder.exists(), "Folder should be created"); for (String fileName : NEW_REFRESH_IG_LIBRARY_FILE_NAMES) { - // Check if the specific file exists jsonFile = new File(folder, fileName); assertTrue(jsonFile.exists(), "JSON file " + fileName + " should be created"); } - try (FileReader reader = new FileReader(NEW_REFRESH_IG_LIBRARY_FOLDER_PATH + separator + "GMTPInitialExpressions.json")) { + // Verify the contents of the GMTPInitialExpressions.json file + File gmtpFile = new File(NEW_REFRESH_IG_LIBRARY_FOLDER_PATH, "GMTPInitialExpressions.json"); + assertTrue(gmtpFile.exists(), "GMTPInitialExpressions.json file should exist"); + try (FileReader reader = new FileReader(gmtpFile)) { JsonObject jsonObject = JsonParser.parseReader(reader).getAsJsonObject(); + verifyJsonContent(jsonObject, "GMTPInitialExpressions.json"); + + // Other JSON verifications already in the test String version = jsonObject.get("version").getAsString(); + assertEquals("1.0.1", version, "Version parameter should be modified correctly"); + JsonArray relatedArtifacts = jsonObject.getAsJsonArray("relatedArtifact"); + boolean foundFHIRHelpers = verifyRelatedArtifacts(relatedArtifacts); + assertTrue(foundFHIRHelpers, "Library FHIRHelpers not found with correct resource value"); + } catch (IOException e) { + fail("Error reading GMTPInitialExpressions.json file: " + e.getMessage()); + } + } - boolean foundFHIRHelpers = false; - for (JsonElement element : relatedArtifacts) { - JsonObject artifact = element.getAsJsonObject(); - if (artifact.has("display") && artifact.get("display").getAsString().equals("Library FHIRHelpers")) { - String resource = artifact.get("resource").getAsString(); - if (resource.equals("http://fhir.org/guides/cqf/common/Library/FHIRHelpers|4.0.1")) { - foundFHIRHelpers = true; - break; - } + private void verifyJsonContent(JsonObject jsonObject, String jsonFileName) { + JsonArray contentArray = jsonObject.getAsJsonArray("content"); + assertNotNull(contentArray, "Content array should not be null in " + jsonFileName); + assertTrue(contentArray.size() > 0, "Content array should not be empty in " + jsonFileName); + + JsonObject contentObject = contentArray.get(0).getAsJsonObject(); + assertEquals(contentObject.get("contentType").getAsString(), "text/cql", "Content type should be 'text/cql' in " + jsonFileName); + assertTrue(contentObject.has("data"), "Data field should exist in " + jsonFileName); + } + + private boolean verifyRelatedArtifacts(JsonArray relatedArtifacts) { + for (JsonElement element : relatedArtifacts) { + JsonObject artifact = element.getAsJsonObject(); + if (artifact.has("display") && artifact.get("display").getAsString().equals("Library FHIRHelpers")) { + String resource = artifact.get("resource").getAsString(); + if (resource.equals("http://fhir.org/guides/cqf/common/Library/FHIRHelpers|4.0.1")) { + return true; } } - assertTrue(foundFHIRHelpers, "Library FHIRHelpers not found with correct resource value"); - assertEquals("1.0.1", version, "Version parameter should be modified correctly"); - } catch (IOException e) { - fail("Error reading JSON file: " + e.getMessage()); } + return false; } @AfterSuite @@ -156,6 +185,22 @@ public void cleanup() { } } + private void verifyFileContent(File file, String expectedContent) { + try (BufferedReader reader = new BufferedReader(new FileReader(file))) { + String line; + boolean found = false; + while ((line = reader.readLine()) != null) { + if (line.contains(expectedContent)) { + found = true; + break; + } + } + assertTrue(found, "Expected content not found in " + file.getName()); + } catch (IOException e) { + fail("Failed to read " + file.getName() + ": " + e.getMessage()); + } + } + /** * This test breaks down refreshIG's process and can verify multiple bundles */ From bd038b71c25800b6a6a768dbb183f9efcc088fe9 Mon Sep 17 00:00:00 2001 From: daviddieppois Date: Mon, 13 May 2024 09:27:23 -0400 Subject: [PATCH 03/22] Formatting --- .../operation/RefreshIGOperationTest.java | 206 +++++++++--------- 1 file changed, 102 insertions(+), 104 deletions(-) diff --git a/tooling/src/test/java/org/opencds/cqf/tooling/operation/RefreshIGOperationTest.java b/tooling/src/test/java/org/opencds/cqf/tooling/operation/RefreshIGOperationTest.java index be3d8bb72..8f8844ba0 100644 --- a/tooling/src/test/java/org/opencds/cqf/tooling/operation/RefreshIGOperationTest.java +++ b/tooling/src/test/java/org/opencds/cqf/tooling/operation/RefreshIGOperationTest.java @@ -96,110 +96,108 @@ public void setUp() throws Exception { } @Test - public void testNewRefreshOperation() { - File folder = new File(NEW_REFRESH_IG_FOLDER_PATH); - assertTrue(folder.exists(), "Folder should be present"); - File jsonFile = new File(folder, "ig.ini"); - assertTrue(jsonFile.exists(), "ig.ini file should be present"); - - NewRefreshIGOperation newRefreshIGOperation = new NewRefreshIGOperation(); - String[] args = new String[]{ - "-NewRefreshIG", - "-ini=" + "src/test/resources/NewRefreshIG/ig.ini", - "-rd=" + "src/test/resources/NewRefreshIG", - "-uv=" + "1.0.1", - "-d", - "-p", - "-t" - }; - newRefreshIGOperation.execute(args); - - // Verify correct update of cql files following refresh - File cumulativeMedFile = new File(NEW_REFRESH_IG_CQL_FOLDER_PATH, "CumulativeMedicationDuration.cql"); - assertTrue(cumulativeMedFile.exists(), "CumulativeMedicationDuration.cql should exist"); - verifyFileContent(cumulativeMedFile, "library CumulativeMedicationDuration version '1.0.1'"); - - File mbodaFile = new File(NEW_REFRESH_IG_CQL_FOLDER_PATH, "MBODAInitialExpressions.cql"); - assertTrue(mbodaFile.exists(), "MBODAInitialExpressions.cql should exist"); - verifyFileContent(mbodaFile, "include CumulativeMedicationDuration version '1.0.1' called CMD"); - - folder = new File(NEW_REFRESH_IG_LIBRARY_FOLDER_PATH); - assertTrue(folder.exists(), "Folder should be created"); - - for (String fileName : NEW_REFRESH_IG_LIBRARY_FILE_NAMES) { - jsonFile = new File(folder, fileName); - assertTrue(jsonFile.exists(), "JSON file " + fileName + " should be created"); - } - - // Verify the contents of the GMTPInitialExpressions.json file - File gmtpFile = new File(NEW_REFRESH_IG_LIBRARY_FOLDER_PATH, "GMTPInitialExpressions.json"); - assertTrue(gmtpFile.exists(), "GMTPInitialExpressions.json file should exist"); - try (FileReader reader = new FileReader(gmtpFile)) { - JsonObject jsonObject = JsonParser.parseReader(reader).getAsJsonObject(); - verifyJsonContent(jsonObject, "GMTPInitialExpressions.json"); - - // Other JSON verifications already in the test - String version = jsonObject.get("version").getAsString(); - assertEquals("1.0.1", version, "Version parameter should be modified correctly"); - - JsonArray relatedArtifacts = jsonObject.getAsJsonArray("relatedArtifact"); - boolean foundFHIRHelpers = verifyRelatedArtifacts(relatedArtifacts); - assertTrue(foundFHIRHelpers, "Library FHIRHelpers not found with correct resource value"); - } catch (IOException e) { - fail("Error reading GMTPInitialExpressions.json file: " + e.getMessage()); - } - } - - private void verifyJsonContent(JsonObject jsonObject, String jsonFileName) { - JsonArray contentArray = jsonObject.getAsJsonArray("content"); - assertNotNull(contentArray, "Content array should not be null in " + jsonFileName); - assertTrue(contentArray.size() > 0, "Content array should not be empty in " + jsonFileName); - - JsonObject contentObject = contentArray.get(0).getAsJsonObject(); - assertEquals(contentObject.get("contentType").getAsString(), "text/cql", "Content type should be 'text/cql' in " + jsonFileName); - assertTrue(contentObject.has("data"), "Data field should exist in " + jsonFileName); - } - - private boolean verifyRelatedArtifacts(JsonArray relatedArtifacts) { - for (JsonElement element : relatedArtifacts) { - JsonObject artifact = element.getAsJsonObject(); - if (artifact.has("display") && artifact.get("display").getAsString().equals("Library FHIRHelpers")) { - String resource = artifact.get("resource").getAsString(); - if (resource.equals("http://fhir.org/guides/cqf/common/Library/FHIRHelpers|4.0.1")) { - return true; - } - } - } - return false; - } - - @AfterSuite - public void cleanup() { - // Delete the generated files - File folder = new File(NEW_REFRESH_IG_LIBRARY_FOLDER_PATH); - for (String fileName : NEW_REFRESH_IG_LIBRARY_FILE_NAMES) { - File jsonFile = new File(folder, fileName); - if (jsonFile.exists()) { - jsonFile.delete(); - } - } - } - - private void verifyFileContent(File file, String expectedContent) { - try (BufferedReader reader = new BufferedReader(new FileReader(file))) { - String line; - boolean found = false; - while ((line = reader.readLine()) != null) { - if (line.contains(expectedContent)) { - found = true; - break; - } - } - assertTrue(found, "Expected content not found in " + file.getName()); - } catch (IOException e) { - fail("Failed to read " + file.getName() + ": " + e.getMessage()); - } - } + public void testNewRefreshOperation() { + File folder = new File(NEW_REFRESH_IG_FOLDER_PATH); + assertTrue(folder.exists(), "Folder should be present"); + File jsonFile = new File(folder, "ig.ini"); + assertTrue(jsonFile.exists(), "ig.ini file should be present"); + + NewRefreshIGOperation newRefreshIGOperation = new NewRefreshIGOperation(); + String[] args = new String[]{ + "-NewRefreshIG", + "-ini=" + "src/test/resources/NewRefreshIG/ig.ini", + "-rd=" + "src/test/resources/NewRefreshIG", + "-uv=" + "1.0.1", + "-d", + "-p", + "-t" + }; + newRefreshIGOperation.execute(args); + + // Verify correct update of cql files following refresh + File cumulativeMedFile = new File(NEW_REFRESH_IG_CQL_FOLDER_PATH, "CumulativeMedicationDuration.cql"); + assertTrue(cumulativeMedFile.exists(), "CumulativeMedicationDuration.cql should exist"); + verifyFileContent(cumulativeMedFile, "library CumulativeMedicationDuration version '1.0.1'"); + + File mbodaFile = new File(NEW_REFRESH_IG_CQL_FOLDER_PATH, "MBODAInitialExpressions.cql"); + assertTrue(mbodaFile.exists(), "MBODAInitialExpressions.cql should exist"); + verifyFileContent(mbodaFile, "include CumulativeMedicationDuration version '1.0.1' called CMD"); + + folder = new File(NEW_REFRESH_IG_LIBRARY_FOLDER_PATH); + assertTrue(folder.exists(), "Folder should be created"); + + for (String fileName : NEW_REFRESH_IG_LIBRARY_FILE_NAMES) { + jsonFile = new File(folder, fileName); + assertTrue(jsonFile.exists(), "JSON file " + fileName + " should be created"); + } + + File gmtpFile = new File(NEW_REFRESH_IG_LIBRARY_FOLDER_PATH, "GMTPInitialExpressions.json"); + assertTrue(gmtpFile.exists(), "GMTPInitialExpressions.json file should exist"); + try (FileReader reader = new FileReader(gmtpFile)) { + JsonObject jsonObject = JsonParser.parseReader(reader).getAsJsonObject(); + verifyJsonContent(jsonObject, "GMTPInitialExpressions.json"); + + String version = jsonObject.get("version").getAsString(); + assertEquals("1.0.1", version, "Version parameter should be modified correctly"); + + JsonArray relatedArtifacts = jsonObject.getAsJsonArray("relatedArtifact"); + boolean foundFHIRHelpers = verifyRelatedArtifacts(relatedArtifacts); + assertTrue(foundFHIRHelpers, "Library FHIRHelpers not found with correct resource value"); + } catch (IOException e) { + fail("Error reading GMTPInitialExpressions.json file: " + e.getMessage()); + } + } + + private void verifyJsonContent(JsonObject jsonObject, String jsonFileName) { + JsonArray contentArray = jsonObject.getAsJsonArray("content"); + assertNotNull(contentArray, "Content array should not be null in " + jsonFileName); + assertTrue(contentArray.size() > 0, "Content array should not be empty in " + jsonFileName); + + JsonObject contentObject = contentArray.get(0).getAsJsonObject(); + assertEquals(contentObject.get("contentType").getAsString(), "text/cql", "Content type should be 'text/cql' in " + jsonFileName); + assertTrue(contentObject.has("data"), "Data field should exist in " + jsonFileName); + } + + private boolean verifyRelatedArtifacts(JsonArray relatedArtifacts) { + for (JsonElement element : relatedArtifacts) { + JsonObject artifact = element.getAsJsonObject(); + if (artifact.has("display") && artifact.get("display").getAsString().equals("Library FHIRHelpers")) { + String resource = artifact.get("resource").getAsString(); + if (resource.equals("http://fhir.org/guides/cqf/common/Library/FHIRHelpers|4.0.1")) { + return true; + } + } + } + return false; + } + + @AfterSuite + public void cleanup() { + // Delete the generated files + File folder = new File(NEW_REFRESH_IG_LIBRARY_FOLDER_PATH); + for (String fileName : NEW_REFRESH_IG_LIBRARY_FILE_NAMES) { + File jsonFile = new File(folder, fileName); + if (jsonFile.exists()) { + jsonFile.delete(); + } + } + } + + private void verifyFileContent(File file, String expectedContent) { + try (BufferedReader reader = new BufferedReader(new FileReader(file))) { + String line; + boolean found = false; + while ((line = reader.readLine()) != null) { + if (line.contains(expectedContent)) { + found = true; + break; + } + } + assertTrue(found, "Expected content not found in " + file.getName()); + } catch (IOException e) { + fail("Failed to read " + file.getName() + ": " + e.getMessage()); + } + } /** * This test breaks down refreshIG's process and can verify multiple bundles From 2513f4ecb59e70c293e664375c2d85e9a7f5a32d Mon Sep 17 00:00:00 2001 From: daviddieppois Date: Mon, 13 May 2024 09:34:08 -0400 Subject: [PATCH 04/22] Test update --- .../opencds/cqf/tooling/operation/RefreshIGOperationTest.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tooling/src/test/java/org/opencds/cqf/tooling/operation/RefreshIGOperationTest.java b/tooling/src/test/java/org/opencds/cqf/tooling/operation/RefreshIGOperationTest.java index 8f8844ba0..c7b159965 100644 --- a/tooling/src/test/java/org/opencds/cqf/tooling/operation/RefreshIGOperationTest.java +++ b/tooling/src/test/java/org/opencds/cqf/tooling/operation/RefreshIGOperationTest.java @@ -68,8 +68,8 @@ public RefreshIGOperationTest() { }; private static final String NEW_REFRESH_IG_FOLDER_PATH = "src" + separator + "test" + separator + "resources" + separator + "NewRefreshIG"; - private static final String NEW_REFRESH_IG_CQL_FOLDER_PATH = "src" + separator + "test" + separator + "resources" + separator + "NewRefreshIG" + separator + "input" + separator + "cql"; - private static final String NEW_REFRESH_IG_LIBRARY_FOLDER_PATH = "src" + separator + "test" + separator + "resources" + separator + "NewRefreshIG" + separator + "input" + separator + "resources" + separator + "library"; + private static final String NEW_REFRESH_IG_CQL_FOLDER_PATH = NEW_REFRESH_IG_FOLDER_PATH + separator + "input" + separator + "cql"; + private static final String NEW_REFRESH_IG_LIBRARY_FOLDER_PATH = NEW_REFRESH_IG_FOLDER_PATH + separator + "input" + separator + "resources" + separator + "library"; // Store the original standard out before changing it. private final PrintStream originalStdOut = System.out; From 0cffc31302993b5a37f2586bedf1cc6c1876c5e9 Mon Sep 17 00:00:00 2001 From: daviddieppois Date: Mon, 13 May 2024 09:48:59 -0400 Subject: [PATCH 05/22] Test path update --- .../cqf/tooling/operation/RefreshIGOperationTest.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tooling/src/test/java/org/opencds/cqf/tooling/operation/RefreshIGOperationTest.java b/tooling/src/test/java/org/opencds/cqf/tooling/operation/RefreshIGOperationTest.java index c7b159965..5bffd6cc3 100644 --- a/tooling/src/test/java/org/opencds/cqf/tooling/operation/RefreshIGOperationTest.java +++ b/tooling/src/test/java/org/opencds/cqf/tooling/operation/RefreshIGOperationTest.java @@ -105,8 +105,8 @@ public void testNewRefreshOperation() { NewRefreshIGOperation newRefreshIGOperation = new NewRefreshIGOperation(); String[] args = new String[]{ "-NewRefreshIG", - "-ini=" + "src/test/resources/NewRefreshIG/ig.ini", - "-rd=" + "src/test/resources/NewRefreshIG", + "-ini=" + "src" + separator + "test" + separator + "resources" + separator + "NewRefreshIG" + separator + "ig.ini", + "-rd=" + "src" + separator + "test" + separator + "resources" + separator + "NewRefreshIG", "-uv=" + "1.0.1", "-d", "-p", @@ -230,7 +230,7 @@ public void testBundledFiles() throws IOException { } // Call the method under test, which should use HttpClientUtils.post - copyResourcesToTargetDir("target" + separator + "refreshIG", "testfiles/refreshIG"); + copyResourcesToTargetDir("target" + separator + "refreshIG", "testfiles" +separator + "refreshIG"); // build ini object File iniFile = new File(INI_LOC); String iniFileLocation = iniFile.getAbsolutePath(); From f234eaaaa2971c18fac7879bc59d2da6ae47c1f5 Mon Sep 17 00:00:00 2001 From: daviddieppois Date: Mon, 13 May 2024 15:22:06 -0400 Subject: [PATCH 06/22] Update test files --- .../operation/RefreshIGOperationTest.java | 26 ++++++++++--------- .../opencds/cqf/tooling}/NewRefreshIG/ig.ini | 0 .../tooling}/NewRefreshIG/input/cqf-us.xml | 0 .../cql/CumulativeMedicationDuration.cql | 0 .../input/cql/GMTPInitialExpressions.cql | 0 .../input/cql/MBODAInitialExpressions.cql | 0 .../input/cql/UPPARFInitialExpressions.cql | 0 .../NewRefreshIG/input/cql/USCoreCommon.cql | 0 .../NewRefreshIG/input/cql/USCoreElements.cql | 0 .../NewRefreshIG/input/cql/USCoreTests.cql | 0 .../NewRefreshIG/input/cql/cql-options.json | 0 .../library-CumulativeMedicationDuration.json | 0 .../library-GMTPInitialExpressions.json | 0 .../library-MBODAInitialExpressions.json | 0 .../library/library-USCore-ModelInfo.json | 0 .../library/library-USCoreCommon.json | 0 .../library/library-USCoreElements.json | 0 .../library/library-USCoreTests.json | 0 18 files changed, 14 insertions(+), 12 deletions(-) rename tooling/src/test/resources/{ => org/opencds/cqf/tooling}/NewRefreshIG/ig.ini (100%) rename tooling/src/test/resources/{ => org/opencds/cqf/tooling}/NewRefreshIG/input/cqf-us.xml (100%) rename tooling/src/test/resources/{ => org/opencds/cqf/tooling}/NewRefreshIG/input/cql/CumulativeMedicationDuration.cql (100%) rename tooling/src/test/resources/{ => org/opencds/cqf/tooling}/NewRefreshIG/input/cql/GMTPInitialExpressions.cql (100%) rename tooling/src/test/resources/{ => org/opencds/cqf/tooling}/NewRefreshIG/input/cql/MBODAInitialExpressions.cql (100%) rename tooling/src/test/resources/{ => org/opencds/cqf/tooling}/NewRefreshIG/input/cql/UPPARFInitialExpressions.cql (100%) rename tooling/src/test/resources/{ => org/opencds/cqf/tooling}/NewRefreshIG/input/cql/USCoreCommon.cql (100%) rename tooling/src/test/resources/{ => org/opencds/cqf/tooling}/NewRefreshIG/input/cql/USCoreElements.cql (100%) rename tooling/src/test/resources/{ => org/opencds/cqf/tooling}/NewRefreshIG/input/cql/USCoreTests.cql (100%) rename tooling/src/test/resources/{ => org/opencds/cqf/tooling}/NewRefreshIG/input/cql/cql-options.json (100%) rename tooling/src/test/resources/{ => org/opencds/cqf/tooling}/NewRefreshIG/input/resources/library/library-CumulativeMedicationDuration.json (100%) rename tooling/src/test/resources/{ => org/opencds/cqf/tooling}/NewRefreshIG/input/resources/library/library-GMTPInitialExpressions.json (100%) rename tooling/src/test/resources/{ => org/opencds/cqf/tooling}/NewRefreshIG/input/resources/library/library-MBODAInitialExpressions.json (100%) rename tooling/src/test/resources/{ => org/opencds/cqf/tooling}/NewRefreshIG/input/resources/library/library-USCore-ModelInfo.json (100%) rename tooling/src/test/resources/{ => org/opencds/cqf/tooling}/NewRefreshIG/input/resources/library/library-USCoreCommon.json (100%) rename tooling/src/test/resources/{ => org/opencds/cqf/tooling}/NewRefreshIG/input/resources/library/library-USCoreElements.json (100%) rename tooling/src/test/resources/{ => org/opencds/cqf/tooling}/NewRefreshIG/input/resources/library/library-USCoreTests.json (100%) diff --git a/tooling/src/test/java/org/opencds/cqf/tooling/operation/RefreshIGOperationTest.java b/tooling/src/test/java/org/opencds/cqf/tooling/operation/RefreshIGOperationTest.java index 5bffd6cc3..e6d47c8a5 100644 --- a/tooling/src/test/java/org/opencds/cqf/tooling/operation/RefreshIGOperationTest.java +++ b/tooling/src/test/java/org/opencds/cqf/tooling/operation/RefreshIGOperationTest.java @@ -67,9 +67,10 @@ public RefreshIGOperationTest() { "MBODAInitialExpressions.json", "USCoreCommon.json", "USCoreElements.json", "USCoreTests.json" }; - private static final String NEW_REFRESH_IG_FOLDER_PATH = "src" + separator + "test" + separator + "resources" + separator + "NewRefreshIG"; - private static final String NEW_REFRESH_IG_CQL_FOLDER_PATH = NEW_REFRESH_IG_FOLDER_PATH + separator + "input" + separator + "cql"; - private static final String NEW_REFRESH_IG_LIBRARY_FOLDER_PATH = NEW_REFRESH_IG_FOLDER_PATH + separator + "input" + separator + "resources" + separator + "library"; + private static final String NEW_REFRESH_IG_FOLDER_PATH = "src" + separator + "test" + separator + "resources" + separator + "org/opencds/cqf/tooling/NewRefreshIG"; + private static final String TARGET_OUTPUT_FOLDER_PATH = "target" + separator + "NewRefreshIg"; + private static final String TARGET_OUTPUT_IG_CQL_FOLDER_PATH = TARGET_OUTPUT_FOLDER_PATH + separator + "input" + separator + "cql"; + private static final String TARGET_OUTPUT_IG_LIBRARY_FOLDER_PATH = TARGET_OUTPUT_FOLDER_PATH + separator + "input" + separator + "resources" + separator + "library"; // Store the original standard out before changing it. private final PrintStream originalStdOut = System.out; @@ -96,8 +97,9 @@ public void setUp() throws Exception { } @Test - public void testNewRefreshOperation() { - File folder = new File(NEW_REFRESH_IG_FOLDER_PATH); + public void testNewRefreshOperation() throws IOException { + copyResourcesToTargetDir(TARGET_OUTPUT_FOLDER_PATH, "NewRefreshIG"); + File folder = new File(TARGET_OUTPUT_FOLDER_PATH); assertTrue(folder.exists(), "Folder should be present"); File jsonFile = new File(folder, "ig.ini"); assertTrue(jsonFile.exists(), "ig.ini file should be present"); @@ -105,8 +107,8 @@ public void testNewRefreshOperation() { NewRefreshIGOperation newRefreshIGOperation = new NewRefreshIGOperation(); String[] args = new String[]{ "-NewRefreshIG", - "-ini=" + "src" + separator + "test" + separator + "resources" + separator + "NewRefreshIG" + separator + "ig.ini", - "-rd=" + "src" + separator + "test" + separator + "resources" + separator + "NewRefreshIG", + "-ini=" + TARGET_OUTPUT_FOLDER_PATH + separator + "ig.ini", + "-rd=" + TARGET_OUTPUT_FOLDER_PATH, "-uv=" + "1.0.1", "-d", "-p", @@ -115,15 +117,15 @@ public void testNewRefreshOperation() { newRefreshIGOperation.execute(args); // Verify correct update of cql files following refresh - File cumulativeMedFile = new File(NEW_REFRESH_IG_CQL_FOLDER_PATH, "CumulativeMedicationDuration.cql"); + File cumulativeMedFile = new File(TARGET_OUTPUT_IG_CQL_FOLDER_PATH, "CumulativeMedicationDuration.cql"); assertTrue(cumulativeMedFile.exists(), "CumulativeMedicationDuration.cql should exist"); verifyFileContent(cumulativeMedFile, "library CumulativeMedicationDuration version '1.0.1'"); - File mbodaFile = new File(NEW_REFRESH_IG_CQL_FOLDER_PATH, "MBODAInitialExpressions.cql"); + File mbodaFile = new File(TARGET_OUTPUT_IG_CQL_FOLDER_PATH, "MBODAInitialExpressions.cql"); assertTrue(mbodaFile.exists(), "MBODAInitialExpressions.cql should exist"); verifyFileContent(mbodaFile, "include CumulativeMedicationDuration version '1.0.1' called CMD"); - folder = new File(NEW_REFRESH_IG_LIBRARY_FOLDER_PATH); + folder = new File(TARGET_OUTPUT_IG_LIBRARY_FOLDER_PATH); assertTrue(folder.exists(), "Folder should be created"); for (String fileName : NEW_REFRESH_IG_LIBRARY_FILE_NAMES) { @@ -131,7 +133,7 @@ public void testNewRefreshOperation() { assertTrue(jsonFile.exists(), "JSON file " + fileName + " should be created"); } - File gmtpFile = new File(NEW_REFRESH_IG_LIBRARY_FOLDER_PATH, "GMTPInitialExpressions.json"); + File gmtpFile = new File(TARGET_OUTPUT_IG_LIBRARY_FOLDER_PATH, "GMTPInitialExpressions.json"); assertTrue(gmtpFile.exists(), "GMTPInitialExpressions.json file should exist"); try (FileReader reader = new FileReader(gmtpFile)) { JsonObject jsonObject = JsonParser.parseReader(reader).getAsJsonObject(); @@ -174,7 +176,7 @@ private boolean verifyRelatedArtifacts(JsonArray relatedArtifacts) { @AfterSuite public void cleanup() { // Delete the generated files - File folder = new File(NEW_REFRESH_IG_LIBRARY_FOLDER_PATH); + File folder = new File(TARGET_OUTPUT_IG_LIBRARY_FOLDER_PATH); for (String fileName : NEW_REFRESH_IG_LIBRARY_FILE_NAMES) { File jsonFile = new File(folder, fileName); if (jsonFile.exists()) { diff --git a/tooling/src/test/resources/NewRefreshIG/ig.ini b/tooling/src/test/resources/org/opencds/cqf/tooling/NewRefreshIG/ig.ini similarity index 100% rename from tooling/src/test/resources/NewRefreshIG/ig.ini rename to tooling/src/test/resources/org/opencds/cqf/tooling/NewRefreshIG/ig.ini diff --git a/tooling/src/test/resources/NewRefreshIG/input/cqf-us.xml b/tooling/src/test/resources/org/opencds/cqf/tooling/NewRefreshIG/input/cqf-us.xml similarity index 100% rename from tooling/src/test/resources/NewRefreshIG/input/cqf-us.xml rename to tooling/src/test/resources/org/opencds/cqf/tooling/NewRefreshIG/input/cqf-us.xml diff --git a/tooling/src/test/resources/NewRefreshIG/input/cql/CumulativeMedicationDuration.cql b/tooling/src/test/resources/org/opencds/cqf/tooling/NewRefreshIG/input/cql/CumulativeMedicationDuration.cql similarity index 100% rename from tooling/src/test/resources/NewRefreshIG/input/cql/CumulativeMedicationDuration.cql rename to tooling/src/test/resources/org/opencds/cqf/tooling/NewRefreshIG/input/cql/CumulativeMedicationDuration.cql diff --git a/tooling/src/test/resources/NewRefreshIG/input/cql/GMTPInitialExpressions.cql b/tooling/src/test/resources/org/opencds/cqf/tooling/NewRefreshIG/input/cql/GMTPInitialExpressions.cql similarity index 100% rename from tooling/src/test/resources/NewRefreshIG/input/cql/GMTPInitialExpressions.cql rename to tooling/src/test/resources/org/opencds/cqf/tooling/NewRefreshIG/input/cql/GMTPInitialExpressions.cql diff --git a/tooling/src/test/resources/NewRefreshIG/input/cql/MBODAInitialExpressions.cql b/tooling/src/test/resources/org/opencds/cqf/tooling/NewRefreshIG/input/cql/MBODAInitialExpressions.cql similarity index 100% rename from tooling/src/test/resources/NewRefreshIG/input/cql/MBODAInitialExpressions.cql rename to tooling/src/test/resources/org/opencds/cqf/tooling/NewRefreshIG/input/cql/MBODAInitialExpressions.cql diff --git a/tooling/src/test/resources/NewRefreshIG/input/cql/UPPARFInitialExpressions.cql b/tooling/src/test/resources/org/opencds/cqf/tooling/NewRefreshIG/input/cql/UPPARFInitialExpressions.cql similarity index 100% rename from tooling/src/test/resources/NewRefreshIG/input/cql/UPPARFInitialExpressions.cql rename to tooling/src/test/resources/org/opencds/cqf/tooling/NewRefreshIG/input/cql/UPPARFInitialExpressions.cql diff --git a/tooling/src/test/resources/NewRefreshIG/input/cql/USCoreCommon.cql b/tooling/src/test/resources/org/opencds/cqf/tooling/NewRefreshIG/input/cql/USCoreCommon.cql similarity index 100% rename from tooling/src/test/resources/NewRefreshIG/input/cql/USCoreCommon.cql rename to tooling/src/test/resources/org/opencds/cqf/tooling/NewRefreshIG/input/cql/USCoreCommon.cql diff --git a/tooling/src/test/resources/NewRefreshIG/input/cql/USCoreElements.cql b/tooling/src/test/resources/org/opencds/cqf/tooling/NewRefreshIG/input/cql/USCoreElements.cql similarity index 100% rename from tooling/src/test/resources/NewRefreshIG/input/cql/USCoreElements.cql rename to tooling/src/test/resources/org/opencds/cqf/tooling/NewRefreshIG/input/cql/USCoreElements.cql diff --git a/tooling/src/test/resources/NewRefreshIG/input/cql/USCoreTests.cql b/tooling/src/test/resources/org/opencds/cqf/tooling/NewRefreshIG/input/cql/USCoreTests.cql similarity index 100% rename from tooling/src/test/resources/NewRefreshIG/input/cql/USCoreTests.cql rename to tooling/src/test/resources/org/opencds/cqf/tooling/NewRefreshIG/input/cql/USCoreTests.cql diff --git a/tooling/src/test/resources/NewRefreshIG/input/cql/cql-options.json b/tooling/src/test/resources/org/opencds/cqf/tooling/NewRefreshIG/input/cql/cql-options.json similarity index 100% rename from tooling/src/test/resources/NewRefreshIG/input/cql/cql-options.json rename to tooling/src/test/resources/org/opencds/cqf/tooling/NewRefreshIG/input/cql/cql-options.json diff --git a/tooling/src/test/resources/NewRefreshIG/input/resources/library/library-CumulativeMedicationDuration.json b/tooling/src/test/resources/org/opencds/cqf/tooling/NewRefreshIG/input/resources/library/library-CumulativeMedicationDuration.json similarity index 100% rename from tooling/src/test/resources/NewRefreshIG/input/resources/library/library-CumulativeMedicationDuration.json rename to tooling/src/test/resources/org/opencds/cqf/tooling/NewRefreshIG/input/resources/library/library-CumulativeMedicationDuration.json diff --git a/tooling/src/test/resources/NewRefreshIG/input/resources/library/library-GMTPInitialExpressions.json b/tooling/src/test/resources/org/opencds/cqf/tooling/NewRefreshIG/input/resources/library/library-GMTPInitialExpressions.json similarity index 100% rename from tooling/src/test/resources/NewRefreshIG/input/resources/library/library-GMTPInitialExpressions.json rename to tooling/src/test/resources/org/opencds/cqf/tooling/NewRefreshIG/input/resources/library/library-GMTPInitialExpressions.json diff --git a/tooling/src/test/resources/NewRefreshIG/input/resources/library/library-MBODAInitialExpressions.json b/tooling/src/test/resources/org/opencds/cqf/tooling/NewRefreshIG/input/resources/library/library-MBODAInitialExpressions.json similarity index 100% rename from tooling/src/test/resources/NewRefreshIG/input/resources/library/library-MBODAInitialExpressions.json rename to tooling/src/test/resources/org/opencds/cqf/tooling/NewRefreshIG/input/resources/library/library-MBODAInitialExpressions.json diff --git a/tooling/src/test/resources/NewRefreshIG/input/resources/library/library-USCore-ModelInfo.json b/tooling/src/test/resources/org/opencds/cqf/tooling/NewRefreshIG/input/resources/library/library-USCore-ModelInfo.json similarity index 100% rename from tooling/src/test/resources/NewRefreshIG/input/resources/library/library-USCore-ModelInfo.json rename to tooling/src/test/resources/org/opencds/cqf/tooling/NewRefreshIG/input/resources/library/library-USCore-ModelInfo.json diff --git a/tooling/src/test/resources/NewRefreshIG/input/resources/library/library-USCoreCommon.json b/tooling/src/test/resources/org/opencds/cqf/tooling/NewRefreshIG/input/resources/library/library-USCoreCommon.json similarity index 100% rename from tooling/src/test/resources/NewRefreshIG/input/resources/library/library-USCoreCommon.json rename to tooling/src/test/resources/org/opencds/cqf/tooling/NewRefreshIG/input/resources/library/library-USCoreCommon.json diff --git a/tooling/src/test/resources/NewRefreshIG/input/resources/library/library-USCoreElements.json b/tooling/src/test/resources/org/opencds/cqf/tooling/NewRefreshIG/input/resources/library/library-USCoreElements.json similarity index 100% rename from tooling/src/test/resources/NewRefreshIG/input/resources/library/library-USCoreElements.json rename to tooling/src/test/resources/org/opencds/cqf/tooling/NewRefreshIG/input/resources/library/library-USCoreElements.json diff --git a/tooling/src/test/resources/NewRefreshIG/input/resources/library/library-USCoreTests.json b/tooling/src/test/resources/org/opencds/cqf/tooling/NewRefreshIG/input/resources/library/library-USCoreTests.json similarity index 100% rename from tooling/src/test/resources/NewRefreshIG/input/resources/library/library-USCoreTests.json rename to tooling/src/test/resources/org/opencds/cqf/tooling/NewRefreshIG/input/resources/library/library-USCoreTests.json From 2fb61d52614fc09155d8ea6a847a00f98a518461 Mon Sep 17 00:00:00 2001 From: daviddieppois Date: Mon, 13 May 2024 15:29:40 -0400 Subject: [PATCH 07/22] Update test files 2 --- .../operation/RefreshIGOperationTest.java | 45 ++++++++++++------- 1 file changed, 30 insertions(+), 15 deletions(-) diff --git a/tooling/src/test/java/org/opencds/cqf/tooling/operation/RefreshIGOperationTest.java b/tooling/src/test/java/org/opencds/cqf/tooling/operation/RefreshIGOperationTest.java index e6d47c8a5..42838e92a 100644 --- a/tooling/src/test/java/org/opencds/cqf/tooling/operation/RefreshIGOperationTest.java +++ b/tooling/src/test/java/org/opencds/cqf/tooling/operation/RefreshIGOperationTest.java @@ -88,14 +88,29 @@ public void setUp() throws Exception { IOUtils.resourceDirectories = new ArrayList(); IOUtils.clearDevicePaths(); System.setOut(new PrintStream(this.console)); - File dir = new File("target" + separator + "refreshIG"); - if (dir.exists()) { - FileUtils.deleteDirectory(dir); - } + + // Delete directories + deleteDirectory("target" + File.separator + "refreshIG"); + deleteDirectory("target" + File.separator + "NewRefreshIG"); deleteTempINI(); } + /** + * Attempts to delete a directory if it exists. + * @param path The path to the directory to delete. + */ + private void deleteDirectory(String path) { + File dir = new File(path); + if (dir.exists()) { + try { + FileUtils.deleteDirectory(dir); + } catch (IOException e) { + System.err.println("Failed to delete directory: " + path + " - " + e.getMessage()); + } + } + } + @Test public void testNewRefreshOperation() throws IOException { copyResourcesToTargetDir(TARGET_OUTPUT_FOLDER_PATH, "NewRefreshIG"); @@ -173,17 +188,17 @@ private boolean verifyRelatedArtifacts(JsonArray relatedArtifacts) { return false; } - @AfterSuite - public void cleanup() { - // Delete the generated files - File folder = new File(TARGET_OUTPUT_IG_LIBRARY_FOLDER_PATH); - for (String fileName : NEW_REFRESH_IG_LIBRARY_FILE_NAMES) { - File jsonFile = new File(folder, fileName); - if (jsonFile.exists()) { - jsonFile.delete(); - } - } - } +// @AfterSuite +// public void cleanup() { +// // Delete the generated files +// File folder = new File(TARGET_OUTPUT_IG_LIBRARY_FOLDER_PATH); +// for (String fileName : NEW_REFRESH_IG_LIBRARY_FILE_NAMES) { +// File jsonFile = new File(folder, fileName); +// if (jsonFile.exists()) { +// jsonFile.delete(); +// } +// } +// } private void verifyFileContent(File file, String expectedContent) { try (BufferedReader reader = new BufferedReader(new FileReader(file))) { From 57c072e8ed9d5d64f77283b6c512fe6558142820 Mon Sep 17 00:00:00 2001 From: daviddieppois Date: Mon, 13 May 2024 15:31:32 -0400 Subject: [PATCH 08/22] Clean up of test file --- .../operation/RefreshIGOperationTest.java | 62 +++++++------------ 1 file changed, 21 insertions(+), 41 deletions(-) diff --git a/tooling/src/test/java/org/opencds/cqf/tooling/operation/RefreshIGOperationTest.java b/tooling/src/test/java/org/opencds/cqf/tooling/operation/RefreshIGOperationTest.java index 42838e92a..12489068d 100644 --- a/tooling/src/test/java/org/opencds/cqf/tooling/operation/RefreshIGOperationTest.java +++ b/tooling/src/test/java/org/opencds/cqf/tooling/operation/RefreshIGOperationTest.java @@ -1,27 +1,15 @@ package org.opencds.cqf.tooling.operation; -import java.io.BufferedReader; -import java.io.BufferedWriter; -import java.io.ByteArrayOutputStream; -import java.io.File; -import java.io.FileOutputStream; -import java.io.FileReader; -import java.io.IOException; -import java.io.OutputStreamWriter; -import java.io.PrintStream; -import java.net.ServerSocket; -import java.nio.file.DirectoryStream; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.Paths; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - +import ca.uhn.fhir.context.FhirContext; +import ca.uhn.fhir.context.FhirVersionEnum; +import com.fasterxml.jackson.core.StreamReadConstraints; +import com.github.tomakehurst.wiremock.WireMockServer; +import com.github.tomakehurst.wiremock.client.WireMock; +import com.github.tomakehurst.wiremock.common.Json; import com.google.gson.*; import org.apache.commons.io.FileUtils; import org.hl7.fhir.instance.model.api.IBaseResource; +import org.hl7.fhir.r4.model.Group; import org.hl7.fhir.utilities.IniFile; import org.opencds.cqf.tooling.RefreshTest; import org.opencds.cqf.tooling.operation.ig.NewRefreshIGOperation; @@ -32,18 +20,23 @@ import org.opencds.cqf.tooling.utilities.ResourceUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.testng.annotations.*; +import org.testng.annotations.AfterMethod; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; -import com.fasterxml.jackson.core.StreamReadConstraints; -import com.github.tomakehurst.wiremock.WireMockServer; -import com.github.tomakehurst.wiremock.client.WireMock; -import com.github.tomakehurst.wiremock.common.Json; - -import ca.uhn.fhir.context.FhirContext; -import ca.uhn.fhir.context.FhirVersionEnum; +import java.io.*; +import java.net.ServerSocket; +import java.nio.file.DirectoryStream; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; import static org.testng.Assert.*; -import org.hl7.fhir.r4.model.Group; public class RefreshIGOperationTest extends RefreshTest { protected final Logger logger = LoggerFactory.getLogger(this.getClass()); public RefreshIGOperationTest() { @@ -67,7 +60,6 @@ public RefreshIGOperationTest() { "MBODAInitialExpressions.json", "USCoreCommon.json", "USCoreElements.json", "USCoreTests.json" }; - private static final String NEW_REFRESH_IG_FOLDER_PATH = "src" + separator + "test" + separator + "resources" + separator + "org/opencds/cqf/tooling/NewRefreshIG"; private static final String TARGET_OUTPUT_FOLDER_PATH = "target" + separator + "NewRefreshIg"; private static final String TARGET_OUTPUT_IG_CQL_FOLDER_PATH = TARGET_OUTPUT_FOLDER_PATH + separator + "input" + separator + "cql"; private static final String TARGET_OUTPUT_IG_LIBRARY_FOLDER_PATH = TARGET_OUTPUT_FOLDER_PATH + separator + "input" + separator + "resources" + separator + "library"; @@ -188,18 +180,6 @@ private boolean verifyRelatedArtifacts(JsonArray relatedArtifacts) { return false; } -// @AfterSuite -// public void cleanup() { -// // Delete the generated files -// File folder = new File(TARGET_OUTPUT_IG_LIBRARY_FOLDER_PATH); -// for (String fileName : NEW_REFRESH_IG_LIBRARY_FILE_NAMES) { -// File jsonFile = new File(folder, fileName); -// if (jsonFile.exists()) { -// jsonFile.delete(); -// } -// } -// } - private void verifyFileContent(File file, String expectedContent) { try (BufferedReader reader = new BufferedReader(new FileReader(file))) { String line; From fb1b72a820f365e2d000c65a62cd7959f8b24887 Mon Sep 17 00:00:00 2001 From: daviddieppois Date: Mon, 13 May 2024 15:44:52 -0400 Subject: [PATCH 09/22] Clean up of test file 2 --- .../cqf/tooling/operation/RefreshIGOperationTest.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/tooling/src/test/java/org/opencds/cqf/tooling/operation/RefreshIGOperationTest.java b/tooling/src/test/java/org/opencds/cqf/tooling/operation/RefreshIGOperationTest.java index 12489068d..9743a7fa0 100644 --- a/tooling/src/test/java/org/opencds/cqf/tooling/operation/RefreshIGOperationTest.java +++ b/tooling/src/test/java/org/opencds/cqf/tooling/operation/RefreshIGOperationTest.java @@ -20,10 +20,7 @@ import org.opencds.cqf.tooling.utilities.ResourceUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.testng.annotations.AfterMethod; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; +import org.testng.annotations.*; import java.io.*; import java.net.ServerSocket; @@ -196,6 +193,11 @@ private void verifyFileContent(File file, String expectedContent) { } } + @AfterSuite + public void cleanup() { + deleteDirectory("null"); + } + /** * This test breaks down refreshIG's process and can verify multiple bundles */ From b0e8efc3272c5c45d38e14966d323460b427f1ec Mon Sep 17 00:00:00 2001 From: Jonathan Percival Date: Mon, 13 May 2024 13:56:32 -0600 Subject: [PATCH 10/22] This one is not a file path --- .../opencds/cqf/tooling/operation/RefreshIGOperationTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tooling/src/test/java/org/opencds/cqf/tooling/operation/RefreshIGOperationTest.java b/tooling/src/test/java/org/opencds/cqf/tooling/operation/RefreshIGOperationTest.java index 9743a7fa0..9d5bc7c31 100644 --- a/tooling/src/test/java/org/opencds/cqf/tooling/operation/RefreshIGOperationTest.java +++ b/tooling/src/test/java/org/opencds/cqf/tooling/operation/RefreshIGOperationTest.java @@ -229,7 +229,7 @@ public void testBundledFiles() throws IOException { } // Call the method under test, which should use HttpClientUtils.post - copyResourcesToTargetDir("target" + separator + "refreshIG", "testfiles" +separator + "refreshIG"); + copyResourcesToTargetDir("target" + separator + "refreshIG", "testfiles/refreshIG"); // build ini object File iniFile = new File(INI_LOC); String iniFileLocation = iniFile.getAbsolutePath(); From b5e059c3f82d10515f7cfc90b87fbe58a2c0d5e0 Mon Sep 17 00:00:00 2001 From: Jonathan Percival Date: Mon, 13 May 2024 14:01:09 -0600 Subject: [PATCH 11/22] Fix output directory --- .../opencds/cqf/tooling/operation/RefreshIGOperationTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tooling/src/test/java/org/opencds/cqf/tooling/operation/RefreshIGOperationTest.java b/tooling/src/test/java/org/opencds/cqf/tooling/operation/RefreshIGOperationTest.java index 9d5bc7c31..c31649e5d 100644 --- a/tooling/src/test/java/org/opencds/cqf/tooling/operation/RefreshIGOperationTest.java +++ b/tooling/src/test/java/org/opencds/cqf/tooling/operation/RefreshIGOperationTest.java @@ -102,7 +102,7 @@ private void deleteDirectory(String path) { @Test public void testNewRefreshOperation() throws IOException { - copyResourcesToTargetDir(TARGET_OUTPUT_FOLDER_PATH, "NewRefreshIG"); + copyResourcesToTargetDir(TARGET_OUTPUT_FOLDER_PATH, "target/NewRefreshIG"); File folder = new File(TARGET_OUTPUT_FOLDER_PATH); assertTrue(folder.exists(), "Folder should be present"); File jsonFile = new File(folder, "ig.ini"); From b69379ea51d9914fe80e4299b982e5013bc7b445 Mon Sep 17 00:00:00 2001 From: Jonathan Percival Date: Mon, 13 May 2024 14:05:55 -0600 Subject: [PATCH 12/22] Move files to same directory --- .../opencds/cqf/tooling/operation/RefreshIGOperationTest.java | 2 +- .../org/opencds/cqf/tooling/{ => testfiles}/NewRefreshIG/ig.ini | 0 .../cqf/tooling/{ => testfiles}/NewRefreshIG/input/cqf-us.xml | 0 .../NewRefreshIG/input/cql/CumulativeMedicationDuration.cql | 0 .../NewRefreshIG/input/cql/GMTPInitialExpressions.cql | 0 .../NewRefreshIG/input/cql/MBODAInitialExpressions.cql | 0 .../NewRefreshIG/input/cql/UPPARFInitialExpressions.cql | 0 .../{ => testfiles}/NewRefreshIG/input/cql/USCoreCommon.cql | 0 .../{ => testfiles}/NewRefreshIG/input/cql/USCoreElements.cql | 0 .../{ => testfiles}/NewRefreshIG/input/cql/USCoreTests.cql | 0 .../{ => testfiles}/NewRefreshIG/input/cql/cql-options.json | 0 .../resources/library/library-CumulativeMedicationDuration.json | 0 .../input/resources/library/library-GMTPInitialExpressions.json | 0 .../resources/library/library-MBODAInitialExpressions.json | 0 .../input/resources/library/library-USCore-ModelInfo.json | 0 .../input/resources/library/library-USCoreCommon.json | 0 .../input/resources/library/library-USCoreElements.json | 0 .../input/resources/library/library-USCoreTests.json | 0 18 files changed, 1 insertion(+), 1 deletion(-) rename tooling/src/test/resources/org/opencds/cqf/tooling/{ => testfiles}/NewRefreshIG/ig.ini (100%) rename tooling/src/test/resources/org/opencds/cqf/tooling/{ => testfiles}/NewRefreshIG/input/cqf-us.xml (100%) rename tooling/src/test/resources/org/opencds/cqf/tooling/{ => testfiles}/NewRefreshIG/input/cql/CumulativeMedicationDuration.cql (100%) rename tooling/src/test/resources/org/opencds/cqf/tooling/{ => testfiles}/NewRefreshIG/input/cql/GMTPInitialExpressions.cql (100%) rename tooling/src/test/resources/org/opencds/cqf/tooling/{ => testfiles}/NewRefreshIG/input/cql/MBODAInitialExpressions.cql (100%) rename tooling/src/test/resources/org/opencds/cqf/tooling/{ => testfiles}/NewRefreshIG/input/cql/UPPARFInitialExpressions.cql (100%) rename tooling/src/test/resources/org/opencds/cqf/tooling/{ => testfiles}/NewRefreshIG/input/cql/USCoreCommon.cql (100%) rename tooling/src/test/resources/org/opencds/cqf/tooling/{ => testfiles}/NewRefreshIG/input/cql/USCoreElements.cql (100%) rename tooling/src/test/resources/org/opencds/cqf/tooling/{ => testfiles}/NewRefreshIG/input/cql/USCoreTests.cql (100%) rename tooling/src/test/resources/org/opencds/cqf/tooling/{ => testfiles}/NewRefreshIG/input/cql/cql-options.json (100%) rename tooling/src/test/resources/org/opencds/cqf/tooling/{ => testfiles}/NewRefreshIG/input/resources/library/library-CumulativeMedicationDuration.json (100%) rename tooling/src/test/resources/org/opencds/cqf/tooling/{ => testfiles}/NewRefreshIG/input/resources/library/library-GMTPInitialExpressions.json (100%) rename tooling/src/test/resources/org/opencds/cqf/tooling/{ => testfiles}/NewRefreshIG/input/resources/library/library-MBODAInitialExpressions.json (100%) rename tooling/src/test/resources/org/opencds/cqf/tooling/{ => testfiles}/NewRefreshIG/input/resources/library/library-USCore-ModelInfo.json (100%) rename tooling/src/test/resources/org/opencds/cqf/tooling/{ => testfiles}/NewRefreshIG/input/resources/library/library-USCoreCommon.json (100%) rename tooling/src/test/resources/org/opencds/cqf/tooling/{ => testfiles}/NewRefreshIG/input/resources/library/library-USCoreElements.json (100%) rename tooling/src/test/resources/org/opencds/cqf/tooling/{ => testfiles}/NewRefreshIG/input/resources/library/library-USCoreTests.json (100%) diff --git a/tooling/src/test/java/org/opencds/cqf/tooling/operation/RefreshIGOperationTest.java b/tooling/src/test/java/org/opencds/cqf/tooling/operation/RefreshIGOperationTest.java index c31649e5d..ef829d86c 100644 --- a/tooling/src/test/java/org/opencds/cqf/tooling/operation/RefreshIGOperationTest.java +++ b/tooling/src/test/java/org/opencds/cqf/tooling/operation/RefreshIGOperationTest.java @@ -102,7 +102,7 @@ private void deleteDirectory(String path) { @Test public void testNewRefreshOperation() throws IOException { - copyResourcesToTargetDir(TARGET_OUTPUT_FOLDER_PATH, "target/NewRefreshIG"); + copyResourcesToTargetDir(TARGET_OUTPUT_FOLDER_PATH, "testfiles/NewRefreshIG"); File folder = new File(TARGET_OUTPUT_FOLDER_PATH); assertTrue(folder.exists(), "Folder should be present"); File jsonFile = new File(folder, "ig.ini"); diff --git a/tooling/src/test/resources/org/opencds/cqf/tooling/NewRefreshIG/ig.ini b/tooling/src/test/resources/org/opencds/cqf/tooling/testfiles/NewRefreshIG/ig.ini similarity index 100% rename from tooling/src/test/resources/org/opencds/cqf/tooling/NewRefreshIG/ig.ini rename to tooling/src/test/resources/org/opencds/cqf/tooling/testfiles/NewRefreshIG/ig.ini diff --git a/tooling/src/test/resources/org/opencds/cqf/tooling/NewRefreshIG/input/cqf-us.xml b/tooling/src/test/resources/org/opencds/cqf/tooling/testfiles/NewRefreshIG/input/cqf-us.xml similarity index 100% rename from tooling/src/test/resources/org/opencds/cqf/tooling/NewRefreshIG/input/cqf-us.xml rename to tooling/src/test/resources/org/opencds/cqf/tooling/testfiles/NewRefreshIG/input/cqf-us.xml diff --git a/tooling/src/test/resources/org/opencds/cqf/tooling/NewRefreshIG/input/cql/CumulativeMedicationDuration.cql b/tooling/src/test/resources/org/opencds/cqf/tooling/testfiles/NewRefreshIG/input/cql/CumulativeMedicationDuration.cql similarity index 100% rename from tooling/src/test/resources/org/opencds/cqf/tooling/NewRefreshIG/input/cql/CumulativeMedicationDuration.cql rename to tooling/src/test/resources/org/opencds/cqf/tooling/testfiles/NewRefreshIG/input/cql/CumulativeMedicationDuration.cql diff --git a/tooling/src/test/resources/org/opencds/cqf/tooling/NewRefreshIG/input/cql/GMTPInitialExpressions.cql b/tooling/src/test/resources/org/opencds/cqf/tooling/testfiles/NewRefreshIG/input/cql/GMTPInitialExpressions.cql similarity index 100% rename from tooling/src/test/resources/org/opencds/cqf/tooling/NewRefreshIG/input/cql/GMTPInitialExpressions.cql rename to tooling/src/test/resources/org/opencds/cqf/tooling/testfiles/NewRefreshIG/input/cql/GMTPInitialExpressions.cql diff --git a/tooling/src/test/resources/org/opencds/cqf/tooling/NewRefreshIG/input/cql/MBODAInitialExpressions.cql b/tooling/src/test/resources/org/opencds/cqf/tooling/testfiles/NewRefreshIG/input/cql/MBODAInitialExpressions.cql similarity index 100% rename from tooling/src/test/resources/org/opencds/cqf/tooling/NewRefreshIG/input/cql/MBODAInitialExpressions.cql rename to tooling/src/test/resources/org/opencds/cqf/tooling/testfiles/NewRefreshIG/input/cql/MBODAInitialExpressions.cql diff --git a/tooling/src/test/resources/org/opencds/cqf/tooling/NewRefreshIG/input/cql/UPPARFInitialExpressions.cql b/tooling/src/test/resources/org/opencds/cqf/tooling/testfiles/NewRefreshIG/input/cql/UPPARFInitialExpressions.cql similarity index 100% rename from tooling/src/test/resources/org/opencds/cqf/tooling/NewRefreshIG/input/cql/UPPARFInitialExpressions.cql rename to tooling/src/test/resources/org/opencds/cqf/tooling/testfiles/NewRefreshIG/input/cql/UPPARFInitialExpressions.cql diff --git a/tooling/src/test/resources/org/opencds/cqf/tooling/NewRefreshIG/input/cql/USCoreCommon.cql b/tooling/src/test/resources/org/opencds/cqf/tooling/testfiles/NewRefreshIG/input/cql/USCoreCommon.cql similarity index 100% rename from tooling/src/test/resources/org/opencds/cqf/tooling/NewRefreshIG/input/cql/USCoreCommon.cql rename to tooling/src/test/resources/org/opencds/cqf/tooling/testfiles/NewRefreshIG/input/cql/USCoreCommon.cql diff --git a/tooling/src/test/resources/org/opencds/cqf/tooling/NewRefreshIG/input/cql/USCoreElements.cql b/tooling/src/test/resources/org/opencds/cqf/tooling/testfiles/NewRefreshIG/input/cql/USCoreElements.cql similarity index 100% rename from tooling/src/test/resources/org/opencds/cqf/tooling/NewRefreshIG/input/cql/USCoreElements.cql rename to tooling/src/test/resources/org/opencds/cqf/tooling/testfiles/NewRefreshIG/input/cql/USCoreElements.cql diff --git a/tooling/src/test/resources/org/opencds/cqf/tooling/NewRefreshIG/input/cql/USCoreTests.cql b/tooling/src/test/resources/org/opencds/cqf/tooling/testfiles/NewRefreshIG/input/cql/USCoreTests.cql similarity index 100% rename from tooling/src/test/resources/org/opencds/cqf/tooling/NewRefreshIG/input/cql/USCoreTests.cql rename to tooling/src/test/resources/org/opencds/cqf/tooling/testfiles/NewRefreshIG/input/cql/USCoreTests.cql diff --git a/tooling/src/test/resources/org/opencds/cqf/tooling/NewRefreshIG/input/cql/cql-options.json b/tooling/src/test/resources/org/opencds/cqf/tooling/testfiles/NewRefreshIG/input/cql/cql-options.json similarity index 100% rename from tooling/src/test/resources/org/opencds/cqf/tooling/NewRefreshIG/input/cql/cql-options.json rename to tooling/src/test/resources/org/opencds/cqf/tooling/testfiles/NewRefreshIG/input/cql/cql-options.json diff --git a/tooling/src/test/resources/org/opencds/cqf/tooling/NewRefreshIG/input/resources/library/library-CumulativeMedicationDuration.json b/tooling/src/test/resources/org/opencds/cqf/tooling/testfiles/NewRefreshIG/input/resources/library/library-CumulativeMedicationDuration.json similarity index 100% rename from tooling/src/test/resources/org/opencds/cqf/tooling/NewRefreshIG/input/resources/library/library-CumulativeMedicationDuration.json rename to tooling/src/test/resources/org/opencds/cqf/tooling/testfiles/NewRefreshIG/input/resources/library/library-CumulativeMedicationDuration.json diff --git a/tooling/src/test/resources/org/opencds/cqf/tooling/NewRefreshIG/input/resources/library/library-GMTPInitialExpressions.json b/tooling/src/test/resources/org/opencds/cqf/tooling/testfiles/NewRefreshIG/input/resources/library/library-GMTPInitialExpressions.json similarity index 100% rename from tooling/src/test/resources/org/opencds/cqf/tooling/NewRefreshIG/input/resources/library/library-GMTPInitialExpressions.json rename to tooling/src/test/resources/org/opencds/cqf/tooling/testfiles/NewRefreshIG/input/resources/library/library-GMTPInitialExpressions.json diff --git a/tooling/src/test/resources/org/opencds/cqf/tooling/NewRefreshIG/input/resources/library/library-MBODAInitialExpressions.json b/tooling/src/test/resources/org/opencds/cqf/tooling/testfiles/NewRefreshIG/input/resources/library/library-MBODAInitialExpressions.json similarity index 100% rename from tooling/src/test/resources/org/opencds/cqf/tooling/NewRefreshIG/input/resources/library/library-MBODAInitialExpressions.json rename to tooling/src/test/resources/org/opencds/cqf/tooling/testfiles/NewRefreshIG/input/resources/library/library-MBODAInitialExpressions.json diff --git a/tooling/src/test/resources/org/opencds/cqf/tooling/NewRefreshIG/input/resources/library/library-USCore-ModelInfo.json b/tooling/src/test/resources/org/opencds/cqf/tooling/testfiles/NewRefreshIG/input/resources/library/library-USCore-ModelInfo.json similarity index 100% rename from tooling/src/test/resources/org/opencds/cqf/tooling/NewRefreshIG/input/resources/library/library-USCore-ModelInfo.json rename to tooling/src/test/resources/org/opencds/cqf/tooling/testfiles/NewRefreshIG/input/resources/library/library-USCore-ModelInfo.json diff --git a/tooling/src/test/resources/org/opencds/cqf/tooling/NewRefreshIG/input/resources/library/library-USCoreCommon.json b/tooling/src/test/resources/org/opencds/cqf/tooling/testfiles/NewRefreshIG/input/resources/library/library-USCoreCommon.json similarity index 100% rename from tooling/src/test/resources/org/opencds/cqf/tooling/NewRefreshIG/input/resources/library/library-USCoreCommon.json rename to tooling/src/test/resources/org/opencds/cqf/tooling/testfiles/NewRefreshIG/input/resources/library/library-USCoreCommon.json diff --git a/tooling/src/test/resources/org/opencds/cqf/tooling/NewRefreshIG/input/resources/library/library-USCoreElements.json b/tooling/src/test/resources/org/opencds/cqf/tooling/testfiles/NewRefreshIG/input/resources/library/library-USCoreElements.json similarity index 100% rename from tooling/src/test/resources/org/opencds/cqf/tooling/NewRefreshIG/input/resources/library/library-USCoreElements.json rename to tooling/src/test/resources/org/opencds/cqf/tooling/testfiles/NewRefreshIG/input/resources/library/library-USCoreElements.json diff --git a/tooling/src/test/resources/org/opencds/cqf/tooling/NewRefreshIG/input/resources/library/library-USCoreTests.json b/tooling/src/test/resources/org/opencds/cqf/tooling/testfiles/NewRefreshIG/input/resources/library/library-USCoreTests.json similarity index 100% rename from tooling/src/test/resources/org/opencds/cqf/tooling/NewRefreshIG/input/resources/library/library-USCoreTests.json rename to tooling/src/test/resources/org/opencds/cqf/tooling/testfiles/NewRefreshIG/input/resources/library/library-USCoreTests.json From 4bba09a22e7b88a784be6a166023ac76607c5c1d Mon Sep 17 00:00:00 2001 From: Jonathan Percival Date: Mon, 13 May 2024 14:58:46 -0600 Subject: [PATCH 13/22] TEST: don't swallow exceptions --- .../java/org/opencds/cqf/tooling/processor/CqlProcessor.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tooling/src/main/java/org/opencds/cqf/tooling/processor/CqlProcessor.java b/tooling/src/main/java/org/opencds/cqf/tooling/processor/CqlProcessor.java index 4e5a6ac00..1eb58ba4f 100644 --- a/tooling/src/main/java/org/opencds/cqf/tooling/processor/CqlProcessor.java +++ b/tooling/src/main/java/org/opencds/cqf/tooling/processor/CqlProcessor.java @@ -426,6 +426,7 @@ private void translateFile(LibraryManager libraryManager, File file, CqlCompiler } catch (Exception ex) { logger.logMessage(String.format("CQL Translation succeeded for file: '%s', but ELM generation failed with the following error: %s", file.getAbsolutePath(), ex.getMessage())); + throw ex; } } @@ -434,6 +435,7 @@ private void translateFile(LibraryManager libraryManager, File file, CqlCompiler } catch (Exception e) { result.getErrors().add(new ValidationMessage(ValidationMessage.Source.Publisher, IssueType.EXCEPTION, file.getName(), "CQL Processing failed with exception: "+e.getMessage(), IssueSeverity.ERROR)); + throw new RuntimeException(e); } From 4d4ee8a1e9403d485a5854399231a5b00cdd74cc Mon Sep 17 00:00:00 2001 From: Jonathan Percival Date: Mon, 13 May 2024 15:04:00 -0600 Subject: [PATCH 14/22] Add logging of missing files --- .../org/opencds/cqf/tooling/processor/CqlProcessor.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tooling/src/main/java/org/opencds/cqf/tooling/processor/CqlProcessor.java b/tooling/src/main/java/org/opencds/cqf/tooling/processor/CqlProcessor.java index 1eb58ba4f..36a451452 100644 --- a/tooling/src/main/java/org/opencds/cqf/tooling/processor/CqlProcessor.java +++ b/tooling/src/main/java/org/opencds/cqf/tooling/processor/CqlProcessor.java @@ -365,6 +365,12 @@ private void translateFile(LibraryManager libraryManager, File file, CqlCompiler CqlSourceFileInformation result = new CqlSourceFileInformation(); fileMap.put(file.getAbsoluteFile().toString(), result); + if(!file.exists()) { + var message = String.format("File %s does not exist", file.toString()); + logger.logMessage(message); + throw new RuntimeException(message); + } + if (options.getValidateUnits()) { libraryManager.setUcumService(ucumService); } @@ -426,7 +432,6 @@ private void translateFile(LibraryManager libraryManager, File file, CqlCompiler } catch (Exception ex) { logger.logMessage(String.format("CQL Translation succeeded for file: '%s', but ELM generation failed with the following error: %s", file.getAbsolutePath(), ex.getMessage())); - throw ex; } } @@ -435,7 +440,6 @@ private void translateFile(LibraryManager libraryManager, File file, CqlCompiler } catch (Exception e) { result.getErrors().add(new ValidationMessage(ValidationMessage.Source.Publisher, IssueType.EXCEPTION, file.getName(), "CQL Processing failed with exception: "+e.getMessage(), IssueSeverity.ERROR)); - throw new RuntimeException(e); } From 8d95c1f660d99c1c6b191c46d7314c25e91a1e91 Mon Sep 17 00:00:00 2001 From: Jonathan Percival Date: Mon, 13 May 2024 15:07:58 -0600 Subject: [PATCH 15/22] Revert previous experiments --- .../org/opencds/cqf/tooling/processor/CqlProcessor.java | 6 ------ 1 file changed, 6 deletions(-) diff --git a/tooling/src/main/java/org/opencds/cqf/tooling/processor/CqlProcessor.java b/tooling/src/main/java/org/opencds/cqf/tooling/processor/CqlProcessor.java index 36a451452..4e5a6ac00 100644 --- a/tooling/src/main/java/org/opencds/cqf/tooling/processor/CqlProcessor.java +++ b/tooling/src/main/java/org/opencds/cqf/tooling/processor/CqlProcessor.java @@ -365,12 +365,6 @@ private void translateFile(LibraryManager libraryManager, File file, CqlCompiler CqlSourceFileInformation result = new CqlSourceFileInformation(); fileMap.put(file.getAbsoluteFile().toString(), result); - if(!file.exists()) { - var message = String.format("File %s does not exist", file.toString()); - logger.logMessage(message); - throw new RuntimeException(message); - } - if (options.getValidateUnits()) { libraryManager.setUcumService(ucumService); } From 5c7efb0b9a2bbbd334b8b21464f2229bbec6c036 Mon Sep 17 00:00:00 2001 From: Jonathan Percival Date: Mon, 13 May 2024 15:13:17 -0600 Subject: [PATCH 16/22] Fix casing of folder name --- .../opencds/cqf/tooling/operation/RefreshIGOperationTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tooling/src/test/java/org/opencds/cqf/tooling/operation/RefreshIGOperationTest.java b/tooling/src/test/java/org/opencds/cqf/tooling/operation/RefreshIGOperationTest.java index ef829d86c..d5fa136bc 100644 --- a/tooling/src/test/java/org/opencds/cqf/tooling/operation/RefreshIGOperationTest.java +++ b/tooling/src/test/java/org/opencds/cqf/tooling/operation/RefreshIGOperationTest.java @@ -57,7 +57,7 @@ public RefreshIGOperationTest() { "MBODAInitialExpressions.json", "USCoreCommon.json", "USCoreElements.json", "USCoreTests.json" }; - private static final String TARGET_OUTPUT_FOLDER_PATH = "target" + separator + "NewRefreshIg"; + private static final String TARGET_OUTPUT_FOLDER_PATH = "target" + separator + "NewRefreshIG"; private static final String TARGET_OUTPUT_IG_CQL_FOLDER_PATH = TARGET_OUTPUT_FOLDER_PATH + separator + "input" + separator + "cql"; private static final String TARGET_OUTPUT_IG_LIBRARY_FOLDER_PATH = TARGET_OUTPUT_FOLDER_PATH + separator + "input" + separator + "resources" + separator + "library"; From f52d79f498459f15018bd65d398e248471501d9f Mon Sep 17 00:00:00 2001 From: Jonathan Percival Date: Mon, 13 May 2024 15:40:16 -0600 Subject: [PATCH 17/22] Add path to CQL source information --- .vscode/settings.json | 2 +- .../cqf/tooling/library/LibraryProcessor.java | 5 +++++ .../cqf/tooling/operation/ig/LibraryRefresh.java | 4 ++++ .../opencds/cqf/tooling/processor/CqlProcessor.java | 13 ++++++++++++- 4 files changed, 22 insertions(+), 2 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index 3f86936a0..634ef798a 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -19,5 +19,5 @@ "testng" ], "java.compile.nullAnalysis.mode": "automatic", - "java.jdt.ls.vmargs": "-XX:+UseParallelGC -XX:GCTimeRatio=4 -XX:AdaptiveSizePolicyWeight=90 -Dsun.zip.disableMemoryMapping=true -Xmx2G -Xms100m -Xlog:disable" + "java.jdt.ls.vmargs": "-XX:+UseParallelGC -XX:GCTimeRatio=4 -XX:AdaptiveSizePolicyWeight=90 -Dsun.zip.disableMemoryMapping=true -Xmx4G -Xms100m -Xlog:disable" } \ No newline at end of file diff --git a/tooling/src/main/java/org/opencds/cqf/tooling/library/LibraryProcessor.java b/tooling/src/main/java/org/opencds/cqf/tooling/library/LibraryProcessor.java index f8ceccc79..0c78bd94c 100644 --- a/tooling/src/main/java/org/opencds/cqf/tooling/library/LibraryProcessor.java +++ b/tooling/src/main/java/org/opencds/cqf/tooling/library/LibraryProcessor.java @@ -330,6 +330,11 @@ private List internalRefreshGeneratedContent(List sourceLibrar sourceLibraries.add(newLibrary); } } + else + { + logger.error("No identifier found for CQL file {}", fileInfo.getPath()); + } + } List resources = new ArrayList(); diff --git a/tooling/src/main/java/org/opencds/cqf/tooling/operation/ig/LibraryRefresh.java b/tooling/src/main/java/org/opencds/cqf/tooling/operation/ig/LibraryRefresh.java index 13d8a5957..59a7f9e71 100644 --- a/tooling/src/main/java/org/opencds/cqf/tooling/operation/ig/LibraryRefresh.java +++ b/tooling/src/main/java/org/opencds/cqf/tooling/operation/ig/LibraryRefresh.java @@ -66,6 +66,10 @@ public List refresh(RefreshIGParameters params) { logger.info("Refreshing {}", library.getIdElement()); for (CqlProcessor.CqlSourceFileInformation info : cqlProcessor.getAllFileInformation()) { + if (info.getIdentifier() == null) { + logger.error("No identifier found for CQL file {}", info.getPath()); + } + if (info.getIdentifier().getId().endsWith(name)) { // TODO: should likely verify or resolve/refresh the following elements: // cpg-knowledgeCapability, cpg-knowledgeRepresentationLevel, url, identifier, status, diff --git a/tooling/src/main/java/org/opencds/cqf/tooling/processor/CqlProcessor.java b/tooling/src/main/java/org/opencds/cqf/tooling/processor/CqlProcessor.java index 4e5a6ac00..c8f61328b 100644 --- a/tooling/src/main/java/org/opencds/cqf/tooling/processor/CqlProcessor.java +++ b/tooling/src/main/java/org/opencds/cqf/tooling/processor/CqlProcessor.java @@ -7,6 +7,7 @@ import java.util.*; import java.util.stream.Collectors; +import org.antlr.v4.parse.ANTLRParser.finallyClause_return; import org.cqframework.cql.cql2elm.CqlCompilerException; import org.cqframework.cql.cql2elm.CqlCompilerOptions; import org.cqframework.cql.cql2elm.CqlTranslator; @@ -42,6 +43,7 @@ public class CqlProcessor { * information about a cql file */ public class CqlSourceFileInformation { + private final String path; private CqlTranslatorOptions options; private VersionedIdentifier identifier; private byte[] cql; @@ -51,6 +53,15 @@ public class CqlSourceFileInformation { private List relatedArtifacts = new ArrayList<>(); private List dataRequirements = new ArrayList<>(); private List parameters = new ArrayList<>(); + + public CqlSourceFileInformation(String path) { + this.path = path; + } + + public String getPath() { + return path; + } + public CqlTranslatorOptions getOptions() { return options; } @@ -362,7 +373,7 @@ public static ValidationMessage exceptionToValidationMessage(File file, CqlCompi private void translateFile(LibraryManager libraryManager, File file, CqlCompilerOptions options) { // logger.logMessage(String.format("Translating CQL source in file %s", file.toString())); - CqlSourceFileInformation result = new CqlSourceFileInformation(); + CqlSourceFileInformation result = new CqlSourceFileInformation(file.getAbsolutePath()); fileMap.put(file.getAbsoluteFile().toString(), result); if (options.getValidateUnits()) { From 250c3a85a6bf1e13030d30022428af7acce329d1 Mon Sep 17 00:00:00 2001 From: Jonathan Percival Date: Mon, 13 May 2024 16:01:16 -0600 Subject: [PATCH 18/22] Add more logging --- .../org/opencds/cqf/tooling/processor/CqlProcessor.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tooling/src/main/java/org/opencds/cqf/tooling/processor/CqlProcessor.java b/tooling/src/main/java/org/opencds/cqf/tooling/processor/CqlProcessor.java index c8f61328b..f54ff6176 100644 --- a/tooling/src/main/java/org/opencds/cqf/tooling/processor/CqlProcessor.java +++ b/tooling/src/main/java/org/opencds/cqf/tooling/processor/CqlProcessor.java @@ -7,7 +7,6 @@ import java.util.*; import java.util.stream.Collectors; -import org.antlr.v4.parse.ANTLRParser.finallyClause_return; import org.cqframework.cql.cql2elm.CqlCompilerException; import org.cqframework.cql.cql2elm.CqlCompilerOptions; import org.cqframework.cql.cql2elm.CqlTranslator; @@ -36,9 +35,12 @@ import org.opencds.cqf.tooling.npm.NpmLibrarySourceProvider; import org.opencds.cqf.tooling.npm.NpmModelInfoProvider; import org.opencds.cqf.tooling.utilities.ResourceUtils; +import org.slf4j.Logger; public class CqlProcessor { + private static final Logger log = org.slf4j.LoggerFactory.getLogger(CqlProcessor.class); + /** * information about a cql file */ @@ -394,6 +396,8 @@ private void translateFile(LibraryManager libraryManager, File file, CqlCompiler if (!severeErrorList.isEmpty()) { + var messages = severeErrorList.stream().map(x -> x.getMessage()).reduce("", (x, y) -> x + "\n" + y); + log.error("CQL Processing failed with errors count: {}, messages: {}", severeErrorList.size(), messages); result.getErrors().add(new ValidationMessage(ValidationMessage.Source.Publisher, IssueType.EXCEPTION, file.getName(), String.format("CQL Processing failed with (%d) errors.", translator.getErrors().size()), IssueSeverity.ERROR)); } From ea7c4064fb069c0e4cefadd2716e23f8579b459c Mon Sep 17 00:00:00 2001 From: Jonathan Percival Date: Tue, 14 May 2024 12:02:08 -0600 Subject: [PATCH 19/22] Fix prefix, fix some level 1.3 warnings --- .../cqf/tooling/library/LibraryProcessor.java | 8 ++++---- .../tooling/operation/ig/LibraryRefresh.java | 2 +- .../cqf/tooling/processor/CqlProcessor.java | 2 +- .../r4/input/pagecontent/cql/cql-options.json | 19 +++++++++++++++++++ 4 files changed, 25 insertions(+), 6 deletions(-) create mode 100644 tooling/src/test/resources/org/opencds/cqf/tooling/r4/input/pagecontent/cql/cql-options.json diff --git a/tooling/src/main/java/org/opencds/cqf/tooling/library/LibraryProcessor.java b/tooling/src/main/java/org/opencds/cqf/tooling/library/LibraryProcessor.java index 0c78bd94c..204bbbf9d 100644 --- a/tooling/src/main/java/org/opencds/cqf/tooling/library/LibraryProcessor.java +++ b/tooling/src/main/java/org/opencds/cqf/tooling/library/LibraryProcessor.java @@ -47,7 +47,7 @@ public class LibraryProcessor extends BaseProcessor { private static final Logger logger = LoggerFactory.getLogger(LibraryProcessor.class); - public static final String ResourcePrefix = "library-"; + public static final String ResourcePrefix = "Library-"; public static String getId(String baseId) { return ResourcePrefix + baseId; @@ -280,14 +280,14 @@ protected List refreshGeneratedContent(List sourceLibraries) { } public List refreshGeneratedContent(String cqlDirectoryPath, String fhirVersion) { - List result = new ArrayList(); + var result = new ArrayList(); File input = new File(cqlDirectoryPath); if (input.exists() && input.isDirectory()) { result.add(input.getAbsolutePath()); } setBinaryPaths(result); - List libraries = new ArrayList(); + var libraries = new ArrayList(); return internalRefreshGeneratedContent(libraries); } @@ -332,7 +332,7 @@ private List internalRefreshGeneratedContent(List sourceLibrar } else { - logger.error("No identifier found for CQL file {}", fileInfo.getPath()); + logger.warn("No identifier found for CQL file {}", fileInfo.getPath()); } } diff --git a/tooling/src/main/java/org/opencds/cqf/tooling/operation/ig/LibraryRefresh.java b/tooling/src/main/java/org/opencds/cqf/tooling/operation/ig/LibraryRefresh.java index 59a7f9e71..99a563018 100644 --- a/tooling/src/main/java/org/opencds/cqf/tooling/operation/ig/LibraryRefresh.java +++ b/tooling/src/main/java/org/opencds/cqf/tooling/operation/ig/LibraryRefresh.java @@ -67,7 +67,7 @@ public List refresh(RefreshIGParameters params) { for (CqlProcessor.CqlSourceFileInformation info : cqlProcessor.getAllFileInformation()) { if (info.getIdentifier() == null) { - logger.error("No identifier found for CQL file {}", info.getPath()); + logger.warn("No identifier found for CQL file {}", info.getPath()); } if (info.getIdentifier().getId().endsWith(name)) { diff --git a/tooling/src/main/java/org/opencds/cqf/tooling/processor/CqlProcessor.java b/tooling/src/main/java/org/opencds/cqf/tooling/processor/CqlProcessor.java index f54ff6176..7391086c5 100644 --- a/tooling/src/main/java/org/opencds/cqf/tooling/processor/CqlProcessor.java +++ b/tooling/src/main/java/org/opencds/cqf/tooling/processor/CqlProcessor.java @@ -397,7 +397,7 @@ private void translateFile(LibraryManager libraryManager, File file, CqlCompiler if (!severeErrorList.isEmpty()) { var messages = severeErrorList.stream().map(x -> x.getMessage()).reduce("", (x, y) -> x + "\n" + y); - log.error("CQL Processing failed with errors count: {}, messages: {}", severeErrorList.size(), messages); + log.warn("CQL Processing failed with errors count: {}, messages: {}", severeErrorList.size(), messages); result.getErrors().add(new ValidationMessage(ValidationMessage.Source.Publisher, IssueType.EXCEPTION, file.getName(), String.format("CQL Processing failed with (%d) errors.", translator.getErrors().size()), IssueSeverity.ERROR)); } diff --git a/tooling/src/test/resources/org/opencds/cqf/tooling/r4/input/pagecontent/cql/cql-options.json b/tooling/src/test/resources/org/opencds/cqf/tooling/r4/input/pagecontent/cql/cql-options.json new file mode 100644 index 000000000..5687fea53 --- /dev/null +++ b/tooling/src/test/resources/org/opencds/cqf/tooling/r4/input/pagecontent/cql/cql-options.json @@ -0,0 +1,19 @@ +{ + "options":[ + "EnableAnnotations", + "EnableLocators", + "DisableListDemotion", + "DisableListPromotion", + "EnableDateRangeOptimization" +], + "formats":[ + "XML","JSON" + ], + "validateUnits":true, + "verifyOnly":false, + "errorLevel":"Info", + "signatureLevel":"None", + "analyzeDataRequirements":false, + "collapseDataRequirements":true, + "compatibilityLevel": "1.3" +} From fc3c1d8149ce3ddd91c8999da50e6bf139cce8a8 Mon Sep 17 00:00:00 2001 From: Jonathan Percival Date: Fri, 17 May 2024 08:33:34 -0600 Subject: [PATCH 20/22] Change build to use info log level for debug purposes --- .github/workflows/check-pr.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/check-pr.yaml b/.github/workflows/check-pr.yaml index df7f80c1f..ce6831ae6 100644 --- a/.github/workflows/check-pr.yaml +++ b/.github/workflows/check-pr.yaml @@ -26,7 +26,7 @@ jobs: - name: Compile run: ./mvnw --batch-mode --no-transfer-progress --update-snapshots -T 4 package -DskipTests=true - name: Tests and additional checks - run: ./mvnw --batch-mode --no-transfer-progress -T 4 verify -Ppackage + run: ./mvnw --batch-mode --no-transfer-progress -T 4 verify -Ppackage -Dorg.slf4j.simpleLogger.defaultLogLevel=info - name: Publish test report uses: mikepenz/action-junit-report@v4 if: (success() || failure()) && matrix.os == 'ubuntu-latest' From 4c9e91644b09fa84ea39bff0fef44695a46507bc Mon Sep 17 00:00:00 2001 From: Jonathan Percival Date: Fri, 17 May 2024 08:51:09 -0600 Subject: [PATCH 21/22] Swap up dependency loading code --- .../org/opencds/cqf/tooling/npm/NpmPackageManager.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/tooling/src/main/java/org/opencds/cqf/tooling/npm/NpmPackageManager.java b/tooling/src/main/java/org/opencds/cqf/tooling/npm/NpmPackageManager.java index 8ef3e2f41..976bc66f7 100644 --- a/tooling/src/main/java/org/opencds/cqf/tooling/npm/NpmPackageManager.java +++ b/tooling/src/main/java/org/opencds/cqf/tooling/npm/NpmPackageManager.java @@ -133,9 +133,10 @@ private void loadCorePackage() { } private void loadIg(ImplementationGuide.ImplementationGuideDependsOnComponent dep, int index) throws IOException { + logger.info("Loading IG Dependency {}#{}", dep.getUri(), dep.getVersion()); String name = dep.getId(); if (!dep.hasId()) { - logger.info("Dependency '{}' has no id, so can't be referred to in markdown in the IG", idForDep(dep)); + logger.warn("Dependency '{}' has no id, so can't be referred to in markdown in the IG", idForDep(dep)); name = "u" + Utilities.makeUuidLC().replace("-", ""); } if (!isValidIGToken(name)) { @@ -155,10 +156,9 @@ private void loadIg(ImplementationGuide.ImplementationGuideDependsOnComponent de throw new IllegalArgumentException( "You must specify a version for the IG " + packageId + " (" + canonical + ")"); - NpmPackage pi = packageId == null ? null : pcm.loadPackageFromCacheOnly(packageId, igver); - if (pi != null) - npmList.add(pi); + NpmPackage pi = pcm.loadPackage(packageId, igver); if (pi == null) { + logger.warn("Dependency " + name + " (" + canonical + ") not found by FilesystemPackageCacheManager"); pi = resolveDependency(canonical, packageId, igver); if (pi == null) { if (Utilities.noString(packageId)) @@ -169,6 +169,8 @@ private void loadIg(ImplementationGuide.ImplementationGuideDependsOnComponent de } } + npmList.add(pi); + logger.debug( "Load " + name + " (" + canonical + ") from " + packageId + "#" + igver); From 1685c3e1a69ede8186ffe3effdd3cfa2f4eb5efc Mon Sep 17 00:00:00 2001 From: Jonathan Percival Date: Fri, 17 May 2024 08:54:26 -0600 Subject: [PATCH 22/22] Revert to normal logging --- .github/workflows/check-pr.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/check-pr.yaml b/.github/workflows/check-pr.yaml index ce6831ae6..df7f80c1f 100644 --- a/.github/workflows/check-pr.yaml +++ b/.github/workflows/check-pr.yaml @@ -26,7 +26,7 @@ jobs: - name: Compile run: ./mvnw --batch-mode --no-transfer-progress --update-snapshots -T 4 package -DskipTests=true - name: Tests and additional checks - run: ./mvnw --batch-mode --no-transfer-progress -T 4 verify -Ppackage -Dorg.slf4j.simpleLogger.defaultLogLevel=info + run: ./mvnw --batch-mode --no-transfer-progress -T 4 verify -Ppackage - name: Publish test report uses: mikepenz/action-junit-report@v4 if: (success() || failure()) && matrix.os == 'ubuntu-latest'