-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CQF-Tooling Update and Test coverage increase (#516)
* KALM-110: Increase test Coverage and updated CQF-Tooling Fixed QdmToQICore tool by updating getPageContent and added test to verify HTML pages creation. * KALM-110: Increase test Coverage and updated CQF-Tooling Fixed QdmToQICore tool by updating getPageContent and added test to verify HTML pages creation. * KALM-110: Increase test Coverage and updated CQF-Tooling Updated test to match other tests * KALM-110: Increase test Coverage and updated CQF-Tooling Added example commands for multiple tools in Main (Updated Tech doc) Created Test class for BundleToResource tool (Bundle decomposition). Input Data also added (bundle of libraryevaluationtest-bundle.json) * KALM-110: Increase test Coverage and updated CQF-Tooling Added static final variable for BundleToResource args parameters * KALM-110: Increase test Coverage and updated CQF-Tooling Added test for BundleToTransaction tooling. Updated tech docs with example command
- Loading branch information
Showing
6 changed files
with
172 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
61 changes: 61 additions & 0 deletions
61
tooling/src/test/java/org/opencds/cqf/tooling/operation/BundleToResourcesTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
package org.opencds.cqf.tooling.operation; | ||
|
||
import org.testng.Assert; | ||
import org.testng.annotations.Test; | ||
|
||
import java.io.File; | ||
import java.util.HashSet; | ||
import java.util.Set; | ||
|
||
public class BundleToResourcesTest { | ||
private final BundleToResources bundleToResources = new BundleToResources(); | ||
private final String PATH_ARGUMENT = "-p="; | ||
private final String OUTPUT_PATH_ARGUMENT = "-op="; | ||
private final String ENCODING_ARGUMENT = "-e="; | ||
|
||
@Test | ||
public void testExecute_BundleDecomposition() { | ||
String projectPath = System.getProperty("user.dir"); | ||
|
||
String relativeJsonPath = "src/main/resources/libraryevaluationtest-bundle.json"; | ||
String jsonFilePath = projectPath + File.separator + relativeJsonPath; | ||
|
||
String relativePath = "tooling-cli/bundleResourcesResults"; | ||
|
||
String[] args = new String[4]; | ||
args[0] = "-BundleToResources"; | ||
args[1] = PATH_ARGUMENT + jsonFilePath; | ||
args[2] = ENCODING_ARGUMENT+ "json"; | ||
args[3] = OUTPUT_PATH_ARGUMENT + projectPath + File.separator + relativePath; | ||
bundleToResources.execute(args); | ||
|
||
File resultDir = new File(projectPath + File.separator + relativePath); | ||
|
||
Assert.assertTrue(resultDir.exists() && resultDir.isDirectory(), "Result directory does not exist."); | ||
|
||
// Expected file names | ||
Set<String> expectedFiles = new HashSet<>(); | ||
expectedFiles.add("Library-LibraryEvaluationTest.json"); | ||
expectedFiles.add("Library-LibraryEvaluationTestConcepts.json"); | ||
expectedFiles.add("Library-LibraryEvaluationTestDependency.json"); | ||
expectedFiles.add("Questionnaire-libraryevaluationtest.json"); | ||
expectedFiles.add("ValueSet-condition-problem-list-category.json"); | ||
|
||
File[] actualFiles = resultDir.listFiles((dir, name) -> name.endsWith(".json")); | ||
Assert.assertNotNull(actualFiles, "Bundle resource folder should not be null."); | ||
|
||
// Check if all expected files are present | ||
for (String expectedFile : expectedFiles) { | ||
boolean found = false; | ||
for (File file : actualFiles) { | ||
if (file.getName().equals(expectedFile)) { | ||
found = true; | ||
break; | ||
} | ||
} | ||
Assert.assertTrue(found, "Expected file not found: " + expectedFile); | ||
} | ||
|
||
Assert.assertEquals(actualFiles.length, expectedFiles.size(), "Expected " + expectedFiles.size() + " resources files, but found " + actualFiles.length + "."); | ||
} | ||
} |
51 changes: 51 additions & 0 deletions
51
...ing/src/test/java/org/opencds/cqf/tooling/operation/BundleToTransactionOperationTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package org.opencds.cqf.tooling.operation; | ||
|
||
import junit.framework.TestCase; | ||
import org.testng.Assert; | ||
import org.testng.annotations.Test; | ||
|
||
import java.io.File; | ||
import java.util.HashSet; | ||
import java.util.Set; | ||
|
||
public class BundleToTransactionOperationTest extends TestCase { | ||
private final BundleToTransactionOperation bundleToTransactionOperation = new BundleToTransactionOperation(); | ||
private final String PATH_ARGUMENT = "-p="; | ||
private final String OUTPUT_PATH_ARGUMENT = "-op="; | ||
private final String ENCODING_ARGUMENT = "-e="; | ||
|
||
@Test | ||
public void testExecute_BundleDecomposition() { | ||
String projectPath = System.getProperty("user.dir"); | ||
|
||
String relativeJsonPath = "src/main/resources/libraryevaluationtest-bundle.json"; | ||
String jsonFilePath = projectPath + File.separator + relativeJsonPath; | ||
|
||
String relativePath = "tooling-cli/bundleTransactionResults"; | ||
|
||
String[] args = new String[4]; | ||
args[0] = "-MakeTransaction"; | ||
args[1] = PATH_ARGUMENT + jsonFilePath; | ||
args[2] = ENCODING_ARGUMENT + "json"; | ||
args[3] = OUTPUT_PATH_ARGUMENT + projectPath + File.separator + relativePath; | ||
bundleToTransactionOperation.execute(args); | ||
|
||
File resultDir = new File(projectPath + File.separator + relativePath); | ||
|
||
Assert.assertTrue(resultDir.exists() && resultDir.isDirectory(), "Result directory does not exist."); | ||
|
||
String expectedFile = "Bundle-libraryevaluationtest-bundle.json"; | ||
|
||
File[] actualFiles = resultDir.listFiles((dir, name) -> name.endsWith(".json")); | ||
Assert.assertNotNull(actualFiles, "Bundle resource folder should not be null."); | ||
|
||
boolean found = false; | ||
for (File file : actualFiles) { | ||
if (file.getName().equals(expectedFile)) { | ||
found = true; | ||
break; | ||
} | ||
} | ||
Assert.assertTrue(found, "Expected file not found: " + expectedFile); | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
tooling/src/test/java/org/opencds/cqf/tooling/qdm/QdmToQiCoreTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package org.opencds.cqf.tooling.qdm; | ||
|
||
import org.testng.Assert; | ||
import org.testng.annotations.Test; | ||
|
||
import java.io.File; | ||
|
||
public class QdmToQiCoreTest { | ||
|
||
private final QdmToQiCore qdmToQiCore = new QdmToQiCore(); | ||
|
||
@Test | ||
public void testExecute_HtmlFilesCreated() { | ||
String projectPath = System.getProperty("user.dir"); | ||
String relativePath = "tooling-cli/results"; | ||
|
||
String[] args = new String[2]; | ||
args[0] = "-QdmToQiCore"; | ||
args[1] = projectPath + File.separator + relativePath; | ||
qdmToQiCore.execute(args); | ||
|
||
File resultDir = new File(args[1]); | ||
|
||
Assert.assertTrue(resultDir.exists() && resultDir.isDirectory(), "Result directory does not exist."); | ||
|
||
File[] htmlFiles = resultDir.listFiles((dir, name) -> name.endsWith(".html")); | ||
|
||
Assert.assertNotNull(htmlFiles, "HTML files array should not be null."); | ||
|
||
Assert.assertEquals(htmlFiles.length, 21, "Expected 21 HTML files, but found " + htmlFiles.length + "."); | ||
} | ||
|
||
} |