Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/maven.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
strategy:
matrix:
platform: [ ubuntu-latest ]
java-version: [ 8 ]
java-version: [ 8, 11, 17, 21, 24 ]

runs-on: ${{ matrix.platform }}
env:
Expand Down
26 changes: 25 additions & 1 deletion api-tests/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>org.openmrs.module</groupId>
<artifactId>reporting</artifactId>
<version>1.28.0-SNAPSHOT</version>
<version>2.0.0-SNAPSHOT</version>
</parent>

<artifactId>reporting-api-tests</artifactId>
Expand Down Expand Up @@ -40,6 +40,14 @@
<artifactId>javassist</artifactId>
<groupId>javassist</groupId>
</exclusion>
<exclusion>
<groupId>org.powermock</groupId>
<artifactId>powermock-api-mockito2</artifactId>
</exclusion>
<exclusion>
<groupId>org.powermock</groupId>
<artifactId>powermock-api-mockito</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
Expand All @@ -52,6 +60,14 @@
<artifactId>javassist</artifactId>
<groupId>javassist</groupId>
</exclusion>
<exclusion>
<groupId>org.powermock</groupId>
<artifactId>powermock-api-mockito2</artifactId>
</exclusion>
<exclusion>
<groupId>org.powermock</groupId>
<artifactId>powermock-api-mockito</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
Expand All @@ -64,6 +80,14 @@
<artifactId>javassist</artifactId>
<groupId>javassist</groupId>
</exclusion>
<exclusion>
<groupId>org.powermock</groupId>
<artifactId>powermock-api-mockito2</artifactId>
</exclusion>
<exclusion>
<groupId>org.powermock</groupId>
<artifactId>powermock-api-mockito</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
import java.util.Collections;

import org.junit.Assert;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.openmrs.Cohort;
import org.openmrs.Encounter;
import org.openmrs.EncounterType;
Expand All @@ -34,17 +34,21 @@
import org.openmrs.module.reporting.common.TimeQualifier;
import org.openmrs.module.reporting.definition.DefinitionContext;
import org.openmrs.module.reporting.evaluation.EvaluationContext;
import org.openmrs.test.BaseModuleContextSensitiveTest;
import org.openmrs.test.SkipBaseSetup;
import org.openmrs.test.Verifies;
import org.openmrs.test.jupiter.BaseModuleContextSensitiveTest;

@SkipBaseSetup
public class EncounterCohortDefinitionEvaluatorTest extends BaseModuleContextSensitiveTest {

protected static final String XML_DATASET_PATH = "org/openmrs/module/reporting/include/";

protected static final String XML_REPORT_TEST_DATASET = "ReportTestDataset";

@Before
@BeforeEach
public void setup() throws Exception {
initializeInMemoryDatabase();
authenticate();
executeDataSet(XML_DATASET_PATH + new TestUtil().getTestDatasetFilename(XML_REPORT_TEST_DATASET));
}

Expand Down Expand Up @@ -201,7 +205,7 @@ public void evaluate_shouldReturnCorrectPatientsWhenTimeQualifierParametersAreSe
* @see EncounterCohortDefinitionEvaluator#evaluate(CohortDefinition,EvaluationContext)
* @verifies return correct patients when provider parameters are set
*/
@Ignore
@Disabled
@Test
public void evaluate_shouldReturnCorrectPatientsWhenProviderParametersAreSet() throws Exception {
EncounterCohortDefinition cd = new EncounterCohortDefinition();
Expand All @@ -212,7 +216,7 @@ public void evaluate_shouldReturnCorrectPatientsWhenProviderParametersAreSet() t
/**
* @see {@link EncounterCohortDefinitionEvaluator#evaluate(CohortDefinition,EvaluationContext)}
*/
@Ignore
@Disabled
@Test
@Verifies(value = "should not return voided patients", method = "evaluate(CohortDefinition,EvaluationContext)")
public void evaluate_shouldNotReturnVoidedPatients() throws Exception {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public void setUp() throws Exception {
@Test
public void testEvaluateWithNoProperties() throws Exception {
Cohort c = cohortDefinitionService.evaluate(cd, null);
assertThat(c.size(), is(2));
assertThat(c.size(), is(3));
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,12 @@

import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.openmrs.api.context.Context;
import org.powermock.api.mockito.PowerMockito;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;
import org.openmrs.test.BaseModuleContextSensitiveTest;
import org.openmrs.test.SkipBaseSetup;

@RunWith(PowerMockRunner.class)
@PrepareForTest(Context.class)
public class PrivilegedDataConverterTest {
@SkipBaseSetup
public class PrivilegedDataConverterTest extends BaseModuleContextSensitiveTest {

public static final String INPUT = "input";
public static final String REPLACEMENT = "****";
Expand All @@ -32,16 +29,24 @@ public class PrivilegedDataConverterTest {

@Before
public void setUp() throws Exception {
PowerMockito.mockStatic(Context.class);
PowerMockito.when(Context.hasPrivilege(HAS_PRIV)).thenReturn(true);
PowerMockito.when(Context.hasPrivilege(DOES_NOT_HAVE_PRIV)).thenReturn(false);
initializeInMemoryDatabase();
executeDataSet("org/openmrs/module/reporting/include/PrivilegeTest.xml");
Context.logout();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we really need to log out and authenticate?

Context.authenticate("test", "test");
}

@Test
public void testConvertWithPrivilege() throws Exception {
PrivilegedDataConverter converter = new PrivilegedDataConverter(HAS_PRIV);
converter.setReplacement(REPLACEMENT);
assertThat((String) converter.convert(INPUT), is(INPUT));
public void testConvertWithPrivilege() {
try {
Context.addProxyPrivilege(HAS_PRIV);
Context.hasPrivilege(HAS_PRIV);
PrivilegedDataConverter converter = new PrivilegedDataConverter(HAS_PRIV);
converter.setReplacement(REPLACEMENT);
assertThat((String) converter.convert(INPUT), is(INPUT));
}
finally {
Context.removeProxyPrivilege(HAS_PRIV);
}
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
import org.openmrs.test.BaseModuleContextSensitiveTest;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.Arrays;
import java.util.Collections;

import static org.hamcrest.core.Is.is;
import static org.hamcrest.core.IsNull.nullValue;
Expand Down Expand Up @@ -159,7 +159,7 @@ private CohortDefinition setUpTestPatientCohortDefinition(PersonAttributeType te
PersonAttributeCohortDefinition cohortDefinition = new PersonAttributeCohortDefinition();
cohortDefinition.setName("Test Patients");
cohortDefinition.setAttributeType(testAttributeType);
cohortDefinition.setValues(Arrays.asList("true"));
cohortDefinition.setValues(Collections.singletonList("true"));
Context.getService(CohortDefinitionService.class).saveDefinition(cohortDefinition);
return cohortDefinition;
}
Expand Down Expand Up @@ -199,7 +199,7 @@ public String getKeyPrefix() {
public CohortDefinition getTestPatients() {
PersonAttributeCohortDefinition cohortDefinition = new PersonAttributeCohortDefinition();
cohortDefinition.setAttributeType(Context.getPersonService().getPersonAttributeTypeByUuid(TEST_PATIENT_ATTR_TYPE_UUID));
cohortDefinition.setValues(Arrays.asList("true"));
cohortDefinition.setValues(Collections.singletonList("true"));
return cohortDefinition;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@
import org.openmrs.module.reporting.evaluation.context.VisitEvaluationContext;
import org.openmrs.module.reporting.query.visit.VisitIdSet;
import org.openmrs.test.BaseModuleContextSensitiveTest;
import org.openmrs.test.SkipBaseSetup;

@SkipBaseSetup
public class VisitIdDataEvaluatorTest extends BaseModuleContextSensitiveTest{

protected static final String XML_DATASET_PATH = "org/openmrs/module/reporting/include/";
Expand All @@ -37,6 +39,8 @@ public class VisitIdDataEvaluatorTest extends BaseModuleContextSensitiveTest{
*/
@Before
public void setup() throws Exception {
initializeInMemoryDatabase();
authenticate();
executeDataSet(XML_DATASET_PATH + new TestUtil().getTestDatasetFilename(XML_REPORT_TEST_DATASET));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@
import java.util.HashMap;
import java.util.Map;

import static org.mockito.Matchers.argThat;
import static org.mockito.Matchers.eq;
import static org.mockito.ArgumentMatchers.argThat;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,14 @@
import org.junit.BeforeClass;
import org.junit.Test;
import org.openmrs.api.context.Context;
import org.openmrs.logging.MemoryAppender;
import org.openmrs.logging.OpenmrsLoggingUtil;
import org.openmrs.module.reporting.cohort.definition.GenderCohortDefinition;
import org.openmrs.module.reporting.indicator.CohortIndicator;
import org.openmrs.module.reporting.indicator.service.IndicatorService;
import org.openmrs.module.reporting.test.OpenmrsVersionTestListener;
import org.openmrs.module.reporting.test.RequiresVersion;
import org.openmrs.test.BaseModuleContextSensitiveTest;
import org.openmrs.util.MemoryAppender;
import org.openmrs.util.OpenmrsUtil;
import org.springframework.test.context.TestExecutionListeners;

Expand All @@ -38,7 +39,7 @@ public class EvaluationProfilerTest24On extends BaseModuleContextSensitiveTest {

@BeforeClass
public static void beforeClass() {
appender = OpenmrsUtil.getMemoryAppender();
appender = OpenmrsLoggingUtil.getMemoryAppender();

if (appender == null) {
LoggerContext context = (LoggerContext) LogManager.getContext(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
*/
package org.openmrs.module.reporting.query.encounter.evaluator;

import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.openmrs.api.context.Context;
import org.openmrs.module.reporting.common.DateUtil;
import org.openmrs.module.reporting.common.TestUtil;
Expand All @@ -20,7 +20,8 @@
import org.openmrs.module.reporting.query.obs.definition.BasicObsQuery;
import org.openmrs.module.reporting.query.obs.definition.MappedParametersObsQuery;
import org.openmrs.module.reporting.query.obs.service.ObsQueryService;
import org.openmrs.test.BaseModuleContextSensitiveTest;
import org.openmrs.test.SkipBaseSetup;
import org.openmrs.test.jupiter.BaseModuleContextSensitiveTest;

import java.util.Date;
import java.util.HashMap;
Expand All @@ -30,14 +31,17 @@
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;

@SkipBaseSetup
public class MappedParametersObsQueryEvaluatorTest extends BaseModuleContextSensitiveTest {

protected static final String XML_DATASET_PATH = "org/openmrs/module/reporting/include/";

protected static final String XML_REPORT_TEST_DATASET = "ReportTestDataset";

@Before
@BeforeEach
public void setup() throws Exception {
initializeInMemoryDatabase();
authenticate();
executeDataSet(XML_DATASET_PATH + new TestUtil().getTestDatasetFilename(XML_REPORT_TEST_DATASET));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,20 @@
import org.openmrs.module.reporting.query.obs.definition.SqlObsQuery;
import org.openmrs.module.reporting.query.obs.service.ObsQueryService;
import org.openmrs.test.BaseModuleContextSensitiveTest;
import org.openmrs.test.SkipBaseSetup;

/**
* Test the evaluation of the SqlObsQuery
*/
@SkipBaseSetup
public class SqlObsQueryEvaluatorTest extends BaseModuleContextSensitiveTest {

protected static Log log = LogFactory.getLog(SqlObsQueryEvaluatorTest.class);

@Before
public void setup() throws Exception {
initializeInMemoryDatabase();
authenticate();
executeDataSet("org/openmrs/module/reporting/include/" + new TestUtil().getTestDatasetFilename("ReportTestDataset"));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
*/
package org.openmrs.module.reporting.query.visit.evaluator;

import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.openmrs.Patient;
import org.openmrs.Visit;
import org.openmrs.api.VisitService;
Expand All @@ -22,7 +22,8 @@
import org.openmrs.module.reporting.query.visit.VisitQueryResult;
import org.openmrs.module.reporting.query.visit.definition.ActiveVisitQuery;
import org.openmrs.module.reporting.query.visit.service.VisitQueryService;
import org.openmrs.test.BaseModuleContextSensitiveTest;
import org.openmrs.test.SkipBaseSetup;
import org.openmrs.test.jupiter.BaseModuleContextSensitiveTest;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.ArrayList;
Expand All @@ -32,6 +33,7 @@
import static org.hamcrest.collection.IsIterableContainingInAnyOrder.containsInAnyOrder;
import static org.junit.Assert.assertThat;

@SkipBaseSetup
public class ActiveVisitQueryEvaluatorTest extends BaseModuleContextSensitiveTest {

protected static final String XML_DATASET_PATH = "org/openmrs/module/reporting/include/";
Expand All @@ -47,8 +49,10 @@ public class ActiveVisitQueryEvaluatorTest extends BaseModuleContextSensitiveTes
@Autowired
private TestDataManager data;

@Before
@BeforeEach
public void setup() throws Exception {
initializeInMemoryDatabase();
authenticate();
executeDataSet(XML_DATASET_PATH + new TestUtil().getTestDatasetFilename(XML_REPORT_TEST_DATASET));
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version='1.0' encoding='UTF-8'?>
<!--

This Source Code Form is subject to the terms of the Mozilla Public License,
v. 2.0. If a copy of the MPL was not distributed with this file, You can
obtain one at http://mozilla.org/MPL/2.0/. OpenMRS is also distributed under
the terms of the Healthcare Disclaimer located at http://openmrs.org/license.

Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS
graphic logo is a trademark of OpenMRS Inc.

-->
<dataset>
<person person_id="3" gender="" birthdate="1975-06-30" birthdate_estimated="false" dead="false" date_created="2005-01-01 00:00:00.0" voided="false" uuid="6adb7c42-cfd2-4301-b53b-ff17c5654ffa"/>
<users user_id="3" person_id="3" system_id="1-8" username="test" password="4a1750c8607d0fa237de36c6305715c223415189" salt="c788c6ad82a157b712392ca695dfcf2eed193d7f" secret_question="" creator="1" date_created="2005-01-01 00:00:00.0" changed_by="1" date_changed="2007-09-20 21:54:12.0" retired="false" retire_reason="" uuid="1010d442-e134-11de-babe-001e378eb67f"/>
<user_role user_id="1" role="Authenticated"/>
</dataset>
3 changes: 1 addition & 2 deletions api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,12 @@
<parent>
<groupId>org.openmrs.module</groupId>
<artifactId>reporting</artifactId>
<version>1.28.0-SNAPSHOT</version>
<version>2.0.0-SNAPSHOT</version>
</parent>
<artifactId>reporting-api</artifactId>
<packaging>jar</packaging>
<name>Reporting API</name>
<description>API project for Reporting</description>



</project>
Loading