|
1 | 1 | package gov.cms.madie.measure.utilities.qicore411; |
2 | 2 |
|
3 | 3 | import static org.hamcrest.MatcherAssert.assertThat; |
4 | | -import static org.junit.jupiter.api.Assertions.assertNotNull; |
5 | | -import static org.junit.jupiter.api.Assertions.assertThrows; |
6 | | -import static org.junit.jupiter.api.Assertions.fail; |
7 | 4 |
|
8 | 5 | import gov.cms.madie.packaging.utils.ResourceFileUtil; |
9 | 6 | import org.apache.commons.io.FilenameUtils; |
|
18 | 15 | import gov.cms.madie.packaging.utils.qicore411.PackagingUtilityImpl; |
19 | 16 |
|
20 | 17 | import java.io.*; |
| 18 | +import java.util.ArrayList; |
21 | 19 | import java.util.HashMap; |
| 20 | +import java.util.List; |
22 | 21 | import java.util.Map; |
23 | 22 | import java.util.zip.ZipEntry; |
24 | 23 | import java.util.zip.ZipInputStream; |
25 | 24 |
|
26 | 25 | import static org.hamcrest.CoreMatchers.is; |
| 26 | +import static org.junit.jupiter.api.Assertions.*; |
27 | 27 |
|
28 | 28 | class PackagingUtilityImplTest implements ResourceFileUtil { |
29 | 29 |
|
@@ -181,4 +181,48 @@ void testGetZipBundleForMultipleTestCases() throws IOException { |
181 | 181 | assertThat(zipContents.containsKey("TC1.json"), is(true)); |
182 | 182 | assertThat(zipContents.containsKey("TC2.json"), is(true)); |
183 | 183 | } |
| 184 | + |
| 185 | + @Test |
| 186 | + void testBuildCompositeExportNullCompositeBundle() { |
| 187 | + PackagingUtilityImpl utility = new PackagingUtilityImpl(); |
| 188 | + List<Export> componentExports = new ArrayList<>(); |
| 189 | + byte[] result = utility.buildCompositeExport(null, componentExports, "composite"); |
| 190 | + assertNull(result); |
| 191 | + } |
| 192 | + |
| 193 | + @Test |
| 194 | + void testBuildCompositeExportBlankCompositeBundle() { |
| 195 | + PackagingUtilityImpl utility = new PackagingUtilityImpl(); |
| 196 | + List<Export> componentExports = new ArrayList<>(); |
| 197 | + byte[] result = utility.buildCompositeExport("", componentExports, "composite"); |
| 198 | + assertNull(result); |
| 199 | + } |
| 200 | + |
| 201 | + @Test |
| 202 | + void testBuildCompositeExportWithEmptyComponentExports() throws IOException { |
| 203 | + PackagingUtilityImpl utility = new PackagingUtilityImpl(); |
| 204 | + List<Export> componentExports = new ArrayList<>(); |
| 205 | + byte[] result = utility.buildCompositeExport(JsonBits.BUNDLE, componentExports, "composite"); |
| 206 | + assertNotNull(result); |
| 207 | + |
| 208 | + Map<String, String> zipContents = getZipContents(result); |
| 209 | + assertThat(zipContents.containsKey("composite.json"), is(true)); |
| 210 | + assertThat(zipContents.containsKey("composite.xml"), is(true)); |
| 211 | + assertThat(zipContents.containsKey("composite.html"), is(true)); |
| 212 | + } |
| 213 | + |
| 214 | + @Test |
| 215 | + void testBuildCompositeExportWithComponentExports() throws IOException { |
| 216 | + PackagingUtilityImpl utility = new PackagingUtilityImpl(); |
| 217 | + Export componentExport = new Export(); |
| 218 | + componentExport.setMeasureBundleJson(JsonBits.BUNDLE); |
| 219 | + List<Export> componentExports = List.of(componentExport); |
| 220 | + |
| 221 | + byte[] result = utility.buildCompositeExport(JsonBits.BUNDLE, componentExports, "composite"); |
| 222 | + assertNotNull(result); |
| 223 | + |
| 224 | + Map<String, String> zipContents = getZipContents(result); |
| 225 | + assertThat(zipContents.containsKey("composite.json"), is(true)); |
| 226 | + assertThat(zipContents.containsKey("composite.xml"), is(true)); |
| 227 | + } |
184 | 228 | } |
0 commit comments