Skip to content

Commit 8693c85

Browse files
authored
IDGEN-134: Update to OpenMRS Platform 2.8.x and Support Java 21 (#130)
1 parent ed6644d commit 8693c85

36 files changed

Lines changed: 378 additions & 284 deletions

.github/workflows/build-omod.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@ jobs:
99
build:
1010
uses: openmrs/openmrs-contrib-gha-workflows/.github/workflows/build-backend-module.yml@main
1111
with:
12-
java_versions: "[8]"
12+
java_versions: "[8, 11, 17, 21]"
1313
main_java_version: "8"

api/pom.xml

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,12 @@
33
<parent>
44
<groupId>org.openmrs.module</groupId>
55
<artifactId>idgen</artifactId>
6-
<version>5.1.0-SNAPSHOT</version>
6+
<version>6.0.0-SNAPSHOT</version>
77
</parent>
88
<groupId>org.openmrs.module</groupId>
99
<artifactId>idgen-api</artifactId>
1010
<packaging>jar</packaging>
1111
<name>ID Generation API</name>
1212
<description>API project for ID Generation</description>
1313

14-
<dependencies>
15-
<dependency>
16-
<groupId>org.codehaus.jackson</groupId>
17-
<artifactId>jackson-mapper-asl</artifactId>
18-
<version>1.5.0</version>
19-
<type>jar</type>
20-
<scope>provided</scope>
21-
</dependency>
22-
</dependencies>
23-
2414
</project>

api/src/main/java/org/openmrs/module/idgen/BaseIdentifierSource.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
import java.util.HashSet;
1818
import java.util.Set;
1919

20-
import org.codehaus.jackson.annotate.JsonIgnore;
20+
import com.fasterxml.jackson.annotation.JsonIgnore;
2121
import org.openmrs.PatientIdentifierType;
2222
import org.openmrs.User;
2323

api/src/main/java/org/openmrs/module/idgen/IdentifierPool.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,14 @@
1313
*/
1414
package org.openmrs.module.idgen;
1515

16+
import com.fasterxml.jackson.annotation.JsonIgnore;
17+
1618
import java.util.Collections;
1719
import java.util.Date;
1820
import java.util.HashSet;
1921
import java.util.LinkedHashSet;
2022
import java.util.Set;
2123

22-
import org.codehaus.jackson.annotate.JsonIgnore;
23-
2424
/**
2525
* Identifier Source which contains a pre-generated pool of identifiers,
2626
* and which typically is used in conjunction with another IdentifierSource

api/src/main/java/org/openmrs/module/idgen/PooledIdentifier.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,11 @@
1313
*/
1414
package org.openmrs.module.idgen;
1515

16+
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
17+
1618
import java.util.Date;
1719
import java.util.UUID;
1820

19-
import org.codehaus.jackson.annotate.JsonIgnoreProperties;
2021

2122
/**
2223
* Component which encapsulates an identifier that has been allocated to an Identifier Pool

api/src/main/java/org/openmrs/module/idgen/processor/RemoteIdentifierSourceProcessor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
import org.apache.http.impl.client.DefaultHttpClient;
2929
import org.apache.http.message.BasicNameValuePair;
3030
import org.apache.http.util.EntityUtils;
31-
import org.codehaus.jackson.map.ObjectMapper;
31+
import com.fasterxml.jackson.databind.ObjectMapper;
3232
import org.openmrs.module.idgen.IdentifierSource;
3333
import org.openmrs.module.idgen.RemoteIdentifierSource;
3434
import org.openmrs.module.idgen.RemoteIdentifiersMessage;

api/src/main/java/org/openmrs/module/idgen/service/IdentifierSourceService.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
import org.openmrs.module.idgen.PooledIdentifier;
2828
import org.openmrs.module.idgen.SequentialIdentifierGenerator;
2929
import org.openmrs.module.idgen.processor.IdentifierSourceProcessor;
30-
import org.openmrs.util.OpenmrsConstants;
30+
import org.openmrs.util.PrivilegeConstants;
3131

3232
import java.util.Date;
3333
import java.util.List;
@@ -107,21 +107,21 @@ public interface IdentifierSourceService extends OpenmrsService {
107107
* Given a PatientIdentifierType, generates an identifier using the proper IdentifierSource for this server
108108
* Returns null if this PatientIdentifierType is not set to be auto-generated
109109
*/
110-
@Authorized(OpenmrsConstants.PRIV_EDIT_PATIENT_IDENTIFIERS)
110+
@Authorized(PrivilegeConstants.EDIT_PATIENT_IDENTIFIERS)
111111
String generateIdentifier(PatientIdentifierType type, String comment);
112112

113113
/**
114114
* Given a PatientIdentifierType and Location, generates an identifier using the proper IdentifierSource
115115
* Returns null if this PatientIdentifierType is not set to be auto-generated
116116
*/
117-
@Authorized(OpenmrsConstants.PRIV_EDIT_PATIENT_IDENTIFIERS)
117+
@Authorized(PrivilegeConstants.EDIT_PATIENT_IDENTIFIERS)
118118
String generateIdentifier(PatientIdentifierType type, Location location, String comment);
119119

120120
/**
121121
* Generates a Single Identifiers from the given source
122122
* @throws APIException
123123
*/
124-
@Authorized(OpenmrsConstants.PRIV_EDIT_PATIENT_IDENTIFIERS)
124+
@Authorized(PrivilegeConstants.EDIT_PATIENT_IDENTIFIERS)
125125
String generateIdentifier(IdentifierSource source, String comment) throws APIException;
126126

127127
/**

api/src/main/java/org/openmrs/module/idgen/service/db/HibernateIdentifierSourceDAO.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ public Long getSequenceValue(SequentialIdentifierGenerator generator) {
312312

313313

314314
public void refreshIdentifierSource(IdentifierSource source) {
315-
sessionFactory.getCurrentSession().refresh(source);
315+
sessionFactory.getCurrentSession().refresh(source);
316316
}
317317

318318

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,16 @@
11
package org.openmrs.module.idgen;
22

3-
import org.hibernate.cfg.Environment;
4-
import org.junit.Before;
5-
import org.openmrs.test.BaseModuleContextSensitiveTest;
6-
7-
import java.util.Properties;
3+
import org.junit.jupiter.api.BeforeEach;
4+
import org.openmrs.test.jupiter.BaseModuleContextSensitiveTest;
85

96
/**
107
* Base class that can be used for an common functionality or modifications to the standard base module context sensitive test
118
*/
129
public abstract class IdgenBaseTest extends BaseModuleContextSensitiveTest {
1310

14-
@Before
15-
public void setupActivator() {
11+
@BeforeEach
12+
public void before() {
1613
new IdgenModuleActivator().started();
1714
}
1815

19-
@Override
20-
public Properties getRuntimeProperties() {
21-
Properties props = super.getRuntimeProperties();
22-
String url = props.getProperty(Environment.URL);
23-
if (url.contains("jdbc:h2:") && !url.toLowerCase().contains(";mvcc=true")) {
24-
props.setProperty(Environment.URL, url + ";mvcc=true");
25-
}
26-
return props;
27-
}
2816
}

api/src/test/java/org/openmrs/module/idgen/SequentialIdentifierGeneratorTest.java

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,14 @@
33
import static org.hamcrest.core.Is.is;
44
import static org.junit.Assert.assertThat;
55
import static org.mockito.Mockito.mock;
6+
import static org.mockito.Mockito.mockStatic;
67
import static org.mockito.Mockito.when;
7-
import static org.powermock.api.mockito.PowerMockito.mockStatic;
88

9+
import org.junit.After;
910
import org.junit.Assert;
1011
import org.junit.Before;
1112
import org.junit.Test;
12-
import org.junit.runner.RunWith;
13+
import org.mockito.MockedStatic;
1314
import org.openmrs.Location;
1415
import org.openmrs.LocationAttribute;
1516
import org.openmrs.LocationAttributeType;
@@ -20,19 +21,21 @@
2021
import org.openmrs.module.idgen.prefixprovider.PrefixProvider;
2122
import org.openmrs.module.idgen.suffixprovider.LocationBasedSuffixProvider;
2223
import org.openmrs.module.idgen.suffixprovider.SuffixProvider;
23-
import org.powermock.core.classloader.annotations.PrepareForTest;
24-
import org.powermock.modules.junit4.PowerMockRunner;
2524

2625
/**
2726
* test class for {@link SequentialIdentifierGenerator}
2827
*/
29-
@RunWith(PowerMockRunner.class)
30-
@PrepareForTest(Context.class)
3128
public class SequentialIdentifierGeneratorTest {
32-
29+
30+
private MockedStatic<Context> mockedContext;
3331
@Before
3432
public void setup() {
35-
mockStatic(Context.class);
33+
mockedContext = mockStatic(Context.class);
34+
}
35+
36+
@After
37+
public void teardown() {
38+
mockedContext.close();
3639
}
3740

3841
/**

0 commit comments

Comments
 (0)