From b326b21523c8b90b5cd1db0888781acbd5577360 Mon Sep 17 00:00:00 2001 From: MAKOBA REAGAN PATRICK Date: Mon, 30 Jun 2025 15:10:23 +0000 Subject: [PATCH 1/5] (report) Add HIV Ca screening report unit tests --- .../DRCHivCaScreeningReportManager.java | 4 +- .../DRCHIVCaScreeningReportManagerTest.java | 100 ++++++++++++++++++ .../DRCHIVCaScreeningReportTestDataset.xml | 34 ++++++ 3 files changed, 136 insertions(+), 2 deletions(-) create mode 100644 api/src/test/java/org/openmrs/module/drcreports/reports/DRCHIVCaScreeningReportManagerTest.java create mode 100644 api/src/test/resources/org/openmrs/module/drcreports/include/DRCHIVCaScreeningReportTestDataset.xml diff --git a/api/src/main/java/org/openmrs/module/drcreports/reports/DRCHivCaScreeningReportManager.java b/api/src/main/java/org/openmrs/module/drcreports/reports/DRCHivCaScreeningReportManager.java index 2b6ca5d..c2f23c9 100644 --- a/api/src/main/java/org/openmrs/module/drcreports/reports/DRCHivCaScreeningReportManager.java +++ b/api/src/main/java/org/openmrs/module/drcreports/reports/DRCHivCaScreeningReportManager.java @@ -126,7 +126,7 @@ public ReportDefinition constructReportDefinition() { caScreening.addParameter(new Parameter("onOrAfter", "On Or After", Date.class)); caScreening.addParameter(new Parameter("onOrBefore", "On Or Before", Date.class)); caScreening.setOperator(SetComparator.IN); - caScreening.setQuestion(cs.getConceptByUuid("e5e99fc7-ff2d-4306-aefd-b87a07fc9ab4")); // Screened for cervical cancer during this visit + caScreening.setQuestion(cs.getConceptByUuid("e5e99fc7-ff2d-4306-aefd-b87a07fc9ab4")); // Cervical cancer screening status caScreening.setTimeModifier(TimeModifier.LAST); List caScreeningAnswers = new ArrayList(); caScreeningAnswers.add(cs.getConceptByUuid("165619AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA")); // Cervical cancer screening performed @@ -134,7 +134,7 @@ public ReportDefinition constructReportDefinition() { SqlCohortDefinition ptLivingWithHIVsqd = new SqlCohortDefinition(); - //What do you want to do? ---> Enroll new Pt in HIV Care + //Patient Type at Enrolment ---> Enroll new Pt in HIV Care String sql = "SELECT DISTINCT p.patient_id FROM patient p WHERE p.voided = 0 " + "AND EXISTS (SELECT 1 FROM obs o JOIN concept c_question ON o.concept_id = c_question.concept_id JOIN concept c_answer ON o.value_coded = c_answer.concept_id WHERE o.person_id = p.patient_id AND c_question.uuid = '83e40f2c-c316-43e6-a12e-20a338100281' AND c_answer.uuid = '164144AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA' AND o.voided = 0);"; ptLivingWithHIVsqd.setQuery(sql); diff --git a/api/src/test/java/org/openmrs/module/drcreports/reports/DRCHIVCaScreeningReportManagerTest.java b/api/src/test/java/org/openmrs/module/drcreports/reports/DRCHIVCaScreeningReportManagerTest.java new file mode 100644 index 0000000..b706855 --- /dev/null +++ b/api/src/test/java/org/openmrs/module/drcreports/reports/DRCHIVCaScreeningReportManagerTest.java @@ -0,0 +1,100 @@ +package org.openmrs.module.drcreports.reports; + +import static org.hamcrest.CoreMatchers.is; +import static org.junit.Assert.assertThat; +import java.io.File; +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map; + +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.openmrs.Cohort; +import org.openmrs.api.ConceptService; +import org.openmrs.module.initializer.Domain; +import org.openmrs.module.initializer.api.InitializerService; +import org.openmrs.module.initializer.api.loaders.Loader; +import org.openmrs.module.reporting.common.DateUtil; +import org.openmrs.module.reporting.dataset.DataSetRow; +import org.openmrs.module.reporting.evaluation.EvaluationContext; +import org.openmrs.module.reporting.report.ReportData; +import org.openmrs.module.reporting.report.definition.ReportDefinition; +import org.openmrs.module.reporting.report.definition.service.ReportDefinitionService; +import org.openmrs.module.reporting.report.manager.ReportManagerUtil; +import org.openmrs.module.reporting.report.service.ReportService; +import org.openmrs.test.BaseModuleContextSensitiveTest; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; + +public class DRCHIVCaScreeningReportManagerTest extends BaseModuleContextSensitiveTest { + + @Autowired + private InitializerService iniz; + + @Autowired + private ReportService rs; + + @Autowired + private ReportDefinitionService rds; + + @Autowired + @Qualifier("conceptService") + private ConceptService cs; + + @Autowired + private DRCHIVCaScreeningReportManager manager; + + @Before + public void setup() throws Exception { + executeDataSet("org/openmrs/module/reporting/include/ReportTestDataset-openmrs-2.0.xml"); + executeDataSet("org/openmrs/module/drcreports/include/DRCHIVCaScreeningReportTestDataset.xml"); + + String path = getClass().getClassLoader().getResource("testAppDataDir").getPath() + File.separator; + System.setProperty("OPENMRS_APPLICATION_DATA_DIRECTORY", path); + + for (Loader loader : iniz.getLoaders()) { + if (loader.getDomainName().equals(Domain.JSON_KEY_VALUES.getName())) { + loader.load(); + } + } + } + + @Test + public void setupReport_shouldSetupDRCARTTransferOutReport() { + + // replay + ReportManagerUtil.setupReport(manager); + + // verify + Assert.assertNotNull(rs.getReportDesignByUuid("8fd7b2bb-94b4-4e69-8839-95cb4de1b4c2")); + + } + + @Test + public void testReport() throws Exception { + + EvaluationContext context = new EvaluationContext(); + context.addParameterValue("startDate", DateUtil.parseDate("2025-06-01", "yyyy-MM-dd")); + context.addParameterValue("endDate", DateUtil.parseDate("2025-06-30", "yyyy-MM-dd")); + + ReportDefinition rd = manager.constructReportDefinition(); + ReportData data = rds.evaluate(rd, context); + + for (Iterator itr = data.getDataSets().get(rd.getName()).iterator(); itr.hasNext();) { + DataSetRow row = itr.next(); + Map columnValuePairs = getColumnValues(); + for (String column : columnValuePairs.keySet()) { + assertThat(column, ((Cohort) row.getColumnValue(column)).getSize(), is(columnValuePairs.get(column))); + } + } + } + + private Map getColumnValues() { + Map map = new HashMap(); + map.put("DRC HIV+ women who received cervical cancer screening.30-49 years", 1); + + return map; + + } +} diff --git a/api/src/test/resources/org/openmrs/module/drcreports/include/DRCHIVCaScreeningReportTestDataset.xml b/api/src/test/resources/org/openmrs/module/drcreports/include/DRCHIVCaScreeningReportTestDataset.xml new file mode 100644 index 0000000..8d46fdf --- /dev/null +++ b/api/src/test/resources/org/openmrs/module/drcreports/include/DRCHIVCaScreeningReportTestDataset.xml @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file From 8d83b71a1f78de28bc7f354947387a3cead2ffa9 Mon Sep 17 00:00:00 2001 From: MAKOBA REAGAN PATRICK Date: Tue, 8 Jul 2025 21:17:31 +0000 Subject: [PATCH 2/5] Use Hamcrest dependency --- .../reports/DRCHIVCaScreeningReportManagerTest.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/api/src/test/java/org/openmrs/module/drcreports/reports/DRCHIVCaScreeningReportManagerTest.java b/api/src/test/java/org/openmrs/module/drcreports/reports/DRCHIVCaScreeningReportManagerTest.java index b706855..1e38691 100644 --- a/api/src/test/java/org/openmrs/module/drcreports/reports/DRCHIVCaScreeningReportManagerTest.java +++ b/api/src/test/java/org/openmrs/module/drcreports/reports/DRCHIVCaScreeningReportManagerTest.java @@ -1,13 +1,10 @@ package org.openmrs.module.drcreports.reports; -import static org.hamcrest.CoreMatchers.is; -import static org.junit.Assert.assertThat; import java.io.File; import java.util.HashMap; import java.util.Iterator; import java.util.Map; -import org.junit.Assert; import org.junit.Before; import org.junit.Test; import org.openmrs.Cohort; @@ -26,6 +23,9 @@ import org.openmrs.test.BaseModuleContextSensitiveTest; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.is; +import static org.hamcrest.Matchers.notNullValue; public class DRCHIVCaScreeningReportManagerTest extends BaseModuleContextSensitiveTest { @@ -67,7 +67,7 @@ public void setupReport_shouldSetupDRCARTTransferOutReport() { ReportManagerUtil.setupReport(manager); // verify - Assert.assertNotNull(rs.getReportDesignByUuid("8fd7b2bb-94b4-4e69-8839-95cb4de1b4c2")); + assertThat(rs.getReportDesignByUuid("8fd7b2bb-94b4-4e69-8839-95cb4de1b4c2"), is(notNullValue())); } From 566b2fc657928e8628e7208cfd23369d30a43a48 Mon Sep 17 00:00:00 2001 From: reagan-meant Date: Sun, 13 Jul 2025 19:06:07 +0300 Subject: [PATCH 3/5] Rename files --- .../reports/DRCArtDeathReportManagerTest.java | 4 +- .../DRCArtSecondLineReportManagerTest.java | 2 +- .../DRCArtTransferInReportManagerTest.java | 2 +- .../DRCArtTransferOutReportManagerTest.java | 4 +- .../DRCHIVCaScreeningReportManagerTest.java | 9 +- .../DRCHivCaScreeningReportManagerTest.java | 99 +++++++++++++++++++ .../include/DRCArtDeathReportTestDataset.xml | 27 +++++ .../DRCArtSecondLineReportTestDataset.xml | 35 +++++++ .../include/DRCArtTransferOutTestDataset.xml | 20 ++++ .../DRCHivCaScreeningReportTestDataset.xml | 34 +++++++ 10 files changed, 225 insertions(+), 11 deletions(-) create mode 100644 api/src/test/java/org/openmrs/module/drcreports/reports/DRCHivCaScreeningReportManagerTest.java create mode 100644 api/src/test/resources/org/openmrs/module/drcreports/include/DRCArtDeathReportTestDataset.xml create mode 100644 api/src/test/resources/org/openmrs/module/drcreports/include/DRCArtSecondLineReportTestDataset.xml create mode 100644 api/src/test/resources/org/openmrs/module/drcreports/include/DRCArtTransferOutTestDataset.xml create mode 100644 api/src/test/resources/org/openmrs/module/drcreports/include/DRCHivCaScreeningReportTestDataset.xml diff --git a/api/src/test/java/org/openmrs/module/drcreports/reports/DRCArtDeathReportManagerTest.java b/api/src/test/java/org/openmrs/module/drcreports/reports/DRCArtDeathReportManagerTest.java index d519b0f..497f0fb 100644 --- a/api/src/test/java/org/openmrs/module/drcreports/reports/DRCArtDeathReportManagerTest.java +++ b/api/src/test/java/org/openmrs/module/drcreports/reports/DRCArtDeathReportManagerTest.java @@ -49,7 +49,7 @@ public class DRCArtDeathReportManagerTest extends BaseModuleContextSensitiveTest @Before public void setup() throws Exception { executeDataSet("org/openmrs/module/reporting/include/ReportTestDataset-openmrs-2.0.xml"); - executeDataSet("org/openmrs/module/drcreports/include/DRCARTDeathReportTestDataset.xml"); + executeDataSet("org/openmrs/module/drcreports/include/DRCArtDeathReportTestDataset.xml"); String path = getClass().getClassLoader().getResource("testAppDataDir").getPath() + File.separator; System.setProperty("OPENMRS_APPLICATION_DATA_DIRECTORY", path); @@ -62,7 +62,7 @@ public void setup() throws Exception { } @Test - public void setupReport_shouldSetupDRCARTTransferOutReport() { + public void setupReport_shouldSetupDRCArtTransferOutReport() { // replay ReportManagerUtil.setupReport(manager); diff --git a/api/src/test/java/org/openmrs/module/drcreports/reports/DRCArtSecondLineReportManagerTest.java b/api/src/test/java/org/openmrs/module/drcreports/reports/DRCArtSecondLineReportManagerTest.java index 7a0a8fb..04d8a8d 100644 --- a/api/src/test/java/org/openmrs/module/drcreports/reports/DRCArtSecondLineReportManagerTest.java +++ b/api/src/test/java/org/openmrs/module/drcreports/reports/DRCArtSecondLineReportManagerTest.java @@ -88,7 +88,7 @@ private IDatabaseConnection setupDatabaseConnection(Connection connection) throw public void setUp() throws Exception { updateDatabase("org/openmrs/module/drcreports/liquibase/test-liquibase.xml"); executeDataSet("org/openmrs/module/reporting/include/ReportTestDataset-openmrs-2.0.xml"); - executeDataSet("org/openmrs/module/drcreports/include/DRCARTSecondLineReportTestDataset.xml"); + executeDataSet("org/openmrs/module/drcreports/include/DRCArtSecondLineReportTestDataset.xml"); String path = getClass().getClassLoader().getResource("testAppDataDir").getPath() + File.separator; System.setProperty("OPENMRS_APPLICATION_DATA_DIRECTORY", path); diff --git a/api/src/test/java/org/openmrs/module/drcreports/reports/DRCArtTransferInReportManagerTest.java b/api/src/test/java/org/openmrs/module/drcreports/reports/DRCArtTransferInReportManagerTest.java index 73f064b..9d1123c 100644 --- a/api/src/test/java/org/openmrs/module/drcreports/reports/DRCArtTransferInReportManagerTest.java +++ b/api/src/test/java/org/openmrs/module/drcreports/reports/DRCArtTransferInReportManagerTest.java @@ -61,7 +61,7 @@ public void setup() throws Exception { } @Test - public void setupReport_shouldSetupDRCARTTransferOutReport() { + public void setupReport_shouldSetupDRCArtTransferOutReport() { // replay ReportManagerUtil.setupReport(manager); diff --git a/api/src/test/java/org/openmrs/module/drcreports/reports/DRCArtTransferOutReportManagerTest.java b/api/src/test/java/org/openmrs/module/drcreports/reports/DRCArtTransferOutReportManagerTest.java index 5aa175e..b8dac0a 100644 --- a/api/src/test/java/org/openmrs/module/drcreports/reports/DRCArtTransferOutReportManagerTest.java +++ b/api/src/test/java/org/openmrs/module/drcreports/reports/DRCArtTransferOutReportManagerTest.java @@ -49,7 +49,7 @@ public class DRCArtTransferOutReportManagerTest extends BaseModuleContextSensiti @Before public void setup() throws Exception { executeDataSet("org/openmrs/module/reporting/include/ReportTestDataset-openmrs-2.0.xml"); - executeDataSet("org/openmrs/module/drcreports/include/DRCARTTransferOutTestDataset.xml"); + executeDataSet("org/openmrs/module/drcreports/include/DRCArtTransferOutTestDataset.xml"); String path = getClass().getClassLoader().getResource("testAppDataDir").getPath() + File.separator; System.setProperty("OPENMRS_APPLICATION_DATA_DIRECTORY", path); @@ -62,7 +62,7 @@ public void setup() throws Exception { } @Test - public void setupReport_shouldSetupDRCARTTransferOutReport() { + public void setupReport_shouldSetupDRCArtTransferOutReport() { // replay ReportManagerUtil.setupReport(manager); diff --git a/api/src/test/java/org/openmrs/module/drcreports/reports/DRCHIVCaScreeningReportManagerTest.java b/api/src/test/java/org/openmrs/module/drcreports/reports/DRCHIVCaScreeningReportManagerTest.java index 1e38691..d9f27ae 100644 --- a/api/src/test/java/org/openmrs/module/drcreports/reports/DRCHIVCaScreeningReportManagerTest.java +++ b/api/src/test/java/org/openmrs/module/drcreports/reports/DRCHIVCaScreeningReportManagerTest.java @@ -27,7 +27,7 @@ import static org.hamcrest.Matchers.is; import static org.hamcrest.Matchers.notNullValue; -public class DRCHIVCaScreeningReportManagerTest extends BaseModuleContextSensitiveTest { +public class DRCHivCaScreeningReportManagerTest extends BaseModuleContextSensitiveTest { @Autowired private InitializerService iniz; @@ -43,12 +43,12 @@ public class DRCHIVCaScreeningReportManagerTest extends BaseModuleContextSensiti private ConceptService cs; @Autowired - private DRCHIVCaScreeningReportManager manager; + private DRCHivCaScreeningReportManager manager; @Before public void setup() throws Exception { executeDataSet("org/openmrs/module/reporting/include/ReportTestDataset-openmrs-2.0.xml"); - executeDataSet("org/openmrs/module/drcreports/include/DRCHIVCaScreeningReportTestDataset.xml"); + executeDataSet("org/openmrs/module/drcreports/include/DRCHivCaScreeningReportTestDataset.xml"); String path = getClass().getClassLoader().getResource("testAppDataDir").getPath() + File.separator; System.setProperty("OPENMRS_APPLICATION_DATA_DIRECTORY", path); @@ -61,14 +61,13 @@ public void setup() throws Exception { } @Test - public void setupReport_shouldSetupDRCARTTransferOutReport() { + public void setupReport_shouldSetupDRCArtTransferOutReport() { // replay ReportManagerUtil.setupReport(manager); // verify assertThat(rs.getReportDesignByUuid("8fd7b2bb-94b4-4e69-8839-95cb4de1b4c2"), is(notNullValue())); - } @Test diff --git a/api/src/test/java/org/openmrs/module/drcreports/reports/DRCHivCaScreeningReportManagerTest.java b/api/src/test/java/org/openmrs/module/drcreports/reports/DRCHivCaScreeningReportManagerTest.java new file mode 100644 index 0000000..d9f27ae --- /dev/null +++ b/api/src/test/java/org/openmrs/module/drcreports/reports/DRCHivCaScreeningReportManagerTest.java @@ -0,0 +1,99 @@ +package org.openmrs.module.drcreports.reports; + +import java.io.File; +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map; + +import org.junit.Before; +import org.junit.Test; +import org.openmrs.Cohort; +import org.openmrs.api.ConceptService; +import org.openmrs.module.initializer.Domain; +import org.openmrs.module.initializer.api.InitializerService; +import org.openmrs.module.initializer.api.loaders.Loader; +import org.openmrs.module.reporting.common.DateUtil; +import org.openmrs.module.reporting.dataset.DataSetRow; +import org.openmrs.module.reporting.evaluation.EvaluationContext; +import org.openmrs.module.reporting.report.ReportData; +import org.openmrs.module.reporting.report.definition.ReportDefinition; +import org.openmrs.module.reporting.report.definition.service.ReportDefinitionService; +import org.openmrs.module.reporting.report.manager.ReportManagerUtil; +import org.openmrs.module.reporting.report.service.ReportService; +import org.openmrs.test.BaseModuleContextSensitiveTest; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.is; +import static org.hamcrest.Matchers.notNullValue; + +public class DRCHivCaScreeningReportManagerTest extends BaseModuleContextSensitiveTest { + + @Autowired + private InitializerService iniz; + + @Autowired + private ReportService rs; + + @Autowired + private ReportDefinitionService rds; + + @Autowired + @Qualifier("conceptService") + private ConceptService cs; + + @Autowired + private DRCHivCaScreeningReportManager manager; + + @Before + public void setup() throws Exception { + executeDataSet("org/openmrs/module/reporting/include/ReportTestDataset-openmrs-2.0.xml"); + executeDataSet("org/openmrs/module/drcreports/include/DRCHivCaScreeningReportTestDataset.xml"); + + String path = getClass().getClassLoader().getResource("testAppDataDir").getPath() + File.separator; + System.setProperty("OPENMRS_APPLICATION_DATA_DIRECTORY", path); + + for (Loader loader : iniz.getLoaders()) { + if (loader.getDomainName().equals(Domain.JSON_KEY_VALUES.getName())) { + loader.load(); + } + } + } + + @Test + public void setupReport_shouldSetupDRCArtTransferOutReport() { + + // replay + ReportManagerUtil.setupReport(manager); + + // verify + assertThat(rs.getReportDesignByUuid("8fd7b2bb-94b4-4e69-8839-95cb4de1b4c2"), is(notNullValue())); + } + + @Test + public void testReport() throws Exception { + + EvaluationContext context = new EvaluationContext(); + context.addParameterValue("startDate", DateUtil.parseDate("2025-06-01", "yyyy-MM-dd")); + context.addParameterValue("endDate", DateUtil.parseDate("2025-06-30", "yyyy-MM-dd")); + + ReportDefinition rd = manager.constructReportDefinition(); + ReportData data = rds.evaluate(rd, context); + + for (Iterator itr = data.getDataSets().get(rd.getName()).iterator(); itr.hasNext();) { + DataSetRow row = itr.next(); + Map columnValuePairs = getColumnValues(); + for (String column : columnValuePairs.keySet()) { + assertThat(column, ((Cohort) row.getColumnValue(column)).getSize(), is(columnValuePairs.get(column))); + } + } + } + + private Map getColumnValues() { + Map map = new HashMap(); + map.put("DRC HIV+ women who received cervical cancer screening.30-49 years", 1); + + return map; + + } +} diff --git a/api/src/test/resources/org/openmrs/module/drcreports/include/DRCArtDeathReportTestDataset.xml b/api/src/test/resources/org/openmrs/module/drcreports/include/DRCArtDeathReportTestDataset.xml new file mode 100644 index 0000000..3251f1a --- /dev/null +++ b/api/src/test/resources/org/openmrs/module/drcreports/include/DRCArtDeathReportTestDataset.xml @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/api/src/test/resources/org/openmrs/module/drcreports/include/DRCArtSecondLineReportTestDataset.xml b/api/src/test/resources/org/openmrs/module/drcreports/include/DRCArtSecondLineReportTestDataset.xml new file mode 100644 index 0000000..4987e53 --- /dev/null +++ b/api/src/test/resources/org/openmrs/module/drcreports/include/DRCArtSecondLineReportTestDataset.xml @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/api/src/test/resources/org/openmrs/module/drcreports/include/DRCArtTransferOutTestDataset.xml b/api/src/test/resources/org/openmrs/module/drcreports/include/DRCArtTransferOutTestDataset.xml new file mode 100644 index 0000000..d2a8bcc --- /dev/null +++ b/api/src/test/resources/org/openmrs/module/drcreports/include/DRCArtTransferOutTestDataset.xml @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/api/src/test/resources/org/openmrs/module/drcreports/include/DRCHivCaScreeningReportTestDataset.xml b/api/src/test/resources/org/openmrs/module/drcreports/include/DRCHivCaScreeningReportTestDataset.xml new file mode 100644 index 0000000..8d46fdf --- /dev/null +++ b/api/src/test/resources/org/openmrs/module/drcreports/include/DRCHivCaScreeningReportTestDataset.xml @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file From 2a971ea23673e176a6ff83468bb04d5a55db956c Mon Sep 17 00:00:00 2001 From: reagan-meant Date: Sun, 13 Jul 2025 19:12:32 +0300 Subject: [PATCH 4/5] Rename test names --- .../module/drcreports/reports/DRCArtDeathReportManagerTest.java | 2 +- .../drcreports/reports/DRCArtHepatitisReportManagerTest.java | 2 +- .../drcreports/reports/DRCArtSecondLineReportManagerTest.java | 2 +- .../drcreports/reports/DRCArtTransferInReportManagerTest.java | 2 +- .../drcreports/reports/DRCHIVCaScreeningReportManagerTest.java | 2 +- .../drcreports/reports/DRCHivCaScreeningReportManagerTest.java | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/api/src/test/java/org/openmrs/module/drcreports/reports/DRCArtDeathReportManagerTest.java b/api/src/test/java/org/openmrs/module/drcreports/reports/DRCArtDeathReportManagerTest.java index 497f0fb..cc4a969 100644 --- a/api/src/test/java/org/openmrs/module/drcreports/reports/DRCArtDeathReportManagerTest.java +++ b/api/src/test/java/org/openmrs/module/drcreports/reports/DRCArtDeathReportManagerTest.java @@ -62,7 +62,7 @@ public void setup() throws Exception { } @Test - public void setupReport_shouldSetupDRCArtTransferOutReport() { + public void setupReport_shouldSetupDRCArtDeathReportReport() { // replay ReportManagerUtil.setupReport(manager); diff --git a/api/src/test/java/org/openmrs/module/drcreports/reports/DRCArtHepatitisReportManagerTest.java b/api/src/test/java/org/openmrs/module/drcreports/reports/DRCArtHepatitisReportManagerTest.java index 143e003..c3d8d6e 100644 --- a/api/src/test/java/org/openmrs/module/drcreports/reports/DRCArtHepatitisReportManagerTest.java +++ b/api/src/test/java/org/openmrs/module/drcreports/reports/DRCArtHepatitisReportManagerTest.java @@ -101,7 +101,7 @@ public void setUp() throws Exception { } @Test - public void setupReport_shouldCreateExcelTemplateDesign() throws Exception { + public void setupReport_shouldCreateCsvDesign() throws Exception { // setup // replay diff --git a/api/src/test/java/org/openmrs/module/drcreports/reports/DRCArtSecondLineReportManagerTest.java b/api/src/test/java/org/openmrs/module/drcreports/reports/DRCArtSecondLineReportManagerTest.java index 04d8a8d..dd076de 100644 --- a/api/src/test/java/org/openmrs/module/drcreports/reports/DRCArtSecondLineReportManagerTest.java +++ b/api/src/test/java/org/openmrs/module/drcreports/reports/DRCArtSecondLineReportManagerTest.java @@ -101,7 +101,7 @@ public void setUp() throws Exception { } @Test - public void setupReport_shouldCreateExcelTemplateDesign() throws Exception { + public void setupReport_shouldCreateCsvDesign() throws Exception { // setup // replay diff --git a/api/src/test/java/org/openmrs/module/drcreports/reports/DRCArtTransferInReportManagerTest.java b/api/src/test/java/org/openmrs/module/drcreports/reports/DRCArtTransferInReportManagerTest.java index 9d1123c..40ef895 100644 --- a/api/src/test/java/org/openmrs/module/drcreports/reports/DRCArtTransferInReportManagerTest.java +++ b/api/src/test/java/org/openmrs/module/drcreports/reports/DRCArtTransferInReportManagerTest.java @@ -61,7 +61,7 @@ public void setup() throws Exception { } @Test - public void setupReport_shouldSetupDRCArtTransferOutReport() { + public void setupReport_shouldSetupDRCArtTransferInReport() { // replay ReportManagerUtil.setupReport(manager); diff --git a/api/src/test/java/org/openmrs/module/drcreports/reports/DRCHIVCaScreeningReportManagerTest.java b/api/src/test/java/org/openmrs/module/drcreports/reports/DRCHIVCaScreeningReportManagerTest.java index d9f27ae..240dea3 100644 --- a/api/src/test/java/org/openmrs/module/drcreports/reports/DRCHIVCaScreeningReportManagerTest.java +++ b/api/src/test/java/org/openmrs/module/drcreports/reports/DRCHIVCaScreeningReportManagerTest.java @@ -61,7 +61,7 @@ public void setup() throws Exception { } @Test - public void setupReport_shouldSetupDRCArtTransferOutReport() { + public void setupReport_shouldSetupDRCHivCaScreeningReport() { // replay ReportManagerUtil.setupReport(manager); diff --git a/api/src/test/java/org/openmrs/module/drcreports/reports/DRCHivCaScreeningReportManagerTest.java b/api/src/test/java/org/openmrs/module/drcreports/reports/DRCHivCaScreeningReportManagerTest.java index d9f27ae..240dea3 100644 --- a/api/src/test/java/org/openmrs/module/drcreports/reports/DRCHivCaScreeningReportManagerTest.java +++ b/api/src/test/java/org/openmrs/module/drcreports/reports/DRCHivCaScreeningReportManagerTest.java @@ -61,7 +61,7 @@ public void setup() throws Exception { } @Test - public void setupReport_shouldSetupDRCArtTransferOutReport() { + public void setupReport_shouldSetupDRCHivCaScreeningReport() { // replay ReportManagerUtil.setupReport(manager); From 408cbb363309804018d35a259b9e34f48849a5c0 Mon Sep 17 00:00:00 2001 From: reagan-meant Date: Sun, 13 Jul 2025 19:17:56 +0300 Subject: [PATCH 5/5] Remove old case version, keep correctly cased filename --- .../DRCHIVCaScreeningReportManagerTest.java | 99 ------------------- 1 file changed, 99 deletions(-) delete mode 100644 api/src/test/java/org/openmrs/module/drcreports/reports/DRCHIVCaScreeningReportManagerTest.java diff --git a/api/src/test/java/org/openmrs/module/drcreports/reports/DRCHIVCaScreeningReportManagerTest.java b/api/src/test/java/org/openmrs/module/drcreports/reports/DRCHIVCaScreeningReportManagerTest.java deleted file mode 100644 index 240dea3..0000000 --- a/api/src/test/java/org/openmrs/module/drcreports/reports/DRCHIVCaScreeningReportManagerTest.java +++ /dev/null @@ -1,99 +0,0 @@ -package org.openmrs.module.drcreports.reports; - -import java.io.File; -import java.util.HashMap; -import java.util.Iterator; -import java.util.Map; - -import org.junit.Before; -import org.junit.Test; -import org.openmrs.Cohort; -import org.openmrs.api.ConceptService; -import org.openmrs.module.initializer.Domain; -import org.openmrs.module.initializer.api.InitializerService; -import org.openmrs.module.initializer.api.loaders.Loader; -import org.openmrs.module.reporting.common.DateUtil; -import org.openmrs.module.reporting.dataset.DataSetRow; -import org.openmrs.module.reporting.evaluation.EvaluationContext; -import org.openmrs.module.reporting.report.ReportData; -import org.openmrs.module.reporting.report.definition.ReportDefinition; -import org.openmrs.module.reporting.report.definition.service.ReportDefinitionService; -import org.openmrs.module.reporting.report.manager.ReportManagerUtil; -import org.openmrs.module.reporting.report.service.ReportService; -import org.openmrs.test.BaseModuleContextSensitiveTest; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Qualifier; -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.is; -import static org.hamcrest.Matchers.notNullValue; - -public class DRCHivCaScreeningReportManagerTest extends BaseModuleContextSensitiveTest { - - @Autowired - private InitializerService iniz; - - @Autowired - private ReportService rs; - - @Autowired - private ReportDefinitionService rds; - - @Autowired - @Qualifier("conceptService") - private ConceptService cs; - - @Autowired - private DRCHivCaScreeningReportManager manager; - - @Before - public void setup() throws Exception { - executeDataSet("org/openmrs/module/reporting/include/ReportTestDataset-openmrs-2.0.xml"); - executeDataSet("org/openmrs/module/drcreports/include/DRCHivCaScreeningReportTestDataset.xml"); - - String path = getClass().getClassLoader().getResource("testAppDataDir").getPath() + File.separator; - System.setProperty("OPENMRS_APPLICATION_DATA_DIRECTORY", path); - - for (Loader loader : iniz.getLoaders()) { - if (loader.getDomainName().equals(Domain.JSON_KEY_VALUES.getName())) { - loader.load(); - } - } - } - - @Test - public void setupReport_shouldSetupDRCHivCaScreeningReport() { - - // replay - ReportManagerUtil.setupReport(manager); - - // verify - assertThat(rs.getReportDesignByUuid("8fd7b2bb-94b4-4e69-8839-95cb4de1b4c2"), is(notNullValue())); - } - - @Test - public void testReport() throws Exception { - - EvaluationContext context = new EvaluationContext(); - context.addParameterValue("startDate", DateUtil.parseDate("2025-06-01", "yyyy-MM-dd")); - context.addParameterValue("endDate", DateUtil.parseDate("2025-06-30", "yyyy-MM-dd")); - - ReportDefinition rd = manager.constructReportDefinition(); - ReportData data = rds.evaluate(rd, context); - - for (Iterator itr = data.getDataSets().get(rd.getName()).iterator(); itr.hasNext();) { - DataSetRow row = itr.next(); - Map columnValuePairs = getColumnValues(); - for (String column : columnValuePairs.keySet()) { - assertThat(column, ((Cohort) row.getColumnValue(column)).getSize(), is(columnValuePairs.get(column))); - } - } - } - - private Map getColumnValues() { - Map map = new HashMap(); - map.put("DRC HIV+ women who received cervical cancer screening.30-49 years", 1); - - return map; - - } -}