Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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.29.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 @@ -12,36 +12,39 @@
import static org.hamcrest.core.Is.is;
import static org.junit.Assert.assertThat;

import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
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.SkipBaseSetup;
import org.openmrs.test.jupiter.BaseModuleContextSensitiveTest;

@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 = "****";

public static final String HAS_PRIV = "A privilege I have";
public static final String DOES_NOT_HAVE_PRIV = "A privilege I do not have";

@Before
@BeforeEach
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");
}

@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 @@ -10,8 +10,8 @@
package org.openmrs.module.reporting.data.patient.service;

import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.openmrs.Cohort;
import org.openmrs.Patient;
import org.openmrs.PersonAttribute;
Expand All @@ -31,10 +31,10 @@
import org.openmrs.module.reporting.definition.library.DocumentedDefinition;
import org.openmrs.module.reporting.evaluation.EvaluationContext;
import org.openmrs.test.BaseContextSensitiveTest;
import org.openmrs.test.BaseModuleContextSensitiveTest;
import org.openmrs.test.jupiter.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 All @@ -59,7 +59,7 @@ public class PatientDataServiceImplTest extends BaseModuleContextSensitiveTest {
*
* @throws Exception
*/
@Before
@BeforeEach
public void setup() throws Exception {
executeDataSet(XML_DATASET_PATH + new TestUtil().getTestDatasetFilename(XML_REPORT_TEST_DATASET));
}
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 @@ -10,8 +10,8 @@
package org.openmrs.module.reporting.data.visit.evaluator;

import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.openmrs.Cohort;
import org.openmrs.api.context.Context;
import org.openmrs.module.reporting.common.TestUtil;
Expand All @@ -21,9 +21,11 @@
import org.openmrs.module.reporting.evaluation.EvaluationContext;
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;
import org.openmrs.test.jupiter.BaseModuleContextSensitiveTest;

public class VisitIdDataEvaluatorTest extends BaseModuleContextSensitiveTest{
@SkipBaseSetup
public class VisitIdDataEvaluatorTest extends BaseModuleContextSensitiveTest {

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

Expand All @@ -35,8 +37,10 @@ public class VisitIdDataEvaluatorTest extends BaseModuleContextSensitiveTest{
*
* @throws Exception
*/
@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 @@ -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 @@ -9,25 +9,23 @@
*/
package org.openmrs.module.reporting.evaluation;

import static org.junit.Assume.assumeTrue;

import org.apache.log4j.Appender;
import org.apache.log4j.Level;
import org.apache.log4j.LogManager;
import org.apache.log4j.Logger;
import org.apache.log4j.PatternLayout;
import org.apache.log4j.WriterAppender;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.openmrs.api.context.Context;
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.test.jupiter.BaseModuleContextSensitiveTest;
import org.springframework.test.context.TestExecutionListeners;

import java.io.StringWriter;
Expand All @@ -52,7 +50,7 @@ public class EvaluationProfilerTest extends BaseModuleContextSensitiveTest {
/**
* Setup each test by configuring AOP on the relevant services and logging for the profiler class
*/
@Before
@BeforeEach
public void setup() {
profiler1 = new EvaluationProfiler(new EvaluationContext());
profiler2 = new EvaluationProfiler(new EvaluationContext());
Expand All @@ -70,7 +68,7 @@ public void setup() {
/**
* Cleanup after tests by removing AOP and resetting logging
*/
@After
@AfterEach
public void cleanup() {
logger.setLevel(startingLevel);
for (Appender appender : startingAppenders) {
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
Loading