From a9d70a095a7d01d696e0c041ea704e43ef3855ca Mon Sep 17 00:00:00 2001
From: chubert-sb <85900348+chubert-sb@users.noreply.github.com>
Date: Mon, 24 Jul 2023 10:54:52 -0400
Subject: [PATCH 1/5] Add method to zip multiple testcases (#15)
---
pom.xml | 2 +-
.../utils/qicore411/PackagingUtilityImpl.java | 28 +++++++++++++++++++
.../qicore411/PackagingUtilityImplTest.java | 21 ++++++++++++++
3 files changed, 50 insertions(+), 1 deletion(-)
diff --git a/pom.xml b/pom.xml
index 257170f..a5a0683 100644
--- a/pom.xml
+++ b/pom.xml
@@ -6,7 +6,7 @@
4.0.0
gov.cms.madie.packaging
packaging-utility
- 0.2.2
+ 0.2.3
packaging-utility
A simple packaging-utility.
diff --git a/src/main/java/gov/cms/madie/packaging/utils/qicore411/PackagingUtilityImpl.java b/src/main/java/gov/cms/madie/packaging/utils/qicore411/PackagingUtilityImpl.java
index 35584a0..085315e 100644
--- a/src/main/java/gov/cms/madie/packaging/utils/qicore411/PackagingUtilityImpl.java
+++ b/src/main/java/gov/cms/madie/packaging/utils/qicore411/PackagingUtilityImpl.java
@@ -5,6 +5,7 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import java.util.stream.Collectors;
import org.apache.commons.lang3.StringUtils;
import org.hl7.fhir.r4.model.Attachment;
@@ -46,6 +47,9 @@ public byte[] getZipBundle(Object o, String exportFileName) throws InternalServe
} else if (o instanceof Bundle) {
Bundle bundle = (Bundle) o;
return getZipBundle(bundle, exportFileName);
+ } else if (o instanceof Map) {
+ Map map = (Map) o;
+ return getTestCaseZipBundle(map);
} else
throw new InternalServerException(
"Calling gicore411.PackagingUtilityImpl with invalid object");
@@ -76,6 +80,30 @@ private byte[] getZipBundle(Bundle bundle, String exportFileName) throws Interna
}
}
+ private byte[] getTestCaseZipBundle(Map exportBundles)
+ throws InternalServerException {
+
+ IParser jsonParser = context.newJsonParser();
+
+ if (exportBundles.isEmpty()) {
+ return null;
+ }
+
+ Map entries =
+ exportBundles.entrySet().stream()
+ .collect(
+ Collectors.toMap(
+ entry -> entry.getKey() + ".json",
+ entry ->
+ jsonParser
+ .setPrettyPrint(true)
+ .encodeResourceToString(entry.getValue())
+ .getBytes()));
+
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ return new ZipUtility().zipEntries(entries, baos);
+ }
+
private byte[] zipEntries(String exportFileName, IParser jsonParser, Bundle bundle) {
Map entries = new HashMap<>();
diff --git a/src/test/java/gov/cms/madie/measure/utilities/qicore411/PackagingUtilityImplTest.java b/src/test/java/gov/cms/madie/measure/utilities/qicore411/PackagingUtilityImplTest.java
index 6c998f9..0a77ee0 100644
--- a/src/test/java/gov/cms/madie/measure/utilities/qicore411/PackagingUtilityImplTest.java
+++ b/src/test/java/gov/cms/madie/measure/utilities/qicore411/PackagingUtilityImplTest.java
@@ -146,4 +146,25 @@ private Map getZipContents(byte[] inputBytes) throws IOException
}
return zipContents;
}
+
+ @Test
+ void testGetZipBundleForMultipleTestCases() throws IOException {
+ PackagingUtility utility = new PackagingUtilityImpl();
+ String testCaseBundleJson1 = getStringFromTestResource("/testCaseBundle.json");
+ String testCaseBundleJson2 = getStringFromTestResource("/testCaseBundle.json");
+ Bundle testCaseBundle1 =
+ FhirContext.forR4().newJsonParser().parseResource(Bundle.class, testCaseBundleJson1);
+ Bundle testCaseBundle2 =
+ FhirContext.forR4().newJsonParser().parseResource(Bundle.class, testCaseBundleJson2);
+ Map multiTestCases = new HashMap<>();
+ multiTestCases.put("TC1", testCaseBundle1);
+ multiTestCases.put("TC2", testCaseBundle2);
+ byte[] tc1 = utility.getZipBundle(multiTestCases, null);
+ assertNotNull(tc1);
+
+ Map zipContents = getZipContents(tc1);
+ assertThat(zipContents.size(), is(2));
+ assertThat(zipContents.containsKey("TC1.json"), is(true));
+ assertThat(zipContents.containsKey("TC2.json"), is(true));
+ }
}
From f9f96b3fbcf888b7c69e18448311186caf4d2188 Mon Sep 17 00:00:00 2001
From: snyk-bot
Date: Thu, 18 Jan 2024 13:21:40 +0000
Subject: [PATCH 2/5] fix: pom.xml to reduce vulnerabilities
The following vulnerabilities are fixed with an upgrade:
- https://snyk.io/vuln/SNYK-JAVA-COMSQUAREUPOKIO-5820002
---
pom.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/pom.xml b/pom.xml
index a5a0683..7fd94c2 100644
--- a/pom.xml
+++ b/pom.xml
@@ -18,7 +18,7 @@
17
5.9.3
2.0.7
- 6.4.1
+ 6.6.0
2.0.7
From a92ab4f964c1b8847a18c244fa3a4e3b0cf24ea0 Mon Sep 17 00:00:00 2001
From: Joseph Kotanchik
Date: Tue, 21 May 2024 10:45:56 -0400
Subject: [PATCH 3/5] MAT-6576: Use Spotify formatter. Run formatter.
---
pom.xml | 36 ++++++++++++-------
.../utils/PackagingUtilityFactory.java | 8 +++--
.../qicore411/PackagingUtilityImplTest.java | 4 +--
.../utils/ResourceUtilityFactoryTest.java | 3 --
.../madie/packaging/utils/ZipUtilityTest.java | 1 -
5 files changed, 31 insertions(+), 21 deletions(-)
diff --git a/pom.xml b/pom.xml
index 7fd94c2..e3c4983 100644
--- a/pom.xml
+++ b/pom.xml
@@ -154,30 +154,40 @@
maven-deploy-plugin
2.8.2
+
+ com.spotify.fmt
+ fmt-maven-plugin
+ 2.23
+
+
+
+ format
+
+
+
+
+ true
+
+
+
- com.theoryinpractise
- googleformatter-maven-plugin
- 1.7.3
+ com.spotify.fmt
+ fmt-maven-plugin
+ 2.21.1
- reformat-sources
- process-sources
format
-
- false
-
- false
- false
- false
- 100
-
+
+ true
+
+
diff --git a/src/main/java/gov/cms/madie/packaging/utils/PackagingUtilityFactory.java b/src/main/java/gov/cms/madie/packaging/utils/PackagingUtilityFactory.java
index 3f4b751..aa71d80 100644
--- a/src/main/java/gov/cms/madie/packaging/utils/PackagingUtilityFactory.java
+++ b/src/main/java/gov/cms/madie/packaging/utils/PackagingUtilityFactory.java
@@ -7,8 +7,12 @@
public class PackagingUtilityFactory {
public static PackagingUtility getInstance(String model)
- throws InstantiationException, IllegalAccessException, IllegalArgumentException,
- InvocationTargetException, NoSuchMethodException, SecurityException,
+ throws InstantiationException,
+ IllegalAccessException,
+ IllegalArgumentException,
+ InvocationTargetException,
+ NoSuchMethodException,
+ SecurityException,
ClassNotFoundException {
Map modelMap =
new HashMap<>() {
diff --git a/src/test/java/gov/cms/madie/measure/utilities/qicore411/PackagingUtilityImplTest.java b/src/test/java/gov/cms/madie/measure/utilities/qicore411/PackagingUtilityImplTest.java
index 0a77ee0..c0b3fb6 100644
--- a/src/test/java/gov/cms/madie/measure/utilities/qicore411/PackagingUtilityImplTest.java
+++ b/src/test/java/gov/cms/madie/measure/utilities/qicore411/PackagingUtilityImplTest.java
@@ -153,9 +153,9 @@ void testGetZipBundleForMultipleTestCases() throws IOException {
String testCaseBundleJson1 = getStringFromTestResource("/testCaseBundle.json");
String testCaseBundleJson2 = getStringFromTestResource("/testCaseBundle.json");
Bundle testCaseBundle1 =
- FhirContext.forR4().newJsonParser().parseResource(Bundle.class, testCaseBundleJson1);
+ FhirContext.forR4().newJsonParser().parseResource(Bundle.class, testCaseBundleJson1);
Bundle testCaseBundle2 =
- FhirContext.forR4().newJsonParser().parseResource(Bundle.class, testCaseBundleJson2);
+ FhirContext.forR4().newJsonParser().parseResource(Bundle.class, testCaseBundleJson2);
Map multiTestCases = new HashMap<>();
multiTestCases.put("TC1", testCaseBundle1);
multiTestCases.put("TC2", testCaseBundle2);
diff --git a/src/test/java/gov/cms/madie/packaging/utils/ResourceUtilityFactoryTest.java b/src/test/java/gov/cms/madie/packaging/utils/ResourceUtilityFactoryTest.java
index 3d9ed93..b5ea689 100644
--- a/src/test/java/gov/cms/madie/packaging/utils/ResourceUtilityFactoryTest.java
+++ b/src/test/java/gov/cms/madie/packaging/utils/ResourceUtilityFactoryTest.java
@@ -6,9 +6,6 @@
import org.junit.jupiter.api.Test;
-import gov.cms.madie.packaging.utils.PackagingUtility;
-import gov.cms.madie.packaging.utils.PackagingUtilityFactory;
-
class ResourceUtilityFactoryTest {
@Test
diff --git a/src/test/java/gov/cms/madie/packaging/utils/ZipUtilityTest.java b/src/test/java/gov/cms/madie/packaging/utils/ZipUtilityTest.java
index 73d532b..4dfdbdc 100644
--- a/src/test/java/gov/cms/madie/packaging/utils/ZipUtilityTest.java
+++ b/src/test/java/gov/cms/madie/packaging/utils/ZipUtilityTest.java
@@ -3,7 +3,6 @@
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mock;
-import org.mockito.MockedStatic;
import org.mockito.Mockito;
import java.util.Map;
From 316249ffebe31c408f7ceba6b2bad8aa8eb37602 Mon Sep 17 00:00:00 2001
From: snyk-bot
Date: Wed, 31 Jul 2024 13:38:03 +0000
Subject: [PATCH 4/5] fix: pom.xml to reduce vulnerabilities
The following vulnerabilities are fixed with an upgrade:
- https://snyk.io/vuln/SNYK-JAVA-COMFASTERXMLJACKSONCORE-7569538
---
pom.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/pom.xml b/pom.xml
index e3c4983..e8932da 100644
--- a/pom.xml
+++ b/pom.xml
@@ -18,7 +18,7 @@
17
5.9.3
2.0.7
- 6.6.0
+ 6.6.1
2.0.7
From 4a920f0e90cdea4e996d2c111eb2a4cec6bf9929 Mon Sep 17 00:00:00 2001
From: Prateek Keerthi
Date: Tue, 3 Sep 2024 12:02:35 -0400
Subject: [PATCH 5/5] MAT-7653 facilitate the measure resources in QI Core
exports
---
pom.xml | 2 +-
.../utils/qicore411/PackagingUtilityImpl.java | 24 ++++++++++++++++++-
.../qicore411/PackagingUtilityImplTest.java | 22 +++++++++++++----
3 files changed, 42 insertions(+), 6 deletions(-)
diff --git a/pom.xml b/pom.xml
index e8932da..91d1ed3 100644
--- a/pom.xml
+++ b/pom.xml
@@ -6,7 +6,7 @@
4.0.0
gov.cms.madie.packaging
packaging-utility
- 0.2.3
+ 0.2.4
packaging-utility
A simple packaging-utility.
diff --git a/src/main/java/gov/cms/madie/packaging/utils/qicore411/PackagingUtilityImpl.java b/src/main/java/gov/cms/madie/packaging/utils/qicore411/PackagingUtilityImpl.java
index 085315e..5feea7a 100644
--- a/src/main/java/gov/cms/madie/packaging/utils/qicore411/PackagingUtilityImpl.java
+++ b/src/main/java/gov/cms/madie/packaging/utils/qicore411/PackagingUtilityImpl.java
@@ -21,6 +21,7 @@
import gov.cms.madie.packaging.utils.PackagingUtility;
import gov.cms.madie.packaging.utils.ZipUtility;
import lombok.extern.slf4j.Slf4j;
+import org.hl7.fhir.r4.model.Measure;
@Slf4j
public class PackagingUtilityImpl implements PackagingUtility {
@@ -138,12 +139,25 @@ private byte[] zipEntries(
CQL_DIRECTORY + library.getCqlLibraryName() + "-" + library.getVersion() + ".cql";
entries.put(filePath, library.getCql().getBytes());
}
+
+ // add Measure Resource to Export
+ List measure = getMeasureResource(bundle);
+ for (Measure measure1 : measure) {
+ String json = jsonParser.setPrettyPrint(true).encodeResourceToString(measure1);
+ String xml = xmlParser.setPrettyPrint(true).encodeResourceToString(measure1);
+ String fileName =
+ RESOURCES_DIRECTORY + "measure-" + measure1.getName() + "-" + measure1.getVersion();
+ entries.put(fileName + ".json", json.getBytes());
+ entries.put(fileName + ".xml", xml.getBytes());
+ }
+
// add Library Resources to Export
List libraries = getLibraryResources(bundle);
for (Library library1 : libraries) {
String json = jsonParser.setPrettyPrint(true).encodeResourceToString(library1);
String xml = xmlParser.setPrettyPrint(true).encodeResourceToString(library1);
- String fileName = RESOURCES_DIRECTORY + library1.getName() + "-" + library1.getVersion();
+ String fileName =
+ RESOURCES_DIRECTORY + "library-" + library1.getName() + "-" + library1.getVersion();
entries.put(fileName + ".json", json.getBytes());
entries.put(fileName + ".xml", xml.getBytes());
}
@@ -185,4 +199,12 @@ private List getLibraryResources(Bundle measureBundle) {
.map(entry -> (Library) entry.getResource())
.toList();
}
+
+ private List getMeasureResource(Bundle measureBundle) {
+ return measureBundle.getEntry().stream()
+ .filter(
+ entry -> StringUtils.equals("Measure", entry.getResource().getResourceType().name()))
+ .map(entry -> (Measure) entry.getResource())
+ .toList();
+ }
}
diff --git a/src/test/java/gov/cms/madie/measure/utilities/qicore411/PackagingUtilityImplTest.java b/src/test/java/gov/cms/madie/measure/utilities/qicore411/PackagingUtilityImplTest.java
index c0b3fb6..152b030 100644
--- a/src/test/java/gov/cms/madie/measure/utilities/qicore411/PackagingUtilityImplTest.java
+++ b/src/test/java/gov/cms/madie/measure/utilities/qicore411/PackagingUtilityImplTest.java
@@ -79,10 +79,10 @@ void testGetZipBundleWithLibraries() throws IOException {
zipContents.get("widget.xml").startsWith(""),
is(true));
- assertThat(zipContents.containsKey("TestCreateNewLibrary-1.0.000.xml"), is(true));
+ assertThat(zipContents.containsKey("library-TestCreateNewLibrary-1.0.000.xml"), is(true));
assertThat(
zipContents
- .get("TestCreateNewLibrary-1.0.000.xml")
+ .get("library-TestCreateNewLibrary-1.0.000.xml")
.startsWith(""),
is(true));
@@ -100,12 +100,26 @@ void testGetZipBundleWithLibraries() throws IOException {
.startsWith("library TestCreateNewLibrary version '1.0.000'"),
is(true));
- assertThat(zipContents.containsKey("TestCreateNewLibrary-1.0.000.json"), is(true));
+ assertThat(zipContents.containsKey("library-TestCreateNewLibrary-1.0.000.json"), is(true));
assertThat(
zipContents
- .get("TestCreateNewLibrary-1.0.000.json")
+ .get("library-TestCreateNewLibrary-1.0.000.json")
.startsWith("{\n \"resourceType\": \"Library\","),
is(true));
+
+ assertThat(zipContents.containsKey("measure-TestCreateNewLibrary-1.0.000.json"), is(true));
+ assertThat(
+ zipContents
+ .get("measure-TestCreateNewLibrary-1.0.000.json")
+ .startsWith("{\n \"resourceType\": \"Measure\","),
+ is(true));
+
+ assertThat(zipContents.containsKey("measure-TestCreateNewLibrary-1.0.000.xml"), is(true));
+ assertThat(
+ zipContents
+ .get("measure-TestCreateNewLibrary-1.0.000.xml")
+ .startsWith(""),
+ is(true));
}
@Test