Skip to content

Commit

Permalink
MAT-8008: allow zip generation even if some QRDA/HTML is missing
Browse files Browse the repository at this point in the history
  • Loading branch information
nmorasb committed Dec 9, 2024
1 parent ae98239 commit 9605a5a
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/main/java/gov/cms/madie/services/PackagingService.java
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,16 @@ public byte[] createQRDA(QrdaRequestDTO qrdaRequestDTO, String accessToken) {
measure.getEcqmTitle() + "_patients_results.html",
qrdaExport.getSummaryReport().getBytes());
for (QrdaReportDTO qrda : qrdaExport.getIndividualReports()) {
entries.put(qrdaDir + qrda.getFilename() + ".xml", qrda.getQrda().getBytes());
entries.put(htmlDir + qrda.getFilename() + ".html", qrda.getReport().getBytes());
if (qrda.getQrda() == null) {
log.warn("QRDA export for Measure [{}], testcase filename [{}] is missing QRDA", measure.getId(), qrda.getFilename());
} else {
entries.put(qrdaDir + qrda.getFilename() + ".xml", qrda.getQrda().getBytes());
}
if (qrda.getReport() == null) {
log.warn("QRDA export for Measure [{}], testcase filename [{}] is missing HTML", measure.getId(), qrda.getFilename());
} else {
entries.put(htmlDir + qrda.getFilename() + ".html", qrda.getReport().getBytes());
}
}
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
return new ZipUtility().zipEntries(entries, outputStream);
Expand Down
58 changes: 58 additions & 0 deletions src/test/java/gov/cms/madie/services/PackagingServiceTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -176,4 +176,62 @@ void testCreateQRDA() {
assertThat(new String(qrda), containsString("html/"));
assertThat(new String(qrda), containsString("1_test.html"));
}

@Test
void testCreateQrdaHandlesNullQrdaEntry() {
when(qrdaService.generateQrda(any(QrdaRequestDTO.class), any(String.class)))
.thenReturn(
QrdaExportResponseDto.builder()
.summaryReport("summaryReport")
.individualReports(
List.of(
QrdaReportDTO.builder()
.qrda(null)
.filename("1_test")
.report("report1")
.build(),
QrdaReportDTO.builder()
.qrda("qrda2")
.filename("2_test")
.report("report2")
.build()))
.build());
byte[] qrda =
packagingService.createQRDA(QrdaRequestDTO.builder().measure(measure).build(), TOKEN);
assertThat(new String(qrda), containsString("qrda/"));
assertThat(new String(qrda), containsString("2_test.xml"));

assertThat(new String(qrda), containsString("html/"));
assertThat(new String(qrda), containsString("1_test.html"));
assertThat(new String(qrda), containsString("2_test.html"));
}

@Test
void testCreateQrdaHandlesNullHtmlEntry() {
when(qrdaService.generateQrda(any(QrdaRequestDTO.class), any(String.class)))
.thenReturn(
QrdaExportResponseDto.builder()
.summaryReport("summaryReport")
.individualReports(
List.of(
QrdaReportDTO.builder()
.qrda("qrda1")
.filename("1_test")
.report(null)
.build(),
QrdaReportDTO.builder()
.qrda("qrda2")
.filename("2_test")
.report("report2")
.build()))
.build());
byte[] qrda =
packagingService.createQRDA(QrdaRequestDTO.builder().measure(measure).build(), TOKEN);
assertThat(new String(qrda), containsString("qrda/"));
assertThat(new String(qrda), containsString("1_test.xml"));
assertThat(new String(qrda), containsString("2_test.xml"));

assertThat(new String(qrda), containsString("html/"));
assertThat(new String(qrda), containsString("2_test.html"));
}
}

0 comments on commit 9605a5a

Please sign in to comment.