From 74a3e3c7236eced8d00df5548e3fc3a16fadae92 Mon Sep 17 00:00:00 2001 From: vijayanandtwks Date: Thu, 21 Sep 2023 16:55:44 +0530 Subject: [PATCH] BS-258 | Vijay, Siva | Fixing failed tests --- .../sample/SampleResultSetExtension.java | 25 +++++++++++++++++++ .../TSIntegrationDiagnosisLineReportTest.java | 4 +-- 2 files changed, 27 insertions(+), 2 deletions(-) create mode 100644 src/test/java/org/bahmni/reports/extensions/sample/SampleResultSetExtension.java diff --git a/src/test/java/org/bahmni/reports/extensions/sample/SampleResultSetExtension.java b/src/test/java/org/bahmni/reports/extensions/sample/SampleResultSetExtension.java new file mode 100644 index 00000000..60d9226f --- /dev/null +++ b/src/test/java/org/bahmni/reports/extensions/sample/SampleResultSetExtension.java @@ -0,0 +1,25 @@ +package org.bahmni.reports.extensions.sample; + +import net.sf.dynamicreports.jasper.builder.JasperReportBuilder; +import net.sf.dynamicreports.report.constant.HorizontalAlignment; +import org.bahmni.reports.extensions.ResultSetExtension; + +import java.sql.SQLException; +import java.util.Collection; +import java.util.Map; +import java.util.Random; + +import static net.sf.dynamicreports.report.builder.DynamicReports.col; +import static net.sf.dynamicreports.report.builder.DynamicReports.type; +import static org.bahmni.reports.template.Templates.columnStyle; + +public class SampleResultSetExtension implements ResultSetExtension { + public static final String SAMPLE_COLUMN_NAME = "Sample Column"; + + public void enrich(Collection> collection, JasperReportBuilder jasperReport) throws SQLException { + for (Map rowMap : collection) { + enrichRow(rowMap, SAMPLE_COLUMN_NAME, String.valueOf(new Random().nextInt())); + } + jasperReport.addColumn(col.column(SAMPLE_COLUMN_NAME, SAMPLE_COLUMN_NAME, type.stringType()).setStyle(columnStyle).setHorizontalAlignment(HorizontalAlignment.CENTER)); + } +} \ No newline at end of file diff --git a/src/test/java/org/bahmni/reports/report/TSIntegrationDiagnosisLineReportTest.java b/src/test/java/org/bahmni/reports/report/TSIntegrationDiagnosisLineReportTest.java index 3dc37264..d8252735 100644 --- a/src/test/java/org/bahmni/reports/report/TSIntegrationDiagnosisLineReportTest.java +++ b/src/test/java/org/bahmni/reports/report/TSIntegrationDiagnosisLineReportTest.java @@ -262,7 +262,7 @@ public void shouldIncludeIcd10TerminologyCodeColumnInJasperReport() throws Excep tsIntegrationDiagnosisLineReportTemplate.build(mockConnection, mockJasperReport, mockReport, "dummyStartDate", "dummyEndDate", null, PageType.A4); - verify(mockJasperReport, times(9)).addColumn(any()); + verify(mockJasperReport, times(8)).addColumn(any()); } private TSIntegrationDiagnosisLineReportConfig getMockTerminologyDiagnosisLineReportConfig(boolean displayTerminologyCodeFlag, boolean shortNamePreferredFlag, boolean icd10ExtensionFlag) { @@ -272,7 +272,7 @@ private TSIntegrationDiagnosisLineReportConfig getMockTerminologyDiagnosisLineRe if (shortNamePreferredFlag) tsIntegrationDiagnosisLineReportConfig.setConceptNameDisplayFormat("shortNamePreferred"); if (icd10ExtensionFlag) - tsIntegrationDiagnosisLineReportConfig.setExtensions(Arrays.asList("org.bahmni.reports.extensions.icd10.Icd10ResultSetExtension", "org.bahmni.reports.extensions.sample.SampleResultSetExtension")); + tsIntegrationDiagnosisLineReportConfig.setExtensions(Arrays.asList("org.bahmni.reports.extensions.sample.SampleResultSetExtension")); return tsIntegrationDiagnosisLineReportConfig; }