Skip to content

Commit 1179b0f

Browse files
committed
Update to Platform 2.7.0 and Support Java 21
1 parent e4022f6 commit 1179b0f

28 files changed

+106
-4714
lines changed

.github/workflows/maven.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
strategy:
1414
matrix:
1515
platform: [ ubuntu-latest ]
16-
java-version: [ 8 ]
16+
java-version: [ 8, 11, 17, 21, 24 ]
1717

1818
runs-on: ${{ matrix.platform }}
1919
env:

api-tests/pom.xml

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<parent>
55
<groupId>org.openmrs.module</groupId>
66
<artifactId>reporting</artifactId>
7-
<version>1.28.0-SNAPSHOT</version>
7+
<version>2.0.0-SNAPSHOT</version>
88
</parent>
99

1010
<artifactId>reporting-api-tests</artifactId>
@@ -30,11 +30,6 @@
3030
</exclusion>
3131
</exclusions>
3232
</dependency>
33-
<dependency>
34-
<groupId>org.openmrs.module</groupId>
35-
<artifactId>${reportingApiConditionalArtifactId}</artifactId>
36-
<version>${project.parent.version}</version>
37-
</dependency>
3833

3934
<dependency>
4035
<groupId>org.openmrs.api</groupId>
@@ -45,6 +40,14 @@
4540
<artifactId>javassist</artifactId>
4641
<groupId>javassist</groupId>
4742
</exclusion>
43+
<exclusion>
44+
<groupId>org.powermock</groupId>
45+
<artifactId>powermock-api-mockito2</artifactId>
46+
</exclusion>
47+
<exclusion>
48+
<groupId>org.powermock</groupId>
49+
<artifactId>powermock-api-mockito</artifactId>
50+
</exclusion>
4851
</exclusions>
4952
</dependency>
5053
<dependency>
@@ -57,6 +60,14 @@
5760
<artifactId>javassist</artifactId>
5861
<groupId>javassist</groupId>
5962
</exclusion>
63+
<exclusion>
64+
<groupId>org.powermock</groupId>
65+
<artifactId>powermock-api-mockito2</artifactId>
66+
</exclusion>
67+
<exclusion>
68+
<groupId>org.powermock</groupId>
69+
<artifactId>powermock-api-mockito</artifactId>
70+
</exclusion>
6071
</exclusions>
6172
</dependency>
6273
<dependency>
@@ -69,6 +80,14 @@
6980
<artifactId>javassist</artifactId>
7081
<groupId>javassist</groupId>
7182
</exclusion>
83+
<exclusion>
84+
<groupId>org.powermock</groupId>
85+
<artifactId>powermock-api-mockito2</artifactId>
86+
</exclusion>
87+
<exclusion>
88+
<groupId>org.powermock</groupId>
89+
<artifactId>powermock-api-mockito</artifactId>
90+
</exclusion>
7291
</exclusions>
7392
</dependency>
7493
<dependency>

api-tests/src/test/java/org/openmrs/module/reporting/cohort/definition/evaluator/EncounterCohortDefinitionEvaluatorTest.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,10 @@
3535
import org.openmrs.module.reporting.definition.DefinitionContext;
3636
import org.openmrs.module.reporting.evaluation.EvaluationContext;
3737
import org.openmrs.test.BaseModuleContextSensitiveTest;
38+
import org.openmrs.test.SkipBaseSetup;
3839
import org.openmrs.test.Verifies;
3940

41+
@SkipBaseSetup
4042
public class EncounterCohortDefinitionEvaluatorTest extends BaseModuleContextSensitiveTest {
4143

4244
protected static final String XML_DATASET_PATH = "org/openmrs/module/reporting/include/";
@@ -45,6 +47,8 @@ public class EncounterCohortDefinitionEvaluatorTest extends BaseModuleContextSen
4547

4648
@Before
4749
public void setup() throws Exception {
50+
initializeInMemoryDatabase();
51+
authenticate();
4852
executeDataSet(XML_DATASET_PATH + new TestUtil().getTestDatasetFilename(XML_REPORT_TEST_DATASET));
4953
}
5054

api-tests/src/test/java/org/openmrs/module/reporting/cohort/definition/evaluator/VisitCohortDefinitionEvaluatorTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public void setUp() throws Exception {
6868
@Test
6969
public void testEvaluateWithNoProperties() throws Exception {
7070
Cohort c = cohortDefinitionService.evaluate(cd, null);
71-
assertThat(c.size(), is(2));
71+
assertThat(c.size(), is(3));
7272
}
7373

7474
@Test

api-tests/src/test/java/org/openmrs/module/reporting/data/converter/PrivilegedDataConverterTest.java

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,12 @@
1414

1515
import org.junit.Before;
1616
import org.junit.Test;
17-
import org.junit.runner.RunWith;
1817
import org.openmrs.api.context.Context;
19-
import org.powermock.api.mockito.PowerMockito;
20-
import org.powermock.core.classloader.annotations.PrepareForTest;
21-
import org.powermock.modules.junit4.PowerMockRunner;
18+
import org.openmrs.test.BaseModuleContextSensitiveTest;
19+
import org.openmrs.test.SkipBaseSetup;
2220

23-
@RunWith(PowerMockRunner.class)
24-
@PrepareForTest(Context.class)
25-
public class PrivilegedDataConverterTest {
21+
@SkipBaseSetup
22+
public class PrivilegedDataConverterTest extends BaseModuleContextSensitiveTest {
2623

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

3330
@Before
3431
public void setUp() throws Exception {
35-
PowerMockito.mockStatic(Context.class);
36-
PowerMockito.when(Context.hasPrivilege(HAS_PRIV)).thenReturn(true);
37-
PowerMockito.when(Context.hasPrivilege(DOES_NOT_HAVE_PRIV)).thenReturn(false);
32+
initializeInMemoryDatabase();
33+
executeDataSet("org/openmrs/module/reporting/include/PrivilegeTest.xml");
34+
Context.logout();
35+
Context.authenticate("test", "test");
3836
}
3937

4038
@Test
41-
public void testConvertWithPrivilege() throws Exception {
42-
PrivilegedDataConverter converter = new PrivilegedDataConverter(HAS_PRIV);
43-
converter.setReplacement(REPLACEMENT);
44-
assertThat((String) converter.convert(INPUT), is(INPUT));
39+
public void testConvertWithPrivilege() {
40+
try {
41+
Context.addProxyPrivilege(HAS_PRIV);
42+
Context.hasPrivilege(HAS_PRIV);
43+
PrivilegedDataConverter converter = new PrivilegedDataConverter(HAS_PRIV);
44+
converter.setReplacement(REPLACEMENT);
45+
assertThat((String) converter.convert(INPUT), is(INPUT));
46+
}
47+
finally {
48+
Context.removeProxyPrivilege(HAS_PRIV);
49+
}
4550
}
4651

4752
@Test

api-tests/src/test/java/org/openmrs/module/reporting/data/patient/service/PatientDataServiceImplTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
import org.openmrs.test.BaseModuleContextSensitiveTest;
3535
import org.springframework.beans.factory.annotation.Autowired;
3636

37-
import java.util.Arrays;
37+
import java.util.Collections;
3838

3939
import static org.hamcrest.core.Is.is;
4040
import static org.hamcrest.core.IsNull.nullValue;
@@ -159,7 +159,7 @@ private CohortDefinition setUpTestPatientCohortDefinition(PersonAttributeType te
159159
PersonAttributeCohortDefinition cohortDefinition = new PersonAttributeCohortDefinition();
160160
cohortDefinition.setName("Test Patients");
161161
cohortDefinition.setAttributeType(testAttributeType);
162-
cohortDefinition.setValues(Arrays.asList("true"));
162+
cohortDefinition.setValues(Collections.singletonList("true"));
163163
Context.getService(CohortDefinitionService.class).saveDefinition(cohortDefinition);
164164
return cohortDefinition;
165165
}
@@ -199,7 +199,7 @@ public String getKeyPrefix() {
199199
public CohortDefinition getTestPatients() {
200200
PersonAttributeCohortDefinition cohortDefinition = new PersonAttributeCohortDefinition();
201201
cohortDefinition.setAttributeType(Context.getPersonService().getPersonAttributeTypeByUuid(TEST_PATIENT_ATTR_TYPE_UUID));
202-
cohortDefinition.setValues(Arrays.asList("true"));
202+
cohortDefinition.setValues(Collections.singletonList("true"));
203203
return cohortDefinition;
204204
}
205205

api-tests/src/test/java/org/openmrs/module/reporting/data/visit/evaluator/VisitIdDataEvaluatorTest.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@
2222
import org.openmrs.module.reporting.evaluation.context.VisitEvaluationContext;
2323
import org.openmrs.module.reporting.query.visit.VisitIdSet;
2424
import org.openmrs.test.BaseModuleContextSensitiveTest;
25+
import org.openmrs.test.SkipBaseSetup;
2526

27+
@SkipBaseSetup
2628
public class VisitIdDataEvaluatorTest extends BaseModuleContextSensitiveTest{
2729

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

api-tests/src/test/java/org/openmrs/module/reporting/dataset/definition/evaluator/RepeatPerTimePeriodDataSetEvaluatorTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@
3030
import java.util.HashMap;
3131
import java.util.Map;
3232

33-
import static org.mockito.Matchers.argThat;
34-
import static org.mockito.Matchers.eq;
33+
import static org.mockito.ArgumentMatchers.argThat;
34+
import static org.mockito.ArgumentMatchers.eq;
3535
import static org.mockito.Mockito.mock;
3636
import static org.mockito.Mockito.verify;
3737

api-tests/src/test/java/org/openmrs/module/reporting/evaluation/EvaluationProfilerTest24On.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,14 @@
1515
import org.junit.BeforeClass;
1616
import org.junit.Test;
1717
import org.openmrs.api.context.Context;
18+
import org.openmrs.logging.MemoryAppender;
19+
import org.openmrs.logging.OpenmrsLoggingUtil;
1820
import org.openmrs.module.reporting.cohort.definition.GenderCohortDefinition;
1921
import org.openmrs.module.reporting.indicator.CohortIndicator;
2022
import org.openmrs.module.reporting.indicator.service.IndicatorService;
2123
import org.openmrs.module.reporting.test.OpenmrsVersionTestListener;
2224
import org.openmrs.module.reporting.test.RequiresVersion;
2325
import org.openmrs.test.BaseModuleContextSensitiveTest;
24-
import org.openmrs.util.MemoryAppender;
2526
import org.openmrs.util.OpenmrsUtil;
2627
import org.springframework.test.context.TestExecutionListeners;
2728

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

3940
@BeforeClass
4041
public static void beforeClass() {
41-
appender = OpenmrsUtil.getMemoryAppender();
42+
appender = OpenmrsLoggingUtil.getMemoryAppender();
4243

4344
if (appender == null) {
4445
LoggerContext context = (LoggerContext) LogManager.getContext(false);

api-tests/src/test/java/org/openmrs/module/reporting/query/encounter/evaluator/MappedParametersObsQueryEvaluatorTest.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import org.openmrs.module.reporting.query.obs.definition.MappedParametersObsQuery;
2222
import org.openmrs.module.reporting.query.obs.service.ObsQueryService;
2323
import org.openmrs.test.BaseModuleContextSensitiveTest;
24+
import org.openmrs.test.SkipBaseSetup;
2425

2526
import java.util.Date;
2627
import java.util.HashMap;
@@ -30,6 +31,7 @@
3031
import static org.junit.Assert.assertThat;
3132
import static org.junit.Assert.assertTrue;
3233

34+
@SkipBaseSetup
3335
public class MappedParametersObsQueryEvaluatorTest extends BaseModuleContextSensitiveTest {
3436

3537
protected static final String XML_DATASET_PATH = "org/openmrs/module/reporting/include/";
@@ -38,6 +40,8 @@ public class MappedParametersObsQueryEvaluatorTest extends BaseModuleContextSens
3840

3941
@Before
4042
public void setup() throws Exception {
43+
initializeInMemoryDatabase();
44+
authenticate();
4145
executeDataSet(XML_DATASET_PATH + new TestUtil().getTestDatasetFilename(XML_REPORT_TEST_DATASET));
4246
}
4347

0 commit comments

Comments
 (0)