diff --git a/.github/workflows/build-test-publish.yml b/.github/workflows/build-test-publish.yml index 978e6f00a..fce5dc3f4 100644 --- a/.github/workflows/build-test-publish.yml +++ b/.github/workflows/build-test-publish.yml @@ -11,14 +11,14 @@ jobs: steps: - uses: actions/checkout@v2 - - name: Set up JDK 8 + - name: Set up JDK 21 uses: actions/setup-java@v2 with: distribution: 'temurin' - java-version: '8' + java-version: '21' - name: Build and Test - run: mvn --batch-mode --update-snapshots clean package -P validator + run: mvn --batch-mode --update-snapshots clean package - name: Set settings.xml uses: s4u/maven-settings-action@v2.6.0 @@ -37,5 +37,5 @@ jobs: if: ${{ github.ref == 'refs/heads/main' && github.repository_owner == 'mekomsolutions' }} - name: Publish - run: mvn --batch-mode clean deploy -P validator + run: mvn --batch-mode clean deploy if: ${{ github.ref == 'refs/heads/main' && github.repository_owner == 'mekomsolutions' }} diff --git a/.github/workflows/build-test.yml b/.github/workflows/build-test.yml index 606d87ead..34af55718 100644 --- a/.github/workflows/build-test.yml +++ b/.github/workflows/build-test.yml @@ -12,7 +12,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - java: [ '8', '11'] + java: [ '21', '25' ] steps: - uses: actions/checkout@v2 @@ -24,4 +24,4 @@ jobs: java-version: ${{ matrix.java }} - name: Build and Test - run: mvn --batch-mode --update-snapshots clean package -P validator + run: mvn --batch-mode --update-snapshots clean package diff --git a/README.md b/README.md index 835c8a2c6..86d4342ed 100644 --- a/README.md +++ b/README.md @@ -191,7 +191,7 @@ mvn clean package ``` ### Runtime compatibility -* OpenMRS Core 2.1.1 (*required*) +* OpenMRS Core 3.0.0 (*required*), on Java 21 * Bahmni Appointments 1.2.1 (*compatible*) * Bahmni Core 0.93 (*compatible*) * Bahmni I.e Apps 1.1.0 (*compatible*) @@ -199,12 +199,16 @@ mvn clean package * Data Filter 1.0.0 (*compatible*) * Flags 3.0.9 (*compatible*) * HTML Form Entry 4.0.0 (*compatible*) -* ID Gen 4.3 (*compatible*) +* ID Gen 7.0.0 (*compatible*) * Metadata Sharing 1.2.2 (*compatible*) -* Metadata Mapping 1.3.4 (*compatible*) +* Metadata Mapping 3.0.0 (*compatible*) * Open Concept Lab 1.2.9 (*compatible*) * Tasks 1.0.0 (*compatible*) +Apart from ID Gen and Metadata Mapping, these modules have no OpenMRS Core 3.0 version yet, so Initializer is not tested against them on this version. + +On OpenMRS Core 2.x, use an Initializer 2.x release. + ### Test your OpenMRS configs See the [Initializer Validator README page](readme/validator.md). @@ -233,7 +237,10 @@ See the [documentation on Initializer's logging properties](readme/rtprops.md#lo ---- ## Releases notes -#### version 2.13.0 +#### version 3.0.0 +* Requires OpenMRS Core 3.0.0 and Java 21. Initializer 2.x releases remain the ones for OpenMRS Core 2.x. +* Most boolean CSV columns, `Void/Retire` included, and the `initializer.skip.checksums` and `initializer.row.checksums.enabled` properties now read `1` as true. Initializer 2.x read it as false. +* The [Initializer Validator](readme/validator.md) is not available for this version yet and remains on the 2.x line. #### version 2.12.1 * Fix order types domain to apply the parent for order types with concrete Java classes (e.g. org.openmrs.DrugOrder) diff --git a/api-2.2/pom.xml b/api-2.2/pom.xml index 02d07b114..a36bd1ebc 100644 --- a/api-2.2/pom.xml +++ b/api-2.2/pom.xml @@ -4,7 +4,7 @@ org.openmrs.module initializer - 2.13.0-SNAPSHOT + 3.0.0-SNAPSHOT initializer-api-2.2 @@ -12,9 +12,6 @@ Initializer API 2.2 API 2.2 project for Initializer - - ${openmrsVersion2.2} - diff --git a/api-2.2/src/test/java/org/openmrs/module/initializer/api/AttributeTypesLoaderTest2_2.java b/api-2.2/src/test/java/org/openmrs/module/initializer/api/AttributeTypesLoaderTest2_2.java index 830b9b037..3c86cba8a 100644 --- a/api-2.2/src/test/java/org/openmrs/module/initializer/api/AttributeTypesLoaderTest2_2.java +++ b/api-2.2/src/test/java/org/openmrs/module/initializer/api/AttributeTypesLoaderTest2_2.java @@ -2,12 +2,13 @@ import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.text.IsEmptyString.isEmptyOrNullString; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; import static org.openmrs.module.initializer.api.AttributeTypesLoaderTest.assertCustomDatatype; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; +import org.hamcrest.MatcherAssert; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.openmrs.ConceptAttributeType; import org.openmrs.ProgramAttributeType; import org.openmrs.api.ConceptService; @@ -30,7 +31,7 @@ public class AttributeTypesLoaderTest2_2 extends DomainBaseModuleContextSensitiv @Qualifier("programWorkflowService") private ProgramWorkflowService pws; - @Before + @BeforeEach public void setup() { executeDataSet("testdata/test-metadata-2.2.xml"); } @@ -40,13 +41,13 @@ public void load_shouldLoadAccordingToCsvFiles() { // Verify setup { ProgramAttributeType attType = pws.getProgramAttributeType(1089); - Assert.assertNotNull(attType); + Assertions.assertNotNull(attType); assertCustomDatatype(attType.getDatatypeClassname()); - Assert.assertEquals("org.openmrs.customdatatype.datatype.FloatDatatype", attType.getDatatypeClassname()); - Assert.assertEquals("Program Efficiency Score", attType.getName()); - Assert.assertEquals("Metric of the program efficiency", attType.getDescription()); - Assert.assertThat(attType.getMinOccurs(), is(0)); - Assert.assertThat(attType.getMaxOccurs(), is(1)); + Assertions.assertEquals("org.openmrs.customdatatype.datatype.FloatDatatype", attType.getDatatypeClassname()); + Assertions.assertEquals("Program Efficiency Score", attType.getName()); + Assertions.assertEquals("Metric of the program efficiency", attType.getDescription()); + MatcherAssert.assertThat(attType.getMinOccurs(), is(0)); + MatcherAssert.assertThat(attType.getMaxOccurs(), is(1)); } // Replay @@ -55,42 +56,42 @@ public void load_shouldLoadAccordingToCsvFiles() { // Verify creations { ConceptAttributeType attType = cs.getConceptAttributeTypeByUuid("7d002484-0fcd-4759-a67a-04dbf8fdaab1"); - Assert.assertNotNull(attType); + Assertions.assertNotNull(attType); assertCustomDatatype(attType.getDatatypeClassname()); - Assert.assertEquals("org.openmrs.customdatatype.datatype.LocationDatatype", attType.getDatatypeClassname()); - Assert.assertEquals("Concept Location", attType.getName()); + Assertions.assertEquals("org.openmrs.customdatatype.datatype.LocationDatatype", attType.getDatatypeClassname()); + Assertions.assertEquals("Concept Location", attType.getName()); assertThat(attType.getDescription(), isEmptyOrNullString()); - Assert.assertThat(attType.getMinOccurs(), is(1)); - Assert.assertThat(attType.getMaxOccurs(), is(1)); + MatcherAssert.assertThat(attType.getMinOccurs(), is(1)); + MatcherAssert.assertThat(attType.getMaxOccurs(), is(1)); } { ProgramAttributeType attType = pws.getProgramAttributeTypeByUuid("3884c889-35f5-47b4-a6b7-5b1165cee218"); - Assert.assertNotNull(attType); + Assertions.assertNotNull(attType); assertCustomDatatype(attType.getDatatypeClassname()); - Assert.assertEquals("org.openmrs.customdatatype.datatype.FreeTextDatatype", attType.getDatatypeClassname()); - Assert.assertEquals("Program Assessment", attType.getName()); - Assert.assertEquals("Program Assessment's description", attType.getDescription()); - Assert.assertNull(attType.getMinOccurs()); - Assert.assertNull(attType.getMaxOccurs()); + Assertions.assertEquals("org.openmrs.customdatatype.datatype.FreeTextDatatype", attType.getDatatypeClassname()); + Assertions.assertEquals("Program Assessment", attType.getName()); + Assertions.assertEquals("Program Assessment's description", attType.getDescription()); + Assertions.assertNull(attType.getMinOccurs()); + Assertions.assertNull(attType.getMaxOccurs()); } // Verify editions { ProgramAttributeType attType = pws.getProgramAttributeTypeByUuid("b1d98f27-c058-46f2-9c12-87dd7c92f7e3"); - Assert.assertNotNull(attType); + Assertions.assertNotNull(attType); assertCustomDatatype(attType.getDatatypeClassname()); - Assert.assertEquals("org.openmrs.customdatatype.datatype.FloatDatatype", attType.getDatatypeClassname()); - Assert.assertEquals("Program Efficiency Indicator", attType.getName()); - Assert.assertEquals("Metric of the program efficiency", attType.getDescription()); - Assert.assertThat(attType.getMinOccurs(), is(0)); - Assert.assertThat(attType.getMaxOccurs(), is(1)); + Assertions.assertEquals("org.openmrs.customdatatype.datatype.FloatDatatype", attType.getDatatypeClassname()); + Assertions.assertEquals("Program Efficiency Indicator", attType.getName()); + Assertions.assertEquals("Metric of the program efficiency", attType.getDescription()); + MatcherAssert.assertThat(attType.getMinOccurs(), is(0)); + MatcherAssert.assertThat(attType.getMaxOccurs(), is(1)); } // Verify retirement using name as the pivot { ConceptAttributeType attType = cs.getConceptAttributeTypeByName("Concept Family"); - Assert.assertNotNull(attType); - Assert.assertTrue(attType.getRetired()); + Assertions.assertNotNull(attType); + Assertions.assertTrue(attType.getRetired()); } } } diff --git a/api-2.2/src/test/java/org/openmrs/module/initializer/attributes/types/AttributeTypesProxyServiceTest.java b/api-2.2/src/test/java/org/openmrs/module/initializer/attributes/types/AttributeTypesProxyServiceTest.java index 953e4101b..8dfc434f1 100644 --- a/api-2.2/src/test/java/org/openmrs/module/initializer/attributes/types/AttributeTypesProxyServiceTest.java +++ b/api-2.2/src/test/java/org/openmrs/module/initializer/attributes/types/AttributeTypesProxyServiceTest.java @@ -3,10 +3,11 @@ import static org.hamcrest.CoreMatchers.is; import static org.openmrs.module.initializer.api.attributes.types.AttributeTypeEntity.CONCEPT; -import org.apache.commons.lang.RandomStringUtils; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; +import org.apache.commons.lang3.RandomStringUtils; +import org.hamcrest.MatcherAssert; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.openmrs.ConceptAttributeType; import org.openmrs.api.ConceptService; import org.openmrs.attribute.BaseAttributeType; @@ -26,7 +27,7 @@ public class AttributeTypesProxyServiceTest extends DomainBaseModuleContextSensi @Qualifier("conceptService") private ConceptService cs; - @Before + @BeforeEach public void setup() { executeDataSet("testdata/test-metadata-2.2.xml"); } @@ -37,9 +38,9 @@ public void getAttributeTypeByUuid_shouldGetAttributeType() { BaseAttributeType attType = service.getAttributeTypeByUuid(CONCEPT_ATT_TYPE_UUID, CONCEPT); // Verif - Assert.assertNotNull(attType); - Assert.assertThat(attType.getName(), is("Concept Family")); - Assert.assertTrue(attType instanceof ConceptAttributeType); + Assertions.assertNotNull(attType); + MatcherAssert.assertThat(attType.getName(), is("Concept Family")); + Assertions.assertTrue(attType instanceof ConceptAttributeType); } @Test @@ -54,7 +55,7 @@ public void saveAttributeType_shouldSaveAttributeType() { // Verif attType = service.getAttributeTypeByName(newName, CONCEPT); - Assert.assertNotNull(attType); - Assert.assertThat(attType.getId(), is(1089)); + Assertions.assertNotNull(attType); + MatcherAssert.assertThat(attType.getId(), is(1089)); } } diff --git a/api-2.3/pom.xml b/api-2.3/pom.xml index d3bc0f4de..09b4c8573 100644 --- a/api-2.3/pom.xml +++ b/api-2.3/pom.xml @@ -4,7 +4,7 @@ org.openmrs.module initializer - 2.13.0-SNAPSHOT + 3.0.0-SNAPSHOT initializer-api-2.3 @@ -12,9 +12,6 @@ Initializer API 2.3 API 2.3 project for Initializer - - ${openmrsVersion2.3} - @@ -60,6 +57,13 @@ appframework-api ${appframeworkVersion} test + + + + org.antlr + antlr4-runtime + + @@ -74,24 +78,22 @@ provided - - - jakarta.xml.bind - jakarta.xml.bind-api - 2.3.2 - test - - - - org.glassfish.jaxb - jaxb-runtime - 2.3.2 - test - - + + + org.apache.maven.plugins + maven-surefire-plugin + + + + **/DataFilterMappingsLoaderTest.java + **/QueueLoaderIntegrationTest.java + + + + ../api/src/test/resources diff --git a/api-2.3/src/main/java/org/openmrs/module/initializer/api/datafilter/mappings/DataFilterMappingLineProcessor.java b/api-2.3/src/main/java/org/openmrs/module/initializer/api/datafilter/mappings/DataFilterMappingLineProcessor.java index 92af81a46..5c5d3bb64 100644 --- a/api-2.3/src/main/java/org/openmrs/module/initializer/api/datafilter/mappings/DataFilterMappingLineProcessor.java +++ b/api-2.3/src/main/java/org/openmrs/module/initializer/api/datafilter/mappings/DataFilterMappingLineProcessor.java @@ -1,9 +1,12 @@ package org.openmrs.module.initializer.api.datafilter.mappings; -import org.hibernate.Criteria; +import jakarta.persistence.criteria.CriteriaBuilder; +import jakarta.persistence.criteria.CriteriaQuery; +import jakarta.persistence.criteria.Root; + import org.hibernate.HibernateException; +import org.hibernate.Session; import org.hibernate.SessionFactory; -import org.hibernate.criterion.Restrictions; import org.openmrs.OpenmrsObject; import org.openmrs.annotation.OpenmrsProfile; import org.openmrs.module.datafilter.impl.api.DataFilterService; @@ -33,9 +36,16 @@ public class DataFilterMappingLineProcessor extends BaseLineProcessor T getByUuid(Class clazz, String uuid) { + Session session = sessionFactory.getCurrentSession(); + CriteriaBuilder cb = session.getCriteriaBuilder(); + CriteriaQuery cq = cb.createQuery(clazz); + Root root = cq.from(clazz); + cq.where(cb.equal(root.get("uuid"), uuid)); + return session.createQuery(cq).uniqueResult(); } @Autowired diff --git a/api-2.3/src/main/java/org/openmrs/module/initializer/api/datafilter/mappings/DataFilterMappingsCsvParser.java b/api-2.3/src/main/java/org/openmrs/module/initializer/api/datafilter/mappings/DataFilterMappingsCsvParser.java index 02e6af9e9..be474b3f1 100644 --- a/api-2.3/src/main/java/org/openmrs/module/initializer/api/datafilter/mappings/DataFilterMappingsCsvParser.java +++ b/api-2.3/src/main/java/org/openmrs/module/initializer/api/datafilter/mappings/DataFilterMappingsCsvParser.java @@ -1,9 +1,12 @@ package org.openmrs.module.initializer.api.datafilter.mappings; -import org.hibernate.Criteria; +import jakarta.persistence.criteria.CriteriaBuilder; +import jakarta.persistence.criteria.CriteriaQuery; +import jakarta.persistence.criteria.Root; + import org.hibernate.HibernateException; +import org.hibernate.Session; import org.hibernate.SessionFactory; -import org.hibernate.criterion.Restrictions; import org.openmrs.OpenmrsObject; import org.openmrs.annotation.OpenmrsProfile; import org.openmrs.module.initializer.Domain; @@ -36,9 +39,16 @@ public Domain getDomain() { @Transactional(readOnly = true) public OpenmrsObject getOpenmrsObject(String uuid, String className) throws HibernateException, ClassNotFoundException { - Criteria criteria = sessionFactory.getCurrentSession().createCriteria(Class.forName(className)); - criteria.add(Restrictions.eq("uuid", uuid)); - return (OpenmrsObject) criteria.uniqueResult(); + return (OpenmrsObject) getByUuid(Class.forName(className), uuid); + } + + private T getByUuid(Class clazz, String uuid) { + Session session = sessionFactory.getCurrentSession(); + CriteriaBuilder cb = session.getCriteriaBuilder(); + CriteriaQuery cq = cb.createQuery(clazz); + Root root = cq.from(clazz); + cq.where(cb.equal(root.get("uuid"), uuid)); + return session.createQuery(cq).uniqueResult(); } @Override diff --git a/api-2.3/src/test/java/org/openmrs/module/initializer/DomainBaseModuleContextSensitive_2_3_Test.java b/api-2.3/src/test/java/org/openmrs/module/initializer/DomainBaseModuleContextSensitive_2_3_Test.java index 19f3f997d..b2e3b0088 100644 --- a/api-2.3/src/test/java/org/openmrs/module/initializer/DomainBaseModuleContextSensitive_2_3_Test.java +++ b/api-2.3/src/test/java/org/openmrs/module/initializer/DomainBaseModuleContextSensitive_2_3_Test.java @@ -9,11 +9,6 @@ */ package org.openmrs.module.initializer; -import org.openmrs.module.Module; -import org.openmrs.module.ModuleFactory; - -import java.io.File; - /** * This allows to perform Spring context sensitive tests when Data Filter API is a dependency. In * that case it is necessary for each context sensitive test to update the search index. @@ -22,11 +17,7 @@ public abstract class DomainBaseModuleContextSensitive_2_3_Test extends DomainBa public DomainBaseModuleContextSensitive_2_3_Test() { super(); - { - Module mod = new Module("", "queue", "", "", "", "1.0.0"); - mod.setFile(new File("")); - ModuleFactory.getStartedModulesMap().put(mod.getModuleId(), mod); - } + // queue is not started: it has no Platform 3.0 release yet, see Platform3ModuleContextLoader } @Override diff --git a/api-2.3/src/test/java/org/openmrs/module/initializer/api/DataFilterMappingsLoaderTest.java b/api-2.3/src/test/java/org/openmrs/module/initializer/api/DataFilterMappingsLoaderTest.java index 4689f42b7..8e3e53c94 100644 --- a/api-2.3/src/test/java/org/openmrs/module/initializer/api/DataFilterMappingsLoaderTest.java +++ b/api-2.3/src/test/java/org/openmrs/module/initializer/api/DataFilterMappingsLoaderTest.java @@ -1,8 +1,8 @@ package org.openmrs.module.initializer.api; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.openmrs.api.LocationService; import org.openmrs.api.ProgramWorkflowService; import org.openmrs.api.UserService; @@ -32,7 +32,7 @@ public class DataFilterMappingsLoaderTest extends DomainBaseModuleContextSensiti @Autowired private DataFilterService dfs; - @Before + @BeforeEach public void setup() { executeDataSet("testdata/test-metadata.xml"); @@ -45,9 +45,9 @@ public void load_shouldLoadAccordingToCsvFiles() { loader.load(); // verify new access for entity through basis - Assert.assertTrue(dfs.hasAccess(us.getRole("test-entity-role"), pws.getProgram(4089))); + Assertions.assertTrue(dfs.hasAccess(us.getRole("test-entity-role"), pws.getProgram(4089))); // verify revoked access for entity through basis - Assert.assertFalse(dfs.hasAccess(us.getPrivilege("Add Apples"), ls.getLocation(4089))); + Assertions.assertFalse(dfs.hasAccess(us.getPrivilege("Add Apples"), ls.getLocation(4089))); } } diff --git a/api-2.3/src/test/java/org/openmrs/module/initializer/api/DrugsLoaderWithMappingsIntegrationTest.java b/api-2.3/src/test/java/org/openmrs/module/initializer/api/DrugsLoaderWithMappingsIntegrationTest.java index 11bf29c64..c32e3b66d 100644 --- a/api-2.3/src/test/java/org/openmrs/module/initializer/api/DrugsLoaderWithMappingsIntegrationTest.java +++ b/api-2.3/src/test/java/org/openmrs/module/initializer/api/DrugsLoaderWithMappingsIntegrationTest.java @@ -11,9 +11,9 @@ import java.util.Locale; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.openmrs.Concept; import org.openmrs.ConceptName; import org.openmrs.ConceptSource; @@ -34,7 +34,7 @@ public class DrugsLoaderWithMappingsIntegrationTest extends DomainBaseModuleCont @Autowired private DrugsLoader loader; - @Before + @BeforeEach public void setup() { // A concept to be used as 'dosage form' @@ -126,58 +126,58 @@ public void load_shouldLoadDrugsAccordingToCsvFiles() { // a vanilla drug { Drug d = cs.getDrug("Cetirizine 10mg Tablet"); - Assert.assertNotNull(d); - Assert.assertEquals(cs.getConceptByName("Cetirizine"), d.getConcept()); - Assert.assertEquals(cs.getConceptByName("Tablet"), d.getDosageForm()); + Assertions.assertNotNull(d); + Assertions.assertEquals(cs.getConceptByName("Cetirizine"), d.getConcept()); + Assertions.assertEquals(cs.getConceptByName("Tablet"), d.getDosageForm()); assertMappings(d, "SAME-AS:CS1:M1"); } // a drug without dosage form { Drug d = cs.getDrug("Erythromycine 500mg Tablet"); - Assert.assertNotNull(d); - Assert.assertEquals(cs.getConceptByName("Erythromycine"), d.getConcept()); - Assert.assertNull(d.getDosageForm()); + Assertions.assertNotNull(d); + Assertions.assertEquals(cs.getConceptByName("Erythromycine"), d.getConcept()); + Assertions.assertNull(d.getDosageForm()); assertMappings(d, "SAME-AS:CS1:M2", "SAME-AS:CS1:M3"); } // an edited drug { Drug d = cs.getDrug("Metronidazole 500mg Tablet"); - Assert.assertNotNull(d); - Assert.assertEquals(cs.getConceptByName("Metronidazole (new)"), d.getConcept()); - Assert.assertEquals(cs.getConceptByName("Tablet"), d.getDosageForm()); + Assertions.assertNotNull(d); + Assertions.assertEquals(cs.getConceptByName("Metronidazole (new)"), d.getConcept()); + Assertions.assertEquals(cs.getConceptByName("Tablet"), d.getDosageForm()); assertMappings(d, "broader-than:CS2:M4"); } // an edited drug fetched by name { Drug d = cs.getDrugByUuid("42f010f8-26fe-102b-80cb-0017a47871b2"); - Assert.assertNotNull(d); - Assert.assertEquals(cs.getConceptByName("d4T"), d.getConcept()); - Assert.assertEquals("30mg", d.getStrength()); + Assertions.assertNotNull(d); + Assertions.assertEquals(cs.getConceptByName("d4T"), d.getConcept()); + Assertions.assertEquals("30mg", d.getStrength()); assertMappings(d, "broader-than:CS1:M5", "broader-than:CS2:M6"); } // a new drug that starts out retired { Drug d = cs.getDrugByUuid("6e764d43-ae8b-11eb-8168-0242ac110002"); - Assert.assertNotNull(d); - Assert.assertEquals(cs.getConceptByName("Metronidazole (new)"), d.getConcept()); - Assert.assertEquals(cs.getConceptByName("Tablet"), d.getDosageForm()); - Assert.assertEquals("250mg", d.getStrength()); - Assert.assertTrue(d.getRetired()); + Assertions.assertNotNull(d); + Assertions.assertEquals(cs.getConceptByName("Metronidazole (new)"), d.getConcept()); + Assertions.assertEquals(cs.getConceptByName("Tablet"), d.getDosageForm()); + Assertions.assertEquals("250mg", d.getStrength()); + Assertions.assertTrue(d.getRetired()); assertMappings(d); } { Drug d = cs.getDrug("Albendazole 200mg Tablet"); - Assert.assertNotNull(d); - Assert.assertEquals(cs.getConceptByName("Albendazole"), d.getConcept()); - Assert.assertEquals(cs.getConceptByName("Tablet"), d.getDosageForm()); + Assertions.assertNotNull(d); + Assertions.assertEquals(cs.getConceptByName("Albendazole"), d.getConcept()); + Assertions.assertEquals(cs.getConceptByName("Tablet"), d.getDosageForm()); assertMappings(d, "SAME-AS:CS1:M7", "SAME-AS:CS1:M8"); } } protected void assertMappings(Drug d, String... mappings) { - Assert.assertEquals(d.getDrugReferenceMaps().size(), mappings.length); + Assertions.assertEquals(d.getDrugReferenceMaps().size(), mappings.length); for (String mapping : mappings) { String[] components = mapping.split(":"); String mapTypeName = components[0]; @@ -194,7 +194,7 @@ protected void assertMappings(Drug d, String... mappings) { } } if (!found) { - Assert.fail("Mapping " + mapping + " not found."); + Assertions.fail("Mapping " + mapping + " not found."); } } } diff --git a/api-2.3/src/test/java/org/openmrs/module/initializer/api/loaders/LoadersOrderTest.java b/api-2.3/src/test/java/org/openmrs/module/initializer/api/loaders/LoadersOrderTest.java index 2f0b131a9..9e568b8d8 100644 --- a/api-2.3/src/test/java/org/openmrs/module/initializer/api/loaders/LoadersOrderTest.java +++ b/api-2.3/src/test/java/org/openmrs/module/initializer/api/loaders/LoadersOrderTest.java @@ -22,7 +22,7 @@ import org.hamcrest.Description; import org.hamcrest.Matcher; import org.hamcrest.TypeSafeDiagnosingMatcher; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.openmrs.module.initializer.Domain; import org.openmrs.module.initializer.DomainBaseModuleContextSensitive_2_3_Test; @@ -79,6 +79,22 @@ protected boolean matchesSafely(List loaders, Description mismatchDescri exclude.add(Domain.FLAG_PRIORITIES.getName()); exclude.add(Domain.FLAG_TAGS.getName()); exclude.add(Domain.PROCEDURE_TYPES.getName()); + // the liquibase loader active on Platform 3.0 lives in api-2.5 + exclude.add(Domain.LIQUIBASE.getName()); + // optional modules that have no Platform 3.0 release yet are not started in the test context + exclude.add(Domain.METADATASHARING.getName()); + exclude.add(Domain.PROVIDER_ROLES.getName()); + exclude.add(Domain.SYSTEM_TASKS.getName()); + exclude.add(Domain.ADDRESS_HIERARCHY.getName()); + exclude.add(Domain.BAHMNI_FORMS.getName()); + exclude.add(Domain.OCL.getName()); + exclude.add(Domain.APPOINTMENT_SPECIALITIES.getName()); + exclude.add(Domain.APPOINTMENT_SERVICE_DEFINITIONS.getName()); + exclude.add(Domain.APPOINTMENT_SERVICE_TYPES.getName()); + exclude.add(Domain.QUEUES.getName()); + exclude.add(Domain.DATAFILTER_MAPPINGS.getName()); + exclude.add(Domain.HTML_FORMS.getName()); + exclude.add(Domain.DISPOSITIONS.getName()); boolean result = true; Set loaderDomains = loaders.stream().map(Loader::getDomainName).collect(Collectors.toSet()); diff --git a/api-2.3/src/test/java/org/openmrs/module/initializer/api/queues/QueueLoaderIntegrationTest.java b/api-2.3/src/test/java/org/openmrs/module/initializer/api/queues/QueueLoaderIntegrationTest.java index 736f5eb23..c33d4a13c 100644 --- a/api-2.3/src/test/java/org/openmrs/module/initializer/api/queues/QueueLoaderIntegrationTest.java +++ b/api-2.3/src/test/java/org/openmrs/module/initializer/api/queues/QueueLoaderIntegrationTest.java @@ -9,9 +9,9 @@ */ package org.openmrs.module.initializer.api.queues; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.openmrs.module.initializer.DomainBaseModuleContextSensitive_2_3_Test; import org.openmrs.module.queue.api.QueueService; import org.openmrs.module.queue.model.Queue; @@ -27,7 +27,7 @@ public class QueueLoaderIntegrationTest extends DomainBaseModuleContextSensitive @Autowired private QueueLoader loader; - @Before + @BeforeEach public void setup() throws Exception { executeDataSet("testdata/test-queues.xml"); } @@ -38,11 +38,11 @@ public void load_shouldLoadAccordingToCsvFiles() throws Exception { // Initial Queue { Queue queue = queueService.getQueueByUuid("2a0e0eee-6888-11ee-ab8d-0242ac120002").orElse(null); - Assert.assertNotNull(queue); - Assert.assertEquals("Initial Queue", queue.getName()); - Assert.assertEquals("", queue.getDescription()); - Assert.assertEquals(2001, queue.getService().getConceptId().intValue()); - Assert.assertEquals(1, queue.getLocation().getLocationId().intValue()); + Assertions.assertNotNull(queue); + Assertions.assertEquals("Initial Queue", queue.getName()); + Assertions.assertEquals("", queue.getDescription()); + Assertions.assertEquals(2001, queue.getService().getConceptId().intValue()); + Assertions.assertEquals(1, queue.getLocation().getLocationId().intValue()); } loader.load(); @@ -50,31 +50,31 @@ public void load_shouldLoadAccordingToCsvFiles() throws Exception { // Revised Queue { Queue queue = queueService.getQueueByUuid("2a0e0eee-6888-11ee-ab8d-0242ac120002").orElse(null); - Assert.assertNotNull(queue); - Assert.assertEquals("Revised Queue", queue.getName()); - Assert.assertEquals("Revised Description", queue.getDescription()); - Assert.assertEquals(2002, queue.getService().getConceptId().intValue()); - Assert.assertEquals(2, queue.getLocation().getLocationId().intValue()); + Assertions.assertNotNull(queue); + Assertions.assertEquals("Revised Queue", queue.getName()); + Assertions.assertEquals("Revised Description", queue.getDescription()); + Assertions.assertEquals(2002, queue.getService().getConceptId().intValue()); + Assertions.assertEquals(2, queue.getLocation().getLocationId().intValue()); } // New Queue { Queue queue = queueService.getQueueByUuid("288db1cc-688a-11ee-ab8d-0242ac120002").orElse(null); - Assert.assertNotNull(queue); - Assert.assertEquals("New Queue", queue.getName()); - Assert.assertEquals("New Description", queue.getDescription()); - Assert.assertEquals(2001, queue.getService().getConceptId().intValue()); - Assert.assertEquals(3, queue.getLocation().getLocationId().intValue()); + Assertions.assertNotNull(queue); + Assertions.assertEquals("New Queue", queue.getName()); + Assertions.assertEquals("New Description", queue.getDescription()); + Assertions.assertEquals(2001, queue.getService().getConceptId().intValue()); + Assertions.assertEquals(3, queue.getLocation().getLocationId().intValue()); } // Queue with statuses { Queue queue = queueService.getQueueByUuid("4856c1c1-c9b3-4a7e-8669-4220051ab640").orElse(null); - Assert.assertNotNull(queue); - Assert.assertEquals("Triage Queue", queue.getName()); - Assert.assertEquals("Queue with custom statuses", queue.getDescription()); - Assert.assertEquals(2001, queue.getService().getConceptId().intValue()); - Assert.assertEquals(2003, queue.getStatusConceptSet().getConceptId().intValue()); - Assert.assertEquals("Triage queue priorities", queue.getPriorityConceptSet().getName().getName()); - Assert.assertEquals("Xanadu", queue.getLocation().getName()); + Assertions.assertNotNull(queue); + Assertions.assertEquals("Triage Queue", queue.getName()); + Assertions.assertEquals("Queue with custom statuses", queue.getDescription()); + Assertions.assertEquals(2001, queue.getService().getConceptId().intValue()); + Assertions.assertEquals(2003, queue.getStatusConceptSet().getConceptId().intValue()); + Assertions.assertEquals("Triage queue priorities", queue.getPriorityConceptSet().getName().getName()); + Assertions.assertEquals("Xanadu", queue.getLocation().getName()); } } } diff --git a/api-2.4/pom.xml b/api-2.4/pom.xml index 3f0ef4c15..f101c8ff1 100644 --- a/api-2.4/pom.xml +++ b/api-2.4/pom.xml @@ -5,7 +5,7 @@ initializer org.openmrs.module - 2.13.0-SNAPSHOT + 3.0.0-SNAPSHOT 4.0.0 @@ -15,9 +15,7 @@ API 2.4 project for Initializer - ${openmrsVersion2.4} 2.2.0 - 2.0.0 @@ -94,12 +92,6 @@ test - - org.openmrs.module - fhir2-api-2.5 - ${fhir2Version} - test - org.openmrs.module diff --git a/api-2.4/src/main/java/org/openmrs/module/initializer/api/logging/InitializerLogConfigurator2_4.java b/api-2.4/src/main/java/org/openmrs/module/initializer/api/logging/InitializerLogConfigurator2_4.java index 530407229..4eb750cb7 100644 --- a/api-2.4/src/main/java/org/openmrs/module/initializer/api/logging/InitializerLogConfigurator2_4.java +++ b/api-2.4/src/main/java/org/openmrs/module/initializer/api/logging/InitializerLogConfigurator2_4.java @@ -15,7 +15,7 @@ import org.openmrs.annotation.OpenmrsProfile; import org.openmrs.module.initializer.InitializerActivator; -@OpenmrsProfile(openmrsPlatformVersion = "2.1.5 - 2.1.*, 2.4.* - 2.*") +@OpenmrsProfile(openmrsPlatformVersion = "2.1.5 - 2.1.*, 2.4.* - 9.*") public class InitializerLogConfigurator2_4 implements InitializerLogConfigurator { @Override diff --git a/api-2.4/src/test/java/org/openmrs/module/initializer/api/DomainBaseModuleContextSensitive_2_4_test.java b/api-2.4/src/test/java/org/openmrs/module/initializer/api/DomainBaseModuleContextSensitive_2_4_test.java index 8f92eb699..3062d6fcb 100644 --- a/api-2.4/src/test/java/org/openmrs/module/initializer/api/DomainBaseModuleContextSensitive_2_4_test.java +++ b/api-2.4/src/test/java/org/openmrs/module/initializer/api/DomainBaseModuleContextSensitive_2_4_test.java @@ -24,7 +24,7 @@ public abstract class DomainBaseModuleContextSensitive_2_4_test extends DomainBa public DomainBaseModuleContextSensitive_2_4_test() { super(); { - Module mod = new Module("", "billing", "", "", "", "1.1.0"); + Module mod = new Module("", "billing", "", "", "", "1.1.0", ""); mod.setFile(new File("")); ModuleFactory.getStartedModulesMap().put(mod.getModuleId(), mod); } diff --git a/api-2.5/pom.xml b/api-2.5/pom.xml index c0f7ed89b..189a2717b 100644 --- a/api-2.5/pom.xml +++ b/api-2.5/pom.xml @@ -5,7 +5,7 @@ initializer org.openmrs.module - 2.13.0-SNAPSHOT + 3.0.0-SNAPSHOT 4.0.0 @@ -15,7 +15,6 @@ API 2.5 project for Initializer - ${openmrsVersion2.5} 2.2.0 @@ -87,12 +86,6 @@ test-jar - - org.openmrs.module - fhir2-api-2.5 - ${fhir2Version} - provided - org.openmrs.module diff --git a/api-2.5/src/main/java/org/openmrs/module/initializer/api/loaders/LiquibaseLoader2_5.java b/api-2.5/src/main/java/org/openmrs/module/initializer/api/loaders/LiquibaseLoader2_5.java index 7e4c95261..0c76744e4 100644 --- a/api-2.5/src/main/java/org/openmrs/module/initializer/api/loaders/LiquibaseLoader2_5.java +++ b/api-2.5/src/main/java/org/openmrs/module/initializer/api/loaders/LiquibaseLoader2_5.java @@ -1,6 +1,7 @@ package org.openmrs.module.initializer.api.loaders; import org.openmrs.annotation.OpenmrsProfile; +import org.openmrs.api.cache.GlobalPropertyCache; import org.openmrs.api.context.Context; import org.openmrs.liquibase.ChangeSetExecutorCallback; import org.openmrs.module.initializer.Domain; @@ -43,6 +44,11 @@ protected void load(File file) throws Exception { log.error("An error occurred executing liquibase file: " + file, e); throw e; } + finally { + // Changesets write with SQL, behind the back of Platform 3.0's global property cache, and the ones that + // ran before a failing changeset stay committed + Context.getRegisteredComponent("globalPropertyCache", GlobalPropertyCache.class).clear(); + } } } diff --git a/api-2.5/src/test/java/org/openmrs/module/initializer/api/loaders/LiquibaseLoader25IntegrationTest.java b/api-2.5/src/test/java/org/openmrs/module/initializer/api/loaders/LiquibaseLoader25IntegrationTest.java index 390974ab7..33d6ed66b 100644 --- a/api-2.5/src/test/java/org/openmrs/module/initializer/api/loaders/LiquibaseLoader25IntegrationTest.java +++ b/api-2.5/src/test/java/org/openmrs/module/initializer/api/loaders/LiquibaseLoader25IntegrationTest.java @@ -10,16 +10,17 @@ package org.openmrs.module.initializer.api.loaders; import org.apache.commons.io.IOUtils; -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.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.openmrs.api.AdministrationService; import org.openmrs.module.initializer.DomainBaseModuleContextSensitiveTest; import org.openmrs.util.OpenmrsClassLoader; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; +import java.io.File; import java.nio.charset.StandardCharsets; import java.util.List; @@ -32,7 +33,7 @@ public class LiquibaseLoader25IntegrationTest extends DomainBaseModuleContextSen @Qualifier("adminService") private AdministrationService adminService; - @Before + @BeforeEach public void setup() throws Exception { System.setProperty("useInMemoryDatabase", "true"); ClassLoader cl = OpenmrsClassLoader.getInstance(); @@ -40,7 +41,7 @@ public void setup() throws Exception { adminService.executeSQL(schemaSql, false); } - @After + @AfterEach public void teardown() { adminService.executeSQL("drop table LIQUIBASECHANGELOG", false); adminService.executeSQL("drop table LIQUIBASECHANGELOGLOCK", false); @@ -50,15 +51,36 @@ public void teardown() { public void load_shouldExecuteNewChangeSet() { String relativePath = "configuration/liquibase/liquibase.xml"; String absolutePath = getAppDataDirPath() + relativePath; - Assert.assertEquals(0, numChangeLogEntries(absolutePath)); - Assert.assertEquals(0, numChangeLogEntries(relativePath)); - Assert.assertNull(adminService.getGlobalProperty("test_changes_1")); - Assert.assertNull(adminService.getGlobalProperty("test_changes_2")); + Assertions.assertEquals(0, numChangeLogEntries(absolutePath)); + Assertions.assertEquals(0, numChangeLogEntries(relativePath)); + Assertions.assertNull(adminService.getGlobalProperty("test_changes_1")); + Assertions.assertNull(adminService.getGlobalProperty("test_changes_2")); loader.load(); - Assert.assertEquals(0, numChangeLogEntries(absolutePath)); - Assert.assertEquals(2, numChangeLogEntries(relativePath)); - Assert.assertEquals("true", adminService.getGlobalProperty("test_changes_1")); - Assert.assertEquals("true", adminService.getGlobalProperty("test_changes_2")); + Assertions.assertEquals(0, numChangeLogEntries(absolutePath)); + Assertions.assertEquals(2, numChangeLogEntries(relativePath)); + Assertions.assertEquals("true", adminService.getGlobalProperty("test_changes_1")); + Assertions.assertEquals("true", adminService.getGlobalProperty("test_changes_2")); + } + + @Test + public void load_shouldRefreshGlobalPropertiesWrittenBeforeAChangeSetFails() { + String relativePath = "liquibaseWithAFailingChangeSet/liquibase.xml"; + File changelog = new File(getAppDataDirPath() + relativePath); + Assertions.assertNull(adminService.getGlobalProperty("test_changes_before_failure")); + Assertions.assertThrows(Exception.class, () -> loader.load(changelog)); + Assertions.assertEquals(1, numChangeLogEntries(relativePath)); + Assertions.assertEquals("true", adminService.getGlobalProperty("test_changes_before_failure")); + } + + @Test + public void load_shouldExecuteALoadDataChangeSet() throws Exception { + String relativePath = "liquibaseWithLoadData/liquibase.xml"; + Assertions.assertNull(adminService.getGlobalProperty("test_load_data_1")); + Assertions.assertNull(adminService.getGlobalProperty("test_load_data_2")); + loader.load(new File(getAppDataDirPath() + relativePath)); + Assertions.assertEquals(1, numChangeLogEntries(relativePath)); + Assertions.assertEquals("loaded from a CSV file", adminService.getGlobalProperty("test_load_data_1")); + Assertions.assertEquals("also loaded", adminService.getGlobalProperty("test_load_data_2")); } @Test @@ -66,11 +88,11 @@ public void load_shouldUpdateAbsolutePathToRelativePathIfNeeded() { String relativePath = "configuration/liquibase/liquibase.xml"; String absolutePath = getAppDataDirPath() + relativePath; insertExistingChangeLogEntry(absolutePath); - Assert.assertEquals(1, numChangeLogEntries(absolutePath)); - Assert.assertEquals(0, numChangeLogEntries(relativePath)); + Assertions.assertEquals(1, numChangeLogEntries(absolutePath)); + Assertions.assertEquals(0, numChangeLogEntries(relativePath)); loader.updateExistingLiquibaseChangeLogPathsIfNeeded(absolutePath, relativePath); - Assert.assertEquals(0, numChangeLogEntries(absolutePath)); - Assert.assertEquals(1, numChangeLogEntries(relativePath)); + Assertions.assertEquals(0, numChangeLogEntries(absolutePath)); + Assertions.assertEquals(1, numChangeLogEntries(relativePath)); } private int numChangeLogEntries(String filename) { diff --git a/api-2.5/src/test/resources/liquibase-schema.sql b/api-2.5/src/test/resources/liquibase-schema.sql index 037113bd8..723e8992c 100644 --- a/api-2.5/src/test/resources/liquibase-schema.sql +++ b/api-2.5/src/test/resources/liquibase-schema.sql @@ -4,7 +4,7 @@ CREATE TABLE LIQUIBASECHANGELOG AUTHOR varchar(255) NOT NULL, FILENAME varchar(255) NOT NULL, DATEEXECUTED datetime NOT NULL, - ORDEREXECUTED int(11) NOT NULL, + ORDEREXECUTED int NOT NULL, EXECTYPE varchar(10) NOT NULL, MD5SUM varchar(35), DESCRIPTION varchar(255), @@ -19,8 +19,8 @@ CREATE TABLE LIQUIBASECHANGELOG CREATE TABLE LIQUIBASECHANGELOGLOCK ( - ID int(11) NOT NULL, - LOCKED tinyint(1) NOT NULL, + ID int NOT NULL, + LOCKED tinyint NOT NULL, LOCKGRANTED datetime, LOCKEDBY varchar(255), PRIMARY KEY (ID) diff --git a/api-2.5/src/test/resources/testAppDataDir/liquibaseWithAFailingChangeSet/liquibase.xml b/api-2.5/src/test/resources/testAppDataDir/liquibaseWithAFailingChangeSet/liquibase.xml new file mode 100644 index 000000000..3ccba9219 --- /dev/null +++ b/api-2.5/src/test/resources/testAppDataDir/liquibaseWithAFailingChangeSet/liquibase.xml @@ -0,0 +1,17 @@ + + + + + + + insert into global_property (uuid, property, property_value) values (uuid(), 'test_changes_before_failure', 'true') + + + + update table_that_does_not_exist set property_value = 'true' + + + diff --git a/api-2.5/src/test/resources/testAppDataDir/liquibaseWithLoadData/globalproperties.csv b/api-2.5/src/test/resources/testAppDataDir/liquibaseWithLoadData/globalproperties.csv new file mode 100644 index 000000000..797fd2ce9 --- /dev/null +++ b/api-2.5/src/test/resources/testAppDataDir/liquibaseWithLoadData/globalproperties.csv @@ -0,0 +1,3 @@ +property,property_value,uuid +test_load_data_1,loaded from a CSV file,6d8a3f6e-1c4b-4f1a-9a3e-0f2b6c1d7e01 +test_load_data_2,also loaded,6d8a3f6e-1c4b-4f1a-9a3e-0f2b6c1d7e02 diff --git a/api-2.5/src/test/resources/testAppDataDir/liquibaseWithLoadData/liquibase.xml b/api-2.5/src/test/resources/testAppDataDir/liquibaseWithLoadData/liquibase.xml new file mode 100644 index 000000000..4f1147b1d --- /dev/null +++ b/api-2.5/src/test/resources/testAppDataDir/liquibaseWithLoadData/liquibase.xml @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + diff --git a/api-2.7/pom.xml b/api-2.7/pom.xml index 02c3bed86..882b32c85 100644 --- a/api-2.7/pom.xml +++ b/api-2.7/pom.xml @@ -5,7 +5,7 @@ org.openmrs.module initializer - 2.13.0-SNAPSHOT + 3.0.0-SNAPSHOT 4.0.0 @@ -15,8 +15,6 @@ API 2.7 project for Initializer - ${openmrsVersion2.7} - 2.2.0 2.0.0 @@ -66,19 +64,7 @@ test-jar - - org.openmrs.module - fhir2-api-2.5 - ${fhir2Version2.2} - provided - - - org.openmrs.module - fhir2-api-2.6 - ${fhir2Version2.2} - provided - org.openmrs.module @@ -95,4 +81,18 @@ + + + + org.apache.maven.plugins + maven-surefire-plugin + + + + **/billing/*LoaderIntegrationTest.java + + + + + diff --git a/api-2.7/src/main/java/org/openmrs/module/initializer/api/conceptreferencerange/ConceptReferenceRangeLoader.java b/api-2.7/src/main/java/org/openmrs/module/initializer/api/conceptreferencerange/ConceptReferenceRangeLoader.java index c3510603e..5c20e4678 100644 --- a/api-2.7/src/main/java/org/openmrs/module/initializer/api/conceptreferencerange/ConceptReferenceRangeLoader.java +++ b/api-2.7/src/main/java/org/openmrs/module/initializer/api/conceptreferencerange/ConceptReferenceRangeLoader.java @@ -6,7 +6,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; -@OpenmrsProfile(openmrsPlatformVersion = "2.7.0 - 2.*") +@OpenmrsProfile(openmrsPlatformVersion = "2.7.0 - 9.*") @Component public class ConceptReferenceRangeLoader extends BaseCsvLoader { diff --git a/api-2.7/src/test/java/org/openmrs/module/initializer/DomainBaseModuleContextSensitive_2_7_Test.java b/api-2.7/src/test/java/org/openmrs/module/initializer/DomainBaseModuleContextSensitive_2_7_Test.java index d9f6074c2..6295f1f67 100644 --- a/api-2.7/src/test/java/org/openmrs/module/initializer/DomainBaseModuleContextSensitive_2_7_Test.java +++ b/api-2.7/src/test/java/org/openmrs/module/initializer/DomainBaseModuleContextSensitive_2_7_Test.java @@ -9,80 +9,26 @@ public abstract class DomainBaseModuleContextSensitive_2_7_Test extends DomainBa @Override public void initModules() { - { - Module mod = new Module("", "addresshierarchy", "", "", "", "2.17.0", ""); - mod.setFile(new File("")); - ModuleFactory.getStartedModulesMap().put(mod.getModuleId(), mod); - } - { - Module mod = new Module("", "exti18n", "", "", "", "1.0.0", ""); - mod.setFile(new File("")); - ModuleFactory.getStartedModulesMap().put(mod.getModuleId(), mod); - } + // Only the optional modules that have a Platform 3.0 release are started, see Platform3ModuleContextLoader { Module mod = new Module("", "fhir2", "", "", "", "1.6.0", ""); mod.setFile(new File("")); ModuleFactory.getStartedModulesMap().put(mod.getModuleId(), mod); } - { - Module mod = new Module("", "openconceptlab", "", "", "", "1.2.9", ""); - mod.setFile(new File("")); - ModuleFactory.getStartedModulesMap().put(mod.getModuleId(), mod); - } - { - Module mod = new Module("", "htmlformentry", "", "", "", "4.0.0", ""); - mod.setFile(new File("")); - ModuleFactory.getStartedModulesMap().put(mod.getModuleId(), mod); - } { Module mod = new Module("", "idgen", "", "", "", "4.6.0", ""); mod.setFile(new File("")); ModuleFactory.getStartedModulesMap().put(mod.getModuleId(), mod); } - { - Module mod = new Module("", "metadatasharing", "", "", "", "1.2.2", ""); - mod.setFile(new File("")); - ModuleFactory.getStartedModulesMap().put(mod.getModuleId(), mod); - } { Module mod = new Module("", "metadatamapping", "", "", "", "1.3.4", ""); mod.setFile(new File("")); ModuleFactory.getStartedModulesMap().put(mod.getModuleId(), mod); } - { - Module mod = new Module("", "appointments", "", "", "", "1.2", ""); - mod.setFile(new File("")); - ModuleFactory.getStartedModulesMap().put(mod.getModuleId(), mod); - } - { - Module mod = new Module("", "datafilter", "", "", "", "1.0.0", ""); - mod.setFile(new File("")); - ModuleFactory.getStartedModulesMap().put(mod.getModuleId(), mod); - } - { - Module mod = new Module("", "bahmni.ie.apps", "", "", "", "1.0.0", ""); - mod.setFile(new File("")); - ModuleFactory.getStartedModulesMap().put(mod.getModuleId(), mod); - } - { - Module mod = new Module("", "providermanagement", "", "", "", "1.0.0", ""); - mod.setFile(new File("")); - ModuleFactory.getStartedModulesMap().put(mod.getModuleId(), mod); - } { Module mod = new Module("", "cohort", "", "", "", "3.5.0", ""); mod.setFile(new File("")); ModuleFactory.getStartedModulesMap().put(mod.getModuleId(), mod); } - { - Module mod = new Module("", "emrapi", "", "", "", "2.0.0", ""); - mod.setFile(new File("")); - ModuleFactory.getStartedModulesMap().put(mod.getModuleId(), mod); - } - { - Module mod = new Module("", "billing", "", "", "", "2.0.0", ""); - mod.setFile(new File("")); - ModuleFactory.getStartedModulesMap().put(mod.getModuleId(), mod); - } } } diff --git a/api-2.7/src/test/java/org/openmrs/module/initializer/api/billing/BillableServicesCsvParserTest.java b/api-2.7/src/test/java/org/openmrs/module/initializer/api/billing/BillableServicesCsvParserTest.java index 29811ee7b..cdc1fc2af 100644 --- a/api-2.7/src/test/java/org/openmrs/module/initializer/api/billing/BillableServicesCsvParserTest.java +++ b/api-2.7/src/test/java/org/openmrs/module/initializer/api/billing/BillableServicesCsvParserTest.java @@ -1,8 +1,8 @@ package org.openmrs.module.initializer.api.billing; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.mockito.InjectMocks; import org.mockito.Mock; import org.mockito.MockitoAnnotations; @@ -11,8 +11,8 @@ import org.openmrs.module.initializer.Domain; import org.openmrs.module.initializer.api.CsvLine; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.mockito.Mockito.when; public class BillableServicesCsvParserTest { @@ -26,14 +26,14 @@ public class BillableServicesCsvParserTest { @InjectMocks private BillableServicesCsvParser parser; - @Before + @BeforeEach public void setUp() { - MockitoAnnotations.initMocks(this); + MockitoAnnotations.openMocks(this); } @Test public void getDomain_shouldReturnBillableServicesDomain() { - Assert.assertEquals(Domain.BILLABLE_SERVICES, parser.getDomain()); + Assertions.assertEquals(Domain.BILLABLE_SERVICES, parser.getDomain()); } @Test diff --git a/api-2.7/src/test/java/org/openmrs/module/initializer/api/billing/BillableServicesLoaderIntegrationTest.java b/api-2.7/src/test/java/org/openmrs/module/initializer/api/billing/BillableServicesLoaderIntegrationTest.java index 2b859db6a..f354a97e5 100644 --- a/api-2.7/src/test/java/org/openmrs/module/initializer/api/billing/BillableServicesLoaderIntegrationTest.java +++ b/api-2.7/src/test/java/org/openmrs/module/initializer/api/billing/BillableServicesLoaderIntegrationTest.java @@ -9,9 +9,9 @@ */ package org.openmrs.module.initializer.api.billing; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.openmrs.Concept; import org.openmrs.api.ConceptService; import org.openmrs.module.billing.api.BillableServiceService; @@ -33,7 +33,7 @@ public class BillableServicesLoaderIntegrationTest extends DomainBaseModuleConte @Autowired private BillableServiceService billableServiceService; - @Before + @BeforeEach public void setup() { executeDataSet("testdata/test-concepts-2.7.xml"); { @@ -74,31 +74,31 @@ public void load_shouldLoadBillableServicesAccordingToCsvFiles() { { BillableService service = billableServiceService .getBillableServiceByUuid("44ebd6cd-04ad-4eba-8ce1-0de4564bfd17"); - Assert.assertNotNull(service); - Assert.assertNotNull(service.getServiceType()); - Assert.assertEquals("Antenatal Care", service.getName()); - Assert.assertEquals(conceptService.getConceptByUuid("d4b4b6ef-6f3e-43a4-a3b9-9c56f3a1e2d8").getId(), + Assertions.assertNotNull(service); + Assertions.assertNotNull(service.getServiceType()); + Assertions.assertEquals("Antenatal Care", service.getName()); + Assertions.assertEquals(conceptService.getConceptByUuid("d4b4b6ef-6f3e-43a4-a3b9-9c56f3a1e2d8").getId(), service.getConcept().getId()); - Assert.assertEquals(BillableServiceStatus.ENABLED, service.getServiceStatus()); + Assertions.assertEquals(BillableServiceStatus.ENABLED, service.getServiceStatus()); } // Verify edition { BillableService service = billableServiceService .getBillableServiceByUuid("a0f7d8a1-4fa2-418c-aa8a-9b358f43d605"); - Assert.assertNotNull(service); - Assert.assertNotNull(service.getServiceType()); - Assert.assertEquals("Orthopedic Modified", service.getName()); - Assert.assertEquals(conceptService.getConceptByUuid("3f6f6c92-8d5c-4a9e-bb1c-d3e00e4f8b71").getId(), + Assertions.assertNotNull(service); + Assertions.assertNotNull(service.getServiceType()); + Assertions.assertEquals("Orthopedic Modified", service.getName()); + Assertions.assertEquals(conceptService.getConceptByUuid("3f6f6c92-8d5c-4a9e-bb1c-d3e00e4f8b71").getId(), service.getConcept().getId()); - Assert.assertEquals(BillableServiceStatus.DISABLED, service.getServiceStatus()); + Assertions.assertEquals(BillableServiceStatus.DISABLED, service.getServiceStatus()); } // Verify retirement { BillableService service = billableServiceService .getBillableServiceByUuid("16435ab4-27c3-4d91-b21e-52819bd654d8"); - Assert.assertTrue(service.getRetired()); + Assertions.assertTrue(service.getRetired()); } } diff --git a/api-2.7/src/test/java/org/openmrs/module/initializer/api/billing/CashPointsLoaderIntegrationTest.java b/api-2.7/src/test/java/org/openmrs/module/initializer/api/billing/CashPointsLoaderIntegrationTest.java index 33fd1ac84..c1c525877 100644 --- a/api-2.7/src/test/java/org/openmrs/module/initializer/api/billing/CashPointsLoaderIntegrationTest.java +++ b/api-2.7/src/test/java/org/openmrs/module/initializer/api/billing/CashPointsLoaderIntegrationTest.java @@ -1,7 +1,7 @@ package org.openmrs.module.initializer.api.billing; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.openmrs.Location; import org.openmrs.api.LocationService; import org.openmrs.module.billing.api.CashPointService; @@ -10,9 +10,9 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; public class CashPointsLoaderIntegrationTest extends DomainBaseModuleContextSensitive_2_7_Test { @@ -26,7 +26,7 @@ public class CashPointsLoaderIntegrationTest extends DomainBaseModuleContextSens @Autowired private CashPointsLoader loader; - @Before + @BeforeEach public void setup() throws Exception { executeDataSet("testdata/test-concepts-2.7.xml"); { diff --git a/api-2.7/src/test/java/org/openmrs/module/initializer/api/billing/CashierItemPriceLineProcessorTest.java b/api-2.7/src/test/java/org/openmrs/module/initializer/api/billing/CashierItemPriceLineProcessorTest.java index f1b284abe..887813c93 100644 --- a/api-2.7/src/test/java/org/openmrs/module/initializer/api/billing/CashierItemPriceLineProcessorTest.java +++ b/api-2.7/src/test/java/org/openmrs/module/initializer/api/billing/CashierItemPriceLineProcessorTest.java @@ -9,15 +9,16 @@ */ package org.openmrs.module.initializer.api.billing; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertSame; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertSame; import static org.mockito.Mockito.when; +import static org.junit.jupiter.api.Assertions.assertThrows; import java.math.BigDecimal; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.mockito.Mock; import org.mockito.MockitoAnnotations; import org.openmrs.module.billing.api.BillableServiceService; @@ -30,107 +31,111 @@ import org.openmrs.module.stockmanagement.api.model.StockItem; public class CashierItemPriceLineProcessorTest { - + private static final String PAYMENT_MODE_UUID = "pm-0000-0000-0000-000000000001"; - + private static final String STOCK_ITEM_UUID = "si-0000-0000-0000-000000000001"; - + private static final String BILLABLE_SERVICE_UUID = "bs-0000-0000-0000-000000000001"; - + private static final String[] HEADERS = new String[] { "Uuid", "name", "price", "payment mode", "stock item", "billable service" }; - + @Mock private PaymentModeService paymentModeService; - + @Mock private StockManagementService stockManagementService; - + @Mock private BillableServiceService billableServiceService; - + private CashierItemPriceLineProcessor processor; - + private PaymentMode paymentMode; - - @Before + + @BeforeEach public void setUp() { - MockitoAnnotations.initMocks(this); + MockitoAnnotations.openMocks(this); processor = new CashierItemPriceLineProcessor(paymentModeService, stockManagementService, billableServiceService); paymentMode = new PaymentMode(); paymentMode.setUuid(PAYMENT_MODE_UUID); when(paymentModeService.getPaymentModeByUuid(PAYMENT_MODE_UUID)).thenReturn(paymentMode); } - + @Test public void fill_shouldClearBillableServiceWhenSwitchingToStockItem() { CashierItemPrice instance = new CashierItemPrice(); BillableService existing = new BillableService(); existing.setUuid(BILLABLE_SERVICE_UUID); instance.setBillableService(existing); - + StockItem stockItem = new StockItem(); stockItem.setUuid(STOCK_ITEM_UUID); when(stockManagementService.getStockItemByUuid(STOCK_ITEM_UUID)).thenReturn(stockItem); - + CsvLine line = new CsvLine(HEADERS, new String[] { "", "Switched Price", "100.00", PAYMENT_MODE_UUID, STOCK_ITEM_UUID, "" }); - + processor.fill(instance, line); - + assertSame(stockItem, instance.getItem()); assertNull(instance.getBillableService()); } - + @Test public void fill_shouldClearItemWhenSwitchingToBillableService() { CashierItemPrice instance = new CashierItemPrice(); StockItem existing = new StockItem(); existing.setUuid(STOCK_ITEM_UUID); instance.setItem(existing); - + BillableService billableService = new BillableService(); billableService.setUuid(BILLABLE_SERVICE_UUID); when(billableServiceService.getBillableServiceByUuid(BILLABLE_SERVICE_UUID)).thenReturn(billableService); - + CsvLine line = new CsvLine(HEADERS, new String[] { "", "Switched Price", "100.00", PAYMENT_MODE_UUID, "", BILLABLE_SERVICE_UUID }); - + processor.fill(instance, line); - + assertSame(billableService, instance.getBillableService()); assertNull(instance.getItem()); } - + @Test public void fill_shouldSetBasicFields() { CashierItemPrice instance = new CashierItemPrice(); BillableService billableService = new BillableService(); billableService.setUuid(BILLABLE_SERVICE_UUID); when(billableServiceService.getBillableServiceByUuid(BILLABLE_SERVICE_UUID)).thenReturn(billableService); - + CsvLine line = new CsvLine(HEADERS, new String[] { "", "ANC Service Price", "150.00", PAYMENT_MODE_UUID, "", BILLABLE_SERVICE_UUID }); - + processor.fill(instance, line); - + assertEquals("ANC Service Price", instance.getName()); assertEquals(new BigDecimal("150.00"), instance.getPrice()); assertSame(paymentMode, instance.getPaymentMode()); } - - @Test(expected = IllegalArgumentException.class) + + @Test public void fill_shouldRejectWhenBothAssociationsSet() { - CashierItemPrice instance = new CashierItemPrice(); - CsvLine line = new CsvLine(HEADERS, new String[] { "", "Price", "100.00", PAYMENT_MODE_UUID, STOCK_ITEM_UUID, - BILLABLE_SERVICE_UUID }); - processor.fill(instance, line); + assertThrows(IllegalArgumentException.class, () -> { + CashierItemPrice instance = new CashierItemPrice(); + CsvLine line = new CsvLine(HEADERS, + new String[] { "", "Price", "100.00", PAYMENT_MODE_UUID, STOCK_ITEM_UUID, BILLABLE_SERVICE_UUID }); + processor.fill(instance, line); + }); } - - @Test(expected = IllegalArgumentException.class) + + @Test public void fill_shouldRejectWhenNeitherAssociationSet() { - CashierItemPrice instance = new CashierItemPrice(); - CsvLine line = new CsvLine(HEADERS, new String[] { "", "Price", "100.00", PAYMENT_MODE_UUID, "", "" }); - processor.fill(instance, line); + assertThrows(IllegalArgumentException.class, () -> { + CashierItemPrice instance = new CashierItemPrice(); + CsvLine line = new CsvLine(HEADERS, new String[] { "", "Price", "100.00", PAYMENT_MODE_UUID, "", "" }); + processor.fill(instance, line); + }); } -} \ No newline at end of file +} diff --git a/api-2.7/src/test/java/org/openmrs/module/initializer/api/billing/CashierItemPriceLoaderIntegrationTest.java b/api-2.7/src/test/java/org/openmrs/module/initializer/api/billing/CashierItemPriceLoaderIntegrationTest.java index e741606a3..02a744bcc 100644 --- a/api-2.7/src/test/java/org/openmrs/module/initializer/api/billing/CashierItemPriceLoaderIntegrationTest.java +++ b/api-2.7/src/test/java/org/openmrs/module/initializer/api/billing/CashierItemPriceLoaderIntegrationTest.java @@ -9,14 +9,14 @@ */ package org.openmrs.module.initializer.api.billing; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; import java.math.BigDecimal; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.openmrs.module.billing.api.BillableServiceService; import org.openmrs.module.billing.api.CashierItemPriceService; import org.openmrs.module.billing.api.PaymentModeService; @@ -51,7 +51,7 @@ public class CashierItemPriceLoaderIntegrationTest extends DomainBaseModuleConte @Autowired private CashierItemPriceLoader loader; - @Before + @BeforeEach public void setup() { executeDataSet("testdata/test-concepts-2.7.xml"); diff --git a/api-2.7/src/test/java/org/openmrs/module/initializer/api/billing/PaymentModesLoaderIntegrationTest.java b/api-2.7/src/test/java/org/openmrs/module/initializer/api/billing/PaymentModesLoaderIntegrationTest.java index c97176853..ad947dd03 100644 --- a/api-2.7/src/test/java/org/openmrs/module/initializer/api/billing/PaymentModesLoaderIntegrationTest.java +++ b/api-2.7/src/test/java/org/openmrs/module/initializer/api/billing/PaymentModesLoaderIntegrationTest.java @@ -1,15 +1,15 @@ package org.openmrs.module.initializer.api.billing; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.openmrs.module.billing.api.PaymentModeService; import org.openmrs.module.billing.api.model.PaymentMode; import org.openmrs.module.initializer.DomainBaseModuleContextSensitive_2_7_Test; import org.springframework.beans.factory.annotation.Autowired; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; public class PaymentModesLoaderIntegrationTest extends DomainBaseModuleContextSensitive_2_7_Test { @@ -19,7 +19,7 @@ public class PaymentModesLoaderIntegrationTest extends DomainBaseModuleContextSe @Autowired private PaymentModesLoader loader; - @Before + @BeforeEach public void setup() { executeDataSet("testdata/test-concepts-2.7.xml"); } diff --git a/api-2.7/src/test/java/org/openmrs/module/initializer/api/lineprocessor/ConceptReferenceRangeLineProcessorTest.java b/api-2.7/src/test/java/org/openmrs/module/initializer/api/lineprocessor/ConceptReferenceRangeLineProcessorTest.java index 1b0a72e99..b31f2d58d 100644 --- a/api-2.7/src/test/java/org/openmrs/module/initializer/api/lineprocessor/ConceptReferenceRangeLineProcessorTest.java +++ b/api-2.7/src/test/java/org/openmrs/module/initializer/api/lineprocessor/ConceptReferenceRangeLineProcessorTest.java @@ -1,7 +1,7 @@ package org.openmrs.module.initializer.api.lineprocessor; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import org.openmrs.ConceptReferenceRange; import org.openmrs.module.initializer.DomainBaseModuleContextSensitive_2_7_Test; import org.openmrs.module.initializer.api.CsvLine; @@ -28,16 +28,16 @@ public void fill_shouldParseConceptReferenceRange() { ConceptReferenceRange conceptReferenceRange = conceptReferenceRangeLineProcessor.fill(new ConceptReferenceRange(), new CsvLine(headerLine, line)); - Assert.assertNotNull(conceptReferenceRange); - Assert.assertNotNull(conceptReferenceRange.getConceptNumeric()); - Assert.assertEquals("a09ab2c5-878e-4905-b25d-5784167d0216", conceptReferenceRange.getConceptNumeric().getUuid()); - Assert.assertEquals(-100.5, conceptReferenceRange.getLowAbsolute(), 0.01); - Assert.assertEquals(-85.7, conceptReferenceRange.getLowCritical(), 0.01); - Assert.assertEquals(-50.3, conceptReferenceRange.getLowNormal(), 0.01); - Assert.assertEquals(45.1, conceptReferenceRange.getHiNormal(), 0.01); - Assert.assertEquals(78.0, conceptReferenceRange.getHiCritical(), 0.01); - Assert.assertEquals(98.8, conceptReferenceRange.getHiAbsolute(), 0.01); - Assert.assertEquals("$patient.getAge() > 3", conceptReferenceRange.getCriteria()); + Assertions.assertNotNull(conceptReferenceRange); + Assertions.assertNotNull(conceptReferenceRange.getConceptNumeric()); + Assertions.assertEquals("a09ab2c5-878e-4905-b25d-5784167d0216", conceptReferenceRange.getConceptNumeric().getUuid()); + Assertions.assertEquals(-100.5, conceptReferenceRange.getLowAbsolute(), 0.01); + Assertions.assertEquals(-85.7, conceptReferenceRange.getLowCritical(), 0.01); + Assertions.assertEquals(-50.3, conceptReferenceRange.getLowNormal(), 0.01); + Assertions.assertEquals(45.1, conceptReferenceRange.getHiNormal(), 0.01); + Assertions.assertEquals(78.0, conceptReferenceRange.getHiCritical(), 0.01); + Assertions.assertEquals(98.8, conceptReferenceRange.getHiAbsolute(), 0.01); + Assertions.assertEquals("$patient.getAge() > 3", conceptReferenceRange.getCriteria()); } @Test @@ -47,7 +47,7 @@ public void fill_shouldThrowExceptionForInvalidConceptNumericUuid() { String[] line = { "bc059100-4ace-4af5-afbf-2da7f3a34acf", "invalid-uuid", "-100.5", "-85.7", "-50.3", "45.1", "78", "98.8", "$patient.getAge() > 3" }; - Assert.assertThrows(IllegalArgumentException.class, + Assertions.assertThrows(IllegalArgumentException.class, () -> conceptReferenceRangeLineProcessor.fill(new ConceptReferenceRange(), new CsvLine(headerLine, line))); } @@ -58,7 +58,7 @@ public void fill_shouldThrowExceptionIfConceptNumericUuidNotFound() { String[] line = { "bc059100-4ace-4af5-afbf-2da7f3a34acf", "b09ab2c5-878e-4905-b25d-5784d67d0216", "-100.5", "-85.7", "-50.3", "45.1", "78", "98.8", "$patient.getAge() > 3" }; - Assert.assertThrows(IllegalArgumentException.class, + Assertions.assertThrows(IllegalArgumentException.class, () -> conceptReferenceRangeLineProcessor.fill(new ConceptReferenceRange(), new CsvLine(headerLine, line))); } diff --git a/api-2.7/src/test/java/org/openmrs/module/initializer/api/loaders/ConceptReferenceRangeLoaderIntegrationTest.java b/api-2.7/src/test/java/org/openmrs/module/initializer/api/loaders/ConceptReferenceRangeLoaderIntegrationTest.java index d407238f1..2dbacb838 100644 --- a/api-2.7/src/test/java/org/openmrs/module/initializer/api/loaders/ConceptReferenceRangeLoaderIntegrationTest.java +++ b/api-2.7/src/test/java/org/openmrs/module/initializer/api/loaders/ConceptReferenceRangeLoaderIntegrationTest.java @@ -1,7 +1,7 @@ package org.openmrs.module.initializer.api.loaders; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import org.openmrs.ConceptReferenceRange; import org.openmrs.api.ConceptService; import org.openmrs.module.initializer.DomainBaseModuleContextSensitive_2_7_Test; @@ -30,46 +30,49 @@ public void load_shouldLoadConceptReferenceRangesAccordingToCsvFiles() { { ConceptReferenceRange conceptReferenceRange = conceptService .getConceptReferenceRangeByUuid("bc059100-4ace-4af5-afbf-2da7f3a34acf"); - Assert.assertNotNull(conceptReferenceRange); - Assert.assertNotNull(conceptReferenceRange.getConceptNumeric()); - Assert.assertEquals("a09ab2c5-878e-4905-b25d-5784167d0216", conceptReferenceRange.getConceptNumeric().getUuid()); - Assert.assertEquals(-100.5, conceptReferenceRange.getLowAbsolute(), 0.01); - Assert.assertEquals(-85.7, conceptReferenceRange.getLowCritical(), 0.01); - Assert.assertEquals(-50.3, conceptReferenceRange.getLowNormal(), 0.01); - Assert.assertEquals(45.1, conceptReferenceRange.getHiNormal(), 0.01); - Assert.assertEquals(78.0, conceptReferenceRange.getHiCritical(), 0.01); - Assert.assertEquals(98.8, conceptReferenceRange.getHiAbsolute(), 0.01); - Assert.assertEquals("$patient.getAge() > 3", conceptReferenceRange.getCriteria()); + Assertions.assertNotNull(conceptReferenceRange); + Assertions.assertNotNull(conceptReferenceRange.getConceptNumeric()); + Assertions.assertEquals("a09ab2c5-878e-4905-b25d-5784167d0216", + conceptReferenceRange.getConceptNumeric().getUuid()); + Assertions.assertEquals(-100.5, conceptReferenceRange.getLowAbsolute(), 0.01); + Assertions.assertEquals(-85.7, conceptReferenceRange.getLowCritical(), 0.01); + Assertions.assertEquals(-50.3, conceptReferenceRange.getLowNormal(), 0.01); + Assertions.assertEquals(45.1, conceptReferenceRange.getHiNormal(), 0.01); + Assertions.assertEquals(78.0, conceptReferenceRange.getHiCritical(), 0.01); + Assertions.assertEquals(98.8, conceptReferenceRange.getHiAbsolute(), 0.01); + Assertions.assertEquals("$patient.getAge() > 3", conceptReferenceRange.getCriteria()); } { ConceptReferenceRange conceptReferenceRange = conceptService .getConceptReferenceRangeByUuid("930e1fb4-490d-45fe-a137-0cd941c76124"); - Assert.assertNotNull(conceptReferenceRange); - Assert.assertNotNull(conceptReferenceRange.getConceptNumeric()); - Assert.assertEquals("a09ab2c5-878e-4905-b25d-5784167d0216", conceptReferenceRange.getConceptNumeric().getUuid()); - Assert.assertEquals(-100.5, conceptReferenceRange.getLowAbsolute(), 0.01); - Assert.assertEquals(-85.7, conceptReferenceRange.getLowCritical(), 0.01); - Assert.assertEquals(-50.3, conceptReferenceRange.getLowNormal(), 0.01); - Assert.assertEquals(45.1, conceptReferenceRange.getHiNormal(), 0.01); - Assert.assertEquals(78.0, conceptReferenceRange.getHiCritical(), 0.01); - Assert.assertEquals(98.8, conceptReferenceRange.getHiAbsolute(), 0.01); - Assert.assertEquals("$patient.getAge() < 10", conceptReferenceRange.getCriteria()); + Assertions.assertNotNull(conceptReferenceRange); + Assertions.assertNotNull(conceptReferenceRange.getConceptNumeric()); + Assertions.assertEquals("a09ab2c5-878e-4905-b25d-5784167d0216", + conceptReferenceRange.getConceptNumeric().getUuid()); + Assertions.assertEquals(-100.5, conceptReferenceRange.getLowAbsolute(), 0.01); + Assertions.assertEquals(-85.7, conceptReferenceRange.getLowCritical(), 0.01); + Assertions.assertEquals(-50.3, conceptReferenceRange.getLowNormal(), 0.01); + Assertions.assertEquals(45.1, conceptReferenceRange.getHiNormal(), 0.01); + Assertions.assertEquals(78.0, conceptReferenceRange.getHiCritical(), 0.01); + Assertions.assertEquals(98.8, conceptReferenceRange.getHiAbsolute(), 0.01); + Assertions.assertEquals("$patient.getAge() < 10", conceptReferenceRange.getCriteria()); } { ConceptReferenceRange conceptReferenceRange = conceptService .getConceptReferenceRangeByUuid("b5a7b296-e500-4a2c-ab2e-eb012ed9ae1e"); - Assert.assertNotNull(conceptReferenceRange); - Assert.assertNotNull(conceptReferenceRange.getConceptNumeric()); - Assert.assertEquals("a09ab2c5-878e-4905-b25d-5784167d0216", conceptReferenceRange.getConceptNumeric().getUuid()); - Assert.assertEquals(60.0, conceptReferenceRange.getLowAbsolute(), 0.01); - Assert.assertEquals(70.0, conceptReferenceRange.getLowCritical(), 0.01); - Assert.assertEquals(80.0, conceptReferenceRange.getLowNormal(), 0.01); - Assert.assertEquals(120.0, conceptReferenceRange.getHiNormal(), 0.01); - Assert.assertEquals(130.0, conceptReferenceRange.getHiCritical(), 0.01); - Assert.assertEquals(150.0, conceptReferenceRange.getHiAbsolute(), 0.01); - Assert.assertEquals("$fn.getCurrentHour() > 2", conceptReferenceRange.getCriteria()); + Assertions.assertNotNull(conceptReferenceRange); + Assertions.assertNotNull(conceptReferenceRange.getConceptNumeric()); + Assertions.assertEquals("a09ab2c5-878e-4905-b25d-5784167d0216", + conceptReferenceRange.getConceptNumeric().getUuid()); + Assertions.assertEquals(60.0, conceptReferenceRange.getLowAbsolute(), 0.01); + Assertions.assertEquals(70.0, conceptReferenceRange.getLowCritical(), 0.01); + Assertions.assertEquals(80.0, conceptReferenceRange.getLowNormal(), 0.01); + Assertions.assertEquals(120.0, conceptReferenceRange.getHiNormal(), 0.01); + Assertions.assertEquals(130.0, conceptReferenceRange.getHiCritical(), 0.01); + Assertions.assertEquals(150.0, conceptReferenceRange.getHiAbsolute(), 0.01); + Assertions.assertEquals("$fn.getCurrentHour() > 2", conceptReferenceRange.getCriteria()); } } diff --git a/api-2.7/src/test/java/org/openmrs/module/initializer/api/loaders/GlobalPropertiesLoaderIntegration_2_7_Test.java b/api-2.7/src/test/java/org/openmrs/module/initializer/api/loaders/GlobalPropertiesLoaderIntegration_2_7_Test.java index a8fa40d57..51aa04125 100644 --- a/api-2.7/src/test/java/org/openmrs/module/initializer/api/loaders/GlobalPropertiesLoaderIntegration_2_7_Test.java +++ b/api-2.7/src/test/java/org/openmrs/module/initializer/api/loaders/GlobalPropertiesLoaderIntegration_2_7_Test.java @@ -9,8 +9,8 @@ */ package org.openmrs.module.initializer.api.loaders; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import org.openmrs.GlobalProperty; import org.openmrs.api.context.Context; import org.openmrs.module.initializer.DomainBaseModuleContextSensitive_2_7_Test; @@ -34,12 +34,12 @@ public void loadGlobalProperties_shouldLoadGlobalProperties() { loader.load(); // Verif - Assert.assertEquals("GP one one", Context.getAdministrationService().getGlobalProperty("gp.gp11")); - Assert.assertEquals("GP one two", Context.getAdministrationService().getGlobalProperty("gp.gp12")); - Assert.assertEquals("GP two one", Context.getAdministrationService().getGlobalProperty("gp.gp21")); - Assert.assertEquals("GP three one", Context.getAdministrationService().getGlobalProperty("gp.gp31")); - Assert.assertEquals("GP three two", Context.getAdministrationService().getGlobalProperty("gp.gp32")); - Assert.assertEquals("GP three three", Context.getAdministrationService().getGlobalProperty("gp.gp33")); + Assertions.assertEquals("GP one one", Context.getAdministrationService().getGlobalProperty("gp.gp11")); + Assertions.assertEquals("GP one two", Context.getAdministrationService().getGlobalProperty("gp.gp12")); + Assertions.assertEquals("GP two one", Context.getAdministrationService().getGlobalProperty("gp.gp21")); + Assertions.assertEquals("GP three one", Context.getAdministrationService().getGlobalProperty("gp.gp31")); + Assertions.assertEquals("GP three two", Context.getAdministrationService().getGlobalProperty("gp.gp32")); + Assertions.assertEquals("GP three three", Context.getAdministrationService().getGlobalProperty("gp.gp33")); } @Test @@ -47,13 +47,13 @@ public void load_shouldOverrideGlobalProperties() { // Setup Context.getAdministrationService().saveGlobalProperty(new GlobalProperty("gp.gp11", "foobar")); - Assert.assertEquals("foobar", Context.getAdministrationService().getGlobalProperty("gp.gp11")); + Assertions.assertEquals("foobar", Context.getAdministrationService().getGlobalProperty("gp.gp11")); // Replay loader.load(); // Verif - Assert.assertEquals("GP one one", Context.getAdministrationService().getGlobalProperty("gp.gp11")); + Assertions.assertEquals("GP one one", Context.getAdministrationService().getGlobalProperty("gp.gp11")); } @Test @@ -68,8 +68,8 @@ public void load_shouldNotAffectOtherGlobalProperties() { loader.load(); // Verif - Assert.assertEquals("Foo", Context.getAdministrationService().getGlobalProperty("gp.foo")); - Assert.assertEquals("Bar", Context.getAdministrationService().getGlobalProperty("gp.bar")); - Assert.assertEquals("Baz", Context.getAdministrationService().getGlobalProperty("gp.baz")); + Assertions.assertEquals("Foo", Context.getAdministrationService().getGlobalProperty("gp.foo")); + Assertions.assertEquals("Bar", Context.getAdministrationService().getGlobalProperty("gp.bar")); + Assertions.assertEquals("Baz", Context.getAdministrationService().getGlobalProperty("gp.baz")); } } diff --git a/api-2.7/src/test/java/org/openmrs/module/initializer/api/loaders/LocationsLoader_2_7_IntegrationTest.java b/api-2.7/src/test/java/org/openmrs/module/initializer/api/loaders/LocationsLoader_2_7_IntegrationTest.java index 6264a0110..332771dce 100644 --- a/api-2.7/src/test/java/org/openmrs/module/initializer/api/loaders/LocationsLoader_2_7_IntegrationTest.java +++ b/api-2.7/src/test/java/org/openmrs/module/initializer/api/loaders/LocationsLoader_2_7_IntegrationTest.java @@ -9,9 +9,10 @@ */ package org.openmrs.module.initializer.api.loaders; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; +import org.hamcrest.MatcherAssert; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.openmrs.Location; import org.openmrs.LocationAttribute; import org.openmrs.LocationTag; @@ -52,7 +53,7 @@ public class LocationsLoader_2_7_IntegrationTest extends DomainBaseModuleContext private Locale localeKm = new Locale("km", "KH"); - @Before + @BeforeEach public void setup() throws Exception { executeDataSet("testdata/test-metadata.xml"); } @@ -62,23 +63,23 @@ public void load_shouldLoadAccordingToCsvFiles() { // Pre-load verif { Location loc = ls.getLocation(4089); - Assert.assertEquals("a03e395c-b881-49b7-b6fc-983f6bddc7fc", loc.getUuid()); - Assert.assertEquals("Acme Clinic", loc.getName()); - Assert.assertThat(loc.getDescription(), nullValue()); - Assert.assertThat(loc.getParentLocation(), nullValue()); - Assert.assertThat(loc.getTags().size(), is(0)); + Assertions.assertEquals("a03e395c-b881-49b7-b6fc-983f6bddc7fc", loc.getUuid()); + Assertions.assertEquals("Acme Clinic", loc.getName()); + MatcherAssert.assertThat(loc.getDescription(), nullValue()); + MatcherAssert.assertThat(loc.getParentLocation(), nullValue()); + MatcherAssert.assertThat(loc.getTags().size(), is(0)); Collection attributes = loc.getActiveAttributes(); - Assert.assertThat(attributes.size(), is(1)); - Assert.assertEquals("2016-04-14", + MatcherAssert.assertThat(attributes.size(), is(1)); + Assertions.assertEquals("2016-04-14", dateDatatype.serialize((Date) ((LocationAttribute) attributes.toArray()[0]).getValue())); } { Location loc = ls.getLocation(4090); - Assert.assertEquals("cbaaaab4-d960-4ae9-9b6a-8983fbd947b6", loc.getUuid()); - Assert.assertEquals("Legacy Location", loc.getName()); - Assert.assertEquals("Legacy location that must be retired", loc.getDescription()); - Assert.assertThat(loc.getRetired(), is(false)); + Assertions.assertEquals("cbaaaab4-d960-4ae9-9b6a-8983fbd947b6", loc.getUuid()); + Assertions.assertEquals("Legacy Location", loc.getName()); + Assertions.assertEquals("Legacy location that must be retired", loc.getDescription()); + MatcherAssert.assertThat(loc.getRetired(), is(false)); } // Replay @@ -87,113 +88,113 @@ public void load_shouldLoadAccordingToCsvFiles() { // Verify fetch by name { Location loc = ls.getLocation("LOCATION_NO_UUID"); - Assert.assertEquals("Main Street", loc.getAddress1()); - Assert.assertEquals("fdddc31a-3930-11ea-9712-a73c3c19744f", loc.getUuid()); + Assertions.assertEquals("Main Street", loc.getAddress1()); + Assertions.assertEquals("fdddc31a-3930-11ea-9712-a73c3c19744f", loc.getUuid()); } // Verify creation with dynamic tag creation { Location loc = ls.getLocation("The Lake Clinic-Cambodia"); - Assert.assertEquals("Paradise Street", loc.getAddress1()); - Assert.assertEquals("Siem Reap", loc.getCountyDistrict()); - Assert.assertEquals("Siem Reap", loc.getStateProvince()); - Assert.assertEquals("Cambodia", loc.getCountry()); + Assertions.assertEquals("Paradise Street", loc.getAddress1()); + Assertions.assertEquals("Siem Reap", loc.getCountyDistrict()); + Assertions.assertEquals("Siem Reap", loc.getStateProvince()); + Assertions.assertEquals("Cambodia", loc.getCountry()); Set tags = loc.getTags(); - Assert.assertThat(tags, notNullValue()); - Assert.assertThat(tags.size(), is(2)); - Assert.assertThat(tags.contains(ls.getLocationTagByName("Login Location")), is(true)); - Assert.assertThat(tags.contains(ls.getLocationTagByName("Another Location Tag")), is(true)); + MatcherAssert.assertThat(tags, notNullValue()); + MatcherAssert.assertThat(tags.size(), is(2)); + MatcherAssert.assertThat(tags.contains(ls.getLocationTagByName("Login Location")), is(true)); + MatcherAssert.assertThat(tags.contains(ls.getLocationTagByName("Another Location Tag")), is(true)); Collection attributes = loc.getActiveAttributes(); - Assert.assertThat(attributes.size(), is(2)); - Assert.assertEquals("CODE-TLC-123", ((LocationAttribute) attributes.toArray()[0]).getValue()); - Assert.assertEquals("2017-05-15", + MatcherAssert.assertThat(attributes.size(), is(2)); + Assertions.assertEquals("CODE-TLC-123", ((LocationAttribute) attributes.toArray()[0]).getValue()); + Assertions.assertEquals("2017-05-15", dateDatatype.serialize((Date) ((LocationAttribute) attributes.toArray()[1]).getValue())); } // Verify creation with Tag| headers { Location loc = ls.getLocation("OPD Room"); - Assert.assertEquals(ls.getLocation("The Lake Clinic-Cambodia"), loc.getParentLocation()); + Assertions.assertEquals(ls.getLocation("The Lake Clinic-Cambodia"), loc.getParentLocation()); Set tags = loc.getTags(); - Assert.assertThat(tags, notNullValue()); - Assert.assertThat(tags.size(), is(1)); - Assert.assertThat(tags.contains(ls.getLocationTagByName("Facility Location")), is(true)); + MatcherAssert.assertThat(tags, notNullValue()); + MatcherAssert.assertThat(tags.size(), is(1)); + MatcherAssert.assertThat(tags.contains(ls.getLocationTagByName("Facility Location")), is(true)); } // Verify that the provided UUID is correctly assigned { Location loc = ls.getLocationByUuid("1cb58794-3c49-11ea-b3eb-f7801304f314"); - Assert.assertNotNull(loc); - Assert.assertEquals("New Location", loc.getName()); + Assertions.assertNotNull(loc); + Assertions.assertEquals("New Location", loc.getName()); } // Verify edit { Location loc = ls.getLocationByUuid("a03e395c-b881-49b7-b6fc-983f6bddc7fc"); - Assert.assertEquals("Acme Clinic", loc.getName()); - Assert.assertEquals("This now becomes a child of TLC", loc.getDescription()); - Assert.assertEquals(ls.getLocation("The Lake Clinic-Cambodia"), loc.getParentLocation()); + Assertions.assertEquals("Acme Clinic", loc.getName()); + Assertions.assertEquals("This now becomes a child of TLC", loc.getDescription()); + Assertions.assertEquals(ls.getLocation("The Lake Clinic-Cambodia"), loc.getParentLocation()); Set tags = loc.getTags(); - Assert.assertThat(tags, notNullValue()); - Assert.assertThat(tags.size(), is(1)); - Assert.assertThat(tags.contains(ls.getLocationTagByName("Login Location")), is(true)); + MatcherAssert.assertThat(tags, notNullValue()); + MatcherAssert.assertThat(tags.size(), is(1)); + MatcherAssert.assertThat(tags.contains(ls.getLocationTagByName("Login Location")), is(true)); Collection attributes = loc.getActiveAttributes(); - Assert.assertThat(attributes.size(), is(1)); - Assert.assertEquals("2019-03-13", + MatcherAssert.assertThat(attributes.size(), is(1)); + Assertions.assertEquals("2019-03-13", dateDatatype.serialize((Date) ((LocationAttribute) attributes.toArray()[0]).getValue())); } // Verify retire { Location loc = ls.getLocationByUuid("cbaaaab4-d960-4ae9-9b6a-8983fbd947b6"); - Assert.assertThat(loc.getRetired(), is(true)); + MatcherAssert.assertThat(loc.getRetired(), is(true)); } // Verify that location with an invalid parent isn't created { Location loc = ls.getLocationByUuid("2b9824a3-92f0-4966-8f34-1b105624b267"); - Assert.assertNull(loc); + Assertions.assertNull(loc); } // verify Locations domain i18n on entries with display:xy fields { - Assert.assertEquals("Acme Clinic (translated)", Context.getMessageSourceService() + Assertions.assertEquals("Acme Clinic (translated)", Context.getMessageSourceService() .getMessage("ui.i18n.Location.name.a03e395c-b881-49b7-b6fc-983f6bddc7fc", null, localeEn)); - Assert.assertEquals("គ្លីនិកអាមី", Context.getMessageSourceService() + Assertions.assertEquals("គ្លីនិកអាមី", Context.getMessageSourceService() .getMessage("ui.i18n.Location.name.a03e395c-b881-49b7-b6fc-983f6bddc7fc", null, localeKm)); - Assert.assertEquals("Acme Clinic (translated)", Context.getMessageSourceService() + Assertions.assertEquals("Acme Clinic (translated)", Context.getMessageSourceService() .getMessage("org.openmrs.Location.a03e395c-b881-49b7-b6fc-983f6bddc7fc", null, localeEn)); - Assert.assertEquals("គ្លីនិកអាមី", Context.getMessageSourceService() + Assertions.assertEquals("គ្លីនិកអាមី", Context.getMessageSourceService() .getMessage("org.openmrs.Location.a03e395c-b881-49b7-b6fc-983f6bddc7fc", null, localeKm)); } // verify no Locations domain i18n on entries without display:xy fields and entries without pre-filled uuids { - Assert.assertNotNull(ls.getLocationByUuid("1cb58794-3c49-11ea-b3eb-f7801304f314")); - Assert.assertEquals("ui.i18n.Location.name.1cb58794-3c49-11ea-b3eb-f7801304f314", + Assertions.assertNotNull(ls.getLocationByUuid("1cb58794-3c49-11ea-b3eb-f7801304f314")); + Assertions.assertEquals("ui.i18n.Location.name.1cb58794-3c49-11ea-b3eb-f7801304f314", Context.getMessageSourceService().getMessage("ui.i18n.Location.name.1cb58794-3c49-11ea-b3eb-f7801304f314", null, localeEn)); - Assert.assertEquals("ui.i18n.Location.name.1cb58794-3c49-11ea-b3eb-f7801304f314", + Assertions.assertEquals("ui.i18n.Location.name.1cb58794-3c49-11ea-b3eb-f7801304f314", Context.getMessageSourceService().getMessage("ui.i18n.Location.name.1cb58794-3c49-11ea-b3eb-f7801304f314", null, localeKm)); - Assert.assertEquals("org.openmrs.Location.1cb58794-3c49-11ea-b3eb-f7801304f314", + Assertions.assertEquals("org.openmrs.Location.1cb58794-3c49-11ea-b3eb-f7801304f314", Context.getMessageSourceService().getMessage("org.openmrs.Location.1cb58794-3c49-11ea-b3eb-f7801304f314", null, localeEn)); - Assert.assertEquals("org.openmrs.Location.1cb58794-3c49-11ea-b3eb-f7801304f314", + Assertions.assertEquals("org.openmrs.Location.1cb58794-3c49-11ea-b3eb-f7801304f314", Context.getMessageSourceService().getMessage("org.openmrs.Location.1cb58794-3c49-11ea-b3eb-f7801304f314", null, localeKm)); Location loc = ls.getLocation("The Lake Clinic-Cambodia"); - Assert.assertNotNull(loc); + Assertions.assertNotNull(loc); String uuid = loc.getUuid(); - Assert.assertEquals("ui.i18n.Location.name." + uuid, + Assertions.assertEquals("ui.i18n.Location.name." + uuid, Context.getMessageSourceService().getMessage("ui.i18n.Location.name." + uuid, null, localeEn)); - Assert.assertEquals("ui.i18n.Location.name." + uuid, + Assertions.assertEquals("ui.i18n.Location.name." + uuid, Context.getMessageSourceService().getMessage("ui.i18n.Location.name." + uuid, null, localeKm)); - Assert.assertEquals("org.openmrs.Location." + uuid, + Assertions.assertEquals("org.openmrs.Location." + uuid, Context.getMessageSourceService().getMessage("org.openmrs.Location." + uuid, null, localeEn)); - Assert.assertEquals("org.openmrs.Location." + uuid, + Assertions.assertEquals("org.openmrs.Location." + uuid, Context.getMessageSourceService().getMessage("org.openmrs.Location." + uuid, null, localeKm)); } } diff --git a/api-2.7/src/test/resources/test-hibernate.cfg.xml b/api-2.7/src/test/resources/test-hibernate.cfg.xml index 43c58118f..368c31f76 100644 --- a/api-2.7/src/test/resources/test-hibernate.cfg.xml +++ b/api-2.7/src/test/resources/test-hibernate.cfg.xml @@ -7,16 +7,17 @@ + + + + + + + + + + - - - - - - - - - diff --git a/api-2.8/pom.xml b/api-2.8/pom.xml index 1fdad9f9f..818bbcb81 100644 --- a/api-2.8/pom.xml +++ b/api-2.8/pom.xml @@ -5,7 +5,7 @@ org.openmrs.module initializer - 2.13.0-SNAPSHOT + 3.0.0-SNAPSHOT 4.0.0 @@ -15,7 +15,6 @@ API 2.8 project for Initializer - ${openmrsVersion2.8} 3.4.0 @@ -95,7 +94,7 @@ org.apache.maven.plugins maven-surefire-plugin - + org.openmrs.module:providermanagement-api org.openmrs.module:htmlformentry-api org.openmrs.module:fhir2-api @@ -105,6 +104,10 @@ org.openmrs.module:reporting-api org.openmrs.module:reporting-api-2.0 + + + **/ProcedureTypesLoaderIntegrationTest.java + diff --git a/api-2.8/src/test/java/org/openmrs/module/initializer/api/lineprocessor/ProcedureTypeLineProcessorTest.java b/api-2.8/src/test/java/org/openmrs/module/initializer/api/lineprocessor/ProcedureTypeLineProcessorTest.java index 97a3b30c2..46466aaf7 100644 --- a/api-2.8/src/test/java/org/openmrs/module/initializer/api/lineprocessor/ProcedureTypeLineProcessorTest.java +++ b/api-2.8/src/test/java/org/openmrs/module/initializer/api/lineprocessor/ProcedureTypeLineProcessorTest.java @@ -1,9 +1,10 @@ package org.openmrs.module.initializer.api.lineprocessor; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNull; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNull; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.openmrs.module.emrapi.procedure.ProcedureType; import org.openmrs.module.initializer.api.CsvLine; import org.openmrs.module.initializer.api.procedure.ProcedureTypeLineProcessor; @@ -34,19 +35,25 @@ public void shouldAllowMissingDescription() { assertNull(type.getDescription()); } - @Test(expected = IllegalArgumentException.class) + @Test public void shouldThrowWhenNameIsNull() { - String[] headers = { "Uuid", "Name", "Description" }; - String[] line = { "9d9aa7c1-2e0e-4b1e-8b57-7e6f1a0b1234", null, "Description without a name" }; - - processor.fill(new ProcedureType(), new CsvLine(headers, line)); + assertThrows(IllegalArgumentException.class, () -> { + String[] headers = { "Uuid", "Name", "Description" }; + String[] line = { "9d9aa7c1-2e0e-4b1e-8b57-7e6f1a0b1234", null, "Description without a name" }; + + processor.fill(new ProcedureType(), new CsvLine(headers, line)); + + }); } - @Test(expected = IllegalArgumentException.class) + @Test public void shouldThrowWhenNameIsBlank() { - String[] headers = { "Uuid", "Name", "Description" }; - String[] line = { "9d9aa7c1-2e0e-4b1e-8b57-7e6f1a0b1234", "", "Description without a name" }; - - processor.fill(new ProcedureType(), new CsvLine(headers, line)); + assertThrows(IllegalArgumentException.class, () -> { + String[] headers = { "Uuid", "Name", "Description" }; + String[] line = { "9d9aa7c1-2e0e-4b1e-8b57-7e6f1a0b1234", "", "Description without a name" }; + + processor.fill(new ProcedureType(), new CsvLine(headers, line)); + + }); } } diff --git a/api-2.8/src/test/java/org/openmrs/module/initializer/api/procedure/ProcedureTypesCsvParserTest.java b/api-2.8/src/test/java/org/openmrs/module/initializer/api/procedure/ProcedureTypesCsvParserTest.java index 98a4e2416..609ccbb9b 100644 --- a/api-2.8/src/test/java/org/openmrs/module/initializer/api/procedure/ProcedureTypesCsvParserTest.java +++ b/api-2.8/src/test/java/org/openmrs/module/initializer/api/procedure/ProcedureTypesCsvParserTest.java @@ -1,10 +1,11 @@ package org.openmrs.module.initializer.api.procedure; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertSame; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertSame; import static org.mockito.Mockito.anyString; import static org.mockito.Mockito.never; import static org.mockito.Mockito.verify; @@ -13,8 +14,8 @@ import java.util.Arrays; import java.util.Collections; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.mockito.InjectMocks; import org.mockito.Mock; import org.mockito.MockitoAnnotations; @@ -36,9 +37,9 @@ public class ProcedureTypesCsvParserTest { @InjectMocks private ProcedureTypesCsvParser parser; - @Before + @BeforeEach public void setUp() { - MockitoAnnotations.initMocks(this); + MockitoAnnotations.openMocks(this); } @Test @@ -117,17 +118,20 @@ public void shouldFilterMultiMatchByExactName() { assertSame(exact, result); } - @Test(expected = IllegalArgumentException.class) + @Test public void shouldThrowWhenMultipleExactNameMatches() { - ProcedureType a = new ProcedureType(); - a.setName("Appendectomy"); - a.setUuid("9d9aa7c1-2e0e-4b1e-8b57-7e6f1a0b0001"); - ProcedureType b = new ProcedureType(); - b.setName("Appendectomy"); - b.setUuid("9d9aa7c1-2e0e-4b1e-8b57-7e6f1a0b0002"); - when(procedureService.getProcedureTypesByName("Appendectomy")).thenReturn(Arrays.asList(a, b)); - - parser.bootstrap(new CsvLine(HEADERS, new String[] { "", "Appendectomy", "" })); + assertThrows(IllegalArgumentException.class, () -> { + ProcedureType a = new ProcedureType(); + a.setName("Appendectomy"); + a.setUuid("9d9aa7c1-2e0e-4b1e-8b57-7e6f1a0b0001"); + ProcedureType b = new ProcedureType(); + b.setName("Appendectomy"); + b.setUuid("9d9aa7c1-2e0e-4b1e-8b57-7e6f1a0b0002"); + when(procedureService.getProcedureTypesByName("Appendectomy")).thenReturn(Arrays.asList(a, b)); + + parser.bootstrap(new CsvLine(HEADERS, new String[] { "", "Appendectomy", "" })); + + }); } @Test diff --git a/api-2.8/src/test/java/org/openmrs/module/initializer/api/procedure/ProcedureTypesLoaderIntegrationTest.java b/api-2.8/src/test/java/org/openmrs/module/initializer/api/procedure/ProcedureTypesLoaderIntegrationTest.java index ea32798e9..40846e877 100644 --- a/api-2.8/src/test/java/org/openmrs/module/initializer/api/procedure/ProcedureTypesLoaderIntegrationTest.java +++ b/api-2.8/src/test/java/org/openmrs/module/initializer/api/procedure/ProcedureTypesLoaderIntegrationTest.java @@ -2,9 +2,9 @@ import java.util.List; -import org.junit.Assert; -import org.junit.Ignore; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; import org.openmrs.module.emrapi.procedure.ProcedureService; import org.openmrs.module.emrapi.procedure.ProcedureType; import org.openmrs.module.initializer.DomainBaseModuleContextSensitive_2_8_Test; @@ -26,23 +26,23 @@ public void load_shouldLoadProcedureTypesAccordingToCsvFiles() { { ProcedureType type = procedureService.getProcedureTypeByUuid("9d9aa7c1-2e0e-4b1e-8b57-7e6f1a0b1234"); - Assert.assertNotNull(type); - Assert.assertEquals("Appendectomy", type.getName()); - Assert.assertEquals("Surgical removal of the appendix", type.getDescription()); - Assert.assertFalse(type.getRetired()); + Assertions.assertNotNull(type); + Assertions.assertEquals("Appendectomy", type.getName()); + Assertions.assertEquals("Surgical removal of the appendix", type.getDescription()); + Assertions.assertFalse(type.getRetired()); } { List matches = procedureService.getProcedureTypesByName("Cholecystectomy"); - Assert.assertNotNull(matches); - Assert.assertEquals(1, matches.size()); - Assert.assertEquals("Surgical removal of the gallbladder", matches.get(0).getDescription()); + Assertions.assertNotNull(matches); + Assertions.assertEquals(1, matches.size()); + Assertions.assertEquals("Surgical removal of the gallbladder", matches.get(0).getDescription()); } { ProcedureType type = procedureService.getProcedureTypeByUuid("9d9aa7c1-2e0e-4b1e-8b57-7e6f1a0b5678"); - Assert.assertNotNull(type); - Assert.assertTrue(type.getRetired()); + Assertions.assertNotNull(type); + Assertions.assertTrue(type.getRetired()); } } } diff --git a/api-bahmni/pom.xml b/api-bahmni/pom.xml index df3f8b753..6cee35e6c 100644 --- a/api-bahmni/pom.xml +++ b/api-bahmni/pom.xml @@ -4,7 +4,7 @@ org.openmrs.module initializer - 2.13.0-SNAPSHOT + 3.0.0-SNAPSHOT initializer-api-bahmni @@ -13,7 +13,6 @@ API with Bahmni project for Initializer - ${openmrsVersion2.1} 1.23.0 1.0-1.0.0 2.5.6 @@ -102,6 +101,17 @@ + + + org.apache.maven.plugins + maven-surefire-plugin + + true + + org.codehaus.mojo build-helper-maven-plugin diff --git a/api-bahmni/src/test/java/org/openmrs/module/initializer/api/BahmniAttributeTypesLoaderTest.java b/api-bahmni/src/test/java/org/openmrs/module/initializer/api/BahmniAttributeTypesLoaderTest.java index d35eec8b6..7d8ae96a0 100644 --- a/api-bahmni/src/test/java/org/openmrs/module/initializer/api/BahmniAttributeTypesLoaderTest.java +++ b/api-bahmni/src/test/java/org/openmrs/module/initializer/api/BahmniAttributeTypesLoaderTest.java @@ -2,15 +2,15 @@ import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.MatcherAssert.assertThat; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; import static org.openmrs.module.initializer.api.AttributeTypesLoaderTest.assertCustomDatatype; import org.bahmni.module.bahmnicore.model.bahmniPatientProgram.ProgramAttributeType; import org.bahmni.module.bahmnicore.service.BahmniProgramWorkflowService; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.openmrs.module.initializer.DomainBaseModuleContextSensitiveTest; import org.openmrs.module.initializer.api.attributes.types.AttributeTypesLoader; import org.springframework.beans.factory.annotation.Autowired; @@ -23,7 +23,7 @@ public class BahmniAttributeTypesLoaderTest extends DomainBaseModuleContextSensi @Autowired BahmniProgramWorkflowService bahmniProgramWorkflowService; - @Before + @BeforeEach public void setup() throws Exception { executeDataSet("testdata/bahmni-test-metadata.xml"); } diff --git a/api-bahmni/src/test/java/org/openmrs/module/initializer/api/attributes/types/BahmniAttributeTypesProxyServiceTest.java b/api-bahmni/src/test/java/org/openmrs/module/initializer/api/attributes/types/BahmniAttributeTypesProxyServiceTest.java index 95ad82834..8ba400f7f 100644 --- a/api-bahmni/src/test/java/org/openmrs/module/initializer/api/attributes/types/BahmniAttributeTypesProxyServiceTest.java +++ b/api-bahmni/src/test/java/org/openmrs/module/initializer/api/attributes/types/BahmniAttributeTypesProxyServiceTest.java @@ -2,15 +2,15 @@ import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.MatcherAssert.assertThat; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; import static org.openmrs.module.initializer.api.attributes.types.AttributeTypeEntity.PROGRAM; -import org.apache.commons.lang.RandomStringUtils; +import org.apache.commons.lang3.RandomStringUtils; import org.bahmni.module.bahmnicore.model.bahmniPatientProgram.ProgramAttributeType; import org.bahmni.module.bahmnicore.service.BahmniProgramWorkflowService; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.openmrs.attribute.BaseAttributeType; import org.openmrs.module.initializer.DomainBaseModuleContextSensitiveTest; import org.springframework.beans.factory.annotation.Autowired; @@ -25,7 +25,7 @@ public class BahmniAttributeTypesProxyServiceTest extends DomainBaseModuleContex @Autowired BahmniProgramWorkflowService bahmniProgramWorkflowService; - @Before + @BeforeEach public void setup() throws Exception { executeDataSet("testdata/bahmni-test-metadata.xml"); } diff --git a/api/pom.xml b/api/pom.xml index 964b6cb3f..0b4c188e1 100644 --- a/api/pom.xml +++ b/api/pom.xml @@ -4,7 +4,7 @@ org.openmrs.module initializer - 2.13.0-SNAPSHOT + 3.0.0-SNAPSHOT initializer-api @@ -12,20 +12,45 @@ Initializer API API project for Initializer - - ${openmrsVersion2.1} - + commons-codec commons-codec 1.9 + provided + com.opencsv opencsv - 4.5 + 5.11 + provided + + + + org.apache.commons + commons-lang3 + + + org.apache.commons + commons-text + + + commons-beanutils + commons-beanutils + + + org.apache.commons + commons-collections4 + + + + + + org.apache.commons + commons-lang3 com.github.freva @@ -37,5 +62,35 @@ openconceptlab-api - + + + + + org.apache.maven.plugins + maven-surefire-plugin + + + + **/AddressHierarchyLoaderIntegrationTest.java + **/AppointmentServiceDefinitionsLoaderIntegrationTest.java + **/AppointmentServiceTypesLoaderIntegrationTest.java + **/SpecialitiesLoaderIntegrationTest.java + **/BahmniFormsLoaderIntegrationTest.java + **/DispositionsLoaderIntegrationTest.java + **/HtmlFormsLoaderIntegrationTest.java + **/MdsLoaderIntegrationTest.java + **/OpenConceptLabLoaderIntegrationTest.java + **/patientflags/*LoaderIntegrationTest.java + **/ProviderRolesLoaderIntegrationTest.java + + **/LiquibaseLoaderIntegrationTest.java + + + + + + diff --git a/api/src/main/java/org/openmrs/module/initializer/Domain.java b/api/src/main/java/org/openmrs/module/initializer/Domain.java index aae400ea3..d7e2e1390 100644 --- a/api/src/main/java/org/openmrs/module/initializer/Domain.java +++ b/api/src/main/java/org/openmrs/module/initializer/Domain.java @@ -1,6 +1,6 @@ package org.openmrs.module.initializer; -import org.apache.commons.lang.ArrayUtils; +import org.apache.commons.lang3.ArrayUtils; public enum Domain { LIQUIBASE, diff --git a/api/src/main/java/org/openmrs/module/initializer/InitializerMessageSource.java b/api/src/main/java/org/openmrs/module/initializer/InitializerMessageSource.java index a8b190c9c..ba1e7ac0f 100644 --- a/api/src/main/java/org/openmrs/module/initializer/InitializerMessageSource.java +++ b/api/src/main/java/org/openmrs/module/initializer/InitializerMessageSource.java @@ -10,7 +10,7 @@ package org.openmrs.module.initializer; import org.apache.commons.io.FilenameUtils; -import org.apache.commons.lang.time.StopWatch; +import org.apache.commons.lang3.time.StopWatch; import org.apache.commons.lang3.LocaleUtils; import org.apache.commons.lang3.StringUtils; import org.openmrs.api.APIException; @@ -35,7 +35,7 @@ import org.springframework.core.io.support.ResourcePatternResolver; import org.springframework.stereotype.Component; -import javax.annotation.PostConstruct; +import jakarta.annotation.PostConstruct; import java.io.File; import java.io.IOException; import java.text.MessageFormat; @@ -277,7 +277,11 @@ protected Locale getLocaleFromFileBaseName(String baseName) throws IllegalArgume for (int i = parts.length - 1; i > 0; i--) { candidate = parts[i] + (candidate == null ? "" : "_" + candidate); try { - return LocaleUtils.toLocale(candidate); + Locale locale = LocaleUtils.toLocale(candidate); + // Recent commons-lang3 versions parse a lone country code such as "FR" as a language-less locale + if (!locale.getLanguage().isEmpty()) { + return locale; + } } catch (IllegalArgumentException e) { log.trace(candidate + " is not a valid locale"); diff --git a/api/src/main/java/org/openmrs/module/initializer/api/CsvLine.java b/api/src/main/java/org/openmrs/module/initializer/api/CsvLine.java index b5ad4d34b..eb965bd56 100644 --- a/api/src/main/java/org/openmrs/module/initializer/api/CsvLine.java +++ b/api/src/main/java/org/openmrs/module/initializer/api/CsvLine.java @@ -1,6 +1,6 @@ package org.openmrs.module.initializer.api; -import org.apache.commons.lang.BooleanUtils; +import org.apache.commons.lang3.BooleanUtils; import org.apache.commons.lang3.StringUtils; import org.openmrs.module.initializer.api.utils.Utils; diff --git a/api/src/main/java/org/openmrs/module/initializer/api/CsvParser.java b/api/src/main/java/org/openmrs/module/initializer/api/CsvParser.java index 3bf5b565f..e3ca60d59 100644 --- a/api/src/main/java/org/openmrs/module/initializer/api/CsvParser.java +++ b/api/src/main/java/org/openmrs/module/initializer/api/CsvParser.java @@ -9,7 +9,7 @@ import java.util.List; import java.util.Objects; -import org.apache.commons.lang.StringUtils; +import org.apache.commons.lang3.StringUtils; import org.openmrs.BaseOpenmrsData; import org.openmrs.OpenmrsObject; import org.openmrs.Retireable; @@ -21,6 +21,7 @@ import org.slf4j.LoggerFactory; import com.opencsv.CSVReader; +import com.opencsv.exceptions.CsvValidationException; public abstract class CsvParser> { @@ -125,7 +126,7 @@ protected void setLineProcessors(String version) { public void setInputStream(InputStream is) throws IOException { reader = new CSVReader(new InputStreamReader(is, StandardCharsets.UTF_8)); - headerLine = reader.readNext(); + headerLine = readNext(reader); String version = LP.getVersion(headerLine); @@ -139,7 +140,7 @@ public void setInputStream(InputStream is) throws IOException { */ public static String[] getHeaderLine(InputStream is) throws IOException { CSVReader reader = new CSVReader(new InputStreamReader(is, StandardCharsets.UTF_8)); - String[] headerLine = reader.readNext(); + String[] headerLine = readNext(reader); reader.close(); return headerLine; } @@ -286,7 +287,7 @@ protected boolean shouldFill(T instance, CsvLine csvLine) { */ protected String[] fetchNextLine() throws IOException { - line = reader.readNext(); + line = readNext(reader); if (line == null) { close(); return null; @@ -305,4 +306,17 @@ protected String[] fetchNextLine() throws IOException { protected void close() throws IOException { reader.close(); } + + /** + * opencsv 5 also declares {@link CsvValidationException}, which only a registered validator throws, + * and none is registered here. + */ + private static String[] readNext(CSVReader reader) throws IOException { + try { + return reader.readNext(); + } + catch (CsvValidationException e) { + throw new IOException(e); + } + } } diff --git a/api/src/main/java/org/openmrs/module/initializer/api/HibernateInitializerDAO.java b/api/src/main/java/org/openmrs/module/initializer/api/HibernateInitializerDAO.java index ac533fb03..0985ab12e 100644 --- a/api/src/main/java/org/openmrs/module/initializer/api/HibernateInitializerDAO.java +++ b/api/src/main/java/org/openmrs/module/initializer/api/HibernateInitializerDAO.java @@ -1,13 +1,8 @@ package org.openmrs.module.initializer.api; import org.apache.commons.lang3.StringUtils; -import org.hibernate.Criteria; import org.hibernate.SessionFactory; -import org.hibernate.criterion.MatchMode; -import org.hibernate.criterion.Projections; -import org.hibernate.criterion.Restrictions; import org.openmrs.Concept; -import org.openmrs.ConceptName; import org.openmrs.api.ConceptNameType; import org.openmrs.api.context.Context; import org.slf4j.Logger; @@ -46,24 +41,17 @@ public List getUnretiredConceptsByFullySpecifiedName(String name) { if (StringUtils.isBlank(name)) { return Collections.emptyList(); } - Criteria criteria = sessionFactory.getCurrentSession().createCriteria(ConceptName.class); - + String nameClause; if (Context.getAdministrationService().isDatabaseStringComparisonCaseSensitive()) { - name = name.replace("%", "\\%"); - criteria.add(Restrictions.ilike("name", name, MatchMode.EXACT)); + nameClause = "lower(cn.name) = lower(:name)"; } else { - criteria.add(Restrictions.eq("name", name)); + nameClause = "cn.name = :name"; } - criteria.add(Restrictions.eq("voided", false)); - criteria.add(Restrictions.eq("conceptNameType", ConceptNameType.FULLY_SPECIFIED)); - - criteria.createAlias("concept", "concept"); - criteria.add(Restrictions.eq("concept.retired", false)); - criteria.setProjection(Projections.distinct(Projections.property("concept"))); - - @SuppressWarnings("unchecked") - List list = criteria.list(); - return list; + return sessionFactory.getCurrentSession() + .createQuery("select distinct cn.concept from ConceptName cn where " + nameClause + + " and cn.voided = false and cn.conceptNameType = :conceptNameType and cn.concept.retired = false", + Concept.class) + .setParameter("name", name).setParameter("conceptNameType", ConceptNameType.FULLY_SPECIFIED).list(); } } diff --git a/api/src/main/java/org/openmrs/module/initializer/api/InitializerServiceImpl.java b/api/src/main/java/org/openmrs/module/initializer/api/InitializerServiceImpl.java index 6b7e55ecc..1a80846f4 100644 --- a/api/src/main/java/org/openmrs/module/initializer/api/InitializerServiceImpl.java +++ b/api/src/main/java/org/openmrs/module/initializer/api/InitializerServiceImpl.java @@ -26,7 +26,7 @@ import org.apache.commons.lang3.BooleanUtils; import org.apache.commons.lang3.StringUtils; -import org.codehaus.jackson.map.ObjectMapper; +import com.fasterxml.jackson.databind.ObjectMapper; import org.openmrs.Concept; import org.openmrs.PersonAttributeType; import org.openmrs.api.context.Context; diff --git a/api/src/main/java/org/openmrs/module/initializer/api/attributes/types/AttributeTypesProxyServiceImpl.java b/api/src/main/java/org/openmrs/module/initializer/api/attributes/types/AttributeTypesProxyServiceImpl.java index 1dd3a0a25..5d74f346f 100644 --- a/api/src/main/java/org/openmrs/module/initializer/api/attributes/types/AttributeTypesProxyServiceImpl.java +++ b/api/src/main/java/org/openmrs/module/initializer/api/attributes/types/AttributeTypesProxyServiceImpl.java @@ -4,7 +4,7 @@ import java.util.List; import java.util.Set; -import org.apache.commons.lang.StringUtils; +import org.apache.commons.lang3.StringUtils; import org.openmrs.LocationAttributeType; import org.openmrs.ProviderAttributeType; import org.openmrs.VisitAttributeType; diff --git a/api/src/main/java/org/openmrs/module/initializer/api/drugs/IngredientsDrugLineProcessor.java b/api/src/main/java/org/openmrs/module/initializer/api/drugs/IngredientsDrugLineProcessor.java index ccb1d09d4..db8e5a299 100644 --- a/api/src/main/java/org/openmrs/module/initializer/api/drugs/IngredientsDrugLineProcessor.java +++ b/api/src/main/java/org/openmrs/module/initializer/api/drugs/IngredientsDrugLineProcessor.java @@ -1,6 +1,6 @@ package org.openmrs.module.initializer.api.drugs; -import org.apache.commons.lang.StringUtils; +import org.apache.commons.lang3.StringUtils; import org.openmrs.Concept; import org.openmrs.Drug; import org.openmrs.DrugIngredient; diff --git a/api/src/main/java/org/openmrs/module/initializer/api/fhir/cs/FhirConceptSourceCsvParser.java b/api/src/main/java/org/openmrs/module/initializer/api/fhir/cs/FhirConceptSourceCsvParser.java index 2345cc62a..b7b41ce6f 100644 --- a/api/src/main/java/org/openmrs/module/initializer/api/fhir/cs/FhirConceptSourceCsvParser.java +++ b/api/src/main/java/org/openmrs/module/initializer/api/fhir/cs/FhirConceptSourceCsvParser.java @@ -1,6 +1,6 @@ package org.openmrs.module.initializer.api.fhir.cs; -import org.apache.commons.lang.StringUtils; +import org.apache.commons.lang3.StringUtils; import org.openmrs.ConceptSource; import org.openmrs.annotation.OpenmrsProfile; import org.openmrs.api.ConceptService; diff --git a/api/src/main/java/org/openmrs/module/initializer/api/fhir/pis/FhirPatientIdentifierSystemCsvParser.java b/api/src/main/java/org/openmrs/module/initializer/api/fhir/pis/FhirPatientIdentifierSystemCsvParser.java index c18cef49a..430d2a84b 100644 --- a/api/src/main/java/org/openmrs/module/initializer/api/fhir/pis/FhirPatientIdentifierSystemCsvParser.java +++ b/api/src/main/java/org/openmrs/module/initializer/api/fhir/pis/FhirPatientIdentifierSystemCsvParser.java @@ -1,6 +1,6 @@ package org.openmrs.module.initializer.api.fhir.pis; -import org.apache.commons.lang.StringUtils; +import org.apache.commons.lang3.StringUtils; import org.openmrs.PatientIdentifierType; import org.openmrs.annotation.OpenmrsProfile; import org.openmrs.api.PatientService; diff --git a/api/src/main/java/org/openmrs/module/initializer/api/idgen/IdentifierPoolLineProcessor.java b/api/src/main/java/org/openmrs/module/initializer/api/idgen/IdentifierPoolLineProcessor.java index 87e80ad75..72caa5651 100644 --- a/api/src/main/java/org/openmrs/module/initializer/api/idgen/IdentifierPoolLineProcessor.java +++ b/api/src/main/java/org/openmrs/module/initializer/api/idgen/IdentifierPoolLineProcessor.java @@ -1,6 +1,6 @@ package org.openmrs.module.initializer.api.idgen; -import org.apache.commons.lang.StringUtils; +import org.apache.commons.lang3.StringUtils; import org.openmrs.annotation.OpenmrsProfile; import org.openmrs.module.idgen.IdentifierPool; import org.openmrs.module.idgen.IdentifierSource; diff --git a/api/src/main/java/org/openmrs/module/initializer/api/loaders/AmpathFormsLoader.java b/api/src/main/java/org/openmrs/module/initializer/api/loaders/AmpathFormsLoader.java index 87e737c9d..909f4eb2b 100644 --- a/api/src/main/java/org/openmrs/module/initializer/api/loaders/AmpathFormsLoader.java +++ b/api/src/main/java/org/openmrs/module/initializer/api/loaders/AmpathFormsLoader.java @@ -6,7 +6,7 @@ import org.apache.commons.io.FileUtils; import org.apache.commons.lang3.StringUtils; -import org.codehaus.jackson.map.ObjectMapper; +import com.fasterxml.jackson.databind.ObjectMapper; import org.openmrs.EncounterType; import org.openmrs.Form; import org.openmrs.FormResource; diff --git a/api/src/main/java/org/openmrs/module/initializer/api/loaders/AmpathFormsTranslationsLoader.java b/api/src/main/java/org/openmrs/module/initializer/api/loaders/AmpathFormsTranslationsLoader.java index 6391ca1d6..b62d628d8 100644 --- a/api/src/main/java/org/openmrs/module/initializer/api/loaders/AmpathFormsTranslationsLoader.java +++ b/api/src/main/java/org/openmrs/module/initializer/api/loaders/AmpathFormsTranslationsLoader.java @@ -6,7 +6,7 @@ import org.apache.commons.io.FileUtils; import org.apache.commons.lang3.LocaleUtils; import org.apache.commons.lang3.StringUtils; -import org.codehaus.jackson.map.ObjectMapper; +import com.fasterxml.jackson.databind.ObjectMapper; import org.openmrs.Form; import org.openmrs.FormResource; import org.openmrs.api.FormService; diff --git a/api/src/main/java/org/openmrs/module/initializer/api/loaders/BahmniFormsLoader.java b/api/src/main/java/org/openmrs/module/initializer/api/loaders/BahmniFormsLoader.java index b5b6b7b54..3c61eb7cd 100644 --- a/api/src/main/java/org/openmrs/module/initializer/api/loaders/BahmniFormsLoader.java +++ b/api/src/main/java/org/openmrs/module/initializer/api/loaders/BahmniFormsLoader.java @@ -10,8 +10,8 @@ import org.bahmni.module.bahmni.ie.apps.model.FormTranslation; import org.bahmni.module.bahmni.ie.apps.service.BahmniFormService; import org.bahmni.module.bahmni.ie.apps.service.BahmniFormTranslationService; -import org.codehaus.jackson.map.ObjectMapper; -import org.codehaus.jackson.type.TypeReference; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.core.type.TypeReference; import org.openmrs.Form; import org.openmrs.annotation.OpenmrsProfile; import org.openmrs.api.FormService; diff --git a/api/src/main/java/org/openmrs/module/initializer/api/loaders/LiquibaseLoader.java b/api/src/main/java/org/openmrs/module/initializer/api/loaders/LiquibaseLoader.java index 5e9a10490..98b28bb12 100644 --- a/api/src/main/java/org/openmrs/module/initializer/api/loaders/LiquibaseLoader.java +++ b/api/src/main/java/org/openmrs/module/initializer/api/loaders/LiquibaseLoader.java @@ -1,6 +1,7 @@ package org.openmrs.module.initializer.api.loaders; import org.openmrs.annotation.OpenmrsProfile; +import org.openmrs.liquibase.ChangeSetExecutorCallback; import org.openmrs.module.initializer.Domain; import org.openmrs.module.initializer.api.ConfigDirUtil; import org.openmrs.util.DatabaseUpdater; @@ -25,7 +26,7 @@ protected String getFileExtension() { @Override protected void load(File file) throws Exception { if (file.getName().equalsIgnoreCase(LIQUIBASE_FILE_NAME + "." + getFileExtension())) { - DatabaseUpdater.executeChangelog(file.getPath(), null); + DatabaseUpdater.executeChangelog(file.getPath(), (ChangeSetExecutorCallback) null); } } diff --git a/api/src/main/java/org/openmrs/module/initializer/api/loaders/OpenConceptLabLoader.java b/api/src/main/java/org/openmrs/module/initializer/api/loaders/OpenConceptLabLoader.java index 2590b1344..8f597909d 100644 --- a/api/src/main/java/org/openmrs/module/initializer/api/loaders/OpenConceptLabLoader.java +++ b/api/src/main/java/org/openmrs/module/initializer/api/loaders/OpenConceptLabLoader.java @@ -1,6 +1,6 @@ package org.openmrs.module.initializer.api.loaders; -import org.apache.commons.lang.StringUtils; +import org.apache.commons.lang3.StringUtils; import org.openmrs.annotation.OpenmrsProfile; import org.openmrs.api.context.Context; import org.openmrs.module.initializer.Domain; diff --git a/api/src/main/java/org/openmrs/module/initializer/api/mds/MetadataSetMembersCsvParser.java b/api/src/main/java/org/openmrs/module/initializer/api/mds/MetadataSetMembersCsvParser.java index 6fa1aca89..8d88d53b5 100644 --- a/api/src/main/java/org/openmrs/module/initializer/api/mds/MetadataSetMembersCsvParser.java +++ b/api/src/main/java/org/openmrs/module/initializer/api/mds/MetadataSetMembersCsvParser.java @@ -1,6 +1,6 @@ package org.openmrs.module.initializer.api.mds; -import org.apache.commons.lang.StringUtils; +import org.apache.commons.lang3.StringUtils; import org.openmrs.annotation.OpenmrsProfile; import org.openmrs.module.initializer.Domain; import org.openmrs.module.initializer.api.BaseLineProcessor; diff --git a/api/src/main/java/org/openmrs/module/initializer/api/mds/MetadataSetsCsvParser.java b/api/src/main/java/org/openmrs/module/initializer/api/mds/MetadataSetsCsvParser.java index 216c556ae..b86d89bae 100644 --- a/api/src/main/java/org/openmrs/module/initializer/api/mds/MetadataSetsCsvParser.java +++ b/api/src/main/java/org/openmrs/module/initializer/api/mds/MetadataSetsCsvParser.java @@ -1,6 +1,6 @@ package org.openmrs.module.initializer.api.mds; -import org.apache.commons.lang.StringUtils; +import org.apache.commons.lang3.StringUtils; import org.openmrs.annotation.OpenmrsProfile; import org.openmrs.module.initializer.Domain; import org.openmrs.module.initializer.api.BaseLineProcessor; diff --git a/api/src/main/java/org/openmrs/module/initializer/api/pat/PersonAttributeTypesCsvParser.java b/api/src/main/java/org/openmrs/module/initializer/api/pat/PersonAttributeTypesCsvParser.java index 707672d62..43cbfe111 100644 --- a/api/src/main/java/org/openmrs/module/initializer/api/pat/PersonAttributeTypesCsvParser.java +++ b/api/src/main/java/org/openmrs/module/initializer/api/pat/PersonAttributeTypesCsvParser.java @@ -1,6 +1,6 @@ package org.openmrs.module.initializer.api.pat; -import org.apache.commons.lang.StringUtils; +import org.apache.commons.lang3.StringUtils; import org.openmrs.PersonAttributeType; import org.openmrs.api.PersonService; import org.openmrs.module.initializer.Domain; diff --git a/api/src/main/java/org/openmrs/module/initializer/api/programs/ProgramLineProcessor.java b/api/src/main/java/org/openmrs/module/initializer/api/programs/ProgramLineProcessor.java index 4cecccabc..995c7b0fd 100644 --- a/api/src/main/java/org/openmrs/module/initializer/api/programs/ProgramLineProcessor.java +++ b/api/src/main/java/org/openmrs/module/initializer/api/programs/ProgramLineProcessor.java @@ -1,6 +1,6 @@ package org.openmrs.module.initializer.api.programs; -import org.apache.commons.lang.StringUtils; +import org.apache.commons.lang3.StringUtils; import org.openmrs.Concept; import org.openmrs.Program; import org.openmrs.api.ConceptService; diff --git a/api/src/main/java/org/openmrs/module/initializer/api/utils/Utils.java b/api/src/main/java/org/openmrs/module/initializer/api/utils/Utils.java index b467b86a9..2bab04312 100644 --- a/api/src/main/java/org/openmrs/module/initializer/api/utils/Utils.java +++ b/api/src/main/java/org/openmrs/module/initializer/api/utils/Utils.java @@ -2,10 +2,10 @@ import com.github.freva.asciitable.AsciiTable; import org.apache.commons.lang3.StringUtils; -import org.codehaus.jackson.JsonGenerationException; -import org.codehaus.jackson.JsonParseException; -import org.codehaus.jackson.map.JsonMappingException; -import org.codehaus.jackson.map.ObjectMapper; +import com.fasterxml.jackson.core.JsonGenerationException; +import com.fasterxml.jackson.core.JsonParseException; +import com.fasterxml.jackson.databind.JsonMappingException; +import com.fasterxml.jackson.databind.ObjectMapper; import org.openmrs.Concept; import org.openmrs.ConceptClass; import org.openmrs.ConceptMap; diff --git a/api/src/test/java/org/openmrs/module/initializer/DomainBaseModuleContextSensitiveTest.java b/api/src/test/java/org/openmrs/module/initializer/DomainBaseModuleContextSensitiveTest.java index d7fb61c7a..fea924a7f 100644 --- a/api/src/test/java/org/openmrs/module/initializer/DomainBaseModuleContextSensitiveTest.java +++ b/api/src/test/java/org/openmrs/module/initializer/DomainBaseModuleContextSensitiveTest.java @@ -16,25 +16,28 @@ import java.util.Locale; import java.util.Properties; -import org.junit.After; -import org.junit.Before; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; import org.openmrs.api.context.Context; import org.openmrs.messagesource.MessageSourceService; import org.openmrs.module.Module; import org.openmrs.module.ModuleFactory; import org.openmrs.module.initializer.api.InitializerService; -import org.openmrs.test.BaseModuleContextSensitiveTest; +import org.openmrs.test.jupiter.BaseModuleContextSensitiveTest; import org.openmrs.util.OpenmrsConstants; import org.openmrs.util.OpenmrsUtil; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.test.context.ContextConfiguration; /** * This allows to perform context sensitive tests on a specific domain inside the test app data * directory. */ +@ContextConfiguration(locations = { "classpath:applicationContext-service.xml", "classpath*:TestingApplicationContext.xml", + "classpath*:moduleApplicationContext.xml" }, loader = Platform3ModuleContextLoader.class, inheritLocations = false) public abstract class DomainBaseModuleContextSensitiveTest extends BaseModuleContextSensitiveTest { protected final Logger log = LoggerFactory.getLogger(getClass()); @@ -70,97 +73,27 @@ public DomainBaseModuleContextSensitiveTest() { } protected void initModules() { + // Only the optional modules that have a Platform 3.0 release are started, see Platform3ModuleContextLoader { - Module mod = new Module("", "addresshierarchy", "", "", "", "2.17.0"); + Module mod = new Module("", "fhir2", "", "", "", "1.6.0", ""); mod.setFile(new File("")); ModuleFactory.getStartedModulesMap().put(mod.getModuleId(), mod); } { - Module mod = new Module("", "exti18n", "", "", "", "1.0.0"); + Module mod = new Module("", "idgen", "", "", "", "4.6.0", ""); mod.setFile(new File("")); ModuleFactory.getStartedModulesMap().put(mod.getModuleId(), mod); } { - Module mod = new Module("", "fhir2", "", "", "", "1.6.0"); + Module mod = new Module("", "metadatamapping", "", "", "", "1.3.4", ""); mod.setFile(new File("")); ModuleFactory.getStartedModulesMap().put(mod.getModuleId(), mod); } { - Module mod = new Module("", "openconceptlab", "", "", "", "1.2.9"); + Module mod = new Module("", "cohort", "", "", "", "3.5.0", ""); mod.setFile(new File("")); ModuleFactory.getStartedModulesMap().put(mod.getModuleId(), mod); } - { - Module mod = new Module("", "htmlformentry", "", "", "", "4.0.0"); - mod.setFile(new File("")); - ModuleFactory.getStartedModulesMap().put(mod.getModuleId(), mod); - } - { - Module mod = new Module("", "idgen", "", "", "", "4.6.0"); - mod.setFile(new File("")); - ModuleFactory.getStartedModulesMap().put(mod.getModuleId(), mod); - } - { - Module mod = new Module("", "metadatasharing", "", "", "", "1.2.2"); - mod.setFile(new File("")); - ModuleFactory.getStartedModulesMap().put(mod.getModuleId(), mod); - } - { - Module mod = new Module("", "metadatamapping", "", "", "", "1.3.4"); - mod.setFile(new File("")); - ModuleFactory.getStartedModulesMap().put(mod.getModuleId(), mod); - } - { - Module mod = new Module("", "appointments", "", "", "", "1.2"); - mod.setFile(new File("")); - ModuleFactory.getStartedModulesMap().put(mod.getModuleId(), mod); - } - { - Module mod = new Module("", "datafilter", "", "", "", "1.0.0"); - mod.setFile(new File("")); - ModuleFactory.getStartedModulesMap().put(mod.getModuleId(), mod); - } - { - Module mod = new Module("", "bahmni.ie.apps", "", "", "", "1.0.0"); - mod.setFile(new File("")); - ModuleFactory.getStartedModulesMap().put(mod.getModuleId(), mod); - } - { - Module mod = new Module("", "providermanagement", "", "", "", "1.0.0"); - mod.setFile(new File("")); - ModuleFactory.getStartedModulesMap().put(mod.getModuleId(), mod); - } - { - Module mod = new Module("", "cohort", "", "", "", "3.5.0"); - mod.setFile(new File("")); - ModuleFactory.getStartedModulesMap().put(mod.getModuleId(), mod); - } - { - Module mod = new Module("", "emrapi", "", "", "", "2.0.0"); - mod.setFile(new File("")); - ModuleFactory.getStartedModulesMap().put(mod.getModuleId(), mod); - } - { - Module mod = new Module("", "tasks", "", "", "", "1.0.0"); - mod.setFile(new File("")); - ModuleFactory.getStartedModulesMap().put(mod.getModuleId(), mod); - } - { - Module mod = new Module("", "patientflags", "", "", "", "3.0.0"); - mod.setFile(new File("")); - ModuleFactory.getStartedModulesMap().put(mod.getModuleId(), mod); - } - { - try { - Class.forName("org.bahmni.module.bahmnicore.Activator"); - Module mod = new Module("", "bahmnicore", "", "", "", "0.93-1.1.0"); - mod.setFile(new File("")); - ModuleFactory.getStartedModulesMap().put(mod.getModuleId(), mod); - } - catch (Exception e) { - // ignore error since bahmnicore packages are not on the class path. - } - } } protected String getAppDataDirPath() { @@ -175,7 +108,7 @@ public Properties getRuntimeProperties() { return p; } - @Before + @BeforeEach public void setupAppDataDir() { String path = getAppDataDirPath(); System.setProperty("OPENMRS_APPLICATION_DATA_DIRECTORY", path); @@ -192,7 +125,7 @@ public void setupAppDataDir() { Locale.setDefault(Locale.ENGLISH); } - @After + @AfterEach public void tearDown() { deleteFilesByExtension(iniz.getChecksumsDirPath(), CHECKSUM_FILE_EXT); } diff --git a/api/src/test/java/org/openmrs/module/initializer/InitializerMessageSourceIntegrationTest.java b/api/src/test/java/org/openmrs/module/initializer/InitializerMessageSourceIntegrationTest.java index 88d4b4de5..794dddba1 100644 --- a/api/src/test/java/org/openmrs/module/initializer/InitializerMessageSourceIntegrationTest.java +++ b/api/src/test/java/org/openmrs/module/initializer/InitializerMessageSourceIntegrationTest.java @@ -10,15 +10,15 @@ package org.openmrs.module.initializer; import org.apache.commons.lang3.LocaleUtils; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.openmrs.api.context.Context; import org.openmrs.util.LocaleUtility; import org.springframework.beans.factory.annotation.Autowired; import java.util.Locale; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNull; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNull; public class InitializerMessageSourceIntegrationTest extends DomainBaseModuleContextSensitiveTest { diff --git a/api/src/test/java/org/openmrs/module/initializer/InitializerMessageSourceTest.java b/api/src/test/java/org/openmrs/module/initializer/InitializerMessageSourceTest.java index 2c46cfcfd..ac579ef3f 100644 --- a/api/src/test/java/org/openmrs/module/initializer/InitializerMessageSourceTest.java +++ b/api/src/test/java/org/openmrs/module/initializer/InitializerMessageSourceTest.java @@ -9,22 +9,17 @@ */ package org.openmrs.module.initializer; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; +import org.junit.jupiter.api.Test; import java.util.Locale; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNull; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNull; public class InitializerMessageSourceTest { InitializerMessageSource src = new InitializerMessageSource(); - @Rule - public ExpectedException expectedException = ExpectedException.none(); - @Test public void getLocaleFromFileBaseName_shouldInferValidLocale() { assertEquals(Locale.FRENCH, src.getLocaleFromFileBaseName("basename_fr")); diff --git a/api/src/test/java/org/openmrs/module/initializer/Platform3ModuleContextLoader.java b/api/src/test/java/org/openmrs/module/initializer/Platform3ModuleContextLoader.java new file mode 100644 index 000000000..1726775bb --- /dev/null +++ b/api/src/test/java/org/openmrs/module/initializer/Platform3ModuleContextLoader.java @@ -0,0 +1,99 @@ +/** + * 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. + */ +package org.openmrs.module.initializer; + +import java.io.IOException; +import java.io.UncheckedIOException; +import java.util.Arrays; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import org.springframework.beans.factory.support.RootBeanDefinition; +import org.springframework.beans.factory.xml.XmlBeanDefinitionReader; +import org.springframework.context.support.GenericApplicationContext; +import org.springframework.core.io.Resource; +import org.springframework.test.context.MergedContextConfiguration; +import org.springframework.test.context.support.GenericXmlContextLoader; +import org.springframework.util.ClassUtils; + +/** + * Loads the test application context like {@link GenericXmlContextLoader} but leaves out the Spring + * beans of the optional modules that Initializer is still compiled against a Platform 2.x release + * of: their moduleApplicationContext.xml is not loaded and the classes that core's component scan + * of org.openmrs picks up from their API jars are dropped. Those modules have no Platform 3.0 + * compatible release yet and their beans cannot start on Platform 3.0 (Hibernate Criteria API, + * removed *ServiceTarget beans, unresolvable placeholders...). Their jars are only kept on the test + * classpath for the plain unit tests of the Initializer classes integrating with them. + *

+ * It also registers the Platform 2.1 implementations that are profiled out on Platform 3.0 when the + * module providing their replacement is not on the classpath (i.e. when running the tests of + * initializer-api itself), so that those tests keep running against the same implementations as + * when they were run on Platform 2.1. + */ +public class Platform3ModuleContextLoader extends GenericXmlContextLoader { + + private static final List MODULES_WITHOUT_PLATFORM_3_RELEASE = Arrays.asList("addresshierarchy-api", + "appframework-api", "appointments-api", "bahmni.ie.apps-api", "bahmnicore-api", "billing-api", "calculation-api", + "datafilter-api", "emrapi-api", "episodes-api", "exti18n-api", "htmlformentry-api", "metadatasharing-api", + "openconceptlab-api", "patientflags-api", "providermanagement-api", "queue-api", "reporting-api", + "serialization.xstream-api", "tasks-api"); + + private static final Map PLATFORM_2_1_IMPLEMENTATIONS = new LinkedHashMap<>(); + + static { + PLATFORM_2_1_IMPLEMENTATIONS.put( + "org.openmrs.module.initializer.api.attributes.types.AttributeTypesProxyServiceImpl", + "org.openmrs.module.initializer.attributes.types.AttributeTypesProxyServiceImpl2_2"); + PLATFORM_2_1_IMPLEMENTATIONS.put( + "org.openmrs.module.initializer.api.attributes.types.AttributeTypeCsvLineHandlerImpl", + "org.openmrs.module.initializer.attributes.types.AttributeTypeCsvLineHandlerImpl2_2"); + } + + private static final Pattern JAR_NAME = Pattern.compile("/([^/!]+\\.jar)!/"); + + @Override + protected void loadBeanDefinitions(GenericApplicationContext context, MergedContextConfiguration mergedConfig) { + XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(context); + for (String location : mergedConfig.getLocations()) { + try { + for (Resource resource : context.getResources(location)) { + if (!isFromModuleWithoutPlatform3Release(resource.getURL().toString())) { + reader.loadBeanDefinitions(resource); + } + } + } + catch (IOException e) { + throw new UncheckedIOException(e); + } + } + for (String beanName : context.getBeanDefinitionNames()) { + if (isFromModuleWithoutPlatform3Release(context.getBeanDefinition(beanName).getResourceDescription())) { + context.removeBeanDefinition(beanName); + } + } + PLATFORM_2_1_IMPLEMENTATIONS.forEach((implementation, replacement) -> { + if (!ClassUtils.isPresent(replacement, context.getClassLoader())) { + context.registerBeanDefinition(implementation, new RootBeanDefinition(implementation)); + } + }); + } + + private boolean isFromModuleWithoutPlatform3Release(String resource) { + Matcher m = resource == null ? null : JAR_NAME.matcher(resource); + if (m == null || !m.find()) { + return false; + } + String jarName = m.group(1); + return MODULES_WITHOUT_PLATFORM_3_RELEASE.stream().anyMatch(module -> jarName.startsWith(module + "-")); + } +} diff --git a/api/src/test/java/org/openmrs/module/initializer/api/AddressHierarchyLoaderIntegrationTest.java b/api/src/test/java/org/openmrs/module/initializer/api/AddressHierarchyLoaderIntegrationTest.java index 01de3bc7e..39a660d09 100644 --- a/api/src/test/java/org/openmrs/module/initializer/api/AddressHierarchyLoaderIntegrationTest.java +++ b/api/src/test/java/org/openmrs/module/initializer/api/AddressHierarchyLoaderIntegrationTest.java @@ -20,10 +20,10 @@ import java.util.Set; import org.apache.commons.collections.CollectionUtils; -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.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.openmrs.GlobalProperty; import org.openmrs.PersonAddress; import org.openmrs.api.context.Context; @@ -61,7 +61,7 @@ public class AddressHierarchyLoaderIntegrationTest extends DomainBaseModuleConte @Autowired private AddressHierarchyLoader loader; - @Before + @BeforeEach public void setup() { // Disabling AH full caching otherwise loading takes too long Context.getAdministrationService().saveGlobalProperty(new GlobalProperty( @@ -74,12 +74,12 @@ public void setup() { .saveGlobalProperty(new GlobalProperty(ExtI18nConstants.GLOBAL_PROP_REV_I18N_SUPPORT, "true")); runtimeProperties.setProperty(ModuleConstants.RUNTIMEPROPERTY_MODULE_LIST_TO_LOAD, MODULES_TO_LOAD); ModuleUtil.startup(runtimeProperties); - Assert.assertTrue(ModuleFactory.isModuleStarted(ExtI18nConstants.MODULE_ARTIFACT_ID)); + Assertions.assertTrue(ModuleFactory.isModuleStarted(ExtI18nConstants.MODULE_ARTIFACT_ID)); inizSrc = (InitializerMessageSource) Context.getMessageSourceService().getActiveMessageSource(); } - @After + @AfterEach public void tearDown() { Context.getAdministrationService() .saveGlobalProperty(new GlobalProperty(ExtI18nConstants.GLOBAL_PROP_REV_I18N_SUPPORT, "false")); @@ -102,8 +102,8 @@ public void load_shouldLoadAddressHierarchyMessages() throws IOException { lnr.skip(Long.MAX_VALUE); int csvLineCount = lnr.getLineNumber() + 1; lnr.close(); - Assert.assertTrue(csvLineCount < ahs.getAddressHierarchyEntryCount()); // there should be more entries than the - // number of lines in CSV import + Assertions.assertTrue(csvLineCount < ahs.getAddressHierarchyEntryCount()); // there should be more entries than the + // number of lines in CSV import // Working in km_KH Context.getUserContext().setLocale(new Locale("km", "KH")); @@ -117,7 +117,7 @@ public void load_shouldLoadAddressHierarchyMessages() throws IOException { // Looking for possible villages based on an address provided in km_KH AddressHierarchyLevel villageLevel = ahs.getAddressHierarchyLevelByAddressField(AddressField.CITY_VILLAGE); List villageEntries = ahs.getPossibleAddressHierarchyEntries(address, villageLevel); - Assert.assertFalse(CollectionUtils.isEmpty(villageEntries)); + Assertions.assertFalse(CollectionUtils.isEmpty(villageEntries)); // Verifying that possible villages are provided as i18n message codes final Set expectedVillageNames = new HashSet(); // filled by looking at the test CSV @@ -132,7 +132,7 @@ public void load_shouldLoadAddressHierarchyMessages() throws IOException { expectedVillageNames.add("addresshierarchy.snaoTiPir"); expectedVillageNames.add("addresshierarchy.roleangSangkae"); for (AddressHierarchyEntry entry : villageEntries) { - Assert.assertTrue(expectedVillageNames.contains(entry.getName())); + Assertions.assertTrue(expectedVillageNames.contains(entry.getName())); } // Pinpointing a specific village @@ -142,9 +142,9 @@ public void load_shouldLoadAddressHierarchyMessages() throws IOException { villageEntries = ahs.getPossibleAddressHierarchyEntries(address, villageLevel); // We should find our one village - Assert.assertEquals(1, villageEntries.size()); + Assertions.assertEquals(1, villageEntries.size()); String messageKey = villageEntries.get(0).getName(); - Assert.assertEquals(messageKey, "addresshierarchy.paelHael"); - Assert.assertEquals(Context.getMessageSourceService().getMessage(messageKey), "ប៉ែលហែល"); + Assertions.assertEquals(messageKey, "addresshierarchy.paelHael"); + Assertions.assertEquals(Context.getMessageSourceService().getMessage(messageKey), "ប៉ែលហែល"); } } diff --git a/api/src/test/java/org/openmrs/module/initializer/api/AppointmentServiceDefinitionsLoaderIntegrationTest.java b/api/src/test/java/org/openmrs/module/initializer/api/AppointmentServiceDefinitionsLoaderIntegrationTest.java index 35ad90313..35e2adcf2 100644 --- a/api/src/test/java/org/openmrs/module/initializer/api/AppointmentServiceDefinitionsLoaderIntegrationTest.java +++ b/api/src/test/java/org/openmrs/module/initializer/api/AppointmentServiceDefinitionsLoaderIntegrationTest.java @@ -11,9 +11,10 @@ import static org.hamcrest.CoreMatchers.is; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; +import org.hamcrest.MatcherAssert; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.openmrs.Location; import org.openmrs.LocationTag; import org.openmrs.api.LocationService; @@ -42,7 +43,7 @@ public class AppointmentServiceDefinitionsLoaderIntegrationTest extends DomainBa @Autowired private AppointmentServiceDefinitionsLoader loader; - @Before + @BeforeEach public void setup() throws Exception { executeDataSet("testdata/test-metadata.xml"); @@ -57,64 +58,64 @@ public void load_shouldLoadAccordingToCsvFiles() { // Verify setup { - Assert.assertEquals("Orthopaedic", + Assertions.assertEquals("Orthopaedic", apts.getAppointmentServiceByUuid("6b220700-4ba2-4846-86a7-a2afa5b6f2eb").getSpeciality().getName()); - Assert.assertEquals("Xanadu", + Assertions.assertEquals("Xanadu", apts.getAppointmentServiceByUuid("a1039051-6f34-420d-9779-24e77eb0ca00").getLocation().getName()); } // Replay loader.load(); - Assert.assertThat(apts.getAllAppointmentServices(false).size(), is(7)); + MatcherAssert.assertThat(apts.getAllAppointmentServices(false).size(), is(7)); // Location set by UUID { AppointmentServiceDefinition def = apts.getAppointmentServiceByUuid("762e165a-af27-45fe-ad6e-1fe19db78198"); - Assert.assertEquals("Casting", def.getName()); - Assert.assertEquals(new Integer(30), def.getDurationMins()); - Assert.assertEquals(new Integer(15), def.getMaxAppointmentsLimit()); - Assert.assertEquals("Xanadu", def.getLocation().getName()); + Assertions.assertEquals("Casting", def.getName()); + Assertions.assertEquals(new Integer(30), def.getDurationMins()); + Assertions.assertEquals(new Integer(15), def.getMaxAppointmentsLimit()); + Assertions.assertEquals("Xanadu", def.getLocation().getName()); } // Location set by name { AppointmentServiceDefinition def = apts.getAppointmentServiceByUuid("bfff3484-320a-4c1e-84c8-dbe8f0d44e8b"); - Assert.assertEquals("Orthopaedic Follow-up", def.getName()); - Assert.assertEquals("A follow-up appointment at the orthopedic clinic", def.getDescription()); - Assert.assertEquals("Xanadu", def.getLocation().getName()); + Assertions.assertEquals("Orthopaedic Follow-up", def.getName()); + Assertions.assertEquals("A follow-up appointment at the orthopedic clinic", def.getDescription()); + Assertions.assertEquals("Xanadu", def.getLocation().getName()); } // Speciality set by name { AppointmentServiceDefinition def = apts.getAppointmentServiceByUuid("c12829d8-6bdd-426c-a386-104eed0d2c41"); - Assert.assertEquals("Bracing", def.getName()); - Assert.assertEquals("Orthopaedic", def.getSpeciality().getName()); - Assert.assertEquals("#8FBC8F", def.getColor()); + Assertions.assertEquals("Bracing", def.getName()); + Assertions.assertEquals("Orthopaedic", def.getSpeciality().getName()); + Assertions.assertEquals("#8FBC8F", def.getColor()); } // Speciality set by UUID { AppointmentServiceDefinition def = apts.getAppointmentServiceByUuid("b4b96cea-a0ed-4bbc-84f0-6c6b4e79f447"); - Assert.assertEquals("Tenotomy", def.getName()); - Assert.assertEquals("Orthopaedic", def.getSpeciality().getName()); + Assertions.assertEquals("Tenotomy", def.getName()); + Assertions.assertEquals("Orthopaedic", def.getSpeciality().getName()); } // Service start and end times { AppointmentServiceDefinition def = apts.getAppointmentServiceByUuid("fc46dedf-5e96-44d4-bd99-bec1d80d15d5"); - Assert.assertEquals("Surgery", def.getName()); - Assert.assertEquals("Appointment for surgery", def.getDescription()); - Assert.assertEquals("08:00:00", def.getStartTime().toString()); - Assert.assertEquals("17:00:00", def.getEndTime().toString()); + Assertions.assertEquals("Surgery", def.getName()); + Assertions.assertEquals("Appointment for surgery", def.getDescription()); + Assertions.assertEquals("08:00:00", def.getStartTime().toString()); + Assertions.assertEquals("17:00:00", def.getEndTime().toString()); } // Removing speciality { AppointmentServiceDefinition def = apts.getAppointmentServiceByUuid("6b220700-4ba2-4846-86a7-a2afa5b6f2eb"); - Assert.assertEquals("Specialized Appointment", def.getName()); - Assert.assertNull(def.getSpeciality()); + Assertions.assertEquals("Specialized Appointment", def.getName()); + Assertions.assertNull(def.getSpeciality()); } // Removing location { AppointmentServiceDefinition def = apts.getAppointmentServiceByUuid("a1039051-6f34-420d-9779-24e77eb0ca00"); - Assert.assertEquals("On-site Appointment", def.getName()); - Assert.assertNull(def.getLocation()); + Assertions.assertEquals("On-site Appointment", def.getName()); + Assertions.assertNull(def.getLocation()); } } } diff --git a/api/src/test/java/org/openmrs/module/initializer/api/AppointmentServiceTypesLoaderIntegrationTest.java b/api/src/test/java/org/openmrs/module/initializer/api/AppointmentServiceTypesLoaderIntegrationTest.java index dcfd3db7b..745f821cb 100644 --- a/api/src/test/java/org/openmrs/module/initializer/api/AppointmentServiceTypesLoaderIntegrationTest.java +++ b/api/src/test/java/org/openmrs/module/initializer/api/AppointmentServiceTypesLoaderIntegrationTest.java @@ -9,9 +9,9 @@ */ package org.openmrs.module.initializer.api; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.openmrs.module.appointments.model.AppointmentServiceType; import org.openmrs.module.appointments.service.AppointmentServiceDefinitionService; import org.openmrs.module.initializer.DomainBaseModuleContextSensitiveTest; @@ -29,7 +29,7 @@ public class AppointmentServiceTypesLoaderIntegrationTest extends DomainBaseModu @Autowired private AppointmentServiceTypesLoader loader; - @Before + @BeforeEach public void setup() throws Exception { executeDataSet("testdata/test-metadata.xml"); } @@ -44,34 +44,34 @@ public void load_shouldLoadAccordingToCsvFiles() { { AppointmentServiceType type = Utils.fetchBahmniAppointmentServiceType("f378bec4-2d0d-4509-a56e-b709e0a53700", apts); - Assert.assertEquals(Utils.fetchBahmniAppointmentServiceDefinition("On-site Appointment", apts), + Assertions.assertEquals(Utils.fetchBahmniAppointmentServiceDefinition("On-site Appointment", apts), type.getAppointmentServiceDefinition()); - Assert.assertEquals((Integer) 10, type.getDuration()); + Assertions.assertEquals((Integer) 10, type.getDuration()); } { AppointmentServiceType type = Utils.fetchBahmniAppointmentServiceType("0a4624a6-ca81-42e2-a1ab-8f8dca033b83", apts); - Assert.assertEquals(Utils.fetchBahmniAppointmentServiceDefinition("Specialized Appointment", apts), + Assertions.assertEquals(Utils.fetchBahmniAppointmentServiceDefinition("Specialized Appointment", apts), type.getAppointmentServiceDefinition()); - Assert.assertEquals((Integer) 45, type.getDuration()); + Assertions.assertEquals((Integer) 45, type.getDuration()); } // Verify retirement { AppointmentServiceType type = apts.getAppointmentServiceTypeByUuid("4e0f61df-d1f7-4cff-8d69-6264666daf3b"); - Assert.assertTrue(type.getVoided()); + Assertions.assertTrue(type.getVoided()); } // Verify creations { AppointmentServiceType type = apts.getAppointmentServiceTypeByUuid("ffd7e0f4-33f1-4802-b87a-8d610ba1132d"); - Assert.assertEquals(Utils.fetchBahmniAppointmentServiceDefinition("Specialized Appointment", apts), + Assertions.assertEquals(Utils.fetchBahmniAppointmentServiceDefinition("Specialized Appointment", apts), type.getAppointmentServiceDefinition()); - Assert.assertEquals((Integer) 45, type.getDuration()); + Assertions.assertEquals((Integer) 45, type.getDuration()); } { AppointmentServiceType type = Utils.fetchBahmniAppointmentServiceType("Complex Bracing", apts); - Assert.assertEquals(apts.getAppointmentServiceByUuid("6b220700-4ba2-4846-86a7-a2afa5b6f2eb"), + Assertions.assertEquals(apts.getAppointmentServiceByUuid("6b220700-4ba2-4846-86a7-a2afa5b6f2eb"), type.getAppointmentServiceDefinition()); - Assert.assertEquals((Integer) 75, type.getDuration()); + Assertions.assertEquals((Integer) 75, type.getDuration()); } } } diff --git a/api/src/test/java/org/openmrs/module/initializer/api/AttributeTypesLoaderTest.java b/api/src/test/java/org/openmrs/module/initializer/api/AttributeTypesLoaderTest.java index 7924b8531..6cbf8d3dc 100644 --- a/api/src/test/java/org/openmrs/module/initializer/api/AttributeTypesLoaderTest.java +++ b/api/src/test/java/org/openmrs/module/initializer/api/AttributeTypesLoaderTest.java @@ -4,9 +4,10 @@ import static org.hamcrest.core.StringStartsWith.startsWith; import static org.hamcrest.text.IsEmptyString.isEmptyOrNullString; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; +import org.hamcrest.MatcherAssert; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.openmrs.LocationAttributeType; import org.openmrs.ProviderAttributeType; import org.openmrs.VisitAttributeType; @@ -36,16 +37,16 @@ public class AttributeTypesLoaderTest extends DomainBaseModuleContextSensitiveTe private ProviderService ps; public static void assertCustomDatatype(String className) { - Assert.assertThat(className, startsWith("org.openmrs.customdatatype.datatype")); + MatcherAssert.assertThat(className, startsWith("org.openmrs.customdatatype.datatype")); try { Class.forName(className); } catch (ClassNotFoundException e) { - Assert.fail(className + " is not a valid OpenMRS custom data type class name."); + Assertions.fail(className + " is not a valid OpenMRS custom data type class name."); } } - @Before + @BeforeEach public void setup() throws Exception { executeDataSet("testdata/test-metadata.xml"); } @@ -55,24 +56,24 @@ public void load_shouldLoadAccordingToCsvFiles() { // Pre-load verif { LocationAttributeType attType = ls.getLocationAttributeTypeByUuid("9eca4f4e-707f-4bb8-8289-2f9b6e93803c"); - Assert.assertEquals("Location Code", attType.getName()); - Assert.assertThat(attType.getDescription(), isEmptyOrNullString()); - Assert.assertThat(attType.getMinOccurs(), is(0)); - Assert.assertNull(attType.getMaxOccurs()); + Assertions.assertEquals("Location Code", attType.getName()); + MatcherAssert.assertThat(attType.getDescription(), isEmptyOrNullString()); + MatcherAssert.assertThat(attType.getMinOccurs(), is(0)); + Assertions.assertNull(attType.getMaxOccurs()); } { ProviderAttributeType attType = ps.getProviderAttributeType(1090); - Assert.assertEquals("Provider Speciality", attType.getName()); - Assert.assertEquals("Clinical speciality for this provider", attType.getDescription()); - Assert.assertThat(attType.getMinOccurs(), is(0)); - Assert.assertThat(attType.getMaxOccurs(), is(5)); + Assertions.assertEquals("Provider Speciality", attType.getName()); + Assertions.assertEquals("Clinical speciality for this provider", attType.getDescription()); + MatcherAssert.assertThat(attType.getMinOccurs(), is(0)); + MatcherAssert.assertThat(attType.getMaxOccurs(), is(5)); } { ProviderAttributeType attType = ps.getProviderAttributeType(1091); - Assert.assertEquals("Provider Rating", attType.getName()); - Assert.assertThat(attType.getDescription(), isEmptyOrNullString()); - Assert.assertThat(attType.getMinOccurs(), is(1)); - Assert.assertThat(attType.getMaxOccurs(), is(1)); + Assertions.assertEquals("Provider Rating", attType.getName()); + MatcherAssert.assertThat(attType.getDescription(), isEmptyOrNullString()); + MatcherAssert.assertThat(attType.getMinOccurs(), is(1)); + MatcherAssert.assertThat(attType.getMaxOccurs(), is(1)); } // Replay @@ -81,49 +82,49 @@ public void load_shouldLoadAccordingToCsvFiles() { // Verify creations { VisitAttributeType attType = vs.getVisitAttributeTypeByUuid("0bc29982-3193-11e3-93ae-92367f222671"); - Assert.assertNotNull(attType); + Assertions.assertNotNull(attType); assertCustomDatatype(attType.getDatatypeClassname()); - Assert.assertEquals("org.openmrs.customdatatype.datatype.FreeTextDatatype", attType.getDatatypeClassname()); - Assert.assertEquals("Visit Color", attType.getName()); - Assert.assertEquals("Visit Color's description", attType.getDescription()); - Assert.assertThat(attType.getMinOccurs(), is(1)); - Assert.assertThat(attType.getMaxOccurs(), is(1)); + Assertions.assertEquals("org.openmrs.customdatatype.datatype.FreeTextDatatype", attType.getDatatypeClassname()); + Assertions.assertEquals("Visit Color", attType.getName()); + Assertions.assertEquals("Visit Color's description", attType.getDescription()); + MatcherAssert.assertThat(attType.getMinOccurs(), is(1)); + MatcherAssert.assertThat(attType.getMaxOccurs(), is(1)); } { LocationAttributeType attType = ls.getLocationAttributeTypeByUuid("0bb29984-3193-11e7-93ae-92367f002671"); - Assert.assertNotNull(attType); + Assertions.assertNotNull(attType); assertCustomDatatype(attType.getDatatypeClassname()); - Assert.assertEquals("org.openmrs.customdatatype.datatype.FloatDatatype", attType.getDatatypeClassname()); - Assert.assertEquals("Location Height", attType.getName()); + Assertions.assertEquals("org.openmrs.customdatatype.datatype.FloatDatatype", attType.getDatatypeClassname()); + Assertions.assertEquals("Location Height", attType.getName()); } // Verify edition using UUID as pivot { LocationAttributeType attType = ls.getLocationAttributeTypeByUuid("9eca4f4e-707f-4bb8-8289-2f9b6e93803c"); - Assert.assertNotNull(attType); - Assert.assertEquals("Location ISO Code", attType.getName()); - Assert.assertEquals("Location ISO Code's description", attType.getDescription()); + Assertions.assertNotNull(attType); + Assertions.assertEquals("Location ISO Code", attType.getName()); + Assertions.assertEquals("Location ISO Code's description", attType.getDescription()); assertCustomDatatype(attType.getDatatypeClassname()); - Assert.assertEquals("org.openmrs.customdatatype.datatype.FreeTextDatatype", attType.getDatatypeClassname()); - Assert.assertThat(attType.getMinOccurs(), is(1)); - Assert.assertThat(attType.getMaxOccurs(), is(10)); + Assertions.assertEquals("org.openmrs.customdatatype.datatype.FreeTextDatatype", attType.getDatatypeClassname()); + MatcherAssert.assertThat(attType.getMinOccurs(), is(1)); + MatcherAssert.assertThat(attType.getMaxOccurs(), is(10)); } // Verify edition using name as pivot { ProviderAttributeType attType = ps.getProviderAttributeType(1090); - Assert.assertNotNull(attType); - Assert.assertEquals("Provider Speciality", attType.getName()); - Assert.assertEquals("Clinical speciality for this provider", attType.getDescription()); + Assertions.assertNotNull(attType); + Assertions.assertEquals("Provider Speciality", attType.getName()); + Assertions.assertEquals("Clinical speciality for this provider", attType.getDescription()); assertCustomDatatype(attType.getDatatypeClassname()); - Assert.assertEquals("org.openmrs.customdatatype.datatype.FreeTextDatatype", attType.getDatatypeClassname()); - Assert.assertThat(attType.getMinOccurs(), is(0)); - Assert.assertThat(attType.getMaxOccurs(), is(7)); + Assertions.assertEquals("org.openmrs.customdatatype.datatype.FreeTextDatatype", attType.getDatatypeClassname()); + MatcherAssert.assertThat(attType.getMinOccurs(), is(0)); + MatcherAssert.assertThat(attType.getMaxOccurs(), is(7)); } // Verify retirement { ProviderAttributeType attType = ps.getProviderAttributeType(1091); - Assert.assertNotNull(attType); - Assert.assertTrue(attType.getRetired()); + Assertions.assertNotNull(attType); + Assertions.assertTrue(attType.getRetired()); } } } diff --git a/api/src/test/java/org/openmrs/module/initializer/api/AutoGenerationOptionsLoaderIntegrationTest.java b/api/src/test/java/org/openmrs/module/initializer/api/AutoGenerationOptionsLoaderIntegrationTest.java index db50adb11..6450d307d 100644 --- a/api/src/test/java/org/openmrs/module/initializer/api/AutoGenerationOptionsLoaderIntegrationTest.java +++ b/api/src/test/java/org/openmrs/module/initializer/api/AutoGenerationOptionsLoaderIntegrationTest.java @@ -1,8 +1,9 @@ package org.openmrs.module.initializer.api; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; +import org.hamcrest.MatcherAssert; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.openmrs.module.idgen.AutoGenerationOption; import org.openmrs.module.idgen.service.IdentifierSourceService; import org.openmrs.module.initializer.DomainBaseModuleContextSensitiveTest; @@ -21,7 +22,7 @@ public class AutoGenerationOptionsLoaderIntegrationTest extends DomainBaseModule private static String OPTION_TO_EDIT_UUID = "eade77b6-3365-47ed-9ee3-2324598629eb"; - @Before + @BeforeEach public void setup() throws Exception { executeDataSet("testdata/test-metadata.xml"); } @@ -36,14 +37,14 @@ public void load_shouldLoadAutoGenerationOptionsFromCSVLines() { // Verify created option = identifierSourceService.getAutoGenerationOptionByUuid("ca5cc0bf-38f0-41a6-9759-dd2a6763155a"); - Assert.assertNotNull(option); - Assert.assertTrue(option.isAutomaticGenerationEnabled()); - Assert.assertFalse(option.isManualEntryEnabled()); + Assertions.assertNotNull(option); + Assertions.assertTrue(option.isAutomaticGenerationEnabled()); + Assertions.assertFalse(option.isManualEntryEnabled()); //Verify edited option = identifierSourceService.getAutoGenerationOptionByUuid(OPTION_TO_EDIT_UUID); - Assert.assertFalse(option.isAutomaticGenerationEnabled()); - Assert.assertTrue(option.isManualEntryEnabled()); - Assert.assertThat(option.getIdentifierType().getName(), is("Legacy ID")); + Assertions.assertFalse(option.isAutomaticGenerationEnabled()); + Assertions.assertTrue(option.isManualEntryEnabled()); + MatcherAssert.assertThat(option.getIdentifierType().getName(), is("Legacy ID")); } } diff --git a/api/src/test/java/org/openmrs/module/initializer/api/BaseLineProcessorTest.java b/api/src/test/java/org/openmrs/module/initializer/api/BaseLineProcessorTest.java index 62fe5b835..2883baf9e 100644 --- a/api/src/test/java/org/openmrs/module/initializer/api/BaseLineProcessorTest.java +++ b/api/src/test/java/org/openmrs/module/initializer/api/BaseLineProcessorTest.java @@ -1,5 +1,6 @@ package org.openmrs.module.initializer.api; +import static org.junit.jupiter.api.Assertions.assertThrows; import java.util.ArrayList; import java.util.HashSet; import java.util.List; @@ -7,8 +8,8 @@ import java.util.Map; import java.util.Set; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import org.openmrs.module.initializer.api.c.LocalizedHeader; public class BaseLineProcessorTest { @@ -28,41 +29,47 @@ public void getVersion_shouldReturnTheVersionRhs() { hl1.add("Mapping"); // a regular header line - Assert.assertEquals("1", BaseLineProcessor.getVersion(hl1.toArray(new String[hl1.size()]))); + Assertions.assertEquals("1", BaseLineProcessor.getVersion(hl1.toArray(new String[hl1.size()]))); // the empty header line String[] hl2 = new String[0]; - Assert.assertEquals(BaseLineProcessor.UNDEFINED_METADATA_VALUE, BaseLineProcessor.getVersion(hl2)); + Assertions.assertEquals(BaseLineProcessor.UNDEFINED_METADATA_VALUE, BaseLineProcessor.getVersion(hl2)); // the header line with no version Set hl3 = new HashSet(hl1); hl3.remove(version); - Assert.assertEquals(BaseLineProcessor.UNDEFINED_METADATA_VALUE, + Assertions.assertEquals(BaseLineProcessor.UNDEFINED_METADATA_VALUE, BaseLineProcessor.getVersion(hl3.toArray(new String[hl3.size()]))); } - @Test(expected = IllegalArgumentException.class) + @Test public void getVersion_shouldFailWithMultipleVersions() { - - String version1 = BaseLineProcessor.VERSION_LHS + "1"; - String version2 = BaseLineProcessor.VERSION_LHS + "2"; - - Set hl = new HashSet(); - hl.add("Name"); - hl.add("Description"); - hl.add(version2); - hl.add("Class"); - hl.add("Datatype"); - hl.add(version1); - hl.add("Numeric unit"); - hl.add("Mapping"); - - BaseLineProcessor.getVersion(hl.toArray(new String[hl.size()])); + assertThrows(IllegalArgumentException.class, () -> { + + String version1 = BaseLineProcessor.VERSION_LHS + "1"; + String version2 = BaseLineProcessor.VERSION_LHS + "2"; + + Set hl = new HashSet(); + hl.add("Name"); + hl.add("Description"); + hl.add(version2); + hl.add("Class"); + hl.add("Datatype"); + hl.add(version1); + hl.add("Numeric unit"); + hl.add("Mapping"); + + BaseLineProcessor.getVersion(hl.toArray(new String[hl.size()])); + + }); } - @Test(expected = IllegalArgumentException.class) + @Test public void getVersion_shouldFailWithNull() { - BaseLineProcessor.getVersion(null); + assertThrows(IllegalArgumentException.class, () -> { + BaseLineProcessor.getVersion(null); + + }); } @Test @@ -81,28 +88,31 @@ public void createIndexMap_shouldMapHeaderNames() { // a regular header line Map indexMap = BaseLineProcessor.createIndexMap(hl1.toArray(new String[hl1.size()])); - Assert.assertEquals(0, BaseLineProcessor.getColumn(indexMap, "Name")); - Assert.assertEquals(1, BaseLineProcessor.getColumn(indexMap, "Description")); - Assert.assertEquals(2, BaseLineProcessor.getColumn(indexMap, "Class")); - Assert.assertEquals(3, BaseLineProcessor.getColumn(indexMap, "Datatype")); - Assert.assertEquals(4, BaseLineProcessor.getColumn(indexMap, version)); - Assert.assertEquals(5, BaseLineProcessor.getColumn(indexMap, "Numeric unit")); - Assert.assertEquals(6, BaseLineProcessor.getColumn(indexMap, "Mapping")); + Assertions.assertEquals(0, BaseLineProcessor.getColumn(indexMap, "Name")); + Assertions.assertEquals(1, BaseLineProcessor.getColumn(indexMap, "Description")); + Assertions.assertEquals(2, BaseLineProcessor.getColumn(indexMap, "Class")); + Assertions.assertEquals(3, BaseLineProcessor.getColumn(indexMap, "Datatype")); + Assertions.assertEquals(4, BaseLineProcessor.getColumn(indexMap, version)); + Assertions.assertEquals(5, BaseLineProcessor.getColumn(indexMap, "Numeric unit")); + Assertions.assertEquals(6, BaseLineProcessor.getColumn(indexMap, "Mapping")); } - @Test(expected = IllegalArgumentException.class) + @Test public void createIndexMap_shouldFailWithNonUniqueHeaders() { - - List hl1 = new ArrayList(); - hl1.add("Name"); - hl1.add("Description"); - hl1.add("Class"); - hl1.add("Datatype"); - hl1.add("Numeric unit"); - hl1.add("Mapping"); - hl1.add("Datatype"); - - BaseLineProcessor.createIndexMap(hl1.toArray(new String[hl1.size()])); + assertThrows(IllegalArgumentException.class, () -> { + + List hl1 = new ArrayList(); + hl1.add("Name"); + hl1.add("Description"); + hl1.add("Class"); + hl1.add("Datatype"); + hl1.add("Numeric unit"); + hl1.add("Mapping"); + hl1.add("Datatype"); + + BaseLineProcessor.createIndexMap(hl1.toArray(new String[hl1.size()])); + + }); } @Test @@ -127,17 +137,17 @@ public void getLocalizedHeaders_shouldListLocalizedHeaders() { Map lhMap = LocalizedHeader.getLocalizedHeadersMap(hl1.toArray(new String[hl1.size()])); // Verif - Assert.assertEquals(2, lhMap.size()); + Assertions.assertEquals(2, lhMap.size()); LocalizedHeader lh = null; - Assert.assertTrue(lhMap.containsKey("name")); + Assertions.assertTrue(lhMap.containsKey("name")); lh = lhMap.get("name"); - Assert.assertEquals(2, lh.getLocales().size()); - Assert.assertTrue(lh.getLocales().contains(Locale.ENGLISH)); - Assert.assertTrue(lh.getLocales().contains(localeKm)); + Assertions.assertEquals(2, lh.getLocales().size()); + Assertions.assertTrue(lh.getLocales().contains(Locale.ENGLISH)); + Assertions.assertTrue(lh.getLocales().contains(localeKm)); lh = lhMap.get("description"); - Assert.assertEquals(2, lh.getLocales().size()); - Assert.assertTrue(lh.getLocales().contains(Locale.ENGLISH)); - Assert.assertTrue(lh.getLocales().contains(localeKm)); + Assertions.assertEquals(2, lh.getLocales().size()); + Assertions.assertTrue(lh.getLocales().contains(Locale.ENGLISH)); + Assertions.assertTrue(lh.getLocales().contains(localeKm)); } @Test @@ -150,29 +160,32 @@ public void getUuid_shouldValidateUuid() { { String[] line = { uuid_1 }; String uuid = new CsvLine(headerLine, line).getUuid(); - Assert.assertEquals(uuid_1, uuid); + Assertions.assertEquals(uuid_1, uuid); } { String[] line = { uuid_4 }; String uuid = new CsvLine(headerLine, line).getUuid(); - Assert.assertEquals(uuid_4, uuid); + Assertions.assertEquals(uuid_4, uuid); } { String[] line = { null }; String uuid = new CsvLine(headerLine, line).getUuid(); - Assert.assertEquals(null, uuid); + Assertions.assertEquals(null, uuid); } { String[] line = { "" }; String uuid = new CsvLine(headerLine, line).getUuid(); - Assert.assertEquals("", uuid); + Assertions.assertEquals("", uuid); } } - @Test(expected = IllegalArgumentException.class) + @Test public void getUuid_shouldFailOnInvalidUuid() { - String[] headerLine = { "uuid" }; - String[] line = { "foobar" }; - new CsvLine(headerLine, line).getUuid(); + assertThrows(IllegalArgumentException.class, () -> { + String[] headerLine = { "uuid" }; + String[] line = { "foobar" }; + new CsvLine(headerLine, line).getUuid(); + + }); } } diff --git a/api/src/test/java/org/openmrs/module/initializer/api/CohortTypeLoaderIntegrationTest.java b/api/src/test/java/org/openmrs/module/initializer/api/CohortTypeLoaderIntegrationTest.java index 44fe1ba23..0b0dded64 100644 --- a/api/src/test/java/org/openmrs/module/initializer/api/CohortTypeLoaderIntegrationTest.java +++ b/api/src/test/java/org/openmrs/module/initializer/api/CohortTypeLoaderIntegrationTest.java @@ -2,7 +2,7 @@ import java.util.UUID; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.openmrs.module.cohort.CohortType; import org.openmrs.module.cohort.api.CohortTypeService; import org.openmrs.module.initializer.DomainBaseModuleContextSensitiveTest; @@ -14,7 +14,7 @@ import static org.hamcrest.Matchers.is; import static org.hamcrest.Matchers.not; import static org.hamcrest.Matchers.notNullValue; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; public class CohortTypeLoaderIntegrationTest extends DomainBaseModuleContextSensitiveTest { diff --git a/api/src/test/java/org/openmrs/module/initializer/api/ConceptClassesLoaderIntegrationTest.java b/api/src/test/java/org/openmrs/module/initializer/api/ConceptClassesLoaderIntegrationTest.java index 68b428860..2ef6a9b5b 100644 --- a/api/src/test/java/org/openmrs/module/initializer/api/ConceptClassesLoaderIntegrationTest.java +++ b/api/src/test/java/org/openmrs/module/initializer/api/ConceptClassesLoaderIntegrationTest.java @@ -9,8 +9,8 @@ */ package org.openmrs.module.initializer.api; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import org.openmrs.ConceptClass; import org.openmrs.api.ConceptService; import org.openmrs.module.initializer.DomainBaseModuleContextSensitiveTest; @@ -34,23 +34,23 @@ public void load_shouldLoadConceptClassesAccordingToCsvFiles() { { // created with uuid and description ConceptClass c = service.getConceptClassByName("Medical supply"); - Assert.assertNotNull(c); - Assert.assertEquals("69d620da-93c4-4767-916e-48f5fe8824c4", c.getUuid()); - Assert.assertEquals("Materials used in the facility", c.getDescription()); + Assertions.assertNotNull(c); + Assertions.assertEquals("69d620da-93c4-4767-916e-48f5fe8824c4", c.getUuid()); + Assertions.assertEquals("Materials used in the facility", c.getDescription()); } { // retired Procedure ConceptClass c = service.getConceptClassByName("Procedure"); - Assert.assertNotNull(c); - Assert.assertTrue(c.getRetired()); + Assertions.assertNotNull(c); + Assertions.assertTrue(c.getRetired()); } { // created without uuid or description ConceptClass c = service.getConceptClassByName("Animal"); - Assert.assertNotNull(c); + Assertions.assertNotNull(c); } { // edited to change description ConceptClass c = service.getConceptClassByUuid("3d065ed4-b0b9-4710-9a17-6d8c4fd259b7"); - Assert.assertEquals("Drug", c.getName()); // unchanged - Assert.assertEquals("Not what it sounds like", c.getDescription()); + Assertions.assertEquals("Drug", c.getName()); // unchanged + Assertions.assertEquals("Not what it sounds like", c.getDescription()); } } } diff --git a/api/src/test/java/org/openmrs/module/initializer/api/ConceptMapTypesLoaderIntegrationTest.java b/api/src/test/java/org/openmrs/module/initializer/api/ConceptMapTypesLoaderIntegrationTest.java index 9ece59a4b..23a1ed33f 100644 --- a/api/src/test/java/org/openmrs/module/initializer/api/ConceptMapTypesLoaderIntegrationTest.java +++ b/api/src/test/java/org/openmrs/module/initializer/api/ConceptMapTypesLoaderIntegrationTest.java @@ -12,8 +12,8 @@ import java.util.List; import java.util.stream.Collectors; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import org.openmrs.ConceptMapType; import org.openmrs.api.ConceptService; import org.openmrs.module.initializer.DomainBaseModuleContextSensitiveTest; @@ -38,44 +38,44 @@ public void load_shouldLoadConceptMapTypesAccordingToCsvFiles() { { // created with uuid and description ConceptMapType t = service.getConceptMapTypeByName("ASSOCIATED-WITH"); - Assert.assertNotNull(t); - Assert.assertEquals("d3a5e8b1-6c2f-4e7a-9b0d-1f2a3c4d5e6f", t.getUuid()); - Assert.assertEquals("Loosely associated concepts", t.getDescription()); - Assert.assertFalse(t.getIsHidden()); + Assertions.assertNotNull(t); + Assertions.assertEquals("d3a5e8b1-6c2f-4e7a-9b0d-1f2a3c4d5e6f", t.getUuid()); + Assertions.assertEquals("Loosely associated concepts", t.getDescription()); + Assertions.assertFalse(t.getIsHidden()); } { // created without uuid, explicitly not hidden ConceptMapType t = service.getConceptMapTypeByName("NARROWER-THAN"); - Assert.assertNotNull(t); - Assert.assertEquals("Target is narrower than the source", t.getDescription()); - Assert.assertFalse(t.getIsHidden()); + Assertions.assertNotNull(t); + Assertions.assertEquals("Target is narrower than the source", t.getDescription()); + Assertions.assertFalse(t.getIsHidden()); } { // created as hidden ConceptMapType t = service.getConceptMapTypeByName("INTERNAL-ONLY"); - Assert.assertNotNull(t); - Assert.assertTrue(t.getIsHidden()); + Assertions.assertNotNull(t); + Assertions.assertTrue(t.getIsHidden()); } { // edited by uuid: renamed 'related-to' to 'RELATED-TO' and set a description ConceptMapType t = service.getConceptMapTypeByUuid("1ccba764-49d6-11e0-8fed-18a905e044dc"); - Assert.assertNotNull(t); - Assert.assertEquals("RELATED-TO", t.getName()); - Assert.assertEquals("Related but not equivalent", t.getDescription()); + Assertions.assertNotNull(t); + Assertions.assertEquals("RELATED-TO", t.getName()); + Assertions.assertEquals("Related but not equivalent", t.getDescription()); List relatedTo = service.getConceptMapTypes(true, true).stream() .filter(m -> "related-to".equalsIgnoreCase(m.getName())).collect(Collectors.toList()); - Assert.assertEquals(1, relatedTo.size()); // renamed in place, no orphan created + Assertions.assertEquals(1, relatedTo.size()); // renamed in place, no orphan created } { // edited by name: an empty 'Is hidden' cell un-hides an existing hidden map type ConceptMapType t = service.getConceptMapTypeByUuid("be91ed88-64b1-11e0-b901-18a905e044dc"); - Assert.assertNotNull(t); - Assert.assertEquals("hidden", t.getName()); - Assert.assertEquals("No longer hidden", t.getDescription()); - Assert.assertFalse(t.getIsHidden()); + Assertions.assertNotNull(t); + Assertions.assertEquals("hidden", t.getName()); + Assertions.assertEquals("No longer hidden", t.getDescription()); + Assertions.assertFalse(t.getIsHidden()); } { // retired ConceptMapType t = service.getConceptMapTypeByName("is-parent-to"); - Assert.assertNotNull(t); - Assert.assertTrue(t.getRetired()); - Assert.assertEquals(InitializerConstants.DEFAULT_RETIRE_REASON, t.getRetireReason()); + Assertions.assertNotNull(t); + Assertions.assertTrue(t.getRetired()); + Assertions.assertEquals(InitializerConstants.DEFAULT_RETIRE_REASON, t.getRetireReason()); } } } diff --git a/api/src/test/java/org/openmrs/module/initializer/api/ConceptSetsLoaderIntegrationTest.java b/api/src/test/java/org/openmrs/module/initializer/api/ConceptSetsLoaderIntegrationTest.java index 5abdba33f..76cc6ab9e 100644 --- a/api/src/test/java/org/openmrs/module/initializer/api/ConceptSetsLoaderIntegrationTest.java +++ b/api/src/test/java/org/openmrs/module/initializer/api/ConceptSetsLoaderIntegrationTest.java @@ -9,8 +9,8 @@ */ package org.openmrs.module.initializer.api; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.openmrs.Concept; import org.openmrs.ConceptAnswer; import org.openmrs.ConceptSet; @@ -25,9 +25,9 @@ import java.util.Collections; import java.util.List; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; public class ConceptSetsLoaderIntegrationTest extends DomainBaseModuleContextSensitiveTest { @@ -41,7 +41,7 @@ public class ConceptSetsLoaderIntegrationTest extends DomainBaseModuleContextSen @Autowired private ConceptSetsLoader conceptSetsLoader; - @Before + @BeforeEach public void setup() throws Exception { executeDataSet("testdata/test-concepts.xml"); executeDataSet("testdata/test-concepts-numeric.xml"); diff --git a/api/src/test/java/org/openmrs/module/initializer/api/ConceptSourcesLoaderIntegrationTest.java b/api/src/test/java/org/openmrs/module/initializer/api/ConceptSourcesLoaderIntegrationTest.java index 93d264721..decc73d52 100644 --- a/api/src/test/java/org/openmrs/module/initializer/api/ConceptSourcesLoaderIntegrationTest.java +++ b/api/src/test/java/org/openmrs/module/initializer/api/ConceptSourcesLoaderIntegrationTest.java @@ -9,9 +9,9 @@ */ package org.openmrs.module.initializer.api; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.openmrs.ConceptSource; import org.openmrs.api.ConceptService; import org.openmrs.module.initializer.DomainBaseModuleContextSensitiveTest; @@ -28,7 +28,7 @@ public class ConceptSourcesLoaderIntegrationTest extends DomainBaseModuleContext @Autowired private ConceptSourcesLoader loader; - @Before + @BeforeEach public void setup() throws Exception { executeDataSet("testdata/test-concepts.xml"); } @@ -40,39 +40,39 @@ public void load_shouldLoadConceptSourcesAccordingToCsvFiles() { { // created with uuid and description ConceptSource c = service.getConceptSourceByName("Mexico"); - Assert.assertNotNull(c); - Assert.assertEquals("adbd4dc1-eb52-4670-8a69-bb646cef9cd7", c.getUuid()); - Assert.assertEquals("Reference codes for the Mexican MoH", c.getDescription()); + Assertions.assertNotNull(c); + Assertions.assertEquals("adbd4dc1-eb52-4670-8a69-bb646cef9cd7", c.getUuid()); + Assertions.assertEquals("Reference codes for the Mexican MoH", c.getDescription()); } { // retired ConceptSource c = service.getConceptSourceByName("Cambodia"); - Assert.assertNotNull(c); - Assert.assertTrue(c.getRetired()); + Assertions.assertNotNull(c); + Assertions.assertTrue(c.getRetired()); } { // created without uuid ConceptSource c = service.getConceptSourceByName("Peru"); - Assert.assertNotNull(c); - Assert.assertEquals("Reference terms for Peru", c.getDescription()); + Assertions.assertNotNull(c); + Assertions.assertEquals("Reference terms for Peru", c.getDescription()); } { // edited CIEL to change description ConceptSource c = service.getConceptSourceByUuid("245dd8d9-ed8e-4126-8866-d99d140d50b7"); - Assert.assertEquals("CIEL", c.getName()); // unchanged - Assert.assertEquals("The people's terminology source", c.getDescription()); + Assertions.assertEquals("CIEL", c.getName()); // unchanged + Assertions.assertEquals("The people's terminology source", c.getDescription()); } { // created with HL7 code ConceptSource c = service.getConceptSourceByHL7Code("SCT"); - Assert.assertNotNull(c); - Assert.assertEquals("SNOMED CT", c.getName()); - Assert.assertEquals("SNOMED Preferred mapping", c.getDescription()); - Assert.assertEquals("SCT", c.getHl7Code()); + Assertions.assertNotNull(c); + Assertions.assertEquals("SNOMED CT", c.getName()); + Assertions.assertEquals("SNOMED Preferred mapping", c.getDescription()); + Assertions.assertEquals("SCT", c.getHl7Code()); } { // created with Unique ID ConceptSource c = service.getConceptSourceByHL7Code("RADLEX"); - Assert.assertNotNull(c); - Assert.assertEquals("RadLex", c.getName()); - Assert.assertEquals("Radiology Terms", c.getDescription()); - Assert.assertEquals("RADLEX", c.getHl7Code()); - Assert.assertEquals("2.16.840.1.113883.6.256", c.getUniqueId()); + Assertions.assertNotNull(c); + Assertions.assertEquals("RadLex", c.getName()); + Assertions.assertEquals("Radiology Terms", c.getDescription()); + Assertions.assertEquals("RADLEX", c.getHl7Code()); + Assertions.assertEquals("2.16.840.1.113883.6.256", c.getUniqueId()); } } } diff --git a/api/src/test/java/org/openmrs/module/initializer/api/ConceptsLoaderIntegrationTest.java b/api/src/test/java/org/openmrs/module/initializer/api/ConceptsLoaderIntegrationTest.java index 139302827..cb5136560 100644 --- a/api/src/test/java/org/openmrs/module/initializer/api/ConceptsLoaderIntegrationTest.java +++ b/api/src/test/java/org/openmrs/module/initializer/api/ConceptsLoaderIntegrationTest.java @@ -10,9 +10,10 @@ package org.openmrs.module.initializer.api; import org.apache.commons.collections.CollectionUtils; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; +import org.hamcrest.MatcherAssert; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.openmrs.Concept; import org.openmrs.ConceptAnswer; import org.openmrs.ConceptAttribute; @@ -41,8 +42,8 @@ import java.util.Set; import static org.hamcrest.CoreMatchers.is; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotEquals; import static org.openmrs.module.initializer.InitializerConstants.CONCEPT_NAME_NAMESPACE_UUID; public class ConceptsLoaderIntegrationTest extends DomainBaseModuleContextSensitiveTest { @@ -65,7 +66,7 @@ public class ConceptsLoaderIntegrationTest extends DomainBaseModuleContextSensit private Locale localeKm = new Locale("km", "KH"); - @Before + @BeforeEach public void setup() throws Exception { executeDataSet("testdata/test-concepts.xml"); executeDataSet("testdata/test-concepts-numeric.xml"); @@ -80,18 +81,18 @@ public void load_shouldLoadConceptsAccordingToCsvFiles() { { c = cs.getConceptByUuid("d803e973-1010-4415-8659-c011dec707c0"); assertEquals(2, c.getSetMembers().size()); - Assert.assertTrue(c.isSet()); + Assertions.assertTrue(c.isSet()); c = cs.getConceptByUuid("4421da0d-42d0-410d-8ffd-47ec6f155d8f"); - Assert.assertFalse(c.getRetired()); + Assertions.assertFalse(c.getRetired()); // Verify initial state for version tests - Assert.assertNull(cs.getConceptByUuid("276c5861-cd46-429f-9665-e067ddeca8e3").getVersion()); + Assertions.assertNull(cs.getConceptByUuid("276c5861-cd46-429f-9665-e067ddeca8e3").getVersion()); assertEquals("1.0", cs.getConceptByUuid("d803e973-1010-4415-8659-c011dec707c0").getVersion()); assertEquals("1.7", cs.getConceptByName("CONCEPT_FETCH_BY_FSN").getVersion()); // Verify initial state for replaced names c = cs.getConceptByUuid("1ddb8255-00d5-45e8-8830-f9567919a382"); - Assert.assertNotNull(c); + Assertions.assertNotNull(c); assertEquals(3, c.getNames(localeEn).size()); ConceptName cn = c.getName(localeEn); @@ -120,7 +121,7 @@ public void load_shouldLoadConceptsAccordingToCsvFiles() { // Verify by name Context.setLocale(localeEn); c = cs.getConceptByName("Cambodia_Nationality"); - Assert.assertNotNull(c); + Assertions.assertNotNull(c); assertEquals("Nationality", c.getDescription().toString()); assertEquals("Question", c.getConceptClass().getName()); assertEquals("Coded", c.getDatatype().getName()); @@ -128,7 +129,7 @@ public void load_shouldLoadConceptsAccordingToCsvFiles() { // Verify by UUID Context.setLocale(localeEn); c = cs.getConceptByUuid("db2f4fc4-3171-11e7-93ae-92361f002671"); - Assert.assertNotNull(c); + Assertions.assertNotNull(c); assertEquals("Phnong", c.getShortNameInLocale(localeEn).getName()); assertEquals(0, c.getDescriptions().size()); assertEquals("Misc", c.getConceptClass().getName()); @@ -137,21 +138,21 @@ public void load_shouldLoadConceptsAccordingToCsvFiles() { // Verify in another locale Context.setLocale(localeKm); c = cs.getConceptByName("កម្ពុជា_ចាម"); - Assert.assertNotNull(c); - Assert.assertEquals("ចាម", c.getDescription().toString()); - Assert.assertEquals("Misc", c.getConceptClass().getName()); - Assert.assertEquals("Text", c.getDatatype().getName()); + Assertions.assertNotNull(c); + Assertions.assertEquals("ចាម", c.getDescription().toString()); + Assertions.assertEquals("Misc", c.getConceptClass().getName()); + Assertions.assertEquals("Text", c.getDatatype().getName()); name = c.getFullySpecifiedName(localeKm); - Assert.assertEquals(name.getUuid(), Utils.generateUuidFromObjects(CONCEPT_NAME_NAMESPACE_UUID, c.getUuid(), + Assertions.assertEquals(name.getUuid(), Utils.generateUuidFromObjects(CONCEPT_NAME_NAMESPACE_UUID, c.getUuid(), name.getName(), ConceptNameType.FULLY_SPECIFIED, localeKm)); name = c.getShortNameInLocale(localeKm); - Assert.assertEquals(name.getUuid(), Utils.generateUuidFromObjects(CONCEPT_NAME_NAMESPACE_UUID, c.getUuid(), + Assertions.assertEquals(name.getUuid(), Utils.generateUuidFromObjects(CONCEPT_NAME_NAMESPACE_UUID, c.getUuid(), name.getName(), ConceptNameType.SHORT, localeKm)); // Verify in another locale Context.setLocale(localeKm); c = cs.getConceptByName("កម្ពុជា_កួយ"); - Assert.assertNotNull(c); + Assertions.assertNotNull(c); assertEquals(1, c.getShortNames().size()); assertEquals("កួយ", c.getShortNameInLocale(localeKm).getName()); assertEquals("កួយ", c.getDescription().toString()); @@ -161,20 +162,20 @@ public void load_shouldLoadConceptsAccordingToCsvFiles() { // Verify just one name is enough Context.setLocale(localeEn); c = cs.getConceptByName("Cambodia_Kavet"); - Assert.assertNotNull(c); - Assert.assertEquals(1, c.getNames().size()); - Assert.assertEquals(0, c.getShortNames().size()); - Assert.assertEquals(0, c.getDescriptions().size()); - Assert.assertEquals("Misc", c.getConceptClass().getName()); - Assert.assertEquals("Text", c.getDatatype().getName()); + Assertions.assertNotNull(c); + Assertions.assertEquals(1, c.getNames().size()); + Assertions.assertEquals(0, c.getShortNames().size()); + Assertions.assertEquals(0, c.getDescriptions().size()); + Assertions.assertEquals("Misc", c.getConceptClass().getName()); + Assertions.assertEquals("Text", c.getDatatype().getName()); name = c.getFullySpecifiedName(localeEn); - Assert.assertEquals(name.getUuid(), Utils.generateUuidFromObjects(CONCEPT_NAME_NAMESPACE_UUID, c.getUuid(), + Assertions.assertEquals(name.getUuid(), Utils.generateUuidFromObjects(CONCEPT_NAME_NAMESPACE_UUID, c.getUuid(), name.getName(), ConceptNameType.FULLY_SPECIFIED, localeEn)); // Replaced names with updated UUIDs { c = cs.getConceptByUuid("1ddb8255-00d5-45e8-8830-f9567919a382"); - Assert.assertNotNull(c); + Assertions.assertNotNull(c); assertEquals(3, c.getNames(localeEn).size()); ConceptName cn = c.getName(localeEn); @@ -188,7 +189,7 @@ public void load_shouldLoadConceptsAccordingToCsvFiles() { assertNotEquals("8d09f38c-6ecb-4e3d-8a25-5cd204c43390", cn.getUuid()); assertEquals(Utils.generateUuidFromObjects(CONCEPT_NAME_NAMESPACE_UUID, c.getUuid(), cn.getName(), cn.getConceptNameType(), localeEn), cn.getUuid()); - Assert.assertTrue(cs.getConceptNameByUuid("8d09f38c-6ecb-4e3d-8a25-5cd204c43390").getVoided()); + Assertions.assertTrue(cs.getConceptNameByUuid("8d09f38c-6ecb-4e3d-8a25-5cd204c43390").getVoided()); cn = c.getNames(localeEn).stream().filter(cname -> cname.getConceptNameType() == null).findFirst() .orElseThrow(() -> new AssertionError("Expected at least one synonym but found none")); @@ -196,34 +197,34 @@ public void load_shouldLoadConceptsAccordingToCsvFiles() { assertNotEquals("05dfba65-0590-4886-ac50-8c3f69a8ea2e", cn.getUuid()); assertEquals(Utils.generateUuidFromObjects(CONCEPT_NAME_NAMESPACE_UUID, c.getUuid(), cn.getName(), cn.getConceptNameType(), localeEn), cn.getUuid()); - Assert.assertTrue(cs.getConceptNameByUuid("05dfba65-0590-4886-ac50-8c3f69a8ea2e").getVoided()); + Assertions.assertTrue(cs.getConceptNameByUuid("05dfba65-0590-4886-ac50-8c3f69a8ea2e").getVoided()); cn = c.getShortNameInLocale(localeEn); assertEquals("Rpl SN", cn.getName()); assertNotEquals("ff688089-4385-4d6c-9435-523506eda50e", cn.getUuid()); assertEquals(Utils.generateUuidFromObjects(CONCEPT_NAME_NAMESPACE_UUID, c.getUuid(), cn.getName(), cn.getConceptNameType(), localeEn), cn.getUuid()); - Assert.assertTrue(cs.getConceptNameByUuid("ff688089-4385-4d6c-9435-523506eda50e").getVoided()); + Assertions.assertTrue(cs.getConceptNameByUuid("ff688089-4385-4d6c-9435-523506eda50e").getVoided()); } // Failed ones Context.setLocale(localeEn); - Assert.assertNull(cs.getConceptByUuid("db2f5104-3171-11e7-93ae-92361f002671")); - Assert.assertNull(cs.getConceptByName("Cambodia_Krung")); - Assert.assertNull(cs.getConceptByName("db2f5460-3171-11e7-93ae-92361f002671")); - Assert.assertNull(cs.getConceptByName("Cambodia_Lao")); - Assert.assertNull(cs.getConceptByUuid("00b29984-3183-11e7-93ae-92361f002671")); + Assertions.assertNull(cs.getConceptByUuid("db2f5104-3171-11e7-93ae-92361f002671")); + Assertions.assertNull(cs.getConceptByName("Cambodia_Krung")); + Assertions.assertNull(cs.getConceptByName("db2f5460-3171-11e7-93ae-92361f002671")); + Assertions.assertNull(cs.getConceptByName("Cambodia_Lao")); + Assertions.assertNull(cs.getConceptByUuid("00b29984-3183-11e7-93ae-92361f002671")); // Retired one c = cs.getConceptByUuid("4421da0d-42d0-410d-8ffd-47ec6f155d8f"); - Assert.assertTrue(c.isRetired()); + Assertions.assertTrue(c.isRetired()); // Un-retire one Context.setLocale(localeEn); c = cs.getConceptByUuid("4c93c34e-37c2-11ea-bd28-d70ffe7aa802"); - Assert.assertNotNull(c); - Assert.assertFalse(c.getRetired()); + Assertions.assertNotNull(c); + Assertions.assertFalse(c.getRetired()); assertEquals("MMR", c.getFullySpecifiedName(localeEn).getName()); assertEquals("Misc", c.getConceptClass().getName()); assertEquals("N/A", c.getDatatype().getName()); @@ -231,15 +232,15 @@ public void load_shouldLoadConceptsAccordingToCsvFiles() { // Edited one Context.setLocale(localeEn); c = cs.getConceptByUuid("276c5861-cd46-429f-9665-e067ddeca8e3"); - Assert.assertEquals("New short name", c.getShortNameInLocale(localeEn).getName()); + Assertions.assertEquals("New short name", c.getShortNameInLocale(localeEn).getName()); name = c.getShortNameInLocale(localeEn); - Assert.assertEquals(name.getUuid(), Utils.generateUuidFromObjects(CONCEPT_NAME_NAMESPACE_UUID, c.getUuid(), + Assertions.assertEquals(name.getUuid(), Utils.generateUuidFromObjects(CONCEPT_NAME_NAMESPACE_UUID, c.getUuid(), name.getName(), ConceptNameType.SHORT, localeEn)); // Concept attributes c = cs.getConceptByUuid("4d3cfdcf-1f3f-4b41-9b31-02dfd951c582"); Object[] attributes = c.getActiveAttributes().toArray(); - Assert.assertThat(attributes.length, is(2)); + MatcherAssert.assertThat(attributes.length, is(2)); assertEquals("jdoe@example.com", ((ConceptAttribute) attributes[0]).getValue()); assertEquals("2020-04-06", dateDatatype.serialize((Date) ((ConceptAttribute) attributes[1]).getValue())); @@ -265,45 +266,45 @@ public void load_shouldLoadConceptsAccordingToCsvFiles() { // Verify question c = cs.getConceptByUuid("8bc50946-3221-11e7-93ae-92361f002671"); - Assert.assertNotNull(c); + Assertions.assertNotNull(c); // name should have been updated in concepts_set_without_members_or_answers_columns.csv assertEquals("Update concept name but do not remove answers", c.getFullySpecifiedName(localeEn).getName()); // but answers should still be as defined in concepts_nested - Assert.assertFalse(c.isSet()); - Assert.assertFalse(CollectionUtils.isEmpty(c.getAnswers())); + Assertions.assertFalse(c.isSet()); + Assertions.assertFalse(CollectionUtils.isEmpty(c.getAnswers())); assertEquals(2, c.getAnswers().size()); for (ConceptAnswer nested : c.getAnswers()) { - Assert.assertTrue(nestedUuids.contains(nested.getAnswerConcept().getUuid())); + Assertions.assertTrue(nestedUuids.contains(nested.getAnswerConcept().getUuid())); } // Verify set c = cs.getConceptByUuid("c84c3f88-3221-11e7-93ae-92361f002671"); - Assert.assertNotNull(c); + Assertions.assertNotNull(c); // name should have been updated in concepts_set_without_members_or_answers_columns.csv assertEquals("Update concept name but do not remove members", c.getFullySpecifiedName(localeEn).getName()); // but set should still be as defined in concepts_nested - Assert.assertTrue(c.isSet()); - Assert.assertFalse(CollectionUtils.isEmpty(c.getSetMembers())); + Assertions.assertTrue(c.isSet()); + Assertions.assertFalse(CollectionUtils.isEmpty(c.getSetMembers())); assertEquals(2, c.getSetMembers().size()); for (Concept nested : c.getSetMembers()) { - Assert.assertTrue(nestedUuids.contains(nested.getUuid())); + Assertions.assertTrue(nestedUuids.contains(nested.getUuid())); } // Verify not saved with missing answer(s) or member(s) - Assert.assertNull(cs.getConceptByName("Unexisting concept answer")); - Assert.assertNull(cs.getConceptByName("Unexisting set member")); + Assertions.assertNull(cs.getConceptByName("Unexisting concept answer")); + Assertions.assertNull(cs.getConceptByName("Unexisting set member")); // Verify modified (set members removed) c = cs.getConceptByUuid("d803e973-1010-4415-8659-c011dec707c0"); - Assert.assertTrue(CollectionUtils.isEmpty(c.getSetMembers())); - Assert.assertFalse(c.isSet()); + Assertions.assertTrue(CollectionUtils.isEmpty(c.getSetMembers())); + Assertions.assertFalse(c.isSet()); } // Verify. 'mappings' CSV loading { // Verify mappings are added c = cs.getConceptByUuid("2c4da504-33d4-11e7-a919-92ebcb67fe33"); - Assert.assertNotNull(c); + Assertions.assertNotNull(c); assertEquals(3, c.getConceptMappings().size()); Set names = new HashSet(); for (ConceptMap m : c.getConceptMappings()) { @@ -312,17 +313,17 @@ public void load_shouldLoadConceptsAccordingToCsvFiles() { String code = m.getConceptReferenceTerm().getCode(); names.add(mapType + ":" + source + ":" + code); } - Assert.assertTrue(names.contains("same-as:Cambodia:1234")); - Assert.assertTrue(names.contains("same-as:CIEL:159392")); - Assert.assertTrue(names.contains("broader-than:CIEL:broader-test-1")); + Assertions.assertTrue(names.contains("same-as:Cambodia:1234")); + Assertions.assertTrue(names.contains("same-as:CIEL:159392")); + Assertions.assertTrue(names.contains("broader-than:CIEL:broader-test-1")); // Verify not saved with missing mapping(s) - Assert.assertNull(cs.getConceptByName("Unexisting mapping")); + Assertions.assertNull(cs.getConceptByName("Unexisting mapping")); // Verify the mapping used with a now retired concept is the mapping of a new // concept c = cs.getConceptByMapping("foo12bar", "Cambodia"); - Assert.assertNotNull(c); + Assertions.assertNotNull(c); assertEquals("NEW_CONCEPT_REUSING_MAPPING", c.getFullySpecifiedName(localeEn).getName()); // Verify new mappings are added that are broader-than CIEL @@ -333,9 +334,9 @@ public void load_shouldLoadConceptsAccordingToCsvFiles() { String code = m.getConceptReferenceTerm().getCode(); names.add(mapType + ":" + source + ":" + code); } - Assert.assertTrue(names.contains("same-as:Cambodia:foo12bar")); - Assert.assertTrue(names.contains("broader-than:CIEL:broader-test-2a")); - Assert.assertTrue(names.contains("broader-than:CIEL:broader-test-2b")); + Assertions.assertTrue(names.contains("same-as:Cambodia:foo12bar")); + Assertions.assertTrue(names.contains("broader-than:CIEL:broader-test-2a")); + Assertions.assertTrue(names.contains("broader-than:CIEL:broader-test-2b")); } // Verify. 'numerics' CSV loading @@ -344,9 +345,9 @@ public void load_shouldLoadConceptsAccordingToCsvFiles() { // A valid concept numeric c = cs.getConceptByName("CN_1"); - Assert.assertNotNull(c); + Assertions.assertNotNull(c); cn = cs.getConceptNumeric(c.getId()); - Assert.assertNotNull(cn); + Assertions.assertNotNull(cn); assertEquals(0, cn.getLowAbsolute().compareTo(-100.5)); assertEquals(0, cn.getLowCritical().compareTo(-85.7)); assertEquals(0, cn.getLowNormal().compareTo(-50.3)); @@ -354,17 +355,17 @@ public void load_shouldLoadConceptsAccordingToCsvFiles() { assertEquals(0, cn.getHiCritical().compareTo(78.0)); assertEquals(0, cn.getHiAbsolute().compareTo(98.8)); assertEquals("foo", cn.getUnits()); - Assert.assertTrue(cn.getAllowDecimal()); + Assertions.assertTrue(cn.getAllowDecimal()); assertEquals(1, cn.getDisplayPrecision().intValue()); // This concept should have updated boundaries cn = cs.getConceptNumericByUuid("4280217a-eb93-4e2f-9684-28bed4690e7b"); - Assert.assertNotNull(cn); + Assertions.assertNotNull(cn); assertEquals(0, cn.getLowNormal().compareTo(45.7)); assertEquals(0, cn.getHiNormal().compareTo(55.6)); // Concept with misformatted boundaries should not have been created - Assert.assertNull(cs.getConceptByName("CN_3_ERROR")); + Assertions.assertNull(cs.getConceptByName("CN_3_ERROR")); } // Verify. 'concepts complex' CSV loading @@ -373,21 +374,21 @@ public void load_shouldLoadConceptsAccordingToCsvFiles() { // A valid concept numeric c = cs.getConceptByName("CC_1"); - Assert.assertNotNull(c); + Assertions.assertNotNull(c); cc = cs.getConceptComplex(c.getId()); - Assert.assertNotNull(cc); + Assertions.assertNotNull(cc); assertEquals("ImageHandler", cc.getHandler()); // This concept should have updated boundaries c = cs.getConceptByUuid("b0b15817-79d6-4c33-b7e9-bfa079d46f5f"); - Assert.assertNotNull(c); - Assert.assertNotNull(c.getConceptId()); + Assertions.assertNotNull(c); + Assertions.assertNotNull(c.getConceptId()); cc = cs.getConceptComplex(c.getId()); - Assert.assertNotNull(cc); + Assertions.assertNotNull(cc); assertEquals("BinaryDataHandler", cc.getHandler()); // Concept with missing complex data handler should not have been created - Assert.assertNull(cs.getConceptByName("CN_3_ERROR")); + Assertions.assertNull(cs.getConceptByName("CN_3_ERROR")); } // Verify. fetching and editing by FSN @@ -395,7 +396,7 @@ public void load_shouldLoadConceptsAccordingToCsvFiles() { { // Verify mappings are added c = cs.getConceptByName("CONCEPT_FETCH_BY_FSN"); - Assert.assertNotNull(c); + Assertions.assertNotNull(c); assertEquals("New short name", c.getShortNameInLocale(localeEn).toString()); } // Verify unvoiding ConceptName(s) if they exist @@ -404,19 +405,19 @@ public void load_shouldLoadConceptsAccordingToCsvFiles() { c = cs.getConceptByUuid("fda5cc2a-6245-4d91-be17-446d27aab33b"); ConceptName shortName = c.getShortNameInLocale(localeEn); ConceptName fullySpecifiedName = c.getFullySpecifiedName(localeEn); - Assert.assertNotNull(c); - Assert.assertEquals("Testing Short Name", shortName.toString()); - Assert.assertEquals("Testing Fully Specified Name", fullySpecifiedName.toString()); - Assert.assertEquals(Utils.generateUuidFromObjects(CONCEPT_NAME_NAMESPACE_UUID, c.getUuid(), "Testing Short Name", - ConceptNameType.SHORT, localeEn), shortName.getUuid()); - Assert.assertEquals(Utils.generateUuidFromObjects(CONCEPT_NAME_NAMESPACE_UUID, c.getUuid(), + Assertions.assertNotNull(c); + Assertions.assertEquals("Testing Short Name", shortName.toString()); + Assertions.assertEquals("Testing Fully Specified Name", fullySpecifiedName.toString()); + Assertions.assertEquals(Utils.generateUuidFromObjects(CONCEPT_NAME_NAMESPACE_UUID, c.getUuid(), + "Testing Short Name", ConceptNameType.SHORT, localeEn), shortName.getUuid()); + Assertions.assertEquals(Utils.generateUuidFromObjects(CONCEPT_NAME_NAMESPACE_UUID, c.getUuid(), "Testing Fully Specified Name", ConceptNameType.FULLY_SPECIFIED, localeEn), fullySpecifiedName.getUuid()); } Context.setLocale(localeKm); { // Verify mappings are added c = cs.getConceptByName("គំនិត_ដោយ_FSN"); - Assert.assertNotNull(c); + Assertions.assertNotNull(c); assertEquals("ឈ្មោះខ្លីថ្មី", c.getShortNameInLocale(localeKm).toString()); } } @@ -434,15 +435,15 @@ public void load_shouldLoadConceptNamesAccordingToCsvFiles() { // Initial state is that yellow and green are in the database, red and blue are not Concept yellow = cs.getConceptByUuid("4cfe07b0-3061-11ec-8d2b-0242ac110002"); - Assert.assertEquals(2, yellow.getNames(true).size()); + Assertions.assertEquals(2, yellow.getNames(true).size()); assertName(yellow, yellowUuid, "Yellow", localeEn, true, fsn); assertName(yellow, lemonUuid, "Lemon", localeEn, false, null); Concept green = cs.getConceptByUuid("61214827-303f-11ec-8d2b-0242ac110002"); - Assert.assertEquals(2, green.getNames(true).size()); + Assertions.assertEquals(2, green.getNames(true).size()); - Assert.assertNull(cs.getConceptByUuid("58083852-303f-11ec-8d2b-0242ac110002")); // red - Assert.assertNull(cs.getConceptByUuid("5dcaf167-303f-11ec-8d2b-0242ac110002")); // blue + Assertions.assertNull(cs.getConceptByUuid("58083852-303f-11ec-8d2b-0242ac110002")); // red + Assertions.assertNull(cs.getConceptByUuid("5dcaf167-303f-11ec-8d2b-0242ac110002")); // blue // Load once and test that all existing concept names are updated by uuid, and all new concept names are created loader.load(); @@ -453,7 +454,7 @@ public void load_shouldLoadConceptNamesAccordingToCsvFiles() { // These tests confirm that new names are loaded correctly with a variety of null and not-null fields Concept red = cs.getConceptByUuid("58083852-303f-11ec-8d2b-0242ac110002"); - Assert.assertEquals(5, red.getNames(true).size()); + Assertions.assertEquals(5, red.getNames(true).size()); assertName(red, "e91ab3ad-303f-11ec-8d2b-0242ac110002", "Red", localeEn, true, fsn); assertName(red, "Rojo", localeEs, true, fsn); assertName(red, "R", localeEn, false, shortName); @@ -461,7 +462,7 @@ public void load_shouldLoadConceptNamesAccordingToCsvFiles() { assertName(red, "Maroon", localeEn, false, null); Concept blue = cs.getConceptByUuid("5dcaf167-303f-11ec-8d2b-0242ac110002"); - Assert.assertEquals(7, blue.getNames(true).size()); + Assertions.assertEquals(7, blue.getNames(true).size()); assertName(blue, "fe9c8c03-303f-11ec-8d2b-0242ac110002", "Blue", localeEn, false, fsn); assertName(blue, "Azul", localeEs, true, fsn); assertName(blue, "B", localeEn, false, shortName); @@ -477,13 +478,13 @@ public void load_shouldLoadConceptNamesAccordingToCsvFiles() { // The original two names will be voided because they do not match the generated/seeded UUIDs. green = cs.getConceptByUuid("61214827-303f-11ec-8d2b-0242ac110002"); - Assert.assertEquals(4, green.getNames(true).size()); + Assertions.assertEquals(4, green.getNames(true).size()); assertName(green, "Green", localeEn, true, fsn); - Assert.assertEquals( + Assertions.assertEquals( Utils.generateUuidFromObjects(CONCEPT_NAME_NAMESPACE_UUID, green.getUuid(), "Green", fsn, localeEn), green.getName(localeEn).getUuid()); assertName(green, "Verde", localeEs, true, fsn); - Assert.assertEquals( + Assertions.assertEquals( Utils.generateUuidFromObjects(CONCEPT_NAME_NAMESPACE_UUID, green.getUuid(), "Verde", fsn, localeEs), green.getName(localeEs).getUuid()); @@ -496,10 +497,10 @@ public void load_shouldLoadConceptNamesAccordingToCsvFiles() { // The resulting concept should have 3 non-voided, and 1 voided name yellow = cs.getConceptByUuid("4cfe07b0-3061-11ec-8d2b-0242ac110002"); - Assert.assertEquals(4, yellow.getNames(true).size()); + Assertions.assertEquals(4, yellow.getNames(true).size()); assertName(yellow, yellowUuid, "Yellow", localeEn, true, null); ConceptName lemon = assertName(yellow, lemonUuid, "Lemon", localeEn, false, null); - Assert.assertTrue(lemon.getVoided()); + Assertions.assertTrue(lemon.getVoided()); assertName(yellow, "Lemon Yellow", localeEn, false, fsn); assertName(yellow, "Y", localeEn, false, shortName); } @@ -513,7 +514,7 @@ public void load_shouldLoadConceptSetMembersByFullySpecifiedNameSearch() { // Retrieving the 'Overall vital signs' set concept that should have the actual 'Vital signs' concept // and not the 'False vital signs' concept Concept actualVitalSigns = cs.getConceptByUuid("23542fd3-4315-4e51-b68e-bce887331c0a").getSetMembers().get(0); - Assert.assertNotNull(actualVitalSigns); + Assertions.assertNotNull(actualVitalSigns); assertName(actualVitalSigns, "Vital signs", localeEn, true, ConceptNameType.FULLY_SPECIFIED); } @@ -547,16 +548,16 @@ public void load_shouldFailToLoadConceptSetMembersByFullySpecifiedNameSearchGive // Verify fail Concept actualVitalSigns = cs.getConceptByUuid("23542fd3-4315-4e51-b68e-bce887331c0a"); - Assert.assertNull(actualVitalSigns); - Assert.assertEquals(2, inizService.getUnretiredConceptsByFullySpecifiedName("Vital signs").size()); + Assertions.assertNull(actualVitalSigns); + Assertions.assertEquals(2, inizService.getUnretiredConceptsByFullySpecifiedName("Vital signs").size()); } @Test public void getUnretiredConceptsByFullySpecifiedName_shouldReturnNullGivenBlankNameStringOrConceptNotFound() { // Verify - Assert.assertTrue(inizService.getUnretiredConceptsByFullySpecifiedName(" ").size() == 0); - Assert.assertTrue(inizService.getUnretiredConceptsByFullySpecifiedName(null).size() == 0); - Assert.assertTrue(inizService.getUnretiredConceptsByFullySpecifiedName("Missing Concept").size() == 0); + Assertions.assertTrue(inizService.getUnretiredConceptsByFullySpecifiedName(" ").size() == 0); + Assertions.assertTrue(inizService.getUnretiredConceptsByFullySpecifiedName(null).size() == 0); + Assertions.assertTrue(inizService.getUnretiredConceptsByFullySpecifiedName("Missing Concept").size() == 0); } protected ConceptName assertName(Concept c, String name, Locale locale, boolean preferred, ConceptNameType type) { @@ -569,7 +570,7 @@ protected ConceptName assertName(Concept c, String name, Locale locale, boolean } } if (conceptName == null) { - Assert.fail("No concept names found that match: " + name + "; " + locale + "; " + preferred + "; " + type); + Assertions.fail("No concept names found that match: " + name + "; " + locale + "; " + preferred + "; " + type); } return conceptName; } @@ -577,7 +578,7 @@ protected ConceptName assertName(Concept c, String name, Locale locale, boolean protected ConceptName assertName(Concept concept, String uuid, String name, Locale locale, boolean preferred, ConceptNameType type) { ConceptName cn = assertName(concept, name, locale, preferred, type); - Assert.assertEquals(uuid, cn.getUuid()); + Assertions.assertEquals(uuid, cn.getUuid()); return cn; } } diff --git a/api/src/test/java/org/openmrs/module/initializer/api/ConfigDirUtilTest.java b/api/src/test/java/org/openmrs/module/initializer/api/ConfigDirUtilTest.java index 9117fd9c7..81240df85 100644 --- a/api/src/test/java/org/openmrs/module/initializer/api/ConfigDirUtilTest.java +++ b/api/src/test/java/org/openmrs/module/initializer/api/ConfigDirUtilTest.java @@ -26,9 +26,9 @@ import org.apache.commons.codec.digest.DigestUtils; import org.apache.commons.collections.CollectionUtils; import org.apache.commons.io.FileUtils; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.openmrs.module.initializer.api.c.ConceptsLoader; public class ConfigDirUtilTest { @@ -38,7 +38,7 @@ public class ConfigDirUtilTest { private List allFiles; - @Before + @BeforeEach public void before() { allFiles = Arrays.asList(new File(dirPath).list()); } @@ -46,16 +46,18 @@ public void before() { @Test public void getLocatedFilename_shouldHandleRootLevelAndSubdirLevelFiles() { // with trailing slashes - Assert.assertEquals("cfg", getLocatedFilename("/configuration/domain/", new File("/configuration/domain/cfg.txt"))); - Assert.assertEquals("subdir_cfg", + Assertions.assertEquals("cfg", + getLocatedFilename("/configuration/domain/", new File("/configuration/domain/cfg.txt"))); + Assertions.assertEquals("subdir_cfg", getLocatedFilename("/configuration/domain/", new File("/configuration/domain/subdir/cfg.txt"))); - Assert.assertEquals("subdir_subsubdir_cfg", + Assertions.assertEquals("subdir_subsubdir_cfg", getLocatedFilename("/configuration/domain/", new File("/configuration/domain/subdir/subsubdir/cfg.txt"))); // without trailing slashes - Assert.assertEquals("cfg", getLocatedFilename("/configuration/domain", new File("/configuration/domain/cfg.txt"))); - Assert.assertEquals("subdir_cfg", + Assertions.assertEquals("cfg", + getLocatedFilename("/configuration/domain", new File("/configuration/domain/cfg.txt"))); + Assertions.assertEquals("subdir_cfg", getLocatedFilename("/configuration/domain", new File("/configuration/domain/subdir/cfg.txt"))); - Assert.assertEquals("subdir_subsubdir_cfg", + Assertions.assertEquals("subdir_subsubdir_cfg", getLocatedFilename("/configuration/domain", new File("/configuration/domain/subdir/subsubdir/cfg.txt"))); } @@ -132,7 +134,7 @@ public void getFiles_shouldHandleChecksumsWhenNestedFiles() throws IOException { // verify checksum File checksumFile = new File(Paths.get(checksumsDirPath, "nested_txt_files", checksumFilename).toUri()); assertThat(checksumFile.exists(), is(true)); - Assert.assertEquals(DigestUtils.md5Hex(fileContents.get(locatedFilename)), + Assertions.assertEquals(DigestUtils.md5Hex(fileContents.get(locatedFilename)), FileUtils.readFileToString(checksumFile, "UTF-8")); // verify deletion @@ -147,7 +149,7 @@ public void computeRowChecksum_shouldBeStableUnderColumnReordering() { String[] row1 = { "abc-123", "Acme", "A clinic" }; String[] header2 = { "name", "description", "uuid" }; String[] row2 = { "Acme", "A clinic", "abc-123" }; - Assert.assertEquals(computeRowChecksum(header1, row1), computeRowChecksum(header2, row2)); + Assertions.assertEquals(computeRowChecksum(header1, row1), computeRowChecksum(header2, row2)); } @Test @@ -172,7 +174,7 @@ public void computeRowChecksum_shouldDistinguishAbsentFromPresentButEmpty() { assertThat(computeRowChecksum(header1, row1), is(not(computeRowChecksum(header2, row3)))); // However null and empty values within an existing column should be treated identically, // since CsvParser normalizes blank cells to null on read. - Assert.assertEquals(computeRowChecksum(header2, row2), computeRowChecksum(header2, row3)); + Assertions.assertEquals(computeRowChecksum(header2, row2), computeRowChecksum(header2, row3)); } @Test @@ -245,7 +247,7 @@ public void getFiles_shouldAllowToOrderCsvFilesWithConceptsLoader() { // Setup String configDirPath = getClass().getClassLoader().getResource("org/openmrs/module/initializer/include/csv") .getPath(); - String checksumsDirPath = null; + String checksumsDirPath = ""; // checksums are not used here, and Paths.get(null, ...) throws on recent JDKs String domain = "orders"; ConfigDirUtil dirUtil = new ConfigDirUtil(configDirPath, checksumsDirPath, domain); @@ -256,9 +258,9 @@ public void getFiles_shouldAllowToOrderCsvFilesWithConceptsLoader() { // Verif assertThat(orderedFilenames.size(), is(5)); - Assert.assertEquals("5_order_500.csv", orderedFilenames.get(0)); - Assert.assertEquals("4_order_1000.csv", orderedFilenames.get(1)); - Assert.assertEquals("1_order_1500.csv", orderedFilenames.get(2)); + Assertions.assertEquals("5_order_500.csv", orderedFilenames.get(0)); + Assertions.assertEquals("4_order_1000.csv", orderedFilenames.get(1)); + Assertions.assertEquals("1_order_1500.csv", orderedFilenames.get(2)); assertThat(orderedFilenames.subList(3, 5), containsInAnyOrder("3_order_missing.csv", "2_order_e00.csv")); } } diff --git a/api/src/test/java/org/openmrs/module/initializer/api/DispositionsLoaderIntegrationTest.java b/api/src/test/java/org/openmrs/module/initializer/api/DispositionsLoaderIntegrationTest.java index 78e81c499..510c9166a 100644 --- a/api/src/test/java/org/openmrs/module/initializer/api/DispositionsLoaderIntegrationTest.java +++ b/api/src/test/java/org/openmrs/module/initializer/api/DispositionsLoaderIntegrationTest.java @@ -1,7 +1,8 @@ package org.openmrs.module.initializer.api; +import static org.junit.jupiter.api.Assertions.assertThrows; import org.apache.commons.io.FileUtils; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.openmrs.module.emrapi.disposition.DispositionService; import org.openmrs.module.initializer.DomainBaseModuleContextSensitiveTest; import org.openmrs.module.initializer.api.loaders.DispositionsLoader; @@ -39,19 +40,22 @@ public void load_shouldReloadOnMultipleLoads() { assertEquals(5, dispositionService.getDispositions().size()); } - @Test(expected = RuntimeException.class) + @Test public void load_shouldThrowExceptionInUnsafeModeIfMultipleFiles() throws Exception { - String existingFilePath = loader.getDirUtil().getDomainDirPath() + "/dispositionConfig.json"; - String additionalFilePath = loader.getDirUtil().getDomainDirPath() + "/additionalDispositionConfig.json"; - File srcFile = new File(existingFilePath); - File dstFile = new File(additionalFilePath); - FileUtils.copyFile(srcFile, dstFile); - - try { - loader.loadUnsafe(null, true); - } - finally { - FileUtils.deleteQuietly(dstFile); - } + assertThrows(RuntimeException.class, () -> { + String existingFilePath = loader.getDirUtil().getDomainDirPath() + "/dispositionConfig.json"; + String additionalFilePath = loader.getDirUtil().getDomainDirPath() + "/additionalDispositionConfig.json"; + File srcFile = new File(existingFilePath); + File dstFile = new File(additionalFilePath); + FileUtils.copyFile(srcFile, dstFile); + + try { + loader.loadUnsafe(null, true); + } + finally { + FileUtils.deleteQuietly(dstFile); + } + + }); } } diff --git a/api/src/test/java/org/openmrs/module/initializer/api/DrugsLoaderIntegrationTest.java b/api/src/test/java/org/openmrs/module/initializer/api/DrugsLoaderIntegrationTest.java index 409664596..1cf1f0db9 100644 --- a/api/src/test/java/org/openmrs/module/initializer/api/DrugsLoaderIntegrationTest.java +++ b/api/src/test/java/org/openmrs/module/initializer/api/DrugsLoaderIntegrationTest.java @@ -12,9 +12,9 @@ import java.util.Collection; import java.util.Locale; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.openmrs.Concept; import org.openmrs.ConceptName; import org.openmrs.Drug; @@ -34,7 +34,7 @@ public class DrugsLoaderIntegrationTest extends DomainBaseModuleContextSensitive @Autowired private DrugsLoader loader; - @Before + @BeforeEach public void setup() { // A concept to be used as 'dosage form' @@ -120,41 +120,41 @@ public void load_shouldLoadDrugsAccordingToCsvFiles() { // a vanilla drug { Drug d = cs.getDrug("Cetirizine 10mg Tablet"); - Assert.assertNotNull(d); - Assert.assertEquals(cs.getConceptByName("Cetirizine"), d.getConcept()); - Assert.assertEquals(cs.getConceptByName("Tablet"), d.getDosageForm()); + Assertions.assertNotNull(d); + Assertions.assertEquals(cs.getConceptByName("Cetirizine"), d.getConcept()); + Assertions.assertEquals(cs.getConceptByName("Tablet"), d.getDosageForm()); } // a drug without dosage form { Drug d = cs.getDrug("Erythromycine 500mg Tablet"); - Assert.assertNotNull(d); - Assert.assertEquals(cs.getConceptByName("Erythromycine"), d.getConcept()); - Assert.assertNull(d.getDosageForm()); + Assertions.assertNotNull(d); + Assertions.assertEquals(cs.getConceptByName("Erythromycine"), d.getConcept()); + Assertions.assertNull(d.getDosageForm()); } // an edited drug { Drug d = cs.getDrug("Metronidazole 500mg Tablet"); - Assert.assertNotNull(d); - Assert.assertEquals(cs.getConceptByName("Metronidazole (new)"), d.getConcept()); - Assert.assertEquals(cs.getConceptByName("Tablet"), d.getDosageForm()); + Assertions.assertNotNull(d); + Assertions.assertEquals(cs.getConceptByName("Metronidazole (new)"), d.getConcept()); + Assertions.assertEquals(cs.getConceptByName("Tablet"), d.getDosageForm()); } // an edited drug fetched by name { Drug d = cs.getDrugByUuid("42f010f8-26fe-102b-80cb-0017a47871b2"); - Assert.assertNotNull(d); - Assert.assertEquals(cs.getConceptByName("d4T"), d.getConcept()); - Assert.assertEquals("30mg", d.getStrength()); + Assertions.assertNotNull(d); + Assertions.assertEquals(cs.getConceptByName("d4T"), d.getConcept()); + Assertions.assertEquals("30mg", d.getStrength()); } // a new drug that starts out retired { Drug d = cs.getDrugByUuid("6e764d43-ae8b-11eb-8168-0242ac110002"); - Assert.assertNotNull(d); - Assert.assertEquals(cs.getConceptByName("Metronidazole (new)"), d.getConcept()); - Assert.assertEquals(cs.getConceptByName("Tablet"), d.getDosageForm()); - Assert.assertEquals("250mg", d.getStrength()); - Assert.assertTrue(d.getRetired()); + Assertions.assertNotNull(d); + Assertions.assertEquals(cs.getConceptByName("Metronidazole (new)"), d.getConcept()); + Assertions.assertEquals(cs.getConceptByName("Tablet"), d.getDosageForm()); + Assertions.assertEquals("250mg", d.getStrength()); + Assertions.assertTrue(d.getRetired()); } } @@ -163,24 +163,24 @@ public void load_shouldAddIngredientsToDrugs() { loader.load(); { Drug d = cs.getDrug("Combo Drug"); - Assert.assertNotNull(d); - Assert.assertEquals(cs.getConceptByName("d4T"), d.getConcept()); - Assert.assertEquals(cs.getConceptByName("Tablet"), d.getDosageForm()); - Assert.assertEquals("10mg", d.getStrength()); + Assertions.assertNotNull(d); + Assertions.assertEquals(cs.getConceptByName("d4T"), d.getConcept()); + Assertions.assertEquals(cs.getConceptByName("Tablet"), d.getDosageForm()); + Assertions.assertEquals("10mg", d.getStrength()); Collection ingredients = d.getIngredients(); Concept erythromycine = cs.getConceptByName("Erythromycine"); Concept cetirizine = cs.getConceptByName("Cetirizine"); Concept mg = cs.getConceptByName("mg"); - Assert.assertEquals(2, ingredients.size()); + Assertions.assertEquals(2, ingredients.size()); for (DrugIngredient ingredient : ingredients) { if (ingredient.getIngredient().equals(erythromycine)) { - Assert.assertEquals((Double) 4.0, ingredient.getStrength()); - Assert.assertEquals(mg, ingredient.getUnits()); + Assertions.assertEquals((Double) 4.0, ingredient.getStrength()); + Assertions.assertEquals(mg, ingredient.getUnits()); } else if (ingredient.getIngredient().equals(cetirizine)) { - Assert.assertEquals((Double) 6.0, ingredient.getStrength()); - Assert.assertEquals(mg, ingredient.getUnits()); + Assertions.assertEquals((Double) 6.0, ingredient.getStrength()); + Assertions.assertEquals(mg, ingredient.getUnits()); } else { - Assert.fail("Unexpected ingredient " + ingredient); + Assertions.fail("Unexpected ingredient " + ingredient); } } } @@ -190,25 +190,25 @@ public void load_shouldAddIngredientsToDrugs() { public void load_shouldRemoveIngredientsFromDrugs() { Drug drug = cs.getDrugByUuid("8abf401a-7f65-11f0-9e36-be568b1ab237"); - Assert.assertNotNull(drug); - Assert.assertEquals("Drug with Erythromycine", drug.getName()); - Assert.assertEquals(1, drug.getIngredients().size()); + Assertions.assertNotNull(drug); + Assertions.assertEquals("Drug with Erythromycine", drug.getName()); + Assertions.assertEquals(1, drug.getIngredients().size()); DrugIngredient erythromycine = drug.getIngredients().iterator().next(); - Assert.assertEquals(cs.getConceptByName("Erythromycine"), erythromycine.getIngredient()); - Assert.assertEquals((Double) 20.0, erythromycine.getStrength()); - Assert.assertEquals(cs.getConceptByName("mg"), erythromycine.getUnits()); + Assertions.assertEquals(cs.getConceptByName("Erythromycine"), erythromycine.getIngredient()); + Assertions.assertEquals((Double) 20.0, erythromycine.getStrength()); + Assertions.assertEquals(cs.getConceptByName("mg"), erythromycine.getUnits()); loader.load(); drug = cs.getDrugByUuid("8abf401a-7f65-11f0-9e36-be568b1ab237"); - Assert.assertNotNull(drug); - Assert.assertEquals("Drug without Erythromycine", drug.getName()); - Assert.assertEquals(1, drug.getIngredients().size()); + Assertions.assertNotNull(drug); + Assertions.assertEquals("Drug without Erythromycine", drug.getName()); + Assertions.assertEquals(1, drug.getIngredients().size()); DrugIngredient cetirizine = drug.getIngredients().iterator().next(); - Assert.assertNotEquals(erythromycine.getUuid(), cetirizine.getUuid()); - Assert.assertEquals(cs.getConceptByName("Cetirizine"), cetirizine.getIngredient()); - Assert.assertEquals((Double) 15.0, cetirizine.getStrength()); - Assert.assertEquals(cs.getConceptByName("mg"), cetirizine.getUnits()); + Assertions.assertNotEquals(erythromycine.getUuid(), cetirizine.getUuid()); + Assertions.assertEquals(cs.getConceptByName("Cetirizine"), cetirizine.getIngredient()); + Assertions.assertEquals((Double) 15.0, cetirizine.getStrength()); + Assertions.assertEquals(cs.getConceptByName("mg"), cetirizine.getUnits()); } @Test @@ -217,29 +217,29 @@ public void load_shouldModifyIngredientsInDrugs() { loader.load(); Drug drug = cs.getDrugByUuid("8abf401a-7f65-11f0-9e36-be568b1ab237"); - Assert.assertNotNull(drug); - Assert.assertEquals("Drug without Erythromycine", drug.getName()); - Assert.assertEquals(1, drug.getIngredients().size()); + Assertions.assertNotNull(drug); + Assertions.assertEquals("Drug without Erythromycine", drug.getName()); + Assertions.assertEquals(1, drug.getIngredients().size()); DrugIngredient cetirizine = drug.getIngredients().iterator().next(); - Assert.assertEquals(cs.getConceptByName("Cetirizine"), cetirizine.getIngredient()); - Assert.assertEquals((Double) 15.0, cetirizine.getStrength()); + Assertions.assertEquals(cs.getConceptByName("Cetirizine"), cetirizine.getIngredient()); + Assertions.assertEquals((Double) 15.0, cetirizine.getStrength()); cetirizine.setStrength(20.0); cs.saveDrug(drug); drug = cs.getDrugByUuid("8abf401a-7f65-11f0-9e36-be568b1ab237"); - Assert.assertEquals(1, drug.getIngredients().size()); + Assertions.assertEquals(1, drug.getIngredients().size()); DrugIngredient originalIngredient = drug.getIngredients().iterator().next(); - Assert.assertEquals((Double) 20.0, originalIngredient.getStrength()); + Assertions.assertEquals((Double) 20.0, originalIngredient.getStrength()); loader.getDirUtil().deleteChecksums(); loader.load(); drug = cs.getDrugByUuid("8abf401a-7f65-11f0-9e36-be568b1ab237"); - Assert.assertEquals(1, drug.getIngredients().size()); + Assertions.assertEquals(1, drug.getIngredients().size()); DrugIngredient modifiedIngredient = drug.getIngredients().iterator().next(); // NOTE: Ideally we'd test this, but due to a bug in core with saving drug ingredients, it doesn't work unless you are on very specific versions of core - //Assert.assertEquals(originalIngredient.getUuid(), modifiedIngredient.getUuid()); - Assert.assertEquals((Double) 15.0, modifiedIngredient.getStrength()); + //Assertions.assertEquals(originalIngredient.getUuid(), modifiedIngredient.getUuid()); + Assertions.assertEquals((Double) 15.0, modifiedIngredient.getStrength()); } } diff --git a/api/src/test/java/org/openmrs/module/initializer/api/EncounterRolesLoaderIntegrationTest.java b/api/src/test/java/org/openmrs/module/initializer/api/EncounterRolesLoaderIntegrationTest.java index 8a73e1d13..e71280ed0 100644 --- a/api/src/test/java/org/openmrs/module/initializer/api/EncounterRolesLoaderIntegrationTest.java +++ b/api/src/test/java/org/openmrs/module/initializer/api/EncounterRolesLoaderIntegrationTest.java @@ -9,9 +9,9 @@ */ package org.openmrs.module.initializer.api; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.openmrs.EncounterRole; import org.openmrs.api.EncounterService; import org.openmrs.module.initializer.DomainBaseModuleContextSensitiveTest; @@ -28,7 +28,7 @@ public class EncounterRolesLoaderIntegrationTest extends DomainBaseModuleContext @Autowired private EncounterRolesLoader loader; - @Before + @BeforeEach public void setup() throws Exception { executeDataSet("testdata/test-metadata.xml"); } @@ -40,25 +40,25 @@ public void load_shouldLoadOrderFrequenciesAccordingToCsvFiles() { { EncounterRole er = es.getEncounterRoleByUuid("54ce9816-1062-4636-af95-655066cd6aba"); - Assert.assertNotNull(er); - Assert.assertEquals("Surgeon", er.getName()); - Assert.assertEquals("Does surgery", er.getDescription()); + Assertions.assertNotNull(er); + Assertions.assertEquals("Surgeon", er.getName()); + Assertions.assertEquals("Does surgery", er.getDescription()); } { EncounterRole er = es.getEncounterRoleByUuid("6eb3cf82-cae3-4d50-a31c-90f9230504c8"); - Assert.assertNotNull(er); - Assert.assertEquals("Plague Doctor", er.getName()); - Assert.assertTrue(er.getRetired()); + Assertions.assertNotNull(er); + Assertions.assertEquals("Plague Doctor", er.getName()); + Assertions.assertTrue(er.getRetired()); } { EncounterRole er = es.getEncounterRoleByName("Anesthesiologist"); - Assert.assertNotNull(er); + Assertions.assertNotNull(er); } { EncounterRole er = es.getEncounterRoleByUuid("09a55bcc-2ce2-46a2-836c-4a56dce9d239"); - Assert.assertNotNull(er); - Assert.assertEquals("Phlebotomist", er.getName()); - Assert.assertEquals("Responsible for drawing blood", er.getDescription()); + Assertions.assertNotNull(er); + Assertions.assertEquals("Phlebotomist", er.getName()); + Assertions.assertEquals("Responsible for drawing blood", er.getDescription()); } } } diff --git a/api/src/test/java/org/openmrs/module/initializer/api/EncounterTypesLoaderIntegrationTest.java b/api/src/test/java/org/openmrs/module/initializer/api/EncounterTypesLoaderIntegrationTest.java index d40aa223e..f054bb983 100644 --- a/api/src/test/java/org/openmrs/module/initializer/api/EncounterTypesLoaderIntegrationTest.java +++ b/api/src/test/java/org/openmrs/module/initializer/api/EncounterTypesLoaderIntegrationTest.java @@ -11,9 +11,9 @@ import java.util.Locale; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.openmrs.EncounterType; import org.openmrs.Privilege; import org.openmrs.api.EncounterService; @@ -41,7 +41,7 @@ public class EncounterTypesLoaderIntegrationTest extends DomainBaseModuleContext private Locale localeKm = new Locale("km", "KH"); - @Before + @BeforeEach public void setup() { // a couple of privileges @@ -73,79 +73,79 @@ public void load_shouldLoadEncounterTypesAccordingToCsvFiles() { // verif { EncounterType et = es.getEncounterType("Triage Encounter"); - Assert.assertNotNull(et); - Assert.assertEquals("An encounter for triaging patients.", et.getDescription()); - Assert.assertNull(et.getViewPrivilege()); - Assert.assertNull(et.getEditPrivilege()); + Assertions.assertNotNull(et); + Assertions.assertEquals("An encounter for triaging patients.", et.getDescription()); + Assertions.assertNull(et.getViewPrivilege()); + Assertions.assertNull(et.getEditPrivilege()); } { EncounterType et = es.getEncounterTypeByUuid("aaa1a367-3047-4833-af27-b30e2dac9028"); - Assert.assertNotNull(et); - Assert.assertEquals("Medical History Encounter", et.getName()); - Assert.assertEquals("An interview about the patient medical history.", et.getDescription()); - Assert.assertNull(et.getViewPrivilege()); - Assert.assertNull(et.getEditPrivilege()); + Assertions.assertNotNull(et); + Assertions.assertEquals("Medical History Encounter", et.getName()); + Assertions.assertEquals("An interview about the patient medical history.", et.getDescription()); + Assertions.assertNull(et.getViewPrivilege()); + Assertions.assertNull(et.getEditPrivilege()); } { EncounterType et = es.getEncounterTypeByUuid("439559c2-a3a4-4a25-b4b2-1a0299e287ee"); - Assert.assertNotNull(et); - Assert.assertEquals("X-ray Encounter", et.getName()); - Assert.assertEquals("An encounter during wich X-rays are performed on the patient.", et.getDescription()); - Assert.assertEquals(us.getPrivilege("Can: View X-ray encounter"), et.getViewPrivilege()); - Assert.assertEquals(us.getPrivilege("Can: Edit X-ray encounter"), et.getEditPrivilege()); + Assertions.assertNotNull(et); + Assertions.assertEquals("X-ray Encounter", et.getName()); + Assertions.assertEquals("An encounter during wich X-rays are performed on the patient.", et.getDescription()); + Assertions.assertEquals(us.getPrivilege("Can: View X-ray encounter"), et.getViewPrivilege()); + Assertions.assertEquals(us.getPrivilege("Can: Edit X-ray encounter"), et.getEditPrivilege()); } { - Assert.assertNull(es.getEncounterTypeByUuid("400d7e07-6de6-40ac-8611-dcce12408e71")); - Assert.assertNull(es.getEncounterType("Foo Encounter")); + Assertions.assertNull(es.getEncounterTypeByUuid("400d7e07-6de6-40ac-8611-dcce12408e71")); + Assertions.assertNull(es.getEncounterType("Foo Encounter")); } { EncounterType et = es.getEncounterTypeByUuid("bed6f0f6-ab07-481f-929f-3d26e6cb1138"); - Assert.assertNotNull(et); - Assert.assertTrue(et.isRetired()); + Assertions.assertNotNull(et); + Assertions.assertTrue(et.isRetired()); } { EncounterType et = es.getEncounterType("Oncology Encounter"); - Assert.assertNotNull(et); - Assert.assertEquals("A new description for the oncology encounter.", et.getDescription()); - Assert.assertEquals(us.getPrivilege("Can: View oncology encounter"), et.getViewPrivilege()); + Assertions.assertNotNull(et); + Assertions.assertEquals("A new description for the oncology encounter.", et.getDescription()); + Assertions.assertEquals(us.getPrivilege("Can: View oncology encounter"), et.getViewPrivilege()); } // verify EncounterTypes domain i18n on entries with display:xy fields { - Assert.assertEquals("Medical History Encounter (translated)", Context.getMessageSourceService() + Assertions.assertEquals("Medical History Encounter (translated)", Context.getMessageSourceService() .getMessage("ui.i18n.EncounterType.name.aaa1a367-3047-4833-af27-b30e2dac9028", null, localeEn)); - Assert.assertEquals("ប្រវត្តិសាស្រ្តវេជ្ជសាស្រ្ត", Context.getMessageSourceService() + Assertions.assertEquals("ប្រវត្តិសាស្រ្តវេជ្ជសាស្រ្ត", Context.getMessageSourceService() .getMessage("ui.i18n.EncounterType.name.aaa1a367-3047-4833-af27-b30e2dac9028", null, localeKm)); - Assert.assertEquals("Medical History Encounter (translated)", Context.getMessageSourceService() + Assertions.assertEquals("Medical History Encounter (translated)", Context.getMessageSourceService() .getMessage("org.openmrs.EncounterType.aaa1a367-3047-4833-af27-b30e2dac9028", null, localeEn)); - Assert.assertEquals("ប្រវត្តិសាស្រ្តវេជ្ជសាស្រ្ត", Context.getMessageSourceService() + Assertions.assertEquals("ប្រវត្តិសាស្រ្តវេជ្ជសាស្រ្ត", Context.getMessageSourceService() .getMessage("org.openmrs.EncounterType.aaa1a367-3047-4833-af27-b30e2dac9028", null, localeKm)); } // verify no EncounterTypes domain i18n on entries without display:xy fields and entries without pre-filled uuids { - Assert.assertNotNull(es.getEncounterTypeByUuid("439559c2-a3a4-4a25-b4b2-1a0299e287ee")); - Assert.assertEquals("ui.i18n.EncounterType.name.439559c2-a3a4-4a25-b4b2-1a0299e287ee", + Assertions.assertNotNull(es.getEncounterTypeByUuid("439559c2-a3a4-4a25-b4b2-1a0299e287ee")); + Assertions.assertEquals("ui.i18n.EncounterType.name.439559c2-a3a4-4a25-b4b2-1a0299e287ee", Context.getMessageSourceService() .getMessage("ui.i18n.EncounterType.name.439559c2-a3a4-4a25-b4b2-1a0299e287ee", null, localeEn)); - Assert.assertEquals("ui.i18n.EncounterType.name.439559c2-a3a4-4a25-b4b2-1a0299e287ee", + Assertions.assertEquals("ui.i18n.EncounterType.name.439559c2-a3a4-4a25-b4b2-1a0299e287ee", Context.getMessageSourceService() .getMessage("ui.i18n.EncounterType.name.439559c2-a3a4-4a25-b4b2-1a0299e287ee", null, localeKm)); - Assert.assertEquals("org.openmrs.EncounterType.439559c2-a3a4-4a25-b4b2-1a0299e287ee", + Assertions.assertEquals("org.openmrs.EncounterType.439559c2-a3a4-4a25-b4b2-1a0299e287ee", Context.getMessageSourceService() .getMessage("org.openmrs.EncounterType.439559c2-a3a4-4a25-b4b2-1a0299e287ee", null, localeEn)); - Assert.assertEquals("org.openmrs.EncounterType.439559c2-a3a4-4a25-b4b2-1a0299e287ee", + Assertions.assertEquals("org.openmrs.EncounterType.439559c2-a3a4-4a25-b4b2-1a0299e287ee", Context.getMessageSourceService() .getMessage("org.openmrs.EncounterType.439559c2-a3a4-4a25-b4b2-1a0299e287ee", null, localeKm)); EncounterType et = es.getEncounterType("Triage Encounter"); String uuid = et.getUuid(); - Assert.assertEquals("ui.i18n.EncounterType.name." + uuid, + Assertions.assertEquals("ui.i18n.EncounterType.name." + uuid, Context.getMessageSourceService().getMessage("ui.i18n.EncounterType.name." + uuid, null, localeEn)); - Assert.assertEquals("ui.i18n.EncounterType.name." + uuid, + Assertions.assertEquals("ui.i18n.EncounterType.name." + uuid, Context.getMessageSourceService().getMessage("ui.i18n.EncounterType.name." + uuid, null, localeKm)); - Assert.assertEquals("org.openmrs.EncounterType." + uuid, + Assertions.assertEquals("org.openmrs.EncounterType." + uuid, Context.getMessageSourceService().getMessage("org.openmrs.EncounterType." + uuid, null, localeEn)); - Assert.assertEquals("org.openmrs.EncounterType." + uuid, + Assertions.assertEquals("org.openmrs.EncounterType." + uuid, Context.getMessageSourceService().getMessage("org.openmrs.EncounterType." + uuid, null, localeKm)); } } diff --git a/api/src/test/java/org/openmrs/module/initializer/api/FhirConceptSourcesLoaderIntegrationTest.java b/api/src/test/java/org/openmrs/module/initializer/api/FhirConceptSourcesLoaderIntegrationTest.java index 08269e085..765a3776a 100644 --- a/api/src/test/java/org/openmrs/module/initializer/api/FhirConceptSourcesLoaderIntegrationTest.java +++ b/api/src/test/java/org/openmrs/module/initializer/api/FhirConceptSourcesLoaderIntegrationTest.java @@ -1,7 +1,7 @@ package org.openmrs.module.initializer.api; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.openmrs.ConceptSource; import org.openmrs.api.ConceptService; import org.openmrs.module.fhir2.api.FhirConceptSourceService; @@ -33,7 +33,7 @@ public class FhirConceptSourcesLoaderIntegrationTest extends DomainBaseModuleCon @Autowired private FhirConceptSourcesLoader loader; - @Before + @BeforeEach public void setup() { { ConceptSource conceptSource = new ConceptSource(); diff --git a/api/src/test/java/org/openmrs/module/initializer/api/FhirPatientIdentifierSystemIntegrationTest.java b/api/src/test/java/org/openmrs/module/initializer/api/FhirPatientIdentifierSystemIntegrationTest.java index 41cc25642..58618a4ee 100644 --- a/api/src/test/java/org/openmrs/module/initializer/api/FhirPatientIdentifierSystemIntegrationTest.java +++ b/api/src/test/java/org/openmrs/module/initializer/api/FhirPatientIdentifierSystemIntegrationTest.java @@ -1,7 +1,7 @@ package org.openmrs.module.initializer.api; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.openmrs.PatientIdentifierType; import org.openmrs.api.PatientService; import org.openmrs.module.fhir2.api.FhirPatientIdentifierSystemService; @@ -35,7 +35,7 @@ public class FhirPatientIdentifierSystemIntegrationTest extends DomainBaseModule FhirPatientIdentifierSystem thirdSystem; - @Before + @BeforeEach public void setup() { { firstType = new PatientIdentifierType(); diff --git a/api/src/test/java/org/openmrs/module/initializer/api/GlobalPropertiesLoaderIntegrationTest.java b/api/src/test/java/org/openmrs/module/initializer/api/GlobalPropertiesLoaderIntegrationTest.java index e4df73e56..d010ddb94 100644 --- a/api/src/test/java/org/openmrs/module/initializer/api/GlobalPropertiesLoaderIntegrationTest.java +++ b/api/src/test/java/org/openmrs/module/initializer/api/GlobalPropertiesLoaderIntegrationTest.java @@ -9,8 +9,8 @@ */ package org.openmrs.module.initializer.api; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import org.openmrs.GlobalProperty; import org.openmrs.api.context.Context; import org.openmrs.module.initializer.DomainBaseModuleContextSensitiveTest; @@ -29,12 +29,12 @@ public void loadGlobalProperties_shouldLoadGlobalProperties() { loader.load(); // Verif - Assert.assertEquals("GP one one", Context.getAdministrationService().getGlobalProperty("gp.gp11")); - Assert.assertEquals("GP one two", Context.getAdministrationService().getGlobalProperty("gp.gp12")); - Assert.assertEquals("GP two one", Context.getAdministrationService().getGlobalProperty("gp.gp21")); - Assert.assertEquals("GP three one", Context.getAdministrationService().getGlobalProperty("gp.gp31")); - Assert.assertEquals("GP three two", Context.getAdministrationService().getGlobalProperty("gp.gp32")); - Assert.assertEquals("GP three three", Context.getAdministrationService().getGlobalProperty("gp.gp33")); + Assertions.assertEquals("GP one one", Context.getAdministrationService().getGlobalProperty("gp.gp11")); + Assertions.assertEquals("GP one two", Context.getAdministrationService().getGlobalProperty("gp.gp12")); + Assertions.assertEquals("GP two one", Context.getAdministrationService().getGlobalProperty("gp.gp21")); + Assertions.assertEquals("GP three one", Context.getAdministrationService().getGlobalProperty("gp.gp31")); + Assertions.assertEquals("GP three two", Context.getAdministrationService().getGlobalProperty("gp.gp32")); + Assertions.assertEquals("GP three three", Context.getAdministrationService().getGlobalProperty("gp.gp33")); } @Test @@ -42,13 +42,13 @@ public void load_shouldOverrideGlobalProperties() { // Setup Context.getAdministrationService().saveGlobalProperty(new GlobalProperty("gp.gp11", "foobar")); - Assert.assertEquals("foobar", Context.getAdministrationService().getGlobalProperty("gp.gp11")); + Assertions.assertEquals("foobar", Context.getAdministrationService().getGlobalProperty("gp.gp11")); // Replay loader.load(); // Verif - Assert.assertEquals("GP one one", Context.getAdministrationService().getGlobalProperty("gp.gp11")); + Assertions.assertEquals("GP one one", Context.getAdministrationService().getGlobalProperty("gp.gp11")); } @Test @@ -63,8 +63,8 @@ public void load_shouldNotAffectOtherGlobalProperties() { loader.load(); // Verif - Assert.assertEquals("Foo", Context.getAdministrationService().getGlobalProperty("gp.foo")); - Assert.assertEquals("Bar", Context.getAdministrationService().getGlobalProperty("gp.bar")); - Assert.assertEquals("Baz", Context.getAdministrationService().getGlobalProperty("gp.baz")); + Assertions.assertEquals("Foo", Context.getAdministrationService().getGlobalProperty("gp.foo")); + Assertions.assertEquals("Bar", Context.getAdministrationService().getGlobalProperty("gp.bar")); + Assertions.assertEquals("Baz", Context.getAdministrationService().getGlobalProperty("gp.baz")); } } diff --git a/api/src/test/java/org/openmrs/module/initializer/api/IdentifierSourcesLoaderIntegrationTest.java b/api/src/test/java/org/openmrs/module/initializer/api/IdentifierSourcesLoaderIntegrationTest.java index e3381efd0..cc4f7cf68 100644 --- a/api/src/test/java/org/openmrs/module/initializer/api/IdentifierSourcesLoaderIntegrationTest.java +++ b/api/src/test/java/org/openmrs/module/initializer/api/IdentifierSourcesLoaderIntegrationTest.java @@ -9,10 +9,10 @@ */ package org.openmrs.module.initializer.api; -import org.apache.commons.lang.BooleanUtils; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; +import org.apache.commons.lang3.BooleanUtils; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.openmrs.PatientIdentifierType; import org.openmrs.api.context.Context; import org.openmrs.module.idgen.IdentifierPool; @@ -47,7 +47,7 @@ public class IdentifierSourcesLoaderIntegrationTest extends DomainBaseModuleCont public static final String NEW_POOL = "30799e8f-59cf-11ec-8885-0242ac110002"; - @Before + @BeforeEach public void setup() { PatientIdentifierType type = new PatientIdentifierType(); @@ -102,39 +102,40 @@ public void load_shouldModifyExistingIdentifierSources() throws Exception { { IdentifierSource source = idgenService.getIdentifierSourceByUuid(EXISTING_SEQ); SequentialIdentifierGenerator generator = (SequentialIdentifierGenerator) source; - Assert.assertEquals("Edited sequential name", generator.getName()); - Assert.assertEquals("Edited sequential description", generator.getDescription()); - Assert.assertEquals("PATIENTIDENTIFIERTYPE_1_OPENMRS_ID", generator.getIdentifierType().getName()); - Assert.assertEquals("ACDEFGHJKLMNPRTUVWXY1234567890", generator.getBaseCharacterSet()); - Assert.assertEquals(6, generator.getMinLength().intValue()); - Assert.assertEquals(6, generator.getMaxLength().intValue()); - Assert.assertEquals("Y", generator.getPrefix()); - Assert.assertEquals("", generator.getSuffix()); - Assert.assertEquals("1000", generator.getFirstIdentifierBase()); - Assert.assertFalse(BooleanUtils.isTrue(generator.getRetired())); + Assertions.assertEquals("Edited sequential name", generator.getName()); + Assertions.assertEquals("Edited sequential description", generator.getDescription()); + Assertions.assertEquals("PATIENTIDENTIFIERTYPE_1_OPENMRS_ID", generator.getIdentifierType().getName()); + Assertions.assertEquals("ACDEFGHJKLMNPRTUVWXY1234567890", generator.getBaseCharacterSet()); + Assertions.assertEquals(6, generator.getMinLength().intValue()); + Assertions.assertEquals(6, generator.getMaxLength().intValue()); + Assertions.assertEquals("Y", generator.getPrefix()); + // the idgen service is advised by core's RequiredDataAdvice, which saves empty strings as null + Assertions.assertNull(generator.getSuffix()); + Assertions.assertEquals("1000", generator.getFirstIdentifierBase()); + Assertions.assertFalse(BooleanUtils.isTrue(generator.getRetired())); } { IdentifierSource source = idgenService.getIdentifierSourceByUuid(EXISTING_REMOTE); RemoteIdentifierSource remoteSource = (RemoteIdentifierSource) source; - Assert.assertEquals("Edited remote name", remoteSource.getName()); - Assert.assertEquals("Edited remote description", remoteSource.getDescription()); - Assert.assertEquals("PATIENTIDENTIFIERTYPE_1_OPENMRS_ID", remoteSource.getIdentifierType().getName()); - Assert.assertEquals("http://example.com/edit", remoteSource.getUrl()); - Assert.assertEquals("editUser", remoteSource.getUser()); - Assert.assertEquals("editPass", remoteSource.getPassword()); - Assert.assertFalse(BooleanUtils.isTrue(remoteSource.getRetired())); + Assertions.assertEquals("Edited remote name", remoteSource.getName()); + Assertions.assertEquals("Edited remote description", remoteSource.getDescription()); + Assertions.assertEquals("PATIENTIDENTIFIERTYPE_1_OPENMRS_ID", remoteSource.getIdentifierType().getName()); + Assertions.assertEquals("http://example.com/edit", remoteSource.getUrl()); + Assertions.assertEquals("editUser", remoteSource.getUser()); + Assertions.assertEquals("editPass", remoteSource.getPassword()); + Assertions.assertFalse(BooleanUtils.isTrue(remoteSource.getRetired())); } { IdentifierSource source = idgenService.getIdentifierSourceByUuid(EXISTING_POOL); IdentifierPool pool = (IdentifierPool) source; - Assert.assertEquals("Edited pool name", pool.getName()); - Assert.assertEquals("Edited pool description", pool.getDescription()); - Assert.assertEquals("PATIENTIDENTIFIERTYPE_1_OPENMRS_ID", pool.getIdentifierType().getName()); - Assert.assertEquals(10, pool.getBatchSize().intValue()); - Assert.assertEquals(40, pool.getMinPoolSize().intValue()); - Assert.assertFalse(pool.getRefillWithScheduledTask()); - Assert.assertFalse(pool.getSequential()); - Assert.assertFalse(BooleanUtils.isTrue(pool.getRetired())); + Assertions.assertEquals("Edited pool name", pool.getName()); + Assertions.assertEquals("Edited pool description", pool.getDescription()); + Assertions.assertEquals("PATIENTIDENTIFIERTYPE_1_OPENMRS_ID", pool.getIdentifierType().getName()); + Assertions.assertEquals(10, pool.getBatchSize().intValue()); + Assertions.assertEquals(40, pool.getMinPoolSize().intValue()); + Assertions.assertFalse(pool.getRefillWithScheduledTask()); + Assertions.assertFalse(pool.getSequential()); + Assertions.assertFalse(BooleanUtils.isTrue(pool.getRetired())); } } @@ -148,44 +149,44 @@ public void load_shouldCreateNewIdentifierSources() throws Exception { { IdentifierSource source = idgenService.getIdentifierSourceByUuid(NEW_SEQ); SequentialIdentifierGenerator generator = (SequentialIdentifierGenerator) source; - Assert.assertEquals("New sequential name", generator.getName()); - Assert.assertEquals("New sequential description", generator.getDescription()); - Assert.assertEquals("PATIENTIDENTIFIERTYPE_1_OPENMRS_ID", generator.getIdentifierType().getName()); - Assert.assertEquals("0123456789", generator.getBaseCharacterSet()); - Assert.assertEquals(5, generator.getMinLength().intValue()); - Assert.assertEquals(7, generator.getMaxLength().intValue()); - Assert.assertEquals("A", generator.getPrefix()); - Assert.assertEquals("Z", generator.getSuffix()); - Assert.assertEquals("001", generator.getFirstIdentifierBase()); - Assert.assertFalse(BooleanUtils.isTrue(generator.getRetired())); + Assertions.assertEquals("New sequential name", generator.getName()); + Assertions.assertEquals("New sequential description", generator.getDescription()); + Assertions.assertEquals("PATIENTIDENTIFIERTYPE_1_OPENMRS_ID", generator.getIdentifierType().getName()); + Assertions.assertEquals("0123456789", generator.getBaseCharacterSet()); + Assertions.assertEquals(5, generator.getMinLength().intValue()); + Assertions.assertEquals(7, generator.getMaxLength().intValue()); + Assertions.assertEquals("A", generator.getPrefix()); + Assertions.assertEquals("Z", generator.getSuffix()); + Assertions.assertEquals("001", generator.getFirstIdentifierBase()); + Assertions.assertFalse(BooleanUtils.isTrue(generator.getRetired())); } { IdentifierSource source = idgenService.getIdentifierSourceByUuid(NEW_REMOTE); RemoteIdentifierSource remoteSource = (RemoteIdentifierSource) source; - Assert.assertEquals("New remote name", remoteSource.getName()); - Assert.assertEquals("New remote description", remoteSource.getDescription()); - Assert.assertEquals("PATIENTIDENTIFIERTYPE_1_OPENMRS_ID", remoteSource.getIdentifierType().getName()); - Assert.assertEquals("http://localhost", remoteSource.getUrl()); - Assert.assertEquals("value-from-runtime-property", remoteSource.getUser()); - Assert.assertEquals("value-from-system-property", remoteSource.getPassword()); - Assert.assertFalse(BooleanUtils.isTrue(remoteSource.getRetired())); + Assertions.assertEquals("New remote name", remoteSource.getName()); + Assertions.assertEquals("New remote description", remoteSource.getDescription()); + Assertions.assertEquals("PATIENTIDENTIFIERTYPE_1_OPENMRS_ID", remoteSource.getIdentifierType().getName()); + Assertions.assertEquals("http://localhost", remoteSource.getUrl()); + Assertions.assertEquals("value-from-runtime-property", remoteSource.getUser()); + Assertions.assertEquals("value-from-system-property", remoteSource.getPassword()); + Assertions.assertFalse(BooleanUtils.isTrue(remoteSource.getRetired())); } { IdentifierSource source = idgenService.getIdentifierSourceByUuid(NEW_POOL); IdentifierPool pool = (IdentifierPool) source; - Assert.assertEquals("New pool name", pool.getName()); - Assert.assertEquals("New pool description", pool.getDescription()); - Assert.assertEquals("PATIENTIDENTIFIERTYPE_1_OPENMRS_ID", pool.getIdentifierType().getName()); - Assert.assertEquals(NEW_SEQ, pool.getSource().getUuid()); - Assert.assertEquals(20, pool.getBatchSize().intValue()); - Assert.assertEquals(60, pool.getMinPoolSize().intValue()); - Assert.assertTrue(pool.getRefillWithScheduledTask()); - Assert.assertTrue(pool.getSequential()); - Assert.assertFalse(BooleanUtils.isTrue(pool.getRetired())); + Assertions.assertEquals("New pool name", pool.getName()); + Assertions.assertEquals("New pool description", pool.getDescription()); + Assertions.assertEquals("PATIENTIDENTIFIERTYPE_1_OPENMRS_ID", pool.getIdentifierType().getName()); + Assertions.assertEquals(NEW_SEQ, pool.getSource().getUuid()); + Assertions.assertEquals(20, pool.getBatchSize().intValue()); + Assertions.assertEquals(60, pool.getMinPoolSize().intValue()); + Assertions.assertTrue(pool.getRefillWithScheduledTask()); + Assertions.assertTrue(pool.getSequential()); + Assertions.assertFalse(BooleanUtils.isTrue(pool.getRetired())); } } - @Before + @BeforeEach @Override public void setupAppDataDir() { diff --git a/api/src/test/java/org/openmrs/module/initializer/api/InitializerServiceImplTest.java b/api/src/test/java/org/openmrs/module/initializer/api/InitializerServiceImplTest.java index b27f305c4..5d3e40b5f 100644 --- a/api/src/test/java/org/openmrs/module/initializer/api/InitializerServiceImplTest.java +++ b/api/src/test/java/org/openmrs/module/initializer/api/InitializerServiceImplTest.java @@ -1,8 +1,8 @@ package org.openmrs.module.initializer.api; -import static org.mockito.Matchers.any; -import static org.mockito.Matchers.anyListOf; -import static org.mockito.Matchers.anyBoolean; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.anyList; +import static org.mockito.ArgumentMatchers.anyBoolean; import static org.mockito.Mockito.never; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; @@ -17,7 +17,7 @@ import java.util.Properties; import org.apache.commons.io.IOUtils; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.mockito.Mockito; @@ -63,9 +63,9 @@ public void load_shouldFollowInclusionList() throws Exception { iniz.load(); // verify - verify(conceptsLoader, times(1)).loadUnsafe(anyListOf(String.class), anyBoolean()); - verify(encounterTypesLoader, times(1)).loadUnsafe(anyListOf(String.class), anyBoolean()); - verify(drugsLoader, never()).loadUnsafe(anyListOf(String.class), anyBoolean()); + verify(conceptsLoader, times(1)).loadUnsafe(anyList(), anyBoolean()); + verify(encounterTypesLoader, times(1)).loadUnsafe(anyList(), anyBoolean()); + verify(drugsLoader, never()).loadUnsafe(anyList(), anyBoolean()); } @Test @@ -80,9 +80,9 @@ public void load_shouldSkipExclusionList() throws Exception { iniz.load(); // verify - verify(conceptsLoader, never()).loadUnsafe(anyListOf(String.class), anyBoolean()); - verify(encounterTypesLoader, times(1)).loadUnsafe(anyListOf(String.class), anyBoolean()); - verify(drugsLoader, never()).loadUnsafe(anyListOf(String.class), anyBoolean()); + verify(conceptsLoader, never()).loadUnsafe(anyList(), anyBoolean()); + verify(encounterTypesLoader, times(1)).loadUnsafe(anyList(), anyBoolean()); + verify(drugsLoader, never()).loadUnsafe(anyList(), anyBoolean()); } @Test @@ -92,14 +92,14 @@ public void addKeyValues_shouldFillKeyValuesCache() throws Exception { .getResourceAsStream("org/openmrs/module/initializer/include/jsonKeyValues.json"); iniz.addKeyValues(is); - Assert.assertEquals("value1", iniz.getValueFromKey("key1")); - Assert.assertEquals("value2", iniz.getValueFromKey("key2")); - Assert.assertEquals("value3", iniz.getValueFromKey("key3")); + Assertions.assertEquals("value1", iniz.getValueFromKey("key1")); + Assertions.assertEquals("value2", iniz.getValueFromKey("key2")); + Assertions.assertEquals("value3", iniz.getValueFromKey("key3")); is = IOUtils.toInputStream("{\"key1\":\"value12\"}"); iniz.addKeyValues(is); - Assert.assertEquals("value12", iniz.getValueFromKey("key1")); + Assertions.assertEquals("value12", iniz.getValueFromKey("key1")); } @Test @@ -108,21 +108,21 @@ public void getBooleanFromKey_shouldHandleAllCases() { final String KEY = "key.to.bool.value"; iniz.addKeyValue(KEY, "true"); - Assert.assertTrue(iniz.getBooleanFromKey(KEY)); + Assertions.assertTrue(iniz.getBooleanFromKey(KEY)); iniz.addKeyValue(KEY, "false"); - Assert.assertFalse(iniz.getBooleanFromKey(KEY)); + Assertions.assertFalse(iniz.getBooleanFromKey(KEY)); iniz.addKeyValue(KEY, "yes"); - Assert.assertTrue(iniz.getBooleanFromKey(KEY)); + Assertions.assertTrue(iniz.getBooleanFromKey(KEY)); iniz.addKeyValue(KEY, "no"); - Assert.assertFalse(iniz.getBooleanFromKey(KEY)); + Assertions.assertFalse(iniz.getBooleanFromKey(KEY)); iniz.addKeyValue(KEY, "1"); - Assert.assertTrue(iniz.getBooleanFromKey(KEY)); + Assertions.assertTrue(iniz.getBooleanFromKey(KEY)); iniz.addKeyValue(KEY, "0"); - Assert.assertFalse(iniz.getBooleanFromKey(KEY)); + Assertions.assertFalse(iniz.getBooleanFromKey(KEY)); iniz.addKeyValue(KEY, "foo"); - Assert.assertNull(iniz.getBooleanFromKey(KEY)); + Assertions.assertNull(iniz.getBooleanFromKey(KEY)); } } diff --git a/api/src/test/java/org/openmrs/module/initializer/api/InitializerServiceIntegrationTest.java b/api/src/test/java/org/openmrs/module/initializer/api/InitializerServiceIntegrationTest.java index a578304c1..d2357a871 100644 --- a/api/src/test/java/org/openmrs/module/initializer/api/InitializerServiceIntegrationTest.java +++ b/api/src/test/java/org/openmrs/module/initializer/api/InitializerServiceIntegrationTest.java @@ -9,7 +9,7 @@ */ package org.openmrs.module.initializer.api; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.openmrs.Concept; import org.openmrs.ConceptClass; import org.openmrs.ConceptDatatype; @@ -24,7 +24,7 @@ import java.util.List; import java.util.Locale; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; public class InitializerServiceIntegrationTest extends DomainBaseModuleContextSensitiveTest { diff --git a/api/src/test/java/org/openmrs/module/initializer/api/JsonKeyValuesLoaderIntegrationTest.java b/api/src/test/java/org/openmrs/module/initializer/api/JsonKeyValuesLoaderIntegrationTest.java index 0e5fae9d9..de8d96278 100644 --- a/api/src/test/java/org/openmrs/module/initializer/api/JsonKeyValuesLoaderIntegrationTest.java +++ b/api/src/test/java/org/openmrs/module/initializer/api/JsonKeyValuesLoaderIntegrationTest.java @@ -15,9 +15,10 @@ import java.util.List; import java.util.Locale; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; +import org.hamcrest.MatcherAssert; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.openmrs.Concept; import org.openmrs.ConceptMapType; import org.openmrs.ConceptName; @@ -47,7 +48,7 @@ public class JsonKeyValuesLoaderIntegrationTest extends DomainBaseModuleContextS @Autowired private JsonKeyValuesLoader loader; - @Before + @BeforeEach public void setup() { ConceptSource source = new ConceptSource(); source.setName("Cambodia"); @@ -85,14 +86,14 @@ public void load_shouldFetchConceptsFromAllPossibleKeys() { loader.load(); Concept c1 = getService().getConceptFromKey("impl.purpose.concept.uuid"); - Assert.assertNotNull(c1); + Assertions.assertNotNull(c1); Concept c2 = getService().getConceptFromKey("impl.purpose.concept.fsn"); - Assert.assertEquals(c1, c2); + Assertions.assertEquals(c1, c2); Concept c3 = getService().getConceptFromKey("impl.purpose.concept.mapping"); - Assert.assertEquals(c2, c3); + Assertions.assertEquals(c2, c3); - Assert.assertNull(getService().getConceptFromKey("__invalid_json_key__")); - Assert.assertEquals(c1, getService().getConceptFromKey("__invalid_json_key__", c1)); + Assertions.assertNull(getService().getConceptFromKey("__invalid_json_key__")); + Assertions.assertEquals(c1, getService().getConceptFromKey("__invalid_json_key__", c1)); } @Test @@ -101,12 +102,12 @@ public void load_shouldFetchPATFromAllPossibleKeys() { loader.load(); PersonAttributeType pat1 = getService().getPersonAttributeTypeFromKey("impl.purpose.pat.uuid"); - Assert.assertNotNull(pat1); + Assertions.assertNotNull(pat1); PersonAttributeType pat2 = getService().getPersonAttributeTypeFromKey("impl.purpose.pat.name"); - Assert.assertEquals(pat1, pat2); + Assertions.assertEquals(pat1, pat2); - Assert.assertNull(getService().getPersonAttributeTypeFromKey("__invalid_json_key__")); - Assert.assertEquals(pat1, getService().getPersonAttributeTypeFromKey("__invalid_json_key__", pat1)); + Assertions.assertNull(getService().getPersonAttributeTypeFromKey("__invalid_json_key__")); + Assertions.assertEquals(pat1, getService().getPersonAttributeTypeFromKey("__invalid_json_key__", pat1)); } @Test @@ -116,7 +117,7 @@ public void load_shouldLoadStructuredJsonValue() { String json = getService().getValueFromKey("structured.json"); // Verif - Assert.assertEquals("{\"foo\":\"bar\",\"fooz\":{\"baz\":\"value\"}}", json); + Assertions.assertEquals("{\"foo\":\"bar\",\"fooz\":{\"baz\":\"value\"}}", json); } @Test @@ -126,9 +127,9 @@ public void load_shouldLoadConceptList() { List concepts = getService().getConceptsFromKey("impl.purpose.concepts"); // Verif - Assert.assertThat(concepts.size(), is(2)); + MatcherAssert.assertThat(concepts.size(), is(2)); for (Concept c : concepts) { - Assert.assertNotNull(c); + Assertions.assertNotNull(c); } } @@ -139,9 +140,10 @@ public void getDirUtil_shouldConfigureDirUtilToSkipChecksums() { ConfigDirUtil dirUtil = loader.getDirUtil(); // Verif - Assert.assertEquals(true, dirUtil.skipChecksums); - Assert.assertEquals(iniz.getChecksumsDirPath() + File.separator + loader.getDomainName(), + Assertions.assertEquals(true, dirUtil.skipChecksums); + Assertions.assertEquals(iniz.getChecksumsDirPath() + File.separator + loader.getDomainName(), dirUtil.getDomainChecksumsDirPath()); - Assert.assertEquals(iniz.getConfigDirPath() + File.separator + loader.getDomainName(), dirUtil.getDomainDirPath()); + Assertions.assertEquals(iniz.getConfigDirPath() + File.separator + loader.getDomainName(), + dirUtil.getDomainDirPath()); } } diff --git a/api/src/test/java/org/openmrs/module/initializer/api/LiquibaseLoaderIntegrationTest.java b/api/src/test/java/org/openmrs/module/initializer/api/LiquibaseLoaderIntegrationTest.java index 824dcea70..c83723e8f 100644 --- a/api/src/test/java/org/openmrs/module/initializer/api/LiquibaseLoaderIntegrationTest.java +++ b/api/src/test/java/org/openmrs/module/initializer/api/LiquibaseLoaderIntegrationTest.java @@ -9,23 +9,22 @@ */ package org.openmrs.module.initializer.api; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.openmrs.api.context.Context; import org.openmrs.module.initializer.DomainBaseModuleContextSensitiveTest; import org.openmrs.module.initializer.api.loaders.LiquibaseLoader; import org.springframework.beans.factory.annotation.Autowired; -import static org.hamcrest.Matchers.nullValue; -import static org.junit.Assume.assumeThat; +import static org.junit.jupiter.api.Assumptions.assumeTrue; public class LiquibaseLoaderIntegrationTest extends DomainBaseModuleContextSensitiveTest { @Autowired private LiquibaseLoader loader; - @Before + @BeforeEach public void setup() { System.setProperty("useInMemoryDatabase", "true"); } @@ -33,16 +32,19 @@ public void setup() { @Test public void load_shouldLoadStructuredLiquibaseChangesets() throws Exception { // TODO This test fails on GitHub Actions but the failure cannot be reproduced so for now, skip it - assumeThat(System.getenv("GITHUB_ENV"), nullValue()); + assumeTrue(System.getenv("GITHUB_ENV") == null); // Replay loader.load(); // Verify - Assert.assertNotNull(Context.getConceptService().getConceptByUuid("fbb05a72-b923-4b35-bbb6-5cbcfdc295ed")); - Assert.assertNotNull(Context.getConceptService().getConceptByUuid("ae848d15-6a04-4ad5-b711-a4cf711a566e")); - Assert.assertNotNull(Context.getEncounterService().getEncounterTypeByUuid("13c7556b-e868-4612-a631-bfdbed24c9f0")); - Assert.assertNotNull(Context.getEncounterService().getEncounterTypeByUuid("4c384d33-6fc4-4b99-a3b3-efc285409e7f")); - Assert.assertNotNull(Context.getEncounterService().getEncounterTypeByUuid("4bf982f0-8053-4757-a45e-5da777ffe0f6")); + Assertions.assertNotNull(Context.getConceptService().getConceptByUuid("fbb05a72-b923-4b35-bbb6-5cbcfdc295ed")); + Assertions.assertNotNull(Context.getConceptService().getConceptByUuid("ae848d15-6a04-4ad5-b711-a4cf711a566e")); + Assertions + .assertNotNull(Context.getEncounterService().getEncounterTypeByUuid("13c7556b-e868-4612-a631-bfdbed24c9f0")); + Assertions + .assertNotNull(Context.getEncounterService().getEncounterTypeByUuid("4c384d33-6fc4-4b99-a3b3-efc285409e7f")); + Assertions + .assertNotNull(Context.getEncounterService().getEncounterTypeByUuid("4bf982f0-8053-4757-a45e-5da777ffe0f6")); } } diff --git a/api/src/test/java/org/openmrs/module/initializer/api/LocationTagMapsLoaderIntegrationTest.java b/api/src/test/java/org/openmrs/module/initializer/api/LocationTagMapsLoaderIntegrationTest.java index 4f54103fa..1bc18860c 100644 --- a/api/src/test/java/org/openmrs/module/initializer/api/LocationTagMapsLoaderIntegrationTest.java +++ b/api/src/test/java/org/openmrs/module/initializer/api/LocationTagMapsLoaderIntegrationTest.java @@ -9,9 +9,9 @@ */ package org.openmrs.module.initializer.api; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.openmrs.Location; import org.openmrs.LocationTag; import org.openmrs.api.LocationService; @@ -39,7 +39,7 @@ public class LocationTagMapsLoaderIntegrationTest extends DomainBaseModuleContex LocationTag visitLocation; - @Before + @BeforeEach public void setup() throws Exception { executeDataSet("testdata/test-metadata.xml"); facilityLocation = ls.getLocationTagByName("Facility Location"); @@ -53,11 +53,11 @@ public void load_shouldLoadAccordingToCsvFiles() { // Pre-load verification Location patientHome = ls.getLocationByUuid("af939782-898b-409a-99a4-d1653484edbd"); Set tags = patientHome.getTags(); - Assert.assertEquals(tags.size(), 2); - Assert.assertFalse(tags.contains(shed)); - Assert.assertTrue(tags.contains(facilityLocation)); - Assert.assertFalse(tags.contains(appointmentLocation)); - Assert.assertTrue(tags.contains(visitLocation)); + Assertions.assertEquals(tags.size(), 2); + Assertions.assertFalse(tags.contains(shed)); + Assertions.assertTrue(tags.contains(facilityLocation)); + Assertions.assertFalse(tags.contains(appointmentLocation)); + Assertions.assertTrue(tags.contains(visitLocation)); // Replay loader.load(); @@ -65,10 +65,10 @@ public void load_shouldLoadAccordingToCsvFiles() { // Post-load verification patientHome = ls.getLocationByUuid("af939782-898b-409a-99a4-d1653484edbd"); tags = patientHome.getTags(); - Assert.assertEquals(tags.size(), 2); - Assert.assertFalse(tags.contains(shed)); // Test tag stays absent - Assert.assertFalse(tags.contains(facilityLocation)); // Test tag is removed - Assert.assertTrue(tags.contains(appointmentLocation)); // Test tag is added - Assert.assertTrue(tags.contains(visitLocation)); // Test tag remains present, even if not in CSV + Assertions.assertEquals(tags.size(), 2); + Assertions.assertFalse(tags.contains(shed)); // Test tag stays absent + Assertions.assertFalse(tags.contains(facilityLocation)); // Test tag is removed + Assertions.assertTrue(tags.contains(appointmentLocation)); // Test tag is added + Assertions.assertTrue(tags.contains(visitLocation)); // Test tag remains present, even if not in CSV } } diff --git a/api/src/test/java/org/openmrs/module/initializer/api/LocationTagsLoaderIntegrationTest.java b/api/src/test/java/org/openmrs/module/initializer/api/LocationTagsLoaderIntegrationTest.java index 891352478..69024e81c 100644 --- a/api/src/test/java/org/openmrs/module/initializer/api/LocationTagsLoaderIntegrationTest.java +++ b/api/src/test/java/org/openmrs/module/initializer/api/LocationTagsLoaderIntegrationTest.java @@ -9,9 +9,9 @@ */ package org.openmrs.module.initializer.api; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.openmrs.LocationTag; import org.openmrs.api.LocationService; import org.openmrs.module.initializer.DomainBaseModuleContextSensitiveTest; @@ -28,7 +28,7 @@ public class LocationTagsLoaderIntegrationTest extends DomainBaseModuleContextSe @Autowired private LocationTagsLoader loader; - @Before + @BeforeEach public void setup() throws Exception { executeDataSet("testdata/test-metadata.xml"); } @@ -40,23 +40,23 @@ public void load_shouldLoadLocationTagsAccordingToCsvFiles() { { // created without uuid or description LocationTag tag = service.getLocationTagByName("Sparse"); - Assert.assertNotNull(tag); + Assertions.assertNotNull(tag); } { // created with uuid and description LocationTag tag = service.getLocationTagByName("Filled in"); - Assert.assertNotNull(tag); - Assert.assertEquals("b03e395c-b881-49b7-b6fc-983f6befc7fc", tag.getUuid()); - Assert.assertEquals("A tag with all its fields", tag.getDescription()); + Assertions.assertNotNull(tag); + Assertions.assertEquals("b03e395c-b881-49b7-b6fc-983f6befc7fc", tag.getUuid()); + Assertions.assertEquals("A tag with all its fields", tag.getDescription()); } { // retired Facility Location LocationTag tag = service.getLocationTagByName("Facility Location"); - Assert.assertNotNull(tag); - Assert.assertTrue(tag.getRetired()); + Assertions.assertNotNull(tag); + Assertions.assertTrue(tag.getRetired()); } { // edited to change name and description LocationTag tag = service.getLocationTagByUuid("a1417745-1170-5752-fc8a-dd0ba131f40e"); - Assert.assertEquals("Supply Room", tag.getName()); - Assert.assertEquals("Don't call it a shed", tag.getDescription()); + Assertions.assertEquals("Supply Room", tag.getName()); + Assertions.assertEquals("Don't call it a shed", tag.getDescription()); } } } diff --git a/api/src/test/java/org/openmrs/module/initializer/api/LocationsLoaderIntegrationTest.java b/api/src/test/java/org/openmrs/module/initializer/api/LocationsLoaderIntegrationTest.java index 30e315bcb..70283d794 100644 --- a/api/src/test/java/org/openmrs/module/initializer/api/LocationsLoaderIntegrationTest.java +++ b/api/src/test/java/org/openmrs/module/initializer/api/LocationsLoaderIntegrationTest.java @@ -18,9 +18,10 @@ import java.util.Locale; import java.util.Set; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; +import org.hamcrest.MatcherAssert; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.openmrs.Location; import org.openmrs.LocationAttribute; import org.openmrs.LocationTag; @@ -48,7 +49,7 @@ public class LocationsLoaderIntegrationTest extends DomainBaseModuleContextSensi private Locale localeKm = new Locale("km", "KH"); - @Before + @BeforeEach public void setup() throws Exception { executeDataSet("testdata/test-metadata.xml"); } @@ -58,23 +59,23 @@ public void load_shouldLoadAccordingToCsvFiles() { // Pre-load verif { Location loc = ls.getLocation(4089); - Assert.assertEquals("a03e395c-b881-49b7-b6fc-983f6bddc7fc", loc.getUuid()); - Assert.assertEquals("Acme Clinic", loc.getName()); - Assert.assertThat(loc.getDescription(), nullValue()); - Assert.assertThat(loc.getParentLocation(), nullValue()); - Assert.assertThat(loc.getTags().size(), is(0)); + Assertions.assertEquals("a03e395c-b881-49b7-b6fc-983f6bddc7fc", loc.getUuid()); + Assertions.assertEquals("Acme Clinic", loc.getName()); + MatcherAssert.assertThat(loc.getDescription(), nullValue()); + MatcherAssert.assertThat(loc.getParentLocation(), nullValue()); + MatcherAssert.assertThat(loc.getTags().size(), is(0)); Collection attributes = loc.getActiveAttributes(); - Assert.assertThat(attributes.size(), is(1)); - Assert.assertEquals("2016-04-14", + MatcherAssert.assertThat(attributes.size(), is(1)); + Assertions.assertEquals("2016-04-14", dateDatatype.serialize((Date) ((LocationAttribute) attributes.toArray()[0]).getValue())); } { Location loc = ls.getLocation(4090); - Assert.assertEquals("cbaaaab4-d960-4ae9-9b6a-8983fbd947b6", loc.getUuid()); - Assert.assertEquals("Legacy Location", loc.getName()); - Assert.assertEquals("Legacy location that must be retired", loc.getDescription()); - Assert.assertThat(loc.getRetired(), is(false)); + Assertions.assertEquals("cbaaaab4-d960-4ae9-9b6a-8983fbd947b6", loc.getUuid()); + Assertions.assertEquals("Legacy Location", loc.getName()); + Assertions.assertEquals("Legacy location that must be retired", loc.getDescription()); + MatcherAssert.assertThat(loc.getRetired(), is(false)); } // Replay @@ -83,113 +84,113 @@ public void load_shouldLoadAccordingToCsvFiles() { // Verify fetch by name { Location loc = ls.getLocation("LOCATION_NO_UUID"); - Assert.assertEquals("Main Street", loc.getAddress1()); - Assert.assertEquals("fdddc31a-3930-11ea-9712-a73c3c19744f", loc.getUuid()); + Assertions.assertEquals("Main Street", loc.getAddress1()); + Assertions.assertEquals("fdddc31a-3930-11ea-9712-a73c3c19744f", loc.getUuid()); } // Verify creation with dynamic tag creation { Location loc = ls.getLocation("The Lake Clinic-Cambodia"); - Assert.assertEquals("Paradise Street", loc.getAddress1()); - Assert.assertEquals("Siem Reap", loc.getCountyDistrict()); - Assert.assertEquals("Siem Reap", loc.getStateProvince()); - Assert.assertEquals("Cambodia", loc.getCountry()); + Assertions.assertEquals("Paradise Street", loc.getAddress1()); + Assertions.assertEquals("Siem Reap", loc.getCountyDistrict()); + Assertions.assertEquals("Siem Reap", loc.getStateProvince()); + Assertions.assertEquals("Cambodia", loc.getCountry()); Set tags = loc.getTags(); - Assert.assertThat(tags, notNullValue()); - Assert.assertThat(tags.size(), is(2)); - Assert.assertThat(tags.contains(ls.getLocationTagByName("Login Location")), is(true)); - Assert.assertThat(tags.contains(ls.getLocationTagByName("Another Location Tag")), is(true)); + MatcherAssert.assertThat(tags, notNullValue()); + MatcherAssert.assertThat(tags.size(), is(2)); + MatcherAssert.assertThat(tags.contains(ls.getLocationTagByName("Login Location")), is(true)); + MatcherAssert.assertThat(tags.contains(ls.getLocationTagByName("Another Location Tag")), is(true)); Collection attributes = loc.getActiveAttributes(); - Assert.assertThat(attributes.size(), is(2)); - Assert.assertEquals("CODE-TLC-123", ((LocationAttribute) attributes.toArray()[0]).getValue()); - Assert.assertEquals("2017-05-15", + MatcherAssert.assertThat(attributes.size(), is(2)); + Assertions.assertEquals("CODE-TLC-123", ((LocationAttribute) attributes.toArray()[0]).getValue()); + Assertions.assertEquals("2017-05-15", dateDatatype.serialize((Date) ((LocationAttribute) attributes.toArray()[1]).getValue())); } // Verify creation with Tag| headers { Location loc = ls.getLocation("OPD Room"); - Assert.assertEquals(ls.getLocation("The Lake Clinic-Cambodia"), loc.getParentLocation()); + Assertions.assertEquals(ls.getLocation("The Lake Clinic-Cambodia"), loc.getParentLocation()); Set tags = loc.getTags(); - Assert.assertThat(tags, notNullValue()); - Assert.assertThat(tags.size(), is(1)); - Assert.assertThat(tags.contains(ls.getLocationTagByName("Facility Location")), is(true)); + MatcherAssert.assertThat(tags, notNullValue()); + MatcherAssert.assertThat(tags.size(), is(1)); + MatcherAssert.assertThat(tags.contains(ls.getLocationTagByName("Facility Location")), is(true)); } // Verify that the provided UUID is correctly assigned { Location loc = ls.getLocationByUuid("1cb58794-3c49-11ea-b3eb-f7801304f314"); - Assert.assertNotNull(loc); - Assert.assertEquals("New Location", loc.getName()); + Assertions.assertNotNull(loc); + Assertions.assertEquals("New Location", loc.getName()); } // Verify edit { Location loc = ls.getLocationByUuid("a03e395c-b881-49b7-b6fc-983f6bddc7fc"); - Assert.assertEquals("Acme Clinic", loc.getName()); - Assert.assertEquals("This now becomes a child of TLC", loc.getDescription()); - Assert.assertEquals(ls.getLocation("The Lake Clinic-Cambodia"), loc.getParentLocation()); + Assertions.assertEquals("Acme Clinic", loc.getName()); + Assertions.assertEquals("This now becomes a child of TLC", loc.getDescription()); + Assertions.assertEquals(ls.getLocation("The Lake Clinic-Cambodia"), loc.getParentLocation()); Set tags = loc.getTags(); - Assert.assertThat(tags, notNullValue()); - Assert.assertThat(tags.size(), is(1)); - Assert.assertThat(tags.contains(ls.getLocationTagByName("Login Location")), is(true)); + MatcherAssert.assertThat(tags, notNullValue()); + MatcherAssert.assertThat(tags.size(), is(1)); + MatcherAssert.assertThat(tags.contains(ls.getLocationTagByName("Login Location")), is(true)); Collection attributes = loc.getActiveAttributes(); - Assert.assertThat(attributes.size(), is(1)); - Assert.assertEquals("2019-03-13", + MatcherAssert.assertThat(attributes.size(), is(1)); + Assertions.assertEquals("2019-03-13", dateDatatype.serialize((Date) ((LocationAttribute) attributes.toArray()[0]).getValue())); } // Verify retire { Location loc = ls.getLocationByUuid("cbaaaab4-d960-4ae9-9b6a-8983fbd947b6"); - Assert.assertThat(loc.getRetired(), is(true)); + MatcherAssert.assertThat(loc.getRetired(), is(true)); } // Verify that location with an invalid parent isn't created { Location loc = ls.getLocationByUuid("2b9824a3-92f0-4966-8f34-1b105624b267"); - Assert.assertNull(loc); + Assertions.assertNull(loc); } // verify Locations domain i18n on entries with display:xy fields { - Assert.assertEquals("Acme Clinic (translated)", Context.getMessageSourceService() + Assertions.assertEquals("Acme Clinic (translated)", Context.getMessageSourceService() .getMessage("ui.i18n.Location.name.a03e395c-b881-49b7-b6fc-983f6bddc7fc", null, localeEn)); - Assert.assertEquals("គ្លីនិកអាមី", Context.getMessageSourceService() + Assertions.assertEquals("គ្លីនិកអាមី", Context.getMessageSourceService() .getMessage("ui.i18n.Location.name.a03e395c-b881-49b7-b6fc-983f6bddc7fc", null, localeKm)); - Assert.assertEquals("Acme Clinic (translated)", Context.getMessageSourceService() + Assertions.assertEquals("Acme Clinic (translated)", Context.getMessageSourceService() .getMessage("org.openmrs.Location.a03e395c-b881-49b7-b6fc-983f6bddc7fc", null, localeEn)); - Assert.assertEquals("គ្លីនិកអាមី", Context.getMessageSourceService() + Assertions.assertEquals("គ្លីនិកអាមី", Context.getMessageSourceService() .getMessage("org.openmrs.Location.a03e395c-b881-49b7-b6fc-983f6bddc7fc", null, localeKm)); } // verify no Locations domain i18n on entries without display:xy fields and entries without pre-filled uuids { - Assert.assertNotNull(ls.getLocationByUuid("1cb58794-3c49-11ea-b3eb-f7801304f314")); - Assert.assertEquals("ui.i18n.Location.name.1cb58794-3c49-11ea-b3eb-f7801304f314", + Assertions.assertNotNull(ls.getLocationByUuid("1cb58794-3c49-11ea-b3eb-f7801304f314")); + Assertions.assertEquals("ui.i18n.Location.name.1cb58794-3c49-11ea-b3eb-f7801304f314", Context.getMessageSourceService().getMessage("ui.i18n.Location.name.1cb58794-3c49-11ea-b3eb-f7801304f314", null, localeEn)); - Assert.assertEquals("ui.i18n.Location.name.1cb58794-3c49-11ea-b3eb-f7801304f314", + Assertions.assertEquals("ui.i18n.Location.name.1cb58794-3c49-11ea-b3eb-f7801304f314", Context.getMessageSourceService().getMessage("ui.i18n.Location.name.1cb58794-3c49-11ea-b3eb-f7801304f314", null, localeKm)); - Assert.assertEquals("org.openmrs.Location.1cb58794-3c49-11ea-b3eb-f7801304f314", + Assertions.assertEquals("org.openmrs.Location.1cb58794-3c49-11ea-b3eb-f7801304f314", Context.getMessageSourceService().getMessage("org.openmrs.Location.1cb58794-3c49-11ea-b3eb-f7801304f314", null, localeEn)); - Assert.assertEquals("org.openmrs.Location.1cb58794-3c49-11ea-b3eb-f7801304f314", + Assertions.assertEquals("org.openmrs.Location.1cb58794-3c49-11ea-b3eb-f7801304f314", Context.getMessageSourceService().getMessage("org.openmrs.Location.1cb58794-3c49-11ea-b3eb-f7801304f314", null, localeKm)); Location loc = ls.getLocation("The Lake Clinic-Cambodia"); - Assert.assertNotNull(loc); + Assertions.assertNotNull(loc); String uuid = loc.getUuid(); - Assert.assertEquals("ui.i18n.Location.name." + uuid, + Assertions.assertEquals("ui.i18n.Location.name." + uuid, Context.getMessageSourceService().getMessage("ui.i18n.Location.name." + uuid, null, localeEn)); - Assert.assertEquals("ui.i18n.Location.name." + uuid, + Assertions.assertEquals("ui.i18n.Location.name." + uuid, Context.getMessageSourceService().getMessage("ui.i18n.Location.name." + uuid, null, localeKm)); - Assert.assertEquals("org.openmrs.Location." + uuid, + Assertions.assertEquals("org.openmrs.Location." + uuid, Context.getMessageSourceService().getMessage("org.openmrs.Location." + uuid, null, localeEn)); - Assert.assertEquals("org.openmrs.Location." + uuid, + Assertions.assertEquals("org.openmrs.Location." + uuid, Context.getMessageSourceService().getMessage("org.openmrs.Location." + uuid, null, localeKm)); } } diff --git a/api/src/test/java/org/openmrs/module/initializer/api/LocationsLoaderRowChecksumIntegrationTest.java b/api/src/test/java/org/openmrs/module/initializer/api/LocationsLoaderRowChecksumIntegrationTest.java index 15199c73f..befc6f485 100644 --- a/api/src/test/java/org/openmrs/module/initializer/api/LocationsLoaderRowChecksumIntegrationTest.java +++ b/api/src/test/java/org/openmrs/module/initializer/api/LocationsLoaderRowChecksumIntegrationTest.java @@ -18,9 +18,9 @@ import java.nio.file.Paths; import java.util.Set; -import org.junit.After; -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.module.initializer.DomainBaseModuleContextSensitiveTest; import org.openmrs.module.initializer.InitializerConfig; import org.openmrs.module.initializer.api.loc.LocationsLoader; @@ -42,14 +42,14 @@ public class LocationsLoaderRowChecksumIntegrationTest extends DomainBaseModuleC @Autowired private InitializerService iniz; - @Before + @BeforeEach public void enableRowChecksums() throws Exception { executeDataSet("testdata/test-metadata.xml"); System.setProperty(PROPS_ROW_CHECKSUMS_ENABLED, "true"); cfg.init(); } - @After + @AfterEach public void disableRowChecksums() { System.clearProperty(PROPS_ROW_CHECKSUMS_ENABLED); cfg.init(); diff --git a/api/src/test/java/org/openmrs/module/initializer/api/MdsLoaderIntegrationTest.java b/api/src/test/java/org/openmrs/module/initializer/api/MdsLoaderIntegrationTest.java index b8d581cf8..6f6925d65 100644 --- a/api/src/test/java/org/openmrs/module/initializer/api/MdsLoaderIntegrationTest.java +++ b/api/src/test/java/org/openmrs/module/initializer/api/MdsLoaderIntegrationTest.java @@ -9,8 +9,8 @@ */ package org.openmrs.module.initializer.api; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import org.openmrs.PatientIdentifierType; import org.openmrs.PersonAttributeType; import org.openmrs.api.context.Context; @@ -29,27 +29,27 @@ public void load_shouldImportMDSPackages() { // Replay PersonAttributeType personAttType = null; personAttType = Context.getPersonService().getPersonAttributeTypeByUuid("b3b6d540-a32e-44c7-91b3-292d97667518"); - Assert.assertEquals("Race", personAttType.getName()); + Assertions.assertEquals("Race", personAttType.getName()); loader.load(); // Verif PatientIdentifierType patientIdType = Context.getPatientService() .getPatientIdentifierTypeByUuid("0d2ac572-8de3-46c8-9976-1f78899c599f"); - Assert.assertEquals("National ID card number", patientIdType.getName()); + Assertions.assertEquals("National ID card number", patientIdType.getName()); personAttType = Context.getPersonService().getPersonAttributeTypeByUuid("b3b6d540-a32e-44c7-91b3-292d97667518"); - Assert.assertEquals("Email address", personAttType.getName()); - Assert.assertFalse(personAttType.isRetired()); + Assertions.assertEquals("Email address", personAttType.getName()); + Assertions.assertFalse(personAttType.isRetired()); personAttType = Context.getPersonService().getPersonAttributeTypeByUuid("c1f4a004-3f10-11e4-adec-0800271c1b75"); - Assert.assertEquals("education", personAttType.getName()); - Assert.assertTrue(personAttType.isRetired()); + Assertions.assertEquals("education", personAttType.getName()); + Assertions.assertTrue(personAttType.isRetired()); // RelationshipType relType = // Context.getPersonService().getRelationshipTypeByUuid( // "2a5f4ff4-a179-4b8a-aa4c-40f71956ebbc"); - // Assert.assertEquals("Provider supervisor to provider supervisee + // Assertions.assertEquals("Provider supervisor to provider supervisee // relationship", relType.getDescription()); - // Assert.assertTrue(relType.isRetired()); + // Assertions.assertTrue(relType.isRetired()); } } diff --git a/api/src/test/java/org/openmrs/module/initializer/api/MetadataSetMembersLoaderIntegrationTest.java b/api/src/test/java/org/openmrs/module/initializer/api/MetadataSetMembersLoaderIntegrationTest.java index 66b57fa56..377bd881c 100644 --- a/api/src/test/java/org/openmrs/module/initializer/api/MetadataSetMembersLoaderIntegrationTest.java +++ b/api/src/test/java/org/openmrs/module/initializer/api/MetadataSetMembersLoaderIntegrationTest.java @@ -1,9 +1,10 @@ package org.openmrs.module.initializer.api; import org.hamcrest.CoreMatchers; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; +import org.hamcrest.MatcherAssert; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.openmrs.module.initializer.DomainBaseModuleContextSensitiveTest; import org.openmrs.module.initializer.api.mds.MetadataSetMembersLoader; import org.openmrs.module.metadatamapping.MetadataSetMember; @@ -22,7 +23,7 @@ public class MetadataSetMembersLoaderIntegrationTest extends DomainBaseModuleCon private static String MEMBER_TO_RETIRE = "f0ebcb99-272d-41b7-4c67-078de9342492"; - @Before + @BeforeEach public void setup() throws Exception { executeDataSet("testdata/test-metadatasets.xml"); @@ -38,18 +39,18 @@ public void load_shouldLoadMetadataSetMembersFromCSVLines() { // Verify created member = service.getMetadataSetMemberByUuid("dbfd899d-e9e1-4059-8992-73737c924f88"); - Assert.assertEquals("Outpatient Id", member.getName()); - Assert.assertEquals("IdentifierType for OPD", member.getDescription()); - Assert.assertEquals("7b0f5697-27e3-40c4-8bae-f4049abfb4ed", member.getMetadataUuid()); - Assert.assertThat(member.getSortWeight(), CoreMatchers.is(34.0)); + Assertions.assertEquals("Outpatient Id", member.getName()); + Assertions.assertEquals("IdentifierType for OPD", member.getDescription()); + Assertions.assertEquals("7b0f5697-27e3-40c4-8bae-f4049abfb4ed", member.getMetadataUuid()); + MatcherAssert.assertThat(member.getSortWeight(), CoreMatchers.is(34.0)); // Verify edited member = service.getMetadataSetMemberByUuid(MEMBER_TO_EDIT); - Assert.assertEquals("Legacy Id", member.getName()); - Assert.assertEquals("n0ebcb90-m618-n1b1-b0bf-kff93de97b9j", member.getMetadataUuid()); + Assertions.assertEquals("Legacy Id", member.getName()); + Assertions.assertEquals("n0ebcb90-m618-n1b1-b0bf-kff93de97b9j", member.getMetadataUuid()); // Verify retired member = service.getMetadataSetMemberByUuid(MEMBER_TO_RETIRE); - Assert.assertTrue(member.isRetired()); + Assertions.assertTrue(member.isRetired()); } } diff --git a/api/src/test/java/org/openmrs/module/initializer/api/MetadataSetsLoaderIntegrationTest.java b/api/src/test/java/org/openmrs/module/initializer/api/MetadataSetsLoaderIntegrationTest.java index 9538e6543..f1409a854 100644 --- a/api/src/test/java/org/openmrs/module/initializer/api/MetadataSetsLoaderIntegrationTest.java +++ b/api/src/test/java/org/openmrs/module/initializer/api/MetadataSetsLoaderIntegrationTest.java @@ -1,8 +1,8 @@ package org.openmrs.module.initializer.api; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.openmrs.module.initializer.DomainBaseModuleContextSensitiveTest; import org.openmrs.module.initializer.api.mds.MetadataSetsLoader; import org.openmrs.module.metadatamapping.MetadataSet; @@ -21,7 +21,7 @@ public class MetadataSetsLoaderIntegrationTest extends DomainBaseModuleContextSe private static String SET_TO_EDIT_UUID = "f0ebcb99-7618-41b7-b0bf-8ff93de67b9e"; - @Before + @BeforeEach public void setup() throws Exception { executeDataSet("testdata/test-metadatasets.xml"); } @@ -36,16 +36,16 @@ public void load_shouldLoadMetadataSetsFromCSVLines() { // Verify created set = service.getMetadataSetByUuid("e3410148-a7df-447c-9bde-1a08aaecc0f5"); - Assert.assertNotNull(set); - Assert.assertEquals("Required Attribute Types", set.getName()); + Assertions.assertNotNull(set); + Assertions.assertEquals("Required Attribute Types", set.getName()); // Verify edited set = service.getMetadataSetByUuid(SET_TO_EDIT_UUID); - Assert.assertEquals("Extra Identifiers Set", set.getName()); - Assert.assertEquals("Set of extra patient identifiers", set.getDescription()); + Assertions.assertEquals("Extra Identifiers Set", set.getName()); + Assertions.assertEquals("Set of extra patient identifiers", set.getDescription()); // Verify retired set = service.getMetadataSetByUuid(SET_TO_RETIRE_UUID); - Assert.assertTrue(set.isRetired()); + Assertions.assertTrue(set.isRetired()); } } diff --git a/api/src/test/java/org/openmrs/module/initializer/api/MetadataTermMappingsLoaderIntegrationTest.java b/api/src/test/java/org/openmrs/module/initializer/api/MetadataTermMappingsLoaderIntegrationTest.java index 15f4481c3..fe329f962 100644 --- a/api/src/test/java/org/openmrs/module/initializer/api/MetadataTermMappingsLoaderIntegrationTest.java +++ b/api/src/test/java/org/openmrs/module/initializer/api/MetadataTermMappingsLoaderIntegrationTest.java @@ -1,8 +1,8 @@ package org.openmrs.module.initializer.api; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.openmrs.EncounterType; import org.openmrs.PatientIdentifierType; import org.openmrs.module.initializer.DomainBaseModuleContextSensitiveTest; @@ -23,7 +23,7 @@ public class MetadataTermMappingsLoaderIntegrationTest extends DomainBaseModuleC private MetadataSource ms; - @Before + @BeforeEach public void setup() { ms = new MetadataSource(); @@ -76,34 +76,34 @@ public void load_shouldLoadMetadataTermMappingsFromCsvFiles() { // Verify created mtm = service.getMetadataTermMapping(ms, "emr.atFacilityVisitType"); - Assert.assertNotNull(mtm); - Assert.assertNotNull(mtm.getUuid()); - Assert.assertEquals("org.openmrs.VisitType", mtm.getMetadataClass()); - Assert.assertEquals("7b0f5697-27e3-40c4-8bae-f4049abfb4ed", mtm.getMetadataUuid()); + Assertions.assertNotNull(mtm); + Assertions.assertNotNull(mtm.getUuid()); + Assertions.assertEquals("org.openmrs.VisitType", mtm.getMetadataClass()); + Assertions.assertEquals("7b0f5697-27e3-40c4-8bae-f4049abfb4ed", mtm.getMetadataUuid()); // Verify edited using source and code mtm = service.getMetadataTermMappingByUuid("21e24b36-f9e3-4b0e-986d-9899665597f7"); - Assert.assertNotNull(mtm); - Assert.assertEquals("org.openmrs.module.emrapi", mtm.getMetadataSource().getName()); - Assert.assertEquals("emr.primaryIdentifierType", mtm.getCode()); - Assert.assertEquals("org.openmrs.PatientIdentifierType", mtm.getMetadataClass()); - Assert.assertEquals("264c9e75-77da-486a-8361-31558e051930", mtm.getMetadataUuid()); + Assertions.assertNotNull(mtm); + Assertions.assertEquals("org.openmrs.module.emrapi", mtm.getMetadataSource().getName()); + Assertions.assertEquals("emr.primaryIdentifierType", mtm.getCode()); + Assertions.assertEquals("org.openmrs.PatientIdentifierType", mtm.getMetadataClass()); + Assertions.assertEquals("264c9e75-77da-486a-8361-31558e051930", mtm.getMetadataUuid()); // Verify edited using metadataUuid mtm = service.getMetadataTermMappingByUuid("dbfd899d-e9e1-4059-8992-73737c924f84"); - Assert.assertNotNull(mtm); - Assert.assertEquals("org.openmrs.module.emrapi", mtm.getMetadataSource().getName()); - Assert.assertEquals("emr.admissionEncounterType", mtm.getCode()); - Assert.assertEquals("org.openmrs.EncounterType", mtm.getMetadataClass()); - Assert.assertEquals("e22e39fd-7db2-45e7-80f1-60fa0d5a4378", mtm.getMetadataUuid()); + Assertions.assertNotNull(mtm); + Assertions.assertEquals("org.openmrs.module.emrapi", mtm.getMetadataSource().getName()); + Assertions.assertEquals("emr.admissionEncounterType", mtm.getCode()); + Assertions.assertEquals("org.openmrs.EncounterType", mtm.getMetadataClass()); + Assertions.assertEquals("e22e39fd-7db2-45e7-80f1-60fa0d5a4378", mtm.getMetadataUuid()); // Verify retired mtm = service.getMetadataTermMappingByUuid("5f84b986-232d-475b-aad2-2094306bd655"); - Assert.assertNotNull(mtm); - Assert.assertTrue(mtm.isRetired()); - Assert.assertEquals("org.openmrs.module.emrapi", mtm.getMetadataSource().getName()); - Assert.assertEquals("emr.extraPatientIdentifierTypes", mtm.getCode()); - Assert.assertEquals("org.openmrs.module.metadatamapping.MetadataSet", mtm.getMetadataClass()); - Assert.assertEquals("05a29f94-c0ed-11e2-94be-8c13b969e334", mtm.getMetadataUuid()); + Assertions.assertNotNull(mtm); + Assertions.assertTrue(mtm.isRetired()); + Assertions.assertEquals("org.openmrs.module.emrapi", mtm.getMetadataSource().getName()); + Assertions.assertEquals("emr.extraPatientIdentifierTypes", mtm.getCode()); + Assertions.assertEquals("org.openmrs.module.metadatamapping.MetadataSet", mtm.getMetadataClass()); + Assertions.assertEquals("05a29f94-c0ed-11e2-94be-8c13b969e334", mtm.getMetadataUuid()); } } diff --git a/api/src/test/java/org/openmrs/module/initializer/api/OpenConceptLabLoaderIntegrationTest.java b/api/src/test/java/org/openmrs/module/initializer/api/OpenConceptLabLoaderIntegrationTest.java index d6cdb8fda..502d37398 100644 --- a/api/src/test/java/org/openmrs/module/initializer/api/OpenConceptLabLoaderIntegrationTest.java +++ b/api/src/test/java/org/openmrs/module/initializer/api/OpenConceptLabLoaderIntegrationTest.java @@ -9,10 +9,10 @@ */ package org.openmrs.module.initializer.api; -import org.junit.After; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; import org.openmrs.api.ConceptService; import org.openmrs.api.context.Context; import org.openmrs.module.DaemonToken; @@ -40,7 +40,7 @@ public class OpenConceptLabLoaderIntegrationTest extends DomainBaseModuleContext private ConceptService conceptService; @SuppressWarnings("unchecked") - @BeforeClass + @BeforeAll public static void setupDaemonToken() { Map daemonTokens; try { @@ -57,8 +57,8 @@ public static void setupDaemonToken() { new OpenConceptLabActivator().setDaemonToken(daemonToken); } - @After - public void deleteAllData() throws Exception { + @AfterEach + public void deleteAllData() { // this is necessary or else future test cases will fail because of two sources named CIEL super.deleteAllData(); } @@ -71,156 +71,156 @@ public void load_shouldImportOCLPackages() { // Verify by UUID { Concept c = conceptService.getConceptByUuid("1419AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"); - Assert.assertNotNull(c); - Assert.assertFalse(c.getRetired()); - Assert.assertEquals("Vaccine manufacturer", c.getName(Locale.ENGLISH).getName()); - Assert.assertEquals("Vaccine maker", c.getShortNameInLocale(Locale.ENGLISH).getName()); - Assert.assertEquals("Fabricant du vaccin", c.getName(Locale.FRENCH).getName()); - Assert.assertEquals("Kiwanda cha kutengeneza chanjo", c.getName(LOCALE_SW).getName()); - Assert.assertEquals(0, c.getDescriptions().size()); - Assert.assertEquals("Finding", c.getConceptClass().getName()); - Assert.assertEquals("Text", c.getDatatype().getName()); + Assertions.assertNotNull(c); + Assertions.assertFalse(c.getRetired()); + Assertions.assertEquals("Vaccine manufacturer", c.getName(Locale.ENGLISH).getName()); + Assertions.assertEquals("Vaccine maker", c.getShortNameInLocale(Locale.ENGLISH).getName()); + Assertions.assertEquals("Fabricant du vaccin", c.getName(Locale.FRENCH).getName()); + Assertions.assertEquals("Kiwanda cha kutengeneza chanjo", c.getName(LOCALE_SW).getName()); + Assertions.assertEquals(0, c.getDescriptions().size()); + Assertions.assertEquals("Finding", c.getConceptClass().getName()); + Assertions.assertEquals("Text", c.getDatatype().getName()); } // Verify by UUID { Concept c = conceptService.getConceptByUuid("163100AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"); - Assert.assertNotNull(c); - Assert.assertFalse(c.getRetired()); - Assert.assertEquals("Procedure received by patient", c.getName(Locale.ENGLISH).getName()); - Assert.assertEquals("Procédure reçue par le patient", c.getName(Locale.FRENCH).getName()); - Assert.assertEquals("Pasyan te resevwa pwosedi", c.getName(LOCALE_HT).getName()); - Assert.assertEquals(1, c.getDescriptions().size()); - Assert.assertEquals("Question", c.getConceptClass().getName()); - Assert.assertEquals("Coded", c.getDatatype().getName()); + Assertions.assertNotNull(c); + Assertions.assertFalse(c.getRetired()); + Assertions.assertEquals("Procedure received by patient", c.getName(Locale.ENGLISH).getName()); + Assertions.assertEquals("Procédure reçue par le patient", c.getName(Locale.FRENCH).getName()); + Assertions.assertEquals("Pasyan te resevwa pwosedi", c.getName(LOCALE_HT).getName()); + Assertions.assertEquals(1, c.getDescriptions().size()); + Assertions.assertEquals("Question", c.getConceptClass().getName()); + Assertions.assertEquals("Coded", c.getDatatype().getName()); } // Verify by UUID { Context.setLocale(Locale.ENGLISH); Concept c = conceptService.getConceptByUuid("5864AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"); - Assert.assertNotNull(c); - Assert.assertEquals("Yellow fever vaccination", c.getName(Locale.ENGLISH).getName()); - Assert.assertEquals("Vaccination given for Yellow Fever.", c.getDescription().toString()); - Assert.assertEquals("Procedure", c.getConceptClass().getName()); - Assert.assertEquals("N/A", c.getDatatype().getName()); + Assertions.assertNotNull(c); + Assertions.assertEquals("Yellow fever vaccination", c.getName(Locale.ENGLISH).getName()); + Assertions.assertEquals("Vaccination given for Yellow Fever.", c.getDescription().toString()); + Assertions.assertEquals("Procedure", c.getConceptClass().getName()); + Assertions.assertEquals("N/A", c.getDatatype().getName()); } // Verify by name { Context.setLocale(Locale.ENGLISH); Concept c = conceptService.getConceptByName("Vaccine manufacturer"); - Assert.assertNotNull(c); - Assert.assertFalse(c.getRetired()); - Assert.assertEquals("Vaccine manufacturer", c.getName(Locale.ENGLISH).getName()); - Assert.assertEquals("Vaccine maker", c.getShortNameInLocale(Locale.ENGLISH).getName()); - Assert.assertEquals("Fabricant du vaccin", c.getName(Locale.FRENCH).getName()); - Assert.assertEquals("Kiwanda cha kutengeneza chanjo", c.getName(LOCALE_SW).getName()); - Assert.assertEquals(0, c.getDescriptions().size()); - Assert.assertEquals("Finding", c.getConceptClass().getName()); - Assert.assertEquals("Text", c.getDatatype().getName()); + Assertions.assertNotNull(c); + Assertions.assertFalse(c.getRetired()); + Assertions.assertEquals("Vaccine manufacturer", c.getName(Locale.ENGLISH).getName()); + Assertions.assertEquals("Vaccine maker", c.getShortNameInLocale(Locale.ENGLISH).getName()); + Assertions.assertEquals("Fabricant du vaccin", c.getName(Locale.FRENCH).getName()); + Assertions.assertEquals("Kiwanda cha kutengeneza chanjo", c.getName(LOCALE_SW).getName()); + Assertions.assertEquals(0, c.getDescriptions().size()); + Assertions.assertEquals("Finding", c.getConceptClass().getName()); + Assertions.assertEquals("Text", c.getDatatype().getName()); } // Verify by name { Context.setLocale(Locale.ENGLISH); Concept c = conceptService.getConceptByName("Procedure received by patient"); - Assert.assertNotNull(c); - Assert.assertFalse(c.getRetired()); - Assert.assertEquals("Procedure received by patient", c.getName(Locale.ENGLISH).getName()); - Assert.assertEquals("Procédure reçue par le patient", c.getName(Locale.FRENCH).getName()); - Assert.assertEquals("Pasyan te resevwa pwosedi", c.getName(LOCALE_HT).getName()); - Assert.assertEquals(1, c.getDescriptions().size()); - Assert.assertEquals("Question", c.getConceptClass().getName()); - Assert.assertEquals("Coded", c.getDatatype().getName()); + Assertions.assertNotNull(c); + Assertions.assertFalse(c.getRetired()); + Assertions.assertEquals("Procedure received by patient", c.getName(Locale.ENGLISH).getName()); + Assertions.assertEquals("Procédure reçue par le patient", c.getName(Locale.FRENCH).getName()); + Assertions.assertEquals("Pasyan te resevwa pwosedi", c.getName(LOCALE_HT).getName()); + Assertions.assertEquals(1, c.getDescriptions().size()); + Assertions.assertEquals("Question", c.getConceptClass().getName()); + Assertions.assertEquals("Coded", c.getDatatype().getName()); } // Verify by Mapping { Concept c = conceptService.getConceptByMapping("1419", "CIEL"); - Assert.assertNotNull(c); - Assert.assertFalse(c.getRetired()); - Assert.assertEquals("Vaccine manufacturer", c.getName(Locale.ENGLISH).getName()); - Assert.assertEquals("Vaccine maker", c.getShortNameInLocale(Locale.ENGLISH).getName()); - Assert.assertEquals("Fabricant du vaccin", c.getName(Locale.FRENCH).getName()); - Assert.assertEquals("Kiwanda cha kutengeneza chanjo", c.getName(LOCALE_SW).getName()); - Assert.assertEquals(0, c.getDescriptions().size()); - Assert.assertEquals("Finding", c.getConceptClass().getName()); - Assert.assertEquals("Text", c.getDatatype().getName()); + Assertions.assertNotNull(c); + Assertions.assertFalse(c.getRetired()); + Assertions.assertEquals("Vaccine manufacturer", c.getName(Locale.ENGLISH).getName()); + Assertions.assertEquals("Vaccine maker", c.getShortNameInLocale(Locale.ENGLISH).getName()); + Assertions.assertEquals("Fabricant du vaccin", c.getName(Locale.FRENCH).getName()); + Assertions.assertEquals("Kiwanda cha kutengeneza chanjo", c.getName(LOCALE_SW).getName()); + Assertions.assertEquals(0, c.getDescriptions().size()); + Assertions.assertEquals("Finding", c.getConceptClass().getName()); + Assertions.assertEquals("Text", c.getDatatype().getName()); } // Verify by Mapping { Concept c = conceptService.getConceptByMapping("163100", "CIEL"); - Assert.assertNotNull(c); - Assert.assertFalse(c.getRetired()); - Assert.assertEquals("Procedure received by patient", c.getName(Locale.ENGLISH).getName()); - Assert.assertEquals("Procédure reçue par le patient", c.getName(Locale.FRENCH).getName()); - Assert.assertEquals("Pasyan te resevwa pwosedi", c.getName(LOCALE_HT).getName()); - Assert.assertEquals(1, c.getDescriptions().size()); - Assert.assertEquals("Question", c.getConceptClass().getName()); - Assert.assertEquals("Coded", c.getDatatype().getName()); + Assertions.assertNotNull(c); + Assertions.assertFalse(c.getRetired()); + Assertions.assertEquals("Procedure received by patient", c.getName(Locale.ENGLISH).getName()); + Assertions.assertEquals("Procédure reçue par le patient", c.getName(Locale.FRENCH).getName()); + Assertions.assertEquals("Pasyan te resevwa pwosedi", c.getName(LOCALE_HT).getName()); + Assertions.assertEquals(1, c.getDescriptions().size()); + Assertions.assertEquals("Question", c.getConceptClass().getName()); + Assertions.assertEquals("Coded", c.getDatatype().getName()); } // Verify by Mapping { Concept c = conceptService.getConceptByMapping("166011", "CIEL"); - Assert.assertNotNull(c); - Assert.assertFalse(c.getRetired()); - Assert.assertEquals("Immunization, non-coded", c.getName(Locale.ENGLISH).getName()); - Assert.assertEquals("Immunization, non-coded", c.getFullySpecifiedName(Locale.ENGLISH).getName()); - Assert.assertEquals(0, c.getDescriptions().size()); - Assert.assertEquals("Question", c.getConceptClass().getName()); - Assert.assertEquals("Text", c.getDatatype().getName()); + Assertions.assertNotNull(c); + Assertions.assertFalse(c.getRetired()); + Assertions.assertEquals("Immunization, non-coded", c.getName(Locale.ENGLISH).getName()); + Assertions.assertEquals("Immunization, non-coded", c.getFullySpecifiedName(Locale.ENGLISH).getName()); + Assertions.assertEquals(0, c.getDescriptions().size()); + Assertions.assertEquals("Question", c.getConceptClass().getName()); + Assertions.assertEquals("Text", c.getDatatype().getName()); } // Verify in another locale { Context.setLocale(Locale.FRENCH); Concept c = conceptService.getConceptByName("Fabricant du vaccin"); - Assert.assertNotNull(c); - Assert.assertEquals(0, c.getDescriptions().size()); - Assert.assertEquals("Finding", c.getConceptClass().getName()); - Assert.assertEquals("Text", c.getDatatype().getName()); + Assertions.assertNotNull(c); + Assertions.assertEquals(0, c.getDescriptions().size()); + Assertions.assertEquals("Finding", c.getConceptClass().getName()); + Assertions.assertEquals("Text", c.getDatatype().getName()); } // Verify just one name is enough { Context.setLocale(Locale.ENGLISH); Concept c = conceptService.getConceptByName("PNEUMOCOCCAL VACCINE"); - Assert.assertNotNull(c); - Assert.assertEquals(6, c.getNames().size()); - Assert.assertEquals(0, c.getShortNames().size()); - Assert.assertEquals(0, c.getDescriptions().size()); - Assert.assertEquals("Drug", c.getConceptClass().getName()); - Assert.assertEquals("N/A", c.getDatatype().getName()); + Assertions.assertNotNull(c); + Assertions.assertEquals(6, c.getNames().size()); + Assertions.assertEquals(0, c.getShortNames().size()); + Assertions.assertEquals(0, c.getDescriptions().size()); + Assertions.assertEquals("Drug", c.getConceptClass().getName()); + Assertions.assertEquals("N/A", c.getDatatype().getName()); } // Verify failures { Context.setLocale(Locale.ENGLISH); - Assert.assertNull(conceptService.getConceptByUuid("162339AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAB")); - Assert.assertNull(conceptService.getConceptByName("TETANUS BOOSTERS")); - Assert.assertNull(conceptService.getConceptByUuid("162330AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAB")); - Assert.assertNull(conceptService.getConceptByName("TVACCINE MANUFACTURERS")); - Assert.assertNull(conceptService.getConceptByUuid("162337AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAB")); - Assert.assertNull(conceptService.getConceptByName("DIPTHERIAYY")); + Assertions.assertNull(conceptService.getConceptByUuid("162339AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAB")); + Assertions.assertNull(conceptService.getConceptByName("TETANUS BOOSTERS")); + Assertions.assertNull(conceptService.getConceptByUuid("162330AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAB")); + Assertions.assertNull(conceptService.getConceptByName("TVACCINE MANUFACTURERS")); + Assertions.assertNull(conceptService.getConceptByUuid("162337AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAB")); + Assertions.assertNull(conceptService.getConceptByName("DIPTHERIAYY")); } // Verify retirement { Concept c = conceptService.getConceptByUuid("162339AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"); - Assert.assertTrue(c.getRetired()); + Assertions.assertTrue(c.getRetired()); } // Verify un-retirement { Context.setLocale(Locale.ENGLISH); Concept c = conceptService.getConceptByUuid("17AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"); - Assert.assertNotNull(c); - Assert.assertFalse(c.getRetired()); - Assert.assertEquals("Diptheria tetanus booster", c.getFullySpecifiedName(Locale.ENGLISH).getName()); - Assert.assertEquals("Drug", c.getConceptClass().getName()); - Assert.assertEquals("N/A", c.getDatatype().getName()); + Assertions.assertNotNull(c); + Assertions.assertFalse(c.getRetired()); + Assertions.assertEquals("Diptheria tetanus booster", c.getFullySpecifiedName(Locale.ENGLISH).getName()); + Assertions.assertEquals("Drug", c.getConceptClass().getName()); + Assertions.assertEquals("N/A", c.getDatatype().getName()); } } } diff --git a/api/src/test/java/org/openmrs/module/initializer/api/OrderFrequenciesLoaderIntegrationTest.java b/api/src/test/java/org/openmrs/module/initializer/api/OrderFrequenciesLoaderIntegrationTest.java index 41ded99e1..16166010f 100644 --- a/api/src/test/java/org/openmrs/module/initializer/api/OrderFrequenciesLoaderIntegrationTest.java +++ b/api/src/test/java/org/openmrs/module/initializer/api/OrderFrequenciesLoaderIntegrationTest.java @@ -11,9 +11,9 @@ import java.util.Locale; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.openmrs.Concept; import org.openmrs.ConceptName; import org.openmrs.OrderFrequency; @@ -41,7 +41,7 @@ public class OrderFrequenciesLoaderIntegrationTest extends DomainBaseModuleConte private Concept bidailyConcept; - @Before + @BeforeEach public void setup() { // Concepts to be used as a 'frequency' @@ -99,23 +99,23 @@ public void load_shouldLoadOrderFrequenciesAccordingToCsvFiles() { // created frequency { OrderFrequency freq = os.getOrderFrequencyByConcept(hourlyConcept); - Assert.assertNotNull(freq); - Assert.assertEquals(0, Double.compare(24.0, freq.getFrequencyPerDay())); + Assertions.assertNotNull(freq); + Assertions.assertEquals(0, Double.compare(24.0, freq.getFrequencyPerDay())); } // retired frequency { OrderFrequency freq = os.getOrderFrequencyByUuid("4b33b729-1fe3-4fa5-acc4-084beb069b68"); - Assert.assertNotNull(freq); - Assert.assertTrue(freq.getRetired()); + Assertions.assertNotNull(freq); + Assertions.assertTrue(freq.getRetired()); } // edited frequency { OrderFrequency freq = os.getOrderFrequencyByUuid("136ebdb7-e989-47cf-8ec2-4e8b2ffe0ab3"); - Assert.assertNotNull(freq); - Assert.assertEquals(bidailyConcept, freq.getConcept()); - Assert.assertEquals(0, Double.compare(0.5, freq.getFrequencyPerDay())); + Assertions.assertNotNull(freq); + Assertions.assertEquals(bidailyConcept, freq.getConcept()); + Assertions.assertEquals(0, Double.compare(0.5, freq.getFrequencyPerDay())); } } } diff --git a/api/src/test/java/org/openmrs/module/initializer/api/OrderTypesLoaderIntegrationTest.java b/api/src/test/java/org/openmrs/module/initializer/api/OrderTypesLoaderIntegrationTest.java index 2b335f43b..d57e83400 100644 --- a/api/src/test/java/org/openmrs/module/initializer/api/OrderTypesLoaderIntegrationTest.java +++ b/api/src/test/java/org/openmrs/module/initializer/api/OrderTypesLoaderIntegrationTest.java @@ -10,14 +10,14 @@ package org.openmrs.module.initializer.api; import static org.hamcrest.Matchers.hasItems; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; import java.util.List; import java.util.stream.Collectors; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.openmrs.ConceptClass; import org.openmrs.DrugOrder; import org.openmrs.Order; @@ -42,7 +42,7 @@ public class OrderTypesLoaderIntegrationTest extends DomainBaseModuleContextSens @Autowired private OrderTypesLoader loader; - @Before + @BeforeEach public void setup() { // An order type to rename { @@ -84,46 +84,46 @@ public void load_shouldLoadAccordingToCsvFiles() { // Verif creation of an order type with concept classes and a parent { OrderType ot = os.getOrderTypeByName("Iniz Lab Order"); - Assert.assertEquals("8189b409-3f10-11e4-adec-0800271c1b75", ot.getUuid()); - Assert.assertEquals("An order for laboratory tests created by Iniz", ot.getDescription()); - Assert.assertEquals("org.openmrs.Order", ot.getJavaClassName()); - Assert.assertEquals(Order.class, ot.getJavaClass()); - Assert.assertEquals(2, ot.getConceptClasses().size()); + Assertions.assertEquals("8189b409-3f10-11e4-adec-0800271c1b75", ot.getUuid()); + Assertions.assertEquals("An order for laboratory tests created by Iniz", ot.getDescription()); + Assertions.assertEquals("org.openmrs.Order", ot.getJavaClassName()); + Assertions.assertEquals(Order.class, ot.getJavaClass()); + Assertions.assertEquals(2, ot.getConceptClasses().size()); List classesUuids = ot.getConceptClasses().stream().map(cc -> cc.getUuid()).collect(Collectors.toList()); assertThat(classesUuids, hasItems("c652c923-552f-4634-9418-17692a856f03", "9ce20038-c1de-4856-b2b1-297d06e58326")); List classesNames = ot.getConceptClasses().stream().map(cc -> cc.getName()).collect(Collectors.toList()); assertThat(classesNames, hasItems("Lab orders #1", "Lab orders #2")); - Assert.assertEquals("01727040-a587-484d-b66a-f0afbae6c281", ot.getParent().getUuid()); + Assertions.assertEquals("01727040-a587-484d-b66a-f0afbae6c281", ot.getParent().getUuid()); } // Verif renaming an existing order type { OrderType ot = os.getOrderTypeByUuid("8be5f714-ee92-4d09-939e-2d1897bb2f95"); - Assert.assertEquals("New Order Type Name", ot.getName()); + Assertions.assertEquals("New Order Type Name", ot.getName()); } // Verif retiring an existing order type { OrderType ot = os.getOrderTypeByUuid("96f94b64-6c9e-489d-b258-633878b9af69"); - Assert.assertEquals(true, ot.getRetired()); + Assertions.assertEquals(true, ot.getRetired()); } // Verif bootstrapping by name only { OrderType ot = os.getOrderTypeByName("Order Type Without UUID"); - Assert.assertNotNull(ot); - Assert.assertEquals("For testing loading order types by name.", ot.getDescription()); + Assertions.assertNotNull(ot); + Assertions.assertEquals("For testing loading order types by name.", ot.getDescription()); } // Verif another Java class name than 'org.openmrs.Order' { OrderType ot = os.getOrderTypeByUuid("6721493b-ec7c-4e3f-980a-5be3a09585ce"); - Assert.assertNotNull(ot); - Assert.assertEquals("org.openmrs.DrugOrder", ot.getJavaClassName()); - Assert.assertEquals(DrugOrder.class, ot.getJavaClass()); + Assertions.assertNotNull(ot); + Assertions.assertEquals("org.openmrs.DrugOrder", ot.getJavaClassName()); + Assertions.assertEquals(DrugOrder.class, ot.getJavaClass()); // The parent must be applied even when the Java class name is a concrete subtype of Order - Assert.assertEquals("01727040-a587-484d-b66a-f0afbae6c281", ot.getParent().getUuid()); + Assertions.assertEquals("01727040-a587-484d-b66a-f0afbae6c281", ot.getParent().getUuid()); } } } diff --git a/api/src/test/java/org/openmrs/module/initializer/api/OrderedFileTest.java b/api/src/test/java/org/openmrs/module/initializer/api/OrderedFileTest.java index 6dcbaa8fc..0f41fe675 100644 --- a/api/src/test/java/org/openmrs/module/initializer/api/OrderedFileTest.java +++ b/api/src/test/java/org/openmrs/module/initializer/api/OrderedFileTest.java @@ -1,7 +1,7 @@ package org.openmrs.module.initializer.api; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import java.io.File; @@ -13,8 +13,8 @@ public void orderedFileShouldCompareByNameIfNoOrderSpecified() { OrderedFile file2 = new OrderedFile("/configuration/domain/file2.txt"); OrderedFile file3 = new OrderedFile("/configuration/domain/concepts/file3.txt"); - Assert.assertTrue(file1.compareTo(file2) < 0); - Assert.assertTrue(file1.compareTo(file3) > 0); + Assertions.assertTrue(file1.compareTo(file2) < 0); + Assertions.assertTrue(file1.compareTo(file3) > 0); } @Test @@ -23,9 +23,9 @@ public void orderedFileShouldFirstCompareByOrderIfSpecified() { OrderedFile file2 = new NumericFile("/configuration/domain/9"); OrderedFile file3 = new NumericFile("/configuration/concepts/concepts.csv"); - Assert.assertTrue(file1.compareTo(file2) > 0); - Assert.assertTrue(file1.compareTo(file3) < 0); - Assert.assertTrue(file2.compareTo(file3) < 0); + Assertions.assertTrue(file1.compareTo(file2) > 0); + Assertions.assertTrue(file1.compareTo(file3) < 0); + Assertions.assertTrue(file2.compareTo(file3) < 0); } public class NumericFile extends OrderedFile { diff --git a/api/src/test/java/org/openmrs/module/initializer/api/PatientIdentifierTypesLoaderIntegrationTest.java b/api/src/test/java/org/openmrs/module/initializer/api/PatientIdentifierTypesLoaderIntegrationTest.java index a8f15a190..2755cfb27 100644 --- a/api/src/test/java/org/openmrs/module/initializer/api/PatientIdentifierTypesLoaderIntegrationTest.java +++ b/api/src/test/java/org/openmrs/module/initializer/api/PatientIdentifierTypesLoaderIntegrationTest.java @@ -9,9 +9,9 @@ */ package org.openmrs.module.initializer.api; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.openmrs.PatientIdentifierType; import org.openmrs.api.PatientService; import org.openmrs.module.initializer.DomainBaseModuleContextSensitiveTest; @@ -28,7 +28,7 @@ public class PatientIdentifierTypesLoaderIntegrationTest extends DomainBaseModul @Autowired private PatientIdentifierTypesLoader loader; - @Before + @BeforeEach public void setup() { } @@ -39,36 +39,36 @@ public void load_shouldLoadPatientIdentifierTypesAccordingToCsvFiles() { { // new PIT loaded with all expected fields PatientIdentifierType pit = ps.getPatientIdentifierTypeByUuid("73f4f1d6-6086-41d5-a0f1-6d688a4b10af"); - Assert.assertNotNull(pit); - Assert.assertEquals("Hospital ID", pit.getName()); - Assert.assertEquals("The patient ID for the hospital. You know the one", pit.getDescription()); - Assert.assertTrue(pit.getRequired()); - Assert.assertEquals("H-\\d\\d\\d\\d-\\d", pit.getFormat()); - Assert.assertEquals("Must have format H-####-C where C is the Luhn check digit", pit.getFormatDescription()); - Assert.assertEquals("org.openmrs.patient.impl.LuhnIdentifierValidator", pit.getValidator()); - Assert.assertEquals(PatientIdentifierType.LocationBehavior.NOT_USED, pit.getLocationBehavior()); - Assert.assertEquals(PatientIdentifierType.UniquenessBehavior.UNIQUE, pit.getUniquenessBehavior()); + Assertions.assertNotNull(pit); + Assertions.assertEquals("Hospital ID", pit.getName()); + Assertions.assertEquals("The patient ID for the hospital. You know the one", pit.getDescription()); + Assertions.assertTrue(pit.getRequired()); + Assertions.assertEquals("H-\\d\\d\\d\\d-\\d", pit.getFormat()); + Assertions.assertEquals("Must have format H-####-C where C is the Luhn check digit", pit.getFormatDescription()); + Assertions.assertEquals("org.openmrs.patient.impl.LuhnIdentifierValidator", pit.getValidator()); + Assertions.assertEquals(PatientIdentifierType.LocationBehavior.NOT_USED, pit.getLocationBehavior()); + Assertions.assertEquals(PatientIdentifierType.UniquenessBehavior.UNIQUE, pit.getUniquenessBehavior()); } { // Old Identification Number should be voided PatientIdentifierType pit = ps.getPatientIdentifierTypeByUuid("2f470aa8-1d73-43b7-81b5-01f0c0dfa53c"); - Assert.assertNotNull(pit); - Assert.assertTrue(pit.getRetired()); + Assertions.assertNotNull(pit); + Assertions.assertTrue(pit.getRetired()); } { // Test National ID should have fields modified PatientIdentifierType pit = ps.getPatientIdentifierTypeByUuid("b0d10dc0-d8ce-11e3-9c1a-0800200c9a66"); - Assert.assertNotNull(pit); - Assert.assertEquals("Test National ID No", pit.getName()); - Assert.assertEquals("Changing all the fields", pit.getDescription()); - Assert.assertTrue(pit.getRequired()); - Assert.assertEquals("\\a\\a\\a\\d\\d\\d\\d", pit.getFormat()); - Assert.assertEquals("Three letters and four numbers", pit.getFormatDescription()); - Assert.assertEquals("org.openmrs.patient.impl.LuhnIdentifierValidator", pit.getValidator()); - Assert.assertEquals(PatientIdentifierType.LocationBehavior.REQUIRED, pit.getLocationBehavior()); - Assert.assertEquals(PatientIdentifierType.UniquenessBehavior.LOCATION, pit.getUniquenessBehavior()); + Assertions.assertNotNull(pit); + Assertions.assertEquals("Test National ID No", pit.getName()); + Assertions.assertEquals("Changing all the fields", pit.getDescription()); + Assertions.assertTrue(pit.getRequired()); + Assertions.assertEquals("\\a\\a\\a\\d\\d\\d\\d", pit.getFormat()); + Assertions.assertEquals("Three letters and four numbers", pit.getFormatDescription()); + Assertions.assertEquals("org.openmrs.patient.impl.LuhnIdentifierValidator", pit.getValidator()); + Assertions.assertEquals(PatientIdentifierType.LocationBehavior.REQUIRED, pit.getLocationBehavior()); + Assertions.assertEquals(PatientIdentifierType.UniquenessBehavior.LOCATION, pit.getUniquenessBehavior()); } { // Minimal ID created with minimal required specification PatientIdentifierType pit = ps.getPatientIdentifierTypeByName("Minimal ID"); - Assert.assertNotNull(pit); + Assertions.assertNotNull(pit); } } } diff --git a/api/src/test/java/org/openmrs/module/initializer/api/PersonAttributeTypesLoaderIntegrationTest.java b/api/src/test/java/org/openmrs/module/initializer/api/PersonAttributeTypesLoaderIntegrationTest.java index db0f9c075..03aca3d73 100644 --- a/api/src/test/java/org/openmrs/module/initializer/api/PersonAttributeTypesLoaderIntegrationTest.java +++ b/api/src/test/java/org/openmrs/module/initializer/api/PersonAttributeTypesLoaderIntegrationTest.java @@ -11,9 +11,9 @@ import java.util.Locale; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.openmrs.Concept; import org.openmrs.ConceptName; import org.openmrs.PersonAttributeType; @@ -37,7 +37,7 @@ public class PersonAttributeTypesLoaderIntegrationTest extends DomainBaseModuleC @Autowired private PersonAttributeTypesLoader loader; - @Before + @BeforeEach public void setup() { ConceptService cs = Context.getConceptService(); @@ -99,32 +99,32 @@ public void load_shouldLoadAccordingToCsvFiles() { // Verif fetch by name { PersonAttributeType pat = ps.getPersonAttributeTypeByName("PAT_NO_UUID"); - Assert.assertNotNull(pat); - Assert.assertEquals("fcafe720-392b-11ea-9712-f727922144a4", pat.getUuid()); - Assert.assertEquals("a description", pat.getDescription()); + Assertions.assertNotNull(pat); + Assertions.assertEquals("fcafe720-392b-11ea-9712-f727922144a4", pat.getUuid()); + Assertions.assertEquals("a description", pat.getDescription()); } // Verif foreign key { PersonAttributeType pat = ps.getPersonAttributeTypeByName("PAT_with_concept"); - Assert.assertEquals(conceptForeignKey, pat.getForeignKey().intValue()); - Assert.assertEquals("Edit:PAT", pat.getEditPrivilege().getName()); + Assertions.assertEquals(conceptForeignKey, pat.getForeignKey().intValue()); + Assertions.assertEquals("Edit:PAT", pat.getEditPrivilege().getName()); } // Verif renaming { PersonAttributeType pat = ps.getPersonAttributeTypeByUuid("9eca4f4e-707f-4bb8-8289-2f9b6e93803c"); - Assert.assertEquals("PAT_RENAME_NEW_NAME", pat.getName()); + Assertions.assertEquals("PAT_RENAME_NEW_NAME", pat.getName()); } // Verif that the provided UUID is correctly assigned { PersonAttributeType pat = ps.getPersonAttributeTypeByUuid("717ec942-3c4a-11ea-b024-ffc81a23382e"); - Assert.assertNotNull(pat); - Assert.assertEquals("NEW_PAT", pat.getName()); + Assertions.assertNotNull(pat); + Assertions.assertEquals("NEW_PAT", pat.getName()); } // Verif foreign key changed { PersonAttributeType pat = ps.getPersonAttributeTypeByName("PAT_CHANGE_FOREIGNKEY"); - Assert.assertEquals(conceptForeignKey, pat.getForeignKey().intValue()); - Assert.assertTrue(pat.isSearchable()); + Assertions.assertEquals(conceptForeignKey, pat.getForeignKey().intValue()); + Assertions.assertTrue(pat.isSearchable()); } } } diff --git a/api/src/test/java/org/openmrs/module/initializer/api/PrivilegesLoaderIntegrationTest.java b/api/src/test/java/org/openmrs/module/initializer/api/PrivilegesLoaderIntegrationTest.java index 5958dbace..36894fdb3 100644 --- a/api/src/test/java/org/openmrs/module/initializer/api/PrivilegesLoaderIntegrationTest.java +++ b/api/src/test/java/org/openmrs/module/initializer/api/PrivilegesLoaderIntegrationTest.java @@ -1,8 +1,8 @@ package org.openmrs.module.initializer.api; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.openmrs.Privilege; import org.openmrs.api.UserService; import org.openmrs.module.initializer.DomainBaseModuleContextSensitiveTest; @@ -19,7 +19,7 @@ public class PrivilegesLoaderIntegrationTest extends DomainBaseModuleContextSens @Autowired private PrivilegesLoader loader; - @Before + @BeforeEach public void setup() throws Exception { executeDataSet("testdata/test-metadata.xml"); } @@ -33,34 +33,34 @@ public void load_shouldLoadPrivilegesAccordingToCsvFiles() { // privilege created { Privilege p = us.getPrivilege("Add People"); - Assert.assertNotNull(p); - Assert.assertEquals("Add People", p.getName()); - Assert.assertEquals(p.getName(), p.getPrivilege()); - Assert.assertEquals("Able to add people.", p.getDescription()); + Assertions.assertNotNull(p); + Assertions.assertEquals("Add People", p.getName()); + Assertions.assertEquals(p.getName(), p.getPrivilege()); + Assertions.assertEquals("Able to add people.", p.getDescription()); } // privilege description edited - using name as primary id { Privilege p = us.getPrivilege("Add Apples"); - Assert.assertNotNull(p); - Assert.assertEquals(p.getName(), p.getPrivilege()); - Assert.assertEquals("Able to add apples.", p.getDescription()); + Assertions.assertNotNull(p); + Assertions.assertEquals(p.getName(), p.getPrivilege()); + Assertions.assertEquals("Able to add apples.", p.getDescription()); } // privilege names can't be changed { Privilege p = us.getPrivilegeByUuid("36404041-c255-4c5b-9b47-0d757d2afa95"); - Assert.assertNotNull(p); - Assert.assertNotEquals("Add Chickens", p.getName()); - Assert.assertEquals("Add Hens", p.getName()); - Assert.assertEquals(p.getName(), p.getPrivilege()); - Assert.assertEquals("Able to add poultry.", p.getDescription()); + Assertions.assertNotNull(p); + Assertions.assertNotEquals("Add Chickens", p.getName()); + Assertions.assertEquals("Add Hens", p.getName()); + Assertions.assertEquals(p.getName(), p.getPrivilege()); + Assertions.assertEquals("Able to add poultry.", p.getDescription()); } // privilege description edited - using UUID as primary id { Privilege p = us.getPrivilegeByUuid("cf68a296-2700-102b-80cb-0017a47871b2"); - Assert.assertNotNull(p); - Assert.assertEquals("Add Reports", p.getName()); - Assert.assertEquals(p.getName(), p.getPrivilege()); - Assert.assertEquals("Able to add reports.", p.getDescription()); + Assertions.assertNotNull(p); + Assertions.assertEquals("Add Reports", p.getName()); + Assertions.assertEquals(p.getName(), p.getPrivilege()); + Assertions.assertEquals("Able to add reports.", p.getDescription()); } } } diff --git a/api/src/test/java/org/openmrs/module/initializer/api/ProgramWorkflowStatesLoaderIntegrationTest.java b/api/src/test/java/org/openmrs/module/initializer/api/ProgramWorkflowStatesLoaderIntegrationTest.java index dc5f6fcbe..f9b930f36 100644 --- a/api/src/test/java/org/openmrs/module/initializer/api/ProgramWorkflowStatesLoaderIntegrationTest.java +++ b/api/src/test/java/org/openmrs/module/initializer/api/ProgramWorkflowStatesLoaderIntegrationTest.java @@ -4,9 +4,9 @@ import java.util.Collections; import java.util.Locale; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.openmrs.Concept; import org.openmrs.ConceptDescription; import org.openmrs.ConceptName; @@ -41,7 +41,7 @@ public class ProgramWorkflowStatesLoaderIntegrationTest extends DomainBaseModule @Autowired private ProgramWorkflowStatesLoader loader; - @Before + @BeforeEach public void setup() { ProgramsLoaderIntegrationTest.setupPrograms(cs, pws); @@ -122,36 +122,36 @@ public void load_shouldLoadProgramWorkflowStatesAccordingToCsvFiles() { // created state { ProgramWorkflowState state = pws.getStateByUuid("cfa241f4-2700-102b-80cb-0017a47871b2"); - Assert.assertNotNull(state); + Assertions.assertNotNull(state); ProgramWorkflow wf = Utils.fetchProgramWorkflow("TB Treatment Status (workflow)", pws, cs); - Assert.assertEquals(wf, state.getProgramWorkflow()); + Assertions.assertEquals(wf, state.getProgramWorkflow()); - Assert.assertEquals(cs.getConceptByName("Active treatment (initial)"), state.getConcept()); - Assert.assertEquals("Active treatment (initial)", state.getConcept().getName().getName()); - Assert.assertEquals("Active treatment (initial)", state.getConcept().getDescription().getDescription()); - Assert.assertFalse(state.isRetired()); - Assert.assertTrue(state.getInitial()); - Assert.assertFalse(state.getTerminal()); - Assert.assertEquals(state, wf.getState(state.getId())); + Assertions.assertEquals(cs.getConceptByName("Active treatment (initial)"), state.getConcept()); + Assertions.assertEquals("Active treatment (initial)", state.getConcept().getName().getName()); + Assertions.assertEquals("Active treatment (initial)", state.getConcept().getDescription().getDescription()); + Assertions.assertFalse(state.isRetired()); + Assertions.assertTrue(state.getInitial()); + Assertions.assertFalse(state.getTerminal()); + Assertions.assertEquals(state, wf.getState(state.getId())); } // state created with workflow UUID { ProgramWorkflowState state = pws.getStateByUuid("cfa244b0-2700-102b-80cb-0017a47871b2"); - Assert.assertNotNull(state); - Assert.assertEquals(cs.getConceptByName("Defaulted"), state.getConcept()); + Assertions.assertNotNull(state); + Assertions.assertEquals(cs.getConceptByName("Defaulted"), state.getConcept()); ProgramWorkflow wf = Utils.fetchProgramWorkflow("Extended Discharge (workflow)", pws, cs); - Assert.assertEquals(wf, state.getProgramWorkflow()); + Assertions.assertEquals(wf, state.getProgramWorkflow()); } // state NOT added to a another workflow { ProgramWorkflowState state = pws.getStateByUuid("88b717c0-f580-497a-8d2b-026b60dd6bfd"); - Assert.assertEquals(Utils.fetchProgramWorkflow("Palliative Care (workflow)", pws, cs), + Assertions.assertEquals(Utils.fetchProgramWorkflow("Palliative Care (workflow)", pws, cs), state.getProgramWorkflow()); - Assert.assertFalse( + Assertions.assertFalse( Utils.fetchProgramWorkflow("TB Treatment Status (workflow)", pws, cs).getStates().contains(state)); } @@ -159,17 +159,17 @@ public void load_shouldLoadProgramWorkflowStatesAccordingToCsvFiles() { { ProgramWorkflow wf = Utils.fetchProgramWorkflow("Standard Treatment Status (workflow)", pws, cs); ProgramWorkflowState state = wf.getState("Transferred out"); - Assert.assertNotNull(state); + Assertions.assertNotNull(state); } // retired state { ProgramWorkflowState state = pws.getStateByUuid("cfa24690-2700-102b-80cb-0017a47871b2"); - Assert.assertTrue(state.isRetired()); + Assertions.assertTrue(state.isRetired()); ProgramWorkflow wf = Utils.fetchProgramWorkflow("Extended Discharge (workflow)", pws, cs); - Assert.assertTrue(wf.getStates().contains(state)); - Assert.assertTrue(wf.getStates(true).contains(state)); + Assertions.assertTrue(wf.getStates().contains(state)); + Assertions.assertTrue(wf.getStates(true).contains(state)); } } } diff --git a/api/src/test/java/org/openmrs/module/initializer/api/ProgramWorkflowsLoaderIntegrationTest.java b/api/src/test/java/org/openmrs/module/initializer/api/ProgramWorkflowsLoaderIntegrationTest.java index c07614560..2c780be88 100644 --- a/api/src/test/java/org/openmrs/module/initializer/api/ProgramWorkflowsLoaderIntegrationTest.java +++ b/api/src/test/java/org/openmrs/module/initializer/api/ProgramWorkflowsLoaderIntegrationTest.java @@ -3,9 +3,9 @@ import java.util.Collections; import java.util.Locale; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.openmrs.Concept; import org.openmrs.ConceptDescription; import org.openmrs.ConceptName; @@ -114,7 +114,7 @@ public static void setupWorkflows(ConceptService cs, ProgramWorkflowService pws) } } - @Before + @BeforeEach public void setup() { ProgramsLoaderIntegrationTest.setupPrograms(cs, pws); @@ -133,45 +133,45 @@ public void load_shouldLoadProgramWorkflowsAccordingToCsvFiles() { // created workflow { ProgramWorkflow wf = pws.getWorkflowByUuid("2b98bc76-245c-11e1-9cf0-00248140a5eb"); - Assert.assertNotNull(wf); + Assertions.assertNotNull(wf); Program prog = pws.getProgramByName("TB Program"); - Assert.assertEquals(prog, wf.getProgram()); - Assert.assertEquals(cs.getConceptByName("TB Treatment Status (workflow)"), wf.getConcept()); - Assert.assertEquals("TB Treatment Status (workflow)", wf.getConcept().getName().getName()); - Assert.assertEquals("TB Treatment Status (workflow)", wf.getConcept().getDescription().getDescription()); - Assert.assertFalse(wf.isRetired()); - Assert.assertEquals(wf, prog.getWorkflow(wf.getId())); + Assertions.assertEquals(prog, wf.getProgram()); + Assertions.assertEquals(cs.getConceptByName("TB Treatment Status (workflow)"), wf.getConcept()); + Assertions.assertEquals("TB Treatment Status (workflow)", wf.getConcept().getName().getName()); + Assertions.assertEquals("TB Treatment Status (workflow)", wf.getConcept().getDescription().getDescription()); + Assertions.assertFalse(wf.isRetired()); + Assertions.assertEquals(wf, prog.getWorkflow(wf.getId())); } // workflow NOT added to a another program { ProgramWorkflow wf = pws.getWorkflowByUuid("2b98bc76-245c-11e1-9cf0-00248140a5ee"); - Assert.assertEquals(pws.getProgramByName("AIDS Program"), wf.getProgram()); - Assert.assertFalse(pws.getProgramByName("TB Program").getAllWorkflows().contains(wf)); + Assertions.assertEquals(pws.getProgramByName("AIDS Program"), wf.getProgram()); + Assertions.assertFalse(pws.getProgramByName("TB Program").getAllWorkflows().contains(wf)); } // workflow created without UUID { Program prog = pws.getProgramByName("AIDS Program"); ProgramWorkflow wf = prog.getWorkflowByName("Palliative Care (workflow)"); - Assert.assertNotNull(wf); + Assertions.assertNotNull(wf); } // workflow with its concept changed { ProgramWorkflow wf = pws.getWorkflowByUuid("1b42d0e8-20ad-4bd8-b05d-fbad80a3b665"); - Assert.assertEquals(cs.getConceptByName("Extended Discharge (workflow)"), wf.getConcept()); + Assertions.assertEquals(cs.getConceptByName("Extended Discharge (workflow)"), wf.getConcept()); } // retired workflow { ProgramWorkflow wf = pws.getWorkflowByUuid("45a28ee9-20a3-4065-9955-9cb7a0c6a24b"); - Assert.assertTrue(wf.isRetired()); + Assertions.assertTrue(wf.isRetired()); Program prog = pws.getProgramByName("Mental Health Program"); wf = prog.getWorkflowByName("Electroshock (workflow)"); - Assert.assertFalse(prog.getWorkflows().contains(wf)); - Assert.assertTrue(prog.getAllWorkflows().contains(wf)); + Assertions.assertFalse(prog.getWorkflows().contains(wf)); + Assertions.assertTrue(prog.getAllWorkflows().contains(wf)); } } } diff --git a/api/src/test/java/org/openmrs/module/initializer/api/ProgramsLoaderIntegrationTest.java b/api/src/test/java/org/openmrs/module/initializer/api/ProgramsLoaderIntegrationTest.java index 3ce67d70b..07c310cc7 100644 --- a/api/src/test/java/org/openmrs/module/initializer/api/ProgramsLoaderIntegrationTest.java +++ b/api/src/test/java/org/openmrs/module/initializer/api/ProgramsLoaderIntegrationTest.java @@ -2,9 +2,9 @@ import java.util.Locale; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.openmrs.Concept; import org.openmrs.ConceptDescription; import org.openmrs.ConceptName; @@ -134,7 +134,7 @@ public static void setupPrograms(ConceptService cs, ProgramWorkflowService pws) } } - @Before + @BeforeEach public void setup() { setupPrograms(cs, pws); } @@ -148,42 +148,42 @@ public void load_shouldLoadProgramsAccordingToCsvFiles() { // created programs { Program prog = pws.getProgramByName("TB Program"); - Assert.assertNotNull(prog); - Assert.assertEquals(cs.getConceptByName("TB Program"), prog.getConcept()); - Assert.assertEquals(cs.getConceptByName("TB Program Outcomes"), prog.getOutcomesConcept()); - Assert.assertEquals("TB Program", prog.getDescription()); + Assertions.assertNotNull(prog); + Assertions.assertEquals(cs.getConceptByName("TB Program"), prog.getConcept()); + Assertions.assertEquals(cs.getConceptByName("TB Program Outcomes"), prog.getOutcomesConcept()); + Assertions.assertEquals("TB Program", prog.getDescription()); } { Program prog = pws.getProgramByName("AIDS Program"); - Assert.assertNotNull(prog); - Assert.assertEquals(cs.getConceptByName("AIDS Program"), prog.getConcept()); - Assert.assertEquals(cs.getConceptByName("AIDS Program Outcomes"), prog.getOutcomesConcept()); - Assert.assertEquals("AIDS Program", prog.getDescription()); + Assertions.assertNotNull(prog); + Assertions.assertEquals(cs.getConceptByName("AIDS Program"), prog.getConcept()); + Assertions.assertEquals(cs.getConceptByName("AIDS Program Outcomes"), prog.getOutcomesConcept()); + Assertions.assertEquals("AIDS Program", prog.getDescription()); } { Program prog = pws.getProgramByName("Mental Health Program"); - Assert.assertNotNull(prog); - Assert.assertEquals(cs.getConceptByName("Mental Health Program"), prog.getConcept()); - Assert.assertEquals(cs.getConceptByName("Mental Health Program Outcomes"), prog.getOutcomesConcept()); - Assert.assertEquals("Mental Health Program", prog.getDescription()); + Assertions.assertNotNull(prog); + Assertions.assertEquals(cs.getConceptByName("Mental Health Program"), prog.getConcept()); + Assertions.assertEquals(cs.getConceptByName("Mental Health Program Outcomes"), prog.getOutcomesConcept()); + Assertions.assertEquals("Mental Health Program", prog.getDescription()); } // an edited program { Program prog = pws.getProgramByName("Oncology Program"); - Assert.assertNotNull(prog); - Assert.assertEquals(cs.getConceptByName("Oncology Program"), prog.getConcept()); - Assert.assertEquals(cs.getConceptByName("Oncology Program Outcomes"), prog.getOutcomesConcept()); - Assert.assertEquals("Oncology Program", prog.getName()); - Assert.assertEquals("A regular oncology program with traditional chimotherapy.", prog.getDescription()); + Assertions.assertNotNull(prog); + Assertions.assertEquals(cs.getConceptByName("Oncology Program"), prog.getConcept()); + Assertions.assertEquals(cs.getConceptByName("Oncology Program Outcomes"), prog.getOutcomesConcept()); + Assertions.assertEquals("Oncology Program", prog.getName()); + Assertions.assertEquals("A regular oncology program with traditional chimotherapy.", prog.getDescription()); } // an retired program { Program prog = pws.getProgramByName("Ayurvedic Medicine Program"); - Assert.assertNotNull(prog); - Assert.assertTrue(prog.isRetired()); + Assertions.assertNotNull(prog); + Assertions.assertTrue(prog.isRetired()); } } } diff --git a/api/src/test/java/org/openmrs/module/initializer/api/ProviderRolesLoaderIntegrationTest.java b/api/src/test/java/org/openmrs/module/initializer/api/ProviderRolesLoaderIntegrationTest.java index 7f65c61bc..53c1ea2e4 100644 --- a/api/src/test/java/org/openmrs/module/initializer/api/ProviderRolesLoaderIntegrationTest.java +++ b/api/src/test/java/org/openmrs/module/initializer/api/ProviderRolesLoaderIntegrationTest.java @@ -1,8 +1,8 @@ package org.openmrs.module.initializer.api; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.openmrs.ProviderAttributeType; import org.openmrs.RelationshipType; import org.openmrs.api.PersonService; @@ -35,7 +35,7 @@ public class ProviderRolesLoaderIntegrationTest extends DomainBaseModuleContextS private ProviderAttributeType dateHired; - @Before + @BeforeEach public void setup() throws Exception { executeDataSet("testdata/test-metadata.xml"); supervisor = personService.getRelationshipTypeByUuid("53d8a8f3-0084-4a52-8666-c655f5bd2689"); @@ -57,7 +57,7 @@ public void load_shouldUpdateProviderRolesFromCSVLines() { service.saveProviderRole(chw); chw = service.getProviderRoleByUuid("68624C4C-9E10-473B-A849-204820D16C45"); - Assert.assertEquals("Community Health Worker", chw.getName()); + Assertions.assertEquals("Community Health Worker", chw.getName()); loader.load(); verifyExpectedState(); @@ -69,31 +69,31 @@ protected void verifyExpectedState() { ProviderRole chwSupervisor = service.getProviderRoleByUuid("11C1A56D-82F7-4269-95E8-2B67B9A3D837"); // Verify created - Assert.assertNotNull(chw); - Assert.assertEquals("CHW", chw.getName()); - Assert.assertEquals(0, chw.getSuperviseeProviderRoles().size()); - Assert.assertEquals(1, chw.getRelationshipTypes().size()); - Assert.assertEquals(supervisor, chw.getRelationshipTypes().iterator().next()); - Assert.assertEquals(2, chw.getProviderAttributeTypes().size()); - Assert.assertTrue(chw.getProviderAttributeTypes().contains(households)); - Assert.assertTrue(chw.getProviderAttributeTypes().contains(dateHired)); + Assertions.assertNotNull(chw); + Assertions.assertEquals("CHW", chw.getName()); + Assertions.assertEquals(0, chw.getSuperviseeProviderRoles().size()); + Assertions.assertEquals(1, chw.getRelationshipTypes().size()); + Assertions.assertEquals(supervisor, chw.getRelationshipTypes().iterator().next()); + Assertions.assertEquals(2, chw.getProviderAttributeTypes().size()); + Assertions.assertTrue(chw.getProviderAttributeTypes().contains(households)); + Assertions.assertTrue(chw.getProviderAttributeTypes().contains(dateHired)); - Assert.assertNotNull(nurseAccompagnateur); - Assert.assertEquals("Nurse Accompagnateur", nurseAccompagnateur.getName()); - Assert.assertEquals(0, nurseAccompagnateur.getSuperviseeProviderRoles().size()); - Assert.assertEquals(1, nurseAccompagnateur.getRelationshipTypes().size()); - Assert.assertEquals(supervisor, nurseAccompagnateur.getRelationshipTypes().iterator().next()); - Assert.assertEquals(2, nurseAccompagnateur.getProviderAttributeTypes().size()); - Assert.assertTrue(nurseAccompagnateur.getProviderAttributeTypes().contains(households)); - Assert.assertTrue(nurseAccompagnateur.getProviderAttributeTypes().contains(dateHired)); + Assertions.assertNotNull(nurseAccompagnateur); + Assertions.assertEquals("Nurse Accompagnateur", nurseAccompagnateur.getName()); + Assertions.assertEquals(0, nurseAccompagnateur.getSuperviseeProviderRoles().size()); + Assertions.assertEquals(1, nurseAccompagnateur.getRelationshipTypes().size()); + Assertions.assertEquals(supervisor, nurseAccompagnateur.getRelationshipTypes().iterator().next()); + Assertions.assertEquals(2, nurseAccompagnateur.getProviderAttributeTypes().size()); + Assertions.assertTrue(nurseAccompagnateur.getProviderAttributeTypes().contains(households)); + Assertions.assertTrue(nurseAccompagnateur.getProviderAttributeTypes().contains(dateHired)); - Assert.assertNotNull(chwSupervisor); - Assert.assertEquals("CHW Supervisor", chwSupervisor.getName()); - Assert.assertEquals(2, chwSupervisor.getSuperviseeProviderRoles().size()); - Assert.assertTrue(chwSupervisor.getSuperviseeProviderRoles().contains(chw)); - Assert.assertTrue(chwSupervisor.getSuperviseeProviderRoles().contains(nurseAccompagnateur)); - Assert.assertEquals(0, chwSupervisor.getRelationshipTypes().size()); - Assert.assertEquals(1, chwSupervisor.getProviderAttributeTypes().size()); - Assert.assertTrue(chwSupervisor.getProviderAttributeTypes().contains(dateHired)); + Assertions.assertNotNull(chwSupervisor); + Assertions.assertEquals("CHW Supervisor", chwSupervisor.getName()); + Assertions.assertEquals(2, chwSupervisor.getSuperviseeProviderRoles().size()); + Assertions.assertTrue(chwSupervisor.getSuperviseeProviderRoles().contains(chw)); + Assertions.assertTrue(chwSupervisor.getSuperviseeProviderRoles().contains(nurseAccompagnateur)); + Assertions.assertEquals(0, chwSupervisor.getRelationshipTypes().size()); + Assertions.assertEquals(1, chwSupervisor.getProviderAttributeTypes().size()); + Assertions.assertTrue(chwSupervisor.getProviderAttributeTypes().contains(dateHired)); } } diff --git a/api/src/test/java/org/openmrs/module/initializer/api/RelationshipTypesLoaderIntegrationTest.java b/api/src/test/java/org/openmrs/module/initializer/api/RelationshipTypesLoaderIntegrationTest.java index 5f7e9fa23..c2e7ed76a 100644 --- a/api/src/test/java/org/openmrs/module/initializer/api/RelationshipTypesLoaderIntegrationTest.java +++ b/api/src/test/java/org/openmrs/module/initializer/api/RelationshipTypesLoaderIntegrationTest.java @@ -1,8 +1,8 @@ package org.openmrs.module.initializer.api; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.openmrs.RelationshipType; import org.openmrs.api.PersonService; import org.openmrs.module.initializer.DomainBaseModuleContextSensitiveTest; @@ -28,28 +28,28 @@ public void load_shouldLoadRelationshipTypesAccordingToCsvFiles() { // verify created { RelationshipType rt = ps.getRelationshipTypeByUuid("c86d9979-b8ac-4d8c-85cf-cc04e7f16315"); - Assert.assertNotNull(rt); - Assert.assertEquals("Uncle/Nephew", rt.toString()); - Assert.assertEquals("A relationship of an uncle and his nephew", rt.getDescription()); - Assert.assertEquals("Uncle", rt.getaIsToB()); - Assert.assertEquals("Nephew", rt.getbIsToA()); - Assert.assertEquals(true, rt.getPreferred()); - Assert.assertEquals(1, rt.getWeight().intValue()); + Assertions.assertNotNull(rt); + Assertions.assertEquals("Uncle/Nephew", rt.toString()); + Assertions.assertEquals("A relationship of an uncle and his nephew", rt.getDescription()); + Assertions.assertEquals("Uncle", rt.getaIsToB()); + Assertions.assertEquals("Nephew", rt.getbIsToA()); + Assertions.assertEquals(true, rt.getPreferred()); + Assertions.assertEquals(1, rt.getWeight().intValue()); } // verify edited { RelationshipType rt = ps.getRelationshipTypeByUuid("53d8a8f3-0084-4a52-8666-c655f5bd2689"); - Assert.assertNotNull(rt); - Assert.assertEquals("Supervisor/Supervisee", rt.toString()); - Assert.assertEquals("A new description for supervisor to supervisee relationship", rt.getDescription()); + Assertions.assertNotNull(rt); + Assertions.assertEquals("Supervisor/Supervisee", rt.toString()); + Assertions.assertEquals("A new description for supervisor to supervisee relationship", rt.getDescription()); } // verify retired { RelationshipType rt = ps.getRelationshipTypeByUuid("3982f469-cedc-4b2d-91ea-fe38f881e1a0"); - Assert.assertNotNull(rt); - Assert.assertTrue(rt.getRetired()); + Assertions.assertNotNull(rt); + Assertions.assertTrue(rt.getRetired()); } } diff --git a/api/src/test/java/org/openmrs/module/initializer/api/RolesLoaderIntegrationTest.java b/api/src/test/java/org/openmrs/module/initializer/api/RolesLoaderIntegrationTest.java index 6e2fa2018..16122dcec 100644 --- a/api/src/test/java/org/openmrs/module/initializer/api/RolesLoaderIntegrationTest.java +++ b/api/src/test/java/org/openmrs/module/initializer/api/RolesLoaderIntegrationTest.java @@ -3,9 +3,9 @@ import java.util.HashSet; import java.util.Set; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.openmrs.Privilege; import org.openmrs.Role; import org.openmrs.api.UserService; @@ -23,7 +23,7 @@ public class RolesLoaderIntegrationTest extends DomainBaseModuleContextSensitive @Autowired private RolesLoader loader; - @Before + @BeforeEach public void setup() { // A couple of privileges to use with roles @@ -90,11 +90,11 @@ public void load_shouldLoadRolesAccordingToCsvFiles() { Role role = us.getRoleByUuid("d2fcb604-2700-102b-80cb-0017a47871b2"); // verif - Assert.assertNotNull(role); - Assert.assertEquals("Organizational: Doctor", role.getName()); - Assert.assertEquals("Doctor role", role.getDescription()); - Assert.assertEquals(roles, role.getAllParentRoles()); - Assert.assertEquals(privileges, role.getPrivileges()); + Assertions.assertNotNull(role); + Assertions.assertEquals("Organizational: Doctor", role.getName()); + Assertions.assertEquals("Doctor role", role.getDescription()); + Assertions.assertEquals(roles, role.getAllParentRoles()); + Assertions.assertEquals(privileges, role.getPrivileges()); } // edited role @@ -112,11 +112,11 @@ public void load_shouldLoadRolesAccordingToCsvFiles() { Role role = us.getRole("Organizational: Nurse"); // verif - Assert.assertNotNull(role); - Assert.assertEquals("Organizational: Nurse", role.getName()); - Assert.assertEquals("Nurse role", role.getDescription()); - Assert.assertEquals(roles, role.getAllParentRoles()); - Assert.assertEquals(privileges, role.getPrivileges()); + Assertions.assertNotNull(role); + Assertions.assertEquals("Organizational: Nurse", role.getName()); + Assertions.assertEquals("Nurse role", role.getDescription()); + Assertions.assertEquals(roles, role.getAllParentRoles()); + Assertions.assertEquals(privileges, role.getPrivileges()); } } } diff --git a/api/src/test/java/org/openmrs/module/initializer/api/SpecialitiesLoaderIntegrationTest.java b/api/src/test/java/org/openmrs/module/initializer/api/SpecialitiesLoaderIntegrationTest.java index 4742e6c04..cdd6e6c22 100644 --- a/api/src/test/java/org/openmrs/module/initializer/api/SpecialitiesLoaderIntegrationTest.java +++ b/api/src/test/java/org/openmrs/module/initializer/api/SpecialitiesLoaderIntegrationTest.java @@ -9,8 +9,8 @@ */ package org.openmrs.module.initializer.api; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import org.openmrs.module.appointments.model.Speciality; import org.openmrs.module.appointments.service.SpecialityService; import org.openmrs.module.initializer.DomainBaseModuleContextSensitiveTest; @@ -36,16 +36,16 @@ public void load_shouldLoadAccordingToCsvFiles() { // Verif speciality name { Speciality speciality = sps.getSpecialityByUuid("21ec1632-420f-473c-b380-31ed45214362"); - Assert.assertEquals("Psychiatric", speciality.getName()); + Assertions.assertEquals("Psychiatric", speciality.getName()); } // Verif renaming { Speciality speciality = sps.getSpecialityByUuid("65ae95d9-d1a5-4979-a534-dc17671f2469"); - Assert.assertEquals("Neonatal", speciality.getName()); + Assertions.assertEquals("Neonatal", speciality.getName()); } // Verif creation without UUID { - Assert.assertEquals(3, sps.getAllSpecialities().size()); //Unfortunately, there is no #specialityService.getSpecialityByName method. + Assertions.assertEquals(3, sps.getAllSpecialities().size()); //Unfortunately, there is no #specialityService.getSpecialityByName method. } } diff --git a/api/src/test/java/org/openmrs/module/initializer/api/UtilsTest.java b/api/src/test/java/org/openmrs/module/initializer/api/UtilsTest.java index 5fb608363..8bc0e2730 100644 --- a/api/src/test/java/org/openmrs/module/initializer/api/UtilsTest.java +++ b/api/src/test/java/org/openmrs/module/initializer/api/UtilsTest.java @@ -1,9 +1,10 @@ package org.openmrs.module.initializer.api; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; +import static org.junit.jupiter.api.Assertions.assertThrows; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.openmrs.Concept; import org.openmrs.ConceptMapType; import org.openmrs.ConceptName; @@ -18,29 +19,31 @@ import org.openmrs.api.ProgramWorkflowService; import org.openmrs.api.context.Context; import org.openmrs.module.initializer.api.utils.Utils; -import org.powermock.api.mockito.PowerMockito; -import org.powermock.core.classloader.annotations.PowerMockIgnore; -import org.powermock.core.classloader.annotations.PrepareForTest; -import org.powermock.modules.junit4.PowerMockRunner; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.Locale; +import org.mockito.MockedStatic; +import org.mockito.Mockito; -import static org.mockito.Matchers.anyCollectionOf; -import static org.mockito.Matchers.eq; +import static org.mockito.ArgumentMatchers.anyCollection; +import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; -@RunWith(PowerMockRunner.class) -@PrepareForTest(Context.class) -@PowerMockIgnore("jdk.internal.reflect.*") public class UtilsTest { - @Before + private MockedStatic contextMock; + + @AfterEach + public void closeStaticMocks() { + contextMock.close(); + } + + @BeforeEach public void setUp() { - PowerMockito.mockStatic(Context.class); + contextMock = Mockito.mockStatic(Context.class); AdministrationService as = mock(AdministrationService.class); when(Context.getAdministrationService()).thenReturn(as); when(as.getAllowedLocales()).thenReturn(Arrays.asList(Locale.ENGLISH, Locale.FRENCH, Locale.GERMAN)); @@ -71,30 +74,33 @@ public void prettyPrint_shouldPrettyPrintCsvLines() { } // replay - Assert.assertEquals("\n" + "+------------+-----------+-----+\n" + "| First name | Last name | Age |\n" + Assertions.assertEquals("\n" + "+------------+-----------+-----+\n" + "| First name | Last name | Age |\n" + "+------------+-----------+-----+\n" + "| John | Doe | 40 |\n" + "+------------+-----------+-----+\n" + "| Paul | Smith | 20 |\n" + "+------------+-----------+-----+", Utils.prettyPrint(lines)); } - @Test(expected = IllegalArgumentException.class) + @Test public void prettyPrint_shouldThrowWhenCsvLinesHeadersDiffer() { - // setup - List lines = new ArrayList<>(); - { - String[] header = { "First name", "Last name", "Age" }; - String[] line = { "John", "Doe", "40" }; - lines.add(new CsvLine(header, line)); - } - { - String[] header = { "First name", "Last name", "Height" }; - String[] line = { "Phileas", "Fogg", "1.75" }; - lines.add(new CsvLine(header, line)); - } - - // replay - Utils.prettyPrint(lines); + assertThrows(IllegalArgumentException.class, () -> { + // setup + List lines = new ArrayList<>(); + { + String[] header = { "First name", "Last name", "Age" }; + String[] line = { "John", "Doe", "40" }; + lines.add(new CsvLine(header, line)); + } + { + String[] header = { "First name", "Last name", "Height" }; + String[] line = { "Phileas", "Fogg", "1.75" }; + lines.add(new CsvLine(header, line)); + } + + // replay + Utils.prettyPrint(lines); + + }); } @Test @@ -112,26 +118,29 @@ public void pastePrint_shouldPastePrintCsvLines() { } // replay - Assert.assertEquals("\nFirst name,Last name,Age\n" + "John,Doe,40\n" + "Paul,Smith,20", Utils.pastePrint(lines)); + Assertions.assertEquals("\nFirst name,Last name,Age\n" + "John,Doe,40\n" + "Paul,Smith,20", Utils.pastePrint(lines)); } - @Test(expected = IllegalArgumentException.class) + @Test public void pastePrint_shouldThrowWhenCsvLinesHeadersDiffer() { - // setup - List lines = new ArrayList<>(); - { - String[] header = { "First name", "Last name", "Age" }; - String[] line = { "John", "Doe", "40" }; - lines.add(new CsvLine(header, line)); - } - { - String[] header = { "First name", "Last name", "Height" }; - String[] line = { "Phileas", "Fogg", "1.75" }; - lines.add(new CsvLine(header, line)); - } - - // replay - Utils.pastePrint(lines); + assertThrows(IllegalArgumentException.class, () -> { + // setup + List lines = new ArrayList<>(); + { + String[] header = { "First name", "Last name", "Age" }; + String[] line = { "John", "Doe", "40" }; + lines.add(new CsvLine(header, line)); + } + { + String[] header = { "First name", "Last name", "Height" }; + String[] line = { "Phileas", "Fogg", "1.75" }; + lines.add(new CsvLine(header, line)); + } + + // replay + Utils.pastePrint(lines); + + }); } @Test @@ -146,10 +155,10 @@ public void getBestMatchName_shouldReturnBestMatchForConceptName() throws Except c.addName(cn); } - Assert.assertEquals("A name in English", Utils.getBestMatchName(c, Locale.ENGLISH)); - Assert.assertEquals(c.getPreferredName(Locale.ENGLISH).getName(), Utils.getBestMatchName(c, Locale.ENGLISH)); - Assert.assertEquals("A name in English", Utils.getBestMatchName(c, Locale.FRENCH)); - Assert.assertEquals("A name in English", Utils.getBestMatchName(c, Locale.GERMAN)); + Assertions.assertEquals("A name in English", Utils.getBestMatchName(c, Locale.ENGLISH)); + Assertions.assertEquals(c.getPreferredName(Locale.ENGLISH).getName(), Utils.getBestMatchName(c, Locale.ENGLISH)); + Assertions.assertEquals("A name in English", Utils.getBestMatchName(c, Locale.FRENCH)); + Assertions.assertEquals("A name in English", Utils.getBestMatchName(c, Locale.GERMAN)); { ConceptName cn = new ConceptName(); @@ -159,10 +168,10 @@ public void getBestMatchName_shouldReturnBestMatchForConceptName() throws Except c.setFullySpecifiedName(cn); } - Assert.assertEquals("An FSN in English", Utils.getBestMatchName(c, Locale.ENGLISH)); - Assert.assertEquals(c.getPreferredName(Locale.ENGLISH).getName(), Utils.getBestMatchName(c, Locale.ENGLISH)); - Assert.assertEquals("An FSN in English", Utils.getBestMatchName(c, Locale.FRENCH)); - Assert.assertEquals("An FSN in English", Utils.getBestMatchName(c, Locale.GERMAN)); + Assertions.assertEquals("An FSN in English", Utils.getBestMatchName(c, Locale.ENGLISH)); + Assertions.assertEquals(c.getPreferredName(Locale.ENGLISH).getName(), Utils.getBestMatchName(c, Locale.ENGLISH)); + Assertions.assertEquals("An FSN in English", Utils.getBestMatchName(c, Locale.FRENCH)); + Assertions.assertEquals("An FSN in English", Utils.getBestMatchName(c, Locale.GERMAN)); { ConceptName cn = new ConceptName(); @@ -172,10 +181,10 @@ public void getBestMatchName_shouldReturnBestMatchForConceptName() throws Except c.addName(cn); } - Assert.assertEquals("A preferred name in English", Utils.getBestMatchName(c, Locale.ENGLISH)); - Assert.assertEquals(c.getPreferredName(Locale.ENGLISH).getName(), Utils.getBestMatchName(c, Locale.ENGLISH)); - Assert.assertEquals("A preferred name in English", Utils.getBestMatchName(c, Locale.FRENCH)); - Assert.assertEquals("A preferred name in English", Utils.getBestMatchName(c, Locale.GERMAN)); + Assertions.assertEquals("A preferred name in English", Utils.getBestMatchName(c, Locale.ENGLISH)); + Assertions.assertEquals(c.getPreferredName(Locale.ENGLISH).getName(), Utils.getBestMatchName(c, Locale.ENGLISH)); + Assertions.assertEquals("A preferred name in English", Utils.getBestMatchName(c, Locale.FRENCH)); + Assertions.assertEquals("A preferred name in English", Utils.getBestMatchName(c, Locale.GERMAN)); } @Test @@ -194,9 +203,9 @@ public void fetchProgram_shouldReturnProgramFromAnyId() throws Exception { when(cs.getConceptByUuid("concept-uuid")).thenReturn(c); when(pws.getProgramsByConcept(c)).thenReturn(Arrays.asList(prog)); - Assert.assertEquals(prog, Utils.fetchProgram("Program Name", pws, cs)); - Assert.assertEquals(prog, Utils.fetchProgram("program-uuid", pws, cs)); - Assert.assertEquals(prog, Utils.fetchProgram("concept-uuid", pws, cs)); + Assertions.assertEquals(prog, Utils.fetchProgram("Program Name", pws, cs)); + Assertions.assertEquals(prog, Utils.fetchProgram("program-uuid", pws, cs)); + Assertions.assertEquals(prog, Utils.fetchProgram("concept-uuid", pws, cs)); } @Test @@ -208,7 +217,7 @@ public void fetchProgram_shouldReturnNullWhenMultipleMatchesByConcept() { c.setUuid("concept-uuid"); when(pws.getProgramsByConcept(c)).thenReturn(Arrays.asList(new Program(), new Program())); - Assert.assertNull(Utils.fetchProgram("concept-uuid", pws, cs)); + Assertions.assertNull(Utils.fetchProgram("concept-uuid", pws, cs)); } @Test @@ -225,8 +234,8 @@ public void fetchWorkflow_shouldReturnWorkflowFromAnyId() throws Exception { when(cs.getConceptByUuid("concept-uuid")).thenReturn(c); when(pws.getProgramWorkflowsByConcept(c)).thenReturn(Arrays.asList(wf)); - Assert.assertEquals(wf, Utils.fetchProgramWorkflow("workflow-uuid", pws, cs)); - Assert.assertEquals(wf, Utils.fetchProgramWorkflow("concept-uuid", pws, cs)); + Assertions.assertEquals(wf, Utils.fetchProgramWorkflow("workflow-uuid", pws, cs)); + Assertions.assertEquals(wf, Utils.fetchProgramWorkflow("concept-uuid", pws, cs)); } @Test @@ -238,7 +247,7 @@ public void fetchWorkflow_shouldReturnNullWhenMultipleMatchesByConcept() { c.setUuid("concept-uuid"); when(pws.getProgramWorkflowsByConcept(c)).thenReturn(Arrays.asList(new ProgramWorkflow(), new ProgramWorkflow())); - Assert.assertNull(Utils.fetchProgramWorkflow("concept-uuid", pws, cs)); + Assertions.assertNull(Utils.fetchProgramWorkflow("concept-uuid", pws, cs)); } @Test @@ -255,8 +264,8 @@ public void fetchWorkflowState_shouldReturnWorkflowStateFromAnyId() throws Excep when(cs.getConceptByUuid("concept-uuid")).thenReturn(c); when(pws.getProgramWorkflowStatesByConcept(c)).thenReturn(Arrays.asList(state)); - Assert.assertEquals(state, Utils.fetchProgramWorkflowState("state-uuid", pws, cs)); - Assert.assertEquals(state, Utils.fetchProgramWorkflowState("concept-uuid", pws, cs)); + Assertions.assertEquals(state, Utils.fetchProgramWorkflowState("state-uuid", pws, cs)); + Assertions.assertEquals(state, Utils.fetchProgramWorkflowState("concept-uuid", pws, cs)); } @Test @@ -269,7 +278,7 @@ public void fetchWorkflowState_shouldReturnNullWhenMultipleMatchesByConcept() { when(pws.getProgramWorkflowStatesByConcept(c)) .thenReturn(Arrays.asList(new ProgramWorkflowState(), new ProgramWorkflowState())); - Assert.assertNull(Utils.fetchProgramWorkflowState("concept-uuid", pws, cs)); + Assertions.assertNull(Utils.fetchProgramWorkflowState("concept-uuid", pws, cs)); } @Test @@ -279,8 +288,8 @@ public void generateUuidFromObjects_shouldReturnUuidGivenValidArguments() { ConceptNameType.FULLY_SPECIFIED, Locale.ENGLISH); // verify - Assert.assertNotNull(uuid); - Assert.assertEquals("f6fa2a4e-78a3-3378-a30a-c27c67f5734e", uuid); + Assertions.assertNotNull(uuid); + Assertions.assertEquals("f6fa2a4e-78a3-3378-a30a-c27c67f5734e", uuid); } @Test @@ -289,14 +298,14 @@ public void generateUuidFromObjects_shouldNotFailGivenNullArguments() { String uuid = Utils.generateUuidFromObjects("some-uuid", null, ConceptNameType.SHORT, Locale.ENGLISH); // verify - Assert.assertNotNull(uuid); + Assertions.assertNotNull(uuid); } @Test public void unProxy_shouldReturnOriginalClassName() { - Assert.assertEquals("EncounterType", Utils.unProxy("EncounterType$HibernateProxy$ODcBnusu")); - Assert.assertEquals("EncounterType", Utils.unProxy("EncounterType_$$_javassist_26")); - Assert.assertEquals("EncounterType", Utils.unProxy("EncounterType")); + Assertions.assertEquals("EncounterType", Utils.unProxy("EncounterType$HibernateProxy$ODcBnusu")); + Assertions.assertEquals("EncounterType", Utils.unProxy("EncounterType_$$_javassist_26")); + Assertions.assertEquals("EncounterType", Utils.unProxy("EncounterType")); } @Test @@ -308,7 +317,7 @@ public void fetchConcept_shouldFetchConceptByUuid() { when(cs.getConceptByMapping("lookup", "concept")).thenReturn(mappingConcept); Concept nameConcept = new Concept(); when(cs.getConceptByName("concept:lookup")).thenReturn(nameConcept); - Assert.assertEquals(uuidConcept, Utils.fetchConcept("concept:lookup", cs)); + Assertions.assertEquals(uuidConcept, Utils.fetchConcept("concept:lookup", cs)); } @Test @@ -319,7 +328,7 @@ public void fetchConcept_shouldFetchConceptByMapping() { when(cs.getConceptByMapping("lookup", "concept")).thenReturn(mappingConcept); Concept nameConcept = new Concept(); when(cs.getConceptByName("concept:lookup")).thenReturn(nameConcept); - Assert.assertEquals(mappingConcept, Utils.fetchConcept("concept:lookup", cs)); + Assertions.assertEquals(mappingConcept, Utils.fetchConcept("concept:lookup", cs)); } @Test @@ -332,7 +341,7 @@ public void fetchConcept_shouldFetchConceptByName() { InitializerService ics = mock(InitializerService.class); when(Context.getService(InitializerService.class)).thenReturn(ics); when(ics.getUnretiredConceptsByFullySpecifiedName("concept:lookup")).thenReturn(Arrays.asList(nameConcept)); - Assert.assertEquals(nameConcept, Utils.fetchConcept("concept:lookup", cs)); + Assertions.assertEquals(nameConcept, Utils.fetchConcept("concept:lookup", cs)); } @Test @@ -340,7 +349,7 @@ public void getSameAsConceptMapType_shouldFetchBasedOnUuidConstant() { ConceptService cs = mock(ConceptService.class); ConceptMapType sameAsMapType = new ConceptMapType(); when(cs.getConceptMapTypeByUuid(ConceptMapType.SAME_AS_MAP_TYPE_UUID)).thenReturn(sameAsMapType); - Assert.assertEquals(sameAsMapType, Utils.getSameAsConceptMapType(cs)); + Assertions.assertEquals(sameAsMapType, Utils.getSameAsConceptMapType(cs)); } @Test @@ -353,9 +362,9 @@ public void fetchConceptSource_shouldFetchConceptSourceByName() { when(cs.getConceptSourceByUniqueId(lookup)).thenReturn(null); when(cs.getConceptSourceByUuid(lookup)).thenReturn(null); - Assert.assertNull(Utils.fetchConceptSource(lookup, cs)); + Assertions.assertNull(Utils.fetchConceptSource(lookup, cs)); when(cs.getConceptSourceByName(lookup)).thenReturn(source); - Assert.assertEquals(source, Utils.fetchConceptSource(lookup, cs)); + Assertions.assertEquals(source, Utils.fetchConceptSource(lookup, cs)); } @Test @@ -368,9 +377,9 @@ public void fetchConceptSource_shouldFetchConceptSourceByHl7Code() { when(cs.getConceptSourceByUniqueId(lookup)).thenReturn(null); when(cs.getConceptSourceByUuid(lookup)).thenReturn(null); - Assert.assertNull(Utils.fetchConceptSource(lookup, cs)); + Assertions.assertNull(Utils.fetchConceptSource(lookup, cs)); when(cs.getConceptSourceByHL7Code(lookup)).thenReturn(source); - Assert.assertEquals(source, Utils.fetchConceptSource(lookup, cs)); + Assertions.assertEquals(source, Utils.fetchConceptSource(lookup, cs)); } @Test @@ -383,9 +392,9 @@ public void fetchConceptSource_shouldFetchConceptSourceByUniqueId() { when(cs.getConceptSourceByUniqueId(lookup)).thenReturn(null); when(cs.getConceptSourceByUuid(lookup)).thenReturn(null); - Assert.assertNull(Utils.fetchConceptSource(lookup, cs)); + Assertions.assertNull(Utils.fetchConceptSource(lookup, cs)); when(cs.getConceptSourceByUniqueId(lookup)).thenReturn(source); - Assert.assertEquals(source, Utils.fetchConceptSource(lookup, cs)); + Assertions.assertEquals(source, Utils.fetchConceptSource(lookup, cs)); } @Test @@ -398,31 +407,31 @@ public void fetchConceptSource_shouldFetchConceptSourceByUuid() { when(cs.getConceptSourceByUniqueId(lookup)).thenReturn(null); when(cs.getConceptSourceByUuid(lookup)).thenReturn(null); - Assert.assertNull(Utils.fetchConceptSource(lookup, cs)); + Assertions.assertNull(Utils.fetchConceptSource(lookup, cs)); when(cs.getConceptSourceByUuid(lookup)).thenReturn(source); - Assert.assertEquals(source, Utils.fetchConceptSource(lookup, cs)); + Assertions.assertEquals(source, Utils.fetchConceptSource(lookup, cs)); } @Test public void getDrugByMapping_shouldReturnNullIfLookupIsNullOrEmpty() { ConceptService cs = mock(ConceptService.class); - Assert.assertNull(Utils.getDrugByMapping(null, cs)); - Assert.assertNull(Utils.getDrugByMapping("", cs)); - Assert.assertNull(Utils.getDrugByMapping(" ", cs)); + Assertions.assertNull(Utils.getDrugByMapping(null, cs)); + Assertions.assertNull(Utils.getDrugByMapping("", cs)); + Assertions.assertNull(Utils.getDrugByMapping(" ", cs)); } @Test public void getDrugByMapping_shouldReturnNullIfNoSourceAndCodeSpecified() { ConceptService cs = mock(ConceptService.class); when(cs.getConceptSourceByName("source")).thenReturn(null); - Assert.assertNull(Utils.getDrugByMapping("source_code", cs)); + Assertions.assertNull(Utils.getDrugByMapping("source_code", cs)); } @Test public void getDrugByMapping_shouldReturnNullIfSourceIsNotFound() { ConceptService cs = mock(ConceptService.class); when(cs.getConceptSourceByName("source")).thenReturn(null); - Assert.assertNull(Utils.getDrugByMapping("source:code", cs)); + Assertions.assertNull(Utils.getDrugByMapping("source:code", cs)); } @Test @@ -433,8 +442,8 @@ public void getDrugByMapping_shouldReturnDrugByMapping() { when(cs.getConceptSourceByName("source")).thenReturn(source); ConceptMapType sameAsMapType = new ConceptMapType(); when(cs.getConceptMapTypeByUuid(ConceptMapType.SAME_AS_MAP_TYPE_UUID)).thenReturn(sameAsMapType); - when(cs.getDrugByMapping(eq("code"), eq(source), anyCollectionOf(ConceptMapType.class))).thenReturn(drug); - Assert.assertEquals(drug, Utils.getDrugByMapping("source:code", cs)); + when(cs.getDrugByMapping(eq("code"), eq(source), anyCollection())).thenReturn(drug); + Assertions.assertEquals(drug, Utils.getDrugByMapping("source:code", cs)); } @Test @@ -449,6 +458,6 @@ public void fetchConcept_shouldThrowGivenMoreThanOneConeptWithSameFullySpecified when(Context.getService(InitializerService.class)).thenReturn(ics); when(ics.getUnretiredConceptsByFullySpecifiedName("concept:lookup")) .thenReturn(Arrays.asList(nameConcept, nameConcept2)); - Assert.assertThrows(RuntimeException.class, () -> Utils.fetchConcept("concept:lookup", cs)); + Assertions.assertThrows(RuntimeException.class, () -> Utils.fetchConcept("concept:lookup", cs)); } } diff --git a/api/src/test/java/org/openmrs/module/initializer/api/VisitTypesLoaderIntegrationTest.java b/api/src/test/java/org/openmrs/module/initializer/api/VisitTypesLoaderIntegrationTest.java index a61889624..b71119273 100644 --- a/api/src/test/java/org/openmrs/module/initializer/api/VisitTypesLoaderIntegrationTest.java +++ b/api/src/test/java/org/openmrs/module/initializer/api/VisitTypesLoaderIntegrationTest.java @@ -13,9 +13,10 @@ import java.util.List; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; +import org.hamcrest.MatcherAssert; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.openmrs.VisitType; import org.openmrs.api.VisitService; import org.openmrs.module.initializer.DomainBaseModuleContextSensitiveTest; @@ -32,7 +33,7 @@ public class VisitTypesLoaderIntegrationTest extends DomainBaseModuleContextSens @Autowired private VisitTypesLoader loader; - @Before + @BeforeEach public void setup() throws Exception { executeDataSet("testdata/test-metadata.xml"); } @@ -42,8 +43,8 @@ public void load_shouldLoadVisitTypeAccordingToCsvFiles() { // Pre-asserts { VisitType vt = vs.getVisitType(16000); - Assert.assertEquals("OPD", vt.getName()); - Assert.assertEquals("Legacy OPD visit Description", vt.getDescription()); + Assertions.assertEquals("OPD", vt.getName()); + Assertions.assertEquals("Legacy OPD visit Description", vt.getDescription()); } // Replay @@ -52,50 +53,50 @@ public void load_shouldLoadVisitTypeAccordingToCsvFiles() { // Verify fetch by name { List visitTypes = vs.getVisitTypes("TB"); - Assert.assertNotNull(visitTypes); - Assert.assertThat(visitTypes.size(), is(1)); + Assertions.assertNotNull(visitTypes); + MatcherAssert.assertThat(visitTypes.size(), is(1)); VisitType vt = visitTypes.get(0); - Assert.assertEquals("Return TB Clinic Visit", vt.getName()); + Assertions.assertEquals("Return TB Clinic Visit", vt.getName()); } // Verify fetch by UUID { VisitType vt = vs.getVisitTypeByUuid("2bcf7212-d218-4572-8893-25c4pob71934"); - Assert.assertNotNull(vt); - Assert.assertEquals("Malnutrition", vt.getName()); - Assert.assertEquals("Malnutrition Visit", vt.getDescription()); + Assertions.assertNotNull(vt); + Assertions.assertEquals("Malnutrition", vt.getName()); + Assertions.assertEquals("Malnutrition Visit", vt.getDescription()); } { VisitType vt = vs.getVisitTypeByUuid("abcf7209-d218-4572-8893-25c4b5b71934"); - Assert.assertEquals("General", vt.getName()); - Assert.assertNull(vt.getDescription()); + Assertions.assertEquals("General", vt.getName()); + Assertions.assertNull(vt.getDescription()); } // Verify edition (description) { VisitType vt = vs.getVisitTypeByUuid("287463d3-2233-4c69-9851-5841a1f5e109"); - Assert.assertEquals("OPD", vt.getName()); - Assert.assertEquals("OPD Visit", vt.getDescription()); + Assertions.assertEquals("OPD", vt.getName()); + Assertions.assertEquals("OPD Visit", vt.getDescription()); } // Verify edition using name as pivot in CSV { VisitType vt = vs.getVisitTypeByUuid("759799ab-c9a5-435e-b671-77773ada74e4"); - Assert.assertEquals("Return TB Clinic Visit", vt.getName()); - Assert.assertEquals("Edited Return TB Clinic Visit Description", vt.getDescription()); + Assertions.assertEquals("Return TB Clinic Visit", vt.getName()); + Assertions.assertEquals("Edited Return TB Clinic Visit Description", vt.getDescription()); } // Verify retirement using UUID as pivot in CSV { VisitType vt = vs.getVisitTypeByUuid("e1d02b2e-cc85-48ac-a5bd-b0e4beea96e0"); - Assert.assertEquals(true, vt.getRetired()); + Assertions.assertEquals(true, vt.getRetired()); } // Verify retirement using name as pivot in CSV { List visitTypes = vs.getVisitTypes("Initial HIV"); - Assert.assertNotNull(visitTypes); - Assert.assertThat(visitTypes.size(), is(1)); + Assertions.assertNotNull(visitTypes); + MatcherAssert.assertThat(visitTypes.size(), is(1)); VisitType vt = visitTypes.get(0); - Assert.assertTrue(vt.getRetired()); + Assertions.assertTrue(vt.getRetired()); } } diff --git a/api/src/test/java/org/openmrs/module/initializer/api/appt/servicedefinition/AppointmentsServicesDefinitionLineProcessorTest.java b/api/src/test/java/org/openmrs/module/initializer/api/appt/servicedefinition/AppointmentsServicesDefinitionLineProcessorTest.java index b4fb611df..c11d5fb86 100644 --- a/api/src/test/java/org/openmrs/module/initializer/api/appt/servicedefinition/AppointmentsServicesDefinitionLineProcessorTest.java +++ b/api/src/test/java/org/openmrs/module/initializer/api/appt/servicedefinition/AppointmentsServicesDefinitionLineProcessorTest.java @@ -2,8 +2,8 @@ import static org.mockito.Mockito.mock; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import org.openmrs.api.LocationService; import org.openmrs.module.appointments.model.AppointmentServiceDefinition; import org.openmrs.module.appointments.service.SpecialityService; @@ -31,9 +31,9 @@ public void fill_shouldParseAppointmentsServiceDefinition() { AppointmentServiceDefinition definition = p.fill(new AppointmentServiceDefinition(), new CsvLine(headerLine, line)); // Verif - Assert.assertEquals("X-Ray", definition.getName()); - Assert.assertEquals("Radiology Service", definition.getDescription()); - Assert.assertEquals(Integer.valueOf(30), definition.getDurationMins()); - Assert.assertEquals(Integer.valueOf(50), definition.getMaxAppointmentsLimit()); + Assertions.assertEquals("X-Ray", definition.getName()); + Assertions.assertEquals("Radiology Service", definition.getDescription()); + Assertions.assertEquals(Integer.valueOf(30), definition.getDurationMins()); + Assertions.assertEquals(Integer.valueOf(50), definition.getMaxAppointmentsLimit()); } } diff --git a/api/src/test/java/org/openmrs/module/initializer/api/appt/speciality/AppointmentsSpecialityLineProcessorTest.java b/api/src/test/java/org/openmrs/module/initializer/api/appt/speciality/AppointmentsSpecialityLineProcessorTest.java index c080bb344..35afa9e03 100644 --- a/api/src/test/java/org/openmrs/module/initializer/api/appt/speciality/AppointmentsSpecialityLineProcessorTest.java +++ b/api/src/test/java/org/openmrs/module/initializer/api/appt/speciality/AppointmentsSpecialityLineProcessorTest.java @@ -1,7 +1,7 @@ package org.openmrs.module.initializer.api.appt.speciality; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import org.openmrs.module.appointments.model.Speciality; import org.openmrs.module.initializer.api.CsvLine; import org.openmrs.module.initializer.api.appt.specialities.SpecialityLineProcessor; @@ -23,6 +23,6 @@ public void fill_shouldParseSpeciality() { Speciality speciality = p.fill(new Speciality(), new CsvLine(headerLine, line)); // Verif - Assert.assertEquals("Speciality name", speciality.getName()); + Assertions.assertEquals("Speciality name", speciality.getName()); } } diff --git a/api/src/test/java/org/openmrs/module/initializer/api/attributes/types/AttributeTypesProxyServiceTest.java b/api/src/test/java/org/openmrs/module/initializer/api/attributes/types/AttributeTypesProxyServiceTest.java index 13661dfca..6cf5108b5 100644 --- a/api/src/test/java/org/openmrs/module/initializer/api/attributes/types/AttributeTypesProxyServiceTest.java +++ b/api/src/test/java/org/openmrs/module/initializer/api/attributes/types/AttributeTypesProxyServiceTest.java @@ -3,10 +3,11 @@ import static org.hamcrest.CoreMatchers.is; import static org.openmrs.module.initializer.api.attributes.types.AttributeTypeEntity.LOCATION; -import org.apache.commons.lang.RandomStringUtils; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; +import org.apache.commons.lang3.RandomStringUtils; +import org.hamcrest.MatcherAssert; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.openmrs.LocationAttributeType; import org.openmrs.api.LocationService; import org.openmrs.attribute.BaseAttributeType; @@ -25,7 +26,7 @@ public class AttributeTypesProxyServiceTest extends DomainBaseModuleContextSensi @Qualifier("locationService") private LocationService ls; - @Before + @BeforeEach public void setup() throws Exception { executeDataSet("testdata/test-metadata.xml"); } @@ -36,9 +37,9 @@ public void getAttributeTypeByUuid_shouldGetAttributeType() { BaseAttributeType attType = service.getAttributeTypeByUuid(LOCATION_ATT_TYPE_UUID, LOCATION); // Verif - Assert.assertNotNull(attType); - Assert.assertThat(attType.getName(), is("Location Code")); - Assert.assertTrue(attType instanceof LocationAttributeType); + Assertions.assertNotNull(attType); + MatcherAssert.assertThat(attType.getName(), is("Location Code")); + Assertions.assertTrue(attType instanceof LocationAttributeType); } @Test @@ -53,7 +54,7 @@ public void saveAttributeType_shouldSaveAttributeType() { // Verif attType = service.getAttributeTypeByName(newName, LOCATION); - Assert.assertNotNull(attType); - Assert.assertThat(attType.getId(), is(1089)); + Assertions.assertNotNull(attType); + MatcherAssert.assertThat(attType.getId(), is(1089)); } } diff --git a/api/src/test/java/org/openmrs/module/initializer/api/c/BaseConceptLineProcessorTest.java b/api/src/test/java/org/openmrs/module/initializer/api/c/BaseConceptLineProcessorTest.java index dd179c2f7..9c4d7aef3 100644 --- a/api/src/test/java/org/openmrs/module/initializer/api/c/BaseConceptLineProcessorTest.java +++ b/api/src/test/java/org/openmrs/module/initializer/api/c/BaseConceptLineProcessorTest.java @@ -3,8 +3,8 @@ import static org.mockito.Mockito.mock; import org.apache.commons.collections.CollectionUtils; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import org.openmrs.Concept; import org.openmrs.api.ConceptService; import org.openmrs.module.initializer.api.CsvLine; @@ -28,9 +28,9 @@ public void fill_shouldHandleMissingHeaders() { Concept c = p.fill(new Concept(), new CsvLine(headerLine, line)); // Verif - Assert.assertTrue(CollectionUtils.isEmpty(c.getNames())); - Assert.assertTrue(CollectionUtils.isEmpty(c.getDescriptions())); - Assert.assertNull(c.getConceptClass()); - Assert.assertNull(c.getDatatype()); + Assertions.assertTrue(CollectionUtils.isEmpty(c.getNames())); + Assertions.assertTrue(CollectionUtils.isEmpty(c.getDescriptions())); + Assertions.assertNull(c.getConceptClass()); + Assertions.assertNull(c.getDatatype()); } } diff --git a/api/src/test/java/org/openmrs/module/initializer/api/c/ConceptAttributeLineProcessorTest.java b/api/src/test/java/org/openmrs/module/initializer/api/c/ConceptAttributeLineProcessorTest.java index 16e2cc70d..8855fd7b6 100644 --- a/api/src/test/java/org/openmrs/module/initializer/api/c/ConceptAttributeLineProcessorTest.java +++ b/api/src/test/java/org/openmrs/module/initializer/api/c/ConceptAttributeLineProcessorTest.java @@ -5,16 +5,17 @@ import java.util.Properties; import static org.hamcrest.Matchers.is; -import static org.mockito.Matchers.anyString; +import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; -import static org.mockito.Matchers.eq; +import static org.mockito.ArgumentMatchers.eq; import static org.openmrs.module.initializer.api.BaseAttributeLineProcessor.HEADER_ATTRIBUTE_PREFIX; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.hamcrest.MatcherAssert; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.openmrs.Concept; import org.openmrs.ConceptAttribute; import org.openmrs.ConceptAttributeType; @@ -25,16 +26,21 @@ import org.openmrs.customdatatype.datatype.DateDatatype; import org.openmrs.customdatatype.datatype.FreeTextDatatype; import org.openmrs.module.initializer.api.CsvLine; -import org.powermock.api.mockito.PowerMockito; -import org.powermock.core.classloader.annotations.PowerMockIgnore; -import org.powermock.core.classloader.annotations.PrepareForTest; -import org.powermock.modules.junit4.PowerMockRunner; +import org.mockito.MockedStatic; +import org.mockito.Mockito; -@RunWith(PowerMockRunner.class) -@PrepareForTest({ Context.class, CustomDatatypeUtil.class }) -@PowerMockIgnore("jdk.internal.reflect.*") public class ConceptAttributeLineProcessorTest { + private MockedStatic contextMock; + + private MockedStatic customDatatypeUtilMock; + + @AfterEach + public void closeStaticMocks() { + contextMock.close(); + customDatatypeUtilMock.close(); + } + private ConceptService cs; private ConceptAttributeLineProcessor processor; @@ -45,14 +51,14 @@ public class ConceptAttributeLineProcessorTest { private DateDatatype dateDatatype; - @Before + @BeforeEach public void setup() { - PowerMockito.mockStatic(Context.class); - PowerMockito.mockStatic(CustomDatatypeUtil.class); + contextMock = Mockito.mockStatic(Context.class); + customDatatypeUtilMock = Mockito.mockStatic(CustomDatatypeUtil.class); - when(CustomDatatypeUtil.getDatatype(eq(FreeTextDatatype.class.getName()), anyString())) + when(CustomDatatypeUtil.getDatatype(eq(FreeTextDatatype.class.getName()), any())) .thenReturn((CustomDatatype) new FreeTextDatatype()); - when(CustomDatatypeUtil.getDatatype(eq(DateDatatype.class.getName()), anyString())) + when(CustomDatatypeUtil.getDatatype(eq(DateDatatype.class.getName()), any())) .thenReturn((CustomDatatype) new DateDatatype()); when(Context.getRuntimeProperties()).thenReturn(new Properties()); @@ -85,11 +91,11 @@ public void fill_shouldParseConceptAttributes() { // Verify Collection attributes = concept.getActiveAttributes(); - Assert.assertEquals(2, attributes.size()); + Assertions.assertEquals(2, attributes.size()); Object[] attributesArray = attributes.toArray(); Object auditDate = ((ConceptAttribute) attributesArray[0]).getValue(); - Assert.assertTrue(auditDate instanceof Date); - Assert.assertThat(dateDatatype.serialize(((Date) auditDate)), is("2013-03-19")); - Assert.assertThat(((ConceptAttribute) attributesArray[1]).getValue(), is("jdoe@example.com")); + Assertions.assertTrue(auditDate instanceof Date); + MatcherAssert.assertThat(dateDatatype.serialize(((Date) auditDate)), is("2013-03-19")); + MatcherAssert.assertThat(((ConceptAttribute) attributesArray[1]).getValue(), is("jdoe@example.com")); } } diff --git a/api/src/test/java/org/openmrs/module/initializer/api/c/ConceptNumericLineProcessorTest.java b/api/src/test/java/org/openmrs/module/initializer/api/c/ConceptNumericLineProcessorTest.java index 63fbd313c..6222ed269 100644 --- a/api/src/test/java/org/openmrs/module/initializer/api/c/ConceptNumericLineProcessorTest.java +++ b/api/src/test/java/org/openmrs/module/initializer/api/c/ConceptNumericLineProcessorTest.java @@ -1,14 +1,15 @@ package org.openmrs.module.initializer.api.c; -import static org.mockito.Matchers.any; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.atLeast; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.mockito.invocation.InvocationOnMock; import org.mockito.stubbing.Answer; import org.openmrs.Concept; @@ -24,7 +25,7 @@ public class ConceptNumericLineProcessorTest { private ConceptService cs = mock(ConceptService.class); - @Before + @BeforeEach public void setup() { when(cs.getConceptDatatypeByName(any(String.class))).thenAnswer(new Answer() { @@ -53,16 +54,16 @@ public void fill_shouldParseConceptNumeric() { ConceptNumeric cn = (ConceptNumeric) p.fill(new Concept(), new CsvLine(headerLine, line)); // Verif - Assert.assertEquals(ConceptNumericLineProcessor.DATATYPE_NUMERIC, cn.getDatatype().getName()); - Assert.assertEquals(0, cn.getLowAbsolute().compareTo(-100.5)); - Assert.assertEquals(0, cn.getLowCritical().compareTo(-85.7)); - Assert.assertEquals(0, cn.getLowNormal().compareTo(-50.3)); - Assert.assertEquals(0, cn.getHiNormal().compareTo(45.1)); - Assert.assertEquals(0, cn.getHiCritical().compareTo(78.0)); - Assert.assertEquals(0, cn.getHiAbsolute().compareTo(98.8)); - Assert.assertEquals("foo", cn.getUnits()); - Assert.assertTrue(cn.getAllowDecimal()); - Assert.assertEquals(1, cn.getDisplayPrecision().intValue()); + Assertions.assertEquals(ConceptNumericLineProcessor.DATATYPE_NUMERIC, cn.getDatatype().getName()); + Assertions.assertEquals(0, cn.getLowAbsolute().compareTo(-100.5)); + Assertions.assertEquals(0, cn.getLowCritical().compareTo(-85.7)); + Assertions.assertEquals(0, cn.getLowNormal().compareTo(-50.3)); + Assertions.assertEquals(0, cn.getHiNormal().compareTo(45.1)); + Assertions.assertEquals(0, cn.getHiCritical().compareTo(78.0)); + Assertions.assertEquals(0, cn.getHiAbsolute().compareTo(98.8)); + Assertions.assertEquals("foo", cn.getUnits()); + Assertions.assertTrue(cn.getAllowDecimal()); + Assertions.assertEquals(1, cn.getDisplayPrecision().intValue()); } @Test @@ -77,19 +78,22 @@ public void fill_shouldHandleMissingHeaders() { Concept c = p.fill(new Concept(), new CsvLine(headerLine, line)); // Verif - Assert.assertFalse(c instanceof ConceptNumeric); + Assertions.assertFalse(c instanceof ConceptNumeric); } - @Test(expected = NumberFormatException.class) + @Test public void fill_shouldFailWhenCannotParse() { - - // Setup - String[] headerLine = { "Data type", "Absolute low" }; - String[] line = { "Numeric", "-100.5a" }; - - // Replay - ConceptNumericLineProcessor p = new ConceptNumericLineProcessor(cs); - p.fill(new Concept(), new CsvLine(headerLine, line)); + assertThrows(NumberFormatException.class, () -> { + + // Setup + String[] headerLine = { "Data type", "Absolute low" }; + String[] line = { "Numeric", "-100.5a" }; + + // Replay + ConceptNumericLineProcessor p = new ConceptNumericLineProcessor(cs); + p.fill(new Concept(), new CsvLine(headerLine, line)); + + }); } @Test @@ -106,7 +110,7 @@ public void fill_shouldOverrideProvidedDataType() { // Verify verify(cs, atLeast(1)).getConceptNumeric(any(Integer.class)); - Assert.assertEquals(ConceptNumericLineProcessor.DATATYPE_NUMERIC, cn.getDatatype().getName()); - Assert.assertEquals(0, cn.getLowAbsolute().compareTo(11.11)); + Assertions.assertEquals(ConceptNumericLineProcessor.DATATYPE_NUMERIC, cn.getDatatype().getName()); + Assertions.assertEquals(0, cn.getLowAbsolute().compareTo(11.11)); } } diff --git a/api/src/test/java/org/openmrs/module/initializer/api/c/ConceptsCsvParserTest.java b/api/src/test/java/org/openmrs/module/initializer/api/c/ConceptsCsvParserTest.java index 98027e0cd..cd139f2d2 100644 --- a/api/src/test/java/org/openmrs/module/initializer/api/c/ConceptsCsvParserTest.java +++ b/api/src/test/java/org/openmrs/module/initializer/api/c/ConceptsCsvParserTest.java @@ -1,8 +1,7 @@ package org.openmrs.module.initializer.api.c; -import static org.mockito.Matchers.any; -import static org.mockito.Matchers.anyString; -import static org.mockito.Matchers.eq; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; @@ -11,10 +10,10 @@ import java.util.List; import java.util.Random; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.mockito.invocation.InvocationOnMock; import org.mockito.stubbing.Answer; import org.openmrs.Concept; @@ -28,25 +27,30 @@ import org.openmrs.customdatatype.datatype.DateDatatype; import org.openmrs.customdatatype.datatype.FreeTextDatatype; import org.openmrs.module.initializer.api.utils.ConceptListParser; -import org.powermock.api.mockito.PowerMockito; -import org.powermock.core.classloader.annotations.PowerMockIgnore; -import org.powermock.core.classloader.annotations.PrepareForTest; -import org.powermock.modules.junit4.PowerMockRunner; +import org.mockito.MockedStatic; +import org.mockito.Mockito; /* * This kind of test case can be used to quickly trial the parsing routines on test CSVs */ -@RunWith(PowerMockRunner.class) -@PrepareForTest({ CustomDatatypeUtil.class, Context.class }) -@PowerMockIgnore("jdk.internal.reflect.*") public class ConceptsCsvParserTest { + private MockedStatic customDatatypeUtilMock; + + private MockedStatic contextMock; + + @AfterEach + public void closeStaticMocks() { + customDatatypeUtilMock.close(); + contextMock.close(); + } + private ConceptService cs; - @Before + @BeforeEach public void setup() { - PowerMockito.mockStatic(CustomDatatypeUtil.class); - PowerMockito.mockStatic(Context.class); + customDatatypeUtilMock = Mockito.mockStatic(CustomDatatypeUtil.class); + contextMock = Mockito.mockStatic(Context.class); cs = mock(ConceptService.class); ConceptClass classQuestion = new ConceptClass(); @@ -68,9 +72,9 @@ public void setup() { typeNA.setName("N/A"); when(cs.getConceptDatatypeByName(eq("N/A"))).thenReturn(typeNA); - when(CustomDatatypeUtil.getDatatype(eq(FreeTextDatatype.class.getName()), anyString())) + when(CustomDatatypeUtil.getDatatype(eq(FreeTextDatatype.class.getName()), any())) .thenReturn((CustomDatatype) new FreeTextDatatype()); - when(CustomDatatypeUtil.getDatatype(eq(DateDatatype.class.getName()), anyString())) + when(CustomDatatypeUtil.getDatatype(eq(DateDatatype.class.getName()), any())) .thenReturn((CustomDatatype) new DateDatatype()); ConceptAttributeType autditDateAttType = new ConceptAttributeType(); @@ -123,7 +127,7 @@ public void process_shouldParseBaseCsv() throws IOException { List lines = parser.process(parser.getLines()).getFailingLines(); // verif - Assert.assertEquals(1, lines.size()); + Assertions.assertEquals(1, lines.size()); } @Test @@ -142,7 +146,7 @@ public void process_shouldParseCsvWithBom() throws IOException { List lines = parser.process(parser.getLines()).getFailingLines(); // verify - Assert.assertEquals(1, lines.size()); + Assertions.assertEquals(1, lines.size()); } @Test @@ -156,16 +160,16 @@ public void process_shouldFailOnMisformattedCsv() throws IOException { is = getClass().getClassLoader() .getResourceAsStream("org/openmrs/module/initializer/include/csv/concepts_no_uuid.csv"); parser.setInputStream(is); - Assert.assertEquals(1, parser.process(parser.getLines()).getFailingLines().size()); + Assertions.assertEquals(1, parser.process(parser.getLines()).getFailingLines().size()); is = getClass().getClassLoader() .getResourceAsStream("org/openmrs/module/initializer/include/csv/concepts_no_fsn.csv"); parser.setInputStream(is); - Assert.assertEquals(1, parser.process(parser.getLines()).getFailingLines().size()); + Assertions.assertEquals(1, parser.process(parser.getLines()).getFailingLines().size()); is = getClass().getClassLoader() .getResourceAsStream("org/openmrs/module/initializer/include/csv/concepts_no_shortname.csv"); parser.setInputStream(is); - Assert.assertEquals(1, parser.process(parser.getLines()).getFailingLines().size()); + Assertions.assertEquals(1, parser.process(parser.getLines()).getFailingLines().size()); } } diff --git a/api/src/test/java/org/openmrs/module/initializer/api/c/MappingsConceptLineProcessorTest.java b/api/src/test/java/org/openmrs/module/initializer/api/c/MappingsConceptLineProcessorTest.java index 10e5ca0ae..d5d9f7199 100644 --- a/api/src/test/java/org/openmrs/module/initializer/api/c/MappingsConceptLineProcessorTest.java +++ b/api/src/test/java/org/openmrs/module/initializer/api/c/MappingsConceptLineProcessorTest.java @@ -1,9 +1,9 @@ package org.openmrs.module.initializer.api.c; import org.apache.commons.collections.CollectionUtils; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.mockito.stubbing.Answer; import org.openmrs.Concept; import org.openmrs.ConceptMap; @@ -16,7 +16,7 @@ import java.util.HashSet; import java.util.Set; -import static org.mockito.Matchers.any; +import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; @@ -27,7 +27,7 @@ public class MappingsConceptLineProcessorTest { private ConceptService cs = mock(ConceptService.class); - @Before + @BeforeEach public void setup() { /* @@ -86,15 +86,15 @@ public void fill_shouldParseSameAsMappings() { // Verif Collection mappings = c.getConceptMappings(); - Assert.assertEquals(2, mappings.size()); + Assertions.assertEquals(2, mappings.size()); Set names = new HashSet(); for (ConceptMap m : mappings) { String source = m.getConceptReferenceTerm().getConceptSource().getName(); String code = m.getConceptReferenceTerm().getCode(); names.add(source + ":" + code); } - Assert.assertTrue(names.contains("cambodia:123")); - Assert.assertTrue(names.contains("foo:456")); + Assertions.assertTrue(names.contains("cambodia:123")); + Assertions.assertTrue(names.contains("foo:456")); } @Test @@ -111,7 +111,7 @@ public void fill_shouldParseMappingsForTypeAndSourceInHeader() { // Verif Collection mappings = c.getConceptMappings(); - Assert.assertEquals(6, mappings.size()); + Assertions.assertEquals(6, mappings.size()); Set names = new HashSet(); for (ConceptMap m : mappings) { String mapType = m.getConceptMapType().getName(); @@ -119,12 +119,12 @@ public void fill_shouldParseMappingsForTypeAndSourceInHeader() { String code = m.getConceptReferenceTerm().getCode(); names.add(mapType + ":" + source + ":" + code); } - Assert.assertTrue(names.contains("same-as:cambodia:123")); - Assert.assertTrue(names.contains("broader-than:foo:456")); - Assert.assertTrue(names.contains("related-to:cambodia:789")); - Assert.assertTrue(names.contains("related-to:foo:abc")); - Assert.assertTrue(names.contains("same-as:pih:5089")); - Assert.assertTrue(names.contains("same-as:pih:weight")); + Assertions.assertTrue(names.contains("same-as:cambodia:123")); + Assertions.assertTrue(names.contains("broader-than:foo:456")); + Assertions.assertTrue(names.contains("related-to:cambodia:789")); + Assertions.assertTrue(names.contains("related-to:foo:abc")); + Assertions.assertTrue(names.contains("same-as:pih:5089")); + Assertions.assertTrue(names.contains("same-as:pih:weight")); } @Test @@ -139,7 +139,7 @@ public void fill_shouldHandleNoSameAsMappings() { Concept c = p.fill(new Concept(), new CsvLine(headerLine, line)); // Verif - Assert.assertTrue(CollectionUtils.isEmpty(c.getConceptMappings())); + Assertions.assertTrue(CollectionUtils.isEmpty(c.getConceptMappings())); } public void getConcept_shouldHandleMissingHeaders() { @@ -151,6 +151,6 @@ public void getConcept_shouldHandleMissingHeaders() { // Replay MappingsConceptLineProcessor p = new MappingsConceptLineProcessor(cs); Concept c = p.fill(new Concept(), new CsvLine(headerLine, line)); - Assert.assertNull(c.getConceptMappings()); + Assertions.assertNull(c.getConceptMappings()); } } diff --git a/api/src/test/java/org/openmrs/module/initializer/api/c/NestedConceptLineProcessorTest.java b/api/src/test/java/org/openmrs/module/initializer/api/c/NestedConceptLineProcessorTest.java index 5abdaa61b..f61422737 100644 --- a/api/src/test/java/org/openmrs/module/initializer/api/c/NestedConceptLineProcessorTest.java +++ b/api/src/test/java/org/openmrs/module/initializer/api/c/NestedConceptLineProcessorTest.java @@ -1,6 +1,6 @@ package org.openmrs.module.initializer.api.c; -import static org.mockito.Matchers.any; +import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; @@ -9,9 +9,9 @@ import java.util.List; import java.util.Set; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.mockito.invocation.InvocationOnMock; import org.mockito.stubbing.Answer; import org.openmrs.Concept; @@ -27,7 +27,7 @@ public class NestedConceptLineProcessorTest { private ConceptService cs = mock(ConceptService.class); - @Before + @BeforeEach public void setup() { /* @@ -60,15 +60,15 @@ public void fill_shouldParseAnswers() { Concept c = p.fill(new Concept(), new CsvLine(headerLine, line)); // Verif - Assert.assertFalse(c.getSet()); + Assertions.assertFalse(c.getSet()); Collection answers = c.getAnswers(); - Assert.assertEquals(2, answers.size()); + Assertions.assertEquals(2, answers.size()); Set uuids = new HashSet(); for (ConceptAnswer a : answers) { uuids.add(a.getAnswerConcept().getUuid()); } - Assert.assertTrue(uuids.contains("cambodia:123")); - Assert.assertTrue(uuids.contains("cambodia:456")); + Assertions.assertTrue(uuids.contains("cambodia:123")); + Assertions.assertTrue(uuids.contains("cambodia:456")); } @Test @@ -83,15 +83,15 @@ public void fill_shouldParseSetMembers() { Concept c = p.fill(new Concept(), new CsvLine(headerLine, line)); // Verif - Assert.assertTrue(c.getSet()); + Assertions.assertTrue(c.getSet()); List members = c.getSetMembers(); - Assert.assertEquals(2, members.size()); + Assertions.assertEquals(2, members.size()); Set uuids = new HashSet(); for (Concept cpt : members) { uuids.add(cpt.getUuid()); } - Assert.assertTrue(uuids.contains("cambodia:123")); - Assert.assertTrue(uuids.contains("cambodia:456")); + Assertions.assertTrue(uuids.contains("cambodia:123")); + Assertions.assertTrue(uuids.contains("cambodia:456")); } @Test @@ -106,9 +106,9 @@ public void fill_shouldHandleNoChildren() { Concept c = p.fill(new Concept(), new CsvLine(headerLine, line)); // Verif - Assert.assertFalse(c.getSet()); - Assert.assertEquals(0, c.getSetMembers().size()); - Assert.assertEquals(0, c.getAnswers().size()); + Assertions.assertFalse(c.getSet()); + Assertions.assertEquals(0, c.getSetMembers().size()); + Assertions.assertEquals(0, c.getAnswers().size()); } public void fill_shouldHandleMissingHeaders() { @@ -120,7 +120,7 @@ public void fill_shouldHandleMissingHeaders() { // Replay NestedConceptLineProcessor p = new NestedConceptLineProcessor(cs, new ConceptListParser(cs)); Concept c = p.fill(new Concept(), new CsvLine(headerLine, line)); - Assert.assertNull(c.getAnswers()); - Assert.assertNull(c.getSetMembers()); + Assertions.assertNull(c.getAnswers()); + Assertions.assertNull(c.getSetMembers()); } } diff --git a/api/src/test/java/org/openmrs/module/initializer/api/cohort/cat/CohortAttributeTypesLoaderIntegrationTest.java b/api/src/test/java/org/openmrs/module/initializer/api/cohort/cat/CohortAttributeTypesLoaderIntegrationTest.java index 5d4de3109..4e1965f38 100644 --- a/api/src/test/java/org/openmrs/module/initializer/api/cohort/cat/CohortAttributeTypesLoaderIntegrationTest.java +++ b/api/src/test/java/org/openmrs/module/initializer/api/cohort/cat/CohortAttributeTypesLoaderIntegrationTest.java @@ -9,9 +9,9 @@ */ package org.openmrs.module.initializer.api.cohort.cat; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.openmrs.module.cohort.CohortAttributeType; import org.openmrs.module.cohort.api.CohortService; import org.openmrs.module.initializer.DomainBaseModuleContextSensitiveTest; @@ -27,7 +27,7 @@ public class CohortAttributeTypesLoaderIntegrationTest extends DomainBaseModuleC @Autowired private CohortAttributeTypeLoader loader; - @Before + @BeforeEach public void setup() { } @@ -39,9 +39,9 @@ public void load_shouldLoadCohortAttributeTypesAccordingToCsvFiles() { // Verify CohortAttributeType cat = cs.getCohortAttributeTypeByName("Test"); - Assert.assertNotNull(cat); - Assert.assertEquals("This is a test group.", cat.getDescription()); - Assert.assertEquals("09790099-9190-429d-811a-aac9edb8d98e", cat.getUuid()); - Assert.assertEquals("org.openmrs.customdatatype.datatype.FreeTextDatatype", cat.getDatatypeClassname()); + Assertions.assertNotNull(cat); + Assertions.assertEquals("This is a test group.", cat.getDescription()); + Assertions.assertEquals("09790099-9190-429d-811a-aac9edb8d98e", cat.getUuid()); + Assertions.assertEquals("org.openmrs.customdatatype.datatype.FreeTextDatatype", cat.getDatatypeClassname()); } } diff --git a/api/src/test/java/org/openmrs/module/initializer/api/display/DisplayLineProcessorTest.java b/api/src/test/java/org/openmrs/module/initializer/api/display/DisplayLineProcessorTest.java index 8a93bfb60..ad27a10b3 100644 --- a/api/src/test/java/org/openmrs/module/initializer/api/display/DisplayLineProcessorTest.java +++ b/api/src/test/java/org/openmrs/module/initializer/api/display/DisplayLineProcessorTest.java @@ -1,13 +1,13 @@ package org.openmrs.module.initializer.api.display; -import static org.mockito.Matchers.any; +import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.mockito.Mock; import org.mockito.MockitoAnnotations; import org.openmrs.OpenmrsObject; @@ -22,9 +22,9 @@ public class DisplayLineProcessorTest { @Mock private OpenmrsObject instance; - @Before + @BeforeEach public void setup() { - MockitoAnnotations.initMocks(this); + MockitoAnnotations.openMocks(this); } @Test diff --git a/api/src/test/java/org/openmrs/module/initializer/api/display/DisplaysCsvParserTest.java b/api/src/test/java/org/openmrs/module/initializer/api/display/DisplaysCsvParserTest.java index ee630ee73..f7fe24057 100644 --- a/api/src/test/java/org/openmrs/module/initializer/api/display/DisplaysCsvParserTest.java +++ b/api/src/test/java/org/openmrs/module/initializer/api/display/DisplaysCsvParserTest.java @@ -1,12 +1,12 @@ package org.openmrs.module.initializer.api.display; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.mockito.Mock; import org.openmrs.api.APIException; import org.mockito.MockitoAnnotations; @@ -27,9 +27,9 @@ public class DisplaysCsvParserTest { private DisplaysCsvParser displayParser; - @Before + @BeforeEach public void setup() { - MockitoAnnotations.initMocks(this); + MockitoAnnotations.openMocks(this); displayParser = new DisplaysCsvParser(new DisplayLineProcessor(msgSource)); displayParser.setBootstrapParser(someParser); } diff --git a/api/src/test/java/org/openmrs/module/initializer/api/form/AmpathFormsLoaderIntegrationTest.java b/api/src/test/java/org/openmrs/module/initializer/api/form/AmpathFormsLoaderIntegrationTest.java index 04b730401..abfa791c4 100644 --- a/api/src/test/java/org/openmrs/module/initializer/api/form/AmpathFormsLoaderIntegrationTest.java +++ b/api/src/test/java/org/openmrs/module/initializer/api/form/AmpathFormsLoaderIntegrationTest.java @@ -7,11 +7,11 @@ import java.util.List; import org.apache.commons.io.FileUtils; -import org.codehaus.jackson.JsonNode; -import org.codehaus.jackson.map.ObjectMapper; -import org.junit.After; -import org.junit.Assert; -import org.junit.Test; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import org.openmrs.Form; import org.openmrs.FormResource; import org.openmrs.api.DatatypeService; @@ -34,7 +34,7 @@ public class AmpathFormsLoaderIntegrationTest extends DomainBaseModuleContextSen @Autowired private FormService formService; - @After + @AfterEach public void clean() throws IOException { // Delete created form files @@ -54,20 +54,20 @@ public void load_shouldLoadFormWithAllAttributesSpecified() throws Exception { ClobDatatypeStorage clob = datatypeService .getClobDatatypeStorageByUuid(formService.getFormResource(form, "JSON schema").getValueReference()); // Verify form - Assert.assertEquals("Test Form 1", form.getName()); - Assert.assertEquals(Boolean.TRUE, form.getPublished()); - Assert.assertEquals("1", form.getVersion()); - Assert.assertEquals(Boolean.FALSE, form.getRetired()); - Assert.assertEquals("Emergency", form.getEncounterType().getName()); - Assert.assertEquals("Test 1 Description", form.getDescription()); + Assertions.assertEquals("Test Form 1", form.getName()); + Assertions.assertEquals(Boolean.TRUE, form.getPublished()); + Assertions.assertEquals("1", form.getVersion()); + Assertions.assertEquals(Boolean.FALSE, form.getRetired()); + Assertions.assertEquals("Emergency", form.getEncounterType().getName()); + Assertions.assertEquals("Test 1 Description", form.getDescription()); // Verify clob - Assert.assertNotNull(clob); + Assertions.assertNotNull(clob); ObjectMapper mapper = new ObjectMapper(); JsonNode actualObj = mapper.readTree(clob.getValue()); - Assert.assertEquals("\"Page 1\"", actualObj.get("pages").getElements().next().get("label").toString()); + Assertions.assertEquals("\"Page 1\"", actualObj.get("pages").elements().next().get("label").toString()); // Verify Form Resource - Assert.assertNotNull(formResource); - Assert.assertEquals(clob.getUuid(), formResource.getValueReference()); + Assertions.assertNotNull(formResource); + Assertions.assertEquals(clob.getUuid(), formResource.getValueReference()); } @@ -82,20 +82,20 @@ public void load_shouldLoadAndUpdateClobButNotForm() throws Exception { ClobDatatypeStorage clob = datatypeService .getClobDatatypeStorageByUuid(formService.getFormResource(form, "JSON schema").getValueReference()); // Verify form - Assert.assertEquals("Test Form 1", form.getName()); - Assert.assertEquals(Boolean.TRUE, form.getPublished()); - Assert.assertEquals("1", form.getVersion()); - Assert.assertEquals(Boolean.FALSE, form.getRetired()); - Assert.assertEquals("Emergency", form.getEncounterType().getName()); - Assert.assertEquals("Test 1 Description", form.getDescription()); + Assertions.assertEquals("Test Form 1", form.getName()); + Assertions.assertEquals(Boolean.TRUE, form.getPublished()); + Assertions.assertEquals("1", form.getVersion()); + Assertions.assertEquals(Boolean.FALSE, form.getRetired()); + Assertions.assertEquals("Emergency", form.getEncounterType().getName()); + Assertions.assertEquals("Test 1 Description", form.getDescription()); // Verify clob - Assert.assertNotNull(clob); + Assertions.assertNotNull(clob); ObjectMapper mapper = new ObjectMapper(); JsonNode actualObj = mapper.readTree(clob.getValue()); - Assert.assertEquals("\"Page 1\"", actualObj.get("pages").getElements().next().get("label").toString()); + Assertions.assertEquals("\"Page 1\"", actualObj.get("pages").elements().next().get("label").toString()); // Verify Form Resource - Assert.assertNotNull(formResource); - Assert.assertEquals(clob.getUuid(), formResource.getValueReference()); + Assertions.assertNotNull(formResource); + Assertions.assertEquals(clob.getUuid(), formResource.getValueReference()); String test_file_updated = "src/test/resources/testdata/testAmpathforms/test_form_clob_changed.json"; File srcFile = new File(test_file_updated); @@ -108,17 +108,17 @@ public void load_shouldLoadAndUpdateClobButNotForm() throws Exception { form = formService.getForm("Test Form 1"); // Verify form unchanged - Assert.assertEquals("Test Form 1", form.getName()); - Assert.assertEquals(Boolean.TRUE, form.getPublished()); - Assert.assertEquals("1", form.getVersion()); - Assert.assertEquals(Boolean.FALSE, form.getRetired()); - Assert.assertEquals("Emergency", form.getEncounterType().getName()); - Assert.assertEquals("Test 1 Description", form.getDescription()); + Assertions.assertEquals("Test Form 1", form.getName()); + Assertions.assertEquals(Boolean.TRUE, form.getPublished()); + Assertions.assertEquals("1", form.getVersion()); + Assertions.assertEquals(Boolean.FALSE, form.getRetired()); + Assertions.assertEquals("Emergency", form.getEncounterType().getName()); + Assertions.assertEquals("Test 1 Description", form.getDescription()); // Verify clob changed - Assert.assertNotNull(clob); + Assertions.assertNotNull(clob); ObjectMapper mapper2 = new ObjectMapper(); JsonNode actualObj1 = mapper2.readTree(clob.getValue()); - Assert.assertEquals("\"Page 1 changed\"", actualObj1.get("pages").getElements().next().get("label").toString()); + Assertions.assertEquals("\"Page 1 changed\"", actualObj1.get("pages").elements().next().get("label").toString()); } @Test @@ -132,20 +132,20 @@ public void load_shouldRetireAndCreateNewForm() throws Exception { ClobDatatypeStorage clob = datatypeService .getClobDatatypeStorageByUuid(formService.getFormResource(form, "JSON schema").getValueReference()); // Verify Form - Assert.assertEquals("Test Form 1", form.getName()); - Assert.assertEquals(Boolean.TRUE, form.getPublished()); - Assert.assertEquals("1", form.getVersion()); - Assert.assertEquals(Boolean.FALSE, form.getRetired()); - Assert.assertEquals("Emergency", form.getEncounterType().getName()); - Assert.assertEquals("Test 1 Description", form.getDescription()); + Assertions.assertEquals("Test Form 1", form.getName()); + Assertions.assertEquals(Boolean.TRUE, form.getPublished()); + Assertions.assertEquals("1", form.getVersion()); + Assertions.assertEquals(Boolean.FALSE, form.getRetired()); + Assertions.assertEquals("Emergency", form.getEncounterType().getName()); + Assertions.assertEquals("Test 1 Description", form.getDescription()); // Verify Clob - Assert.assertNotNull(clob); + Assertions.assertNotNull(clob); ObjectMapper mapper = new ObjectMapper(); JsonNode actualObj = mapper.readTree(clob.getValue()); - Assert.assertEquals("\"Page 1\"", actualObj.get("pages").getElements().next().get("label").toString()); + Assertions.assertEquals("\"Page 1\"", actualObj.get("pages").elements().next().get("label").toString()); // Verify Form Resource - Assert.assertNotNull(formResource); - Assert.assertEquals(clob.getUuid(), formResource.getValueReference()); + Assertions.assertNotNull(formResource); + Assertions.assertEquals(clob.getUuid(), formResource.getValueReference()); String test_file_updated = "src/test/resources/testdata/testAmpathforms/test_form_new_version.json"; File srcFile = new File(test_file_updated); @@ -157,33 +157,33 @@ public void load_shouldRetireAndCreateNewForm() throws Exception { ampathFormsLoader.load(); Form form2 = formService.getForm("Test Form 1"); Form initialForm = formService.getFormByUuid(form.getUuid()); - Assert.assertEquals(Boolean.TRUE, initialForm.getRetired()); + Assertions.assertEquals(Boolean.TRUE, initialForm.getRetired()); // Verify Form Changed - Assert.assertEquals("Test Form 1", form2.getName()); - Assert.assertEquals(Boolean.TRUE, form2.getPublished()); - Assert.assertEquals("2", form2.getVersion()); - Assert.assertEquals(Boolean.FALSE, form2.getRetired()); - Assert.assertEquals("Emergency", form2.getEncounterType().getName()); - Assert.assertEquals("Test 1 Description Updated", form2.getDescription()); + Assertions.assertEquals("Test Form 1", form2.getName()); + Assertions.assertEquals(Boolean.TRUE, form2.getPublished()); + Assertions.assertEquals("2", form2.getVersion()); + Assertions.assertEquals(Boolean.FALSE, form2.getRetired()); + Assertions.assertEquals("Emergency", form2.getEncounterType().getName()); + Assertions.assertEquals("Test 1 Description Updated", form2.getDescription()); // Verify Clob Changed ClobDatatypeStorage clob2 = datatypeService .getClobDatatypeStorageByUuid(formService.getFormResource(form2, "JSON schema").getValueReference()); - Assert.assertNotNull(clob2); + Assertions.assertNotNull(clob2); assertNotEquals(clob, clob2); ObjectMapper mapper2 = new ObjectMapper(); JsonNode actualObj1 = mapper2.readTree(clob2.getValue()); - Assert.assertEquals("\"Page X\"", actualObj1.get("pages").getElements().next().get("label").toString()); + Assertions.assertEquals("\"Page X\"", actualObj1.get("pages").elements().next().get("label").toString()); // Verify Form Resource FormResource formResource2 = formService.getFormResource(form2, "JSON schema"); - Assert.assertNotNull(formResource2); - Assert.assertEquals(clob2.getUuid(), formResource2.getValueReference()); + Assertions.assertNotNull(formResource2); + Assertions.assertEquals(clob2.getUuid(), formResource2.getValueReference()); List

forms = formService.getAllForms(true); // There is an initial Basic form - Assert.assertEquals(3, forms.size()); + Assertions.assertEquals(3, forms.size()); } } diff --git a/api/src/test/java/org/openmrs/module/initializer/api/form/AmpathFormsTranslationsLoaderIntegrationTest.java b/api/src/test/java/org/openmrs/module/initializer/api/form/AmpathFormsTranslationsLoaderIntegrationTest.java index f28a5c524..983864158 100644 --- a/api/src/test/java/org/openmrs/module/initializer/api/form/AmpathFormsTranslationsLoaderIntegrationTest.java +++ b/api/src/test/java/org/openmrs/module/initializer/api/form/AmpathFormsTranslationsLoaderIntegrationTest.java @@ -1,15 +1,15 @@ package org.openmrs.module.initializer.api.form; import org.apache.commons.io.FileUtils; -import org.codehaus.jackson.JsonNode; -import org.codehaus.jackson.map.ObjectMapper; -import org.junit.After; -import org.junit.Assert; -import org.junit.FixMethodOrder; -import org.junit.Rule; -import org.junit.runners.MethodSorters; -import org.junit.Test; -import org.junit.rules.ExpectedException; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; +import org.hamcrest.CoreMatchers; +import org.hamcrest.MatcherAssert; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.MethodOrderer; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestMethodOrder; import org.openmrs.Form; import org.openmrs.FormResource; import org.openmrs.api.FormService; @@ -24,12 +24,9 @@ import java.util.Collections; import java.util.Locale; -@FixMethodOrder(MethodSorters.NAME_ASCENDING) +@TestMethodOrder(MethodOrderer.MethodName.class) public class AmpathFormsTranslationsLoaderIntegrationTest extends DomainBaseModuleContextSensitiveTest { - @Rule - public ExpectedException thrown = ExpectedException.none(); - private static final String FORM_TRANSLATIONS_FOLDER_PATH = "src/test/resources/ampathformstranslations/"; @Autowired @@ -41,7 +38,7 @@ public class AmpathFormsTranslationsLoaderIntegrationTest extends DomainBaseModu @Autowired private FormService formService; - @After + @AfterEach public void clean() throws IOException { // Delete created form files @@ -61,20 +58,20 @@ public void load_shouldLoadAFormTranslationsFileWithAllAttributesSpecifiedAsForm // Verify Form form = formService.getForm("Test Form 1"); FormResource formResource = formService.getFormResource(form, "Test Form 1_translations_fr"); - Assert.assertNotNull(formResource); + Assertions.assertNotNull(formResource); ObjectMapper mapper = new ObjectMapper(); JsonNode actualObj = mapper.readTree((String) formResource.getValue()); - Assert.assertEquals("French Translations", actualObj.get("description").getTextValue()); - Assert.assertEquals("fr", actualObj.get("language").getTextValue()); - Assert.assertEquals("Encontre", actualObj.get("translations").get("Encounter").getTextValue()); - Assert.assertEquals("Autre", actualObj.get("translations").get("Other").getTextValue()); - Assert.assertEquals("Enfant", actualObj.get("translations").get("Child").getTextValue()); + Assertions.assertEquals("French Translations", actualObj.get("description").textValue()); + Assertions.assertEquals("fr", actualObj.get("language").textValue()); + Assertions.assertEquals("Encontre", actualObj.get("translations").get("Encounter").textValue()); + Assertions.assertEquals("Autre", actualObj.get("translations").get("Other").textValue()); + Assertions.assertEquals("Enfant", actualObj.get("translations").get("Child").textValue()); // verify form name translation - Assert.assertEquals("Formulaire d'essai 1", Context.getMessageSourceService() + Assertions.assertEquals("Formulaire d'essai 1", Context.getMessageSourceService() .getMessage("ui.i18n.Form.name." + formResource.getForm().getUuid(), null, Locale.CANADA_FRENCH)); - Assert.assertEquals("Formulaire d'essai 1", Context.getMessageSourceService() + Assertions.assertEquals("Formulaire d'essai 1", Context.getMessageSourceService() .getMessage("org.openmrs.Form." + formResource.getForm().getUuid(), null, Locale.CANADA_FRENCH)); } @@ -92,15 +89,15 @@ public void load_shouldLoadAndUpdateAFormTranslationsFileAsFormResource() throws Form form = formService.getForm("Test Form 1"); FormResource formResource = formService.getFormResource(form, "Test Form 1_translations_fr"); - Assert.assertNotNull(formResource); + Assertions.assertNotNull(formResource); ObjectMapper mapper = new ObjectMapper(); JsonNode ampathTranslations = mapper.readTree((String) formResource.getValue()); - Assert.assertEquals("French Translations", ampathTranslations.get("description").getTextValue()); - Assert.assertEquals("fr", ampathTranslations.get("language").getTextValue()); - Assert.assertEquals("Encontre", ampathTranslations.get("translations").get("Encounter").getTextValue()); - Assert.assertEquals("Autre", ampathTranslations.get("translations").get("Other").getTextValue()); - Assert.assertEquals("Enfant", ampathTranslations.get("translations").get("Child").getTextValue()); + Assertions.assertEquals("French Translations", ampathTranslations.get("description").textValue()); + Assertions.assertEquals("fr", ampathTranslations.get("language").textValue()); + Assertions.assertEquals("Encontre", ampathTranslations.get("translations").get("Encounter").textValue()); + Assertions.assertEquals("Autre", ampathTranslations.get("translations").get("Other").textValue()); + Assertions.assertEquals("Enfant", ampathTranslations.get("translations").get("Child").textValue()); String test_file_updated = "src/test/resources/testdata/testAmpathformstranslations/test_form_updated_translations_fr.json"; File srcFile = new File(test_file_updated); @@ -117,32 +114,29 @@ public void load_shouldLoadAndUpdateAFormTranslationsFileAsFormResource() throws FormResource formResourceUpdated = formService.getFormResource(formUpdated, "Test Form 1_translations_fr"); // Verify - Assert.assertNotNull(formResourceUpdated); + Assertions.assertNotNull(formResourceUpdated); ObjectMapper mapperUpdated = new ObjectMapper(); JsonNode ampathTranslationsUpdated = mapperUpdated.readTree((String) formResourceUpdated.getValue()); - Assert.assertEquals("French Translations Updated", ampathTranslationsUpdated.get("description").getTextValue()); - Assert.assertEquals("fr", ampathTranslationsUpdated.get("language").getTextValue()); - Assert.assertEquals("Tante", ampathTranslationsUpdated.get("translations").get("Aunt").getTextValue()); - Assert.assertEquals("Oncle", ampathTranslationsUpdated.get("translations").get("Uncle").getTextValue()); - Assert.assertEquals("Neveu", ampathTranslationsUpdated.get("translations").get("Nephew").getTextValue()); + Assertions.assertEquals("French Translations Updated", ampathTranslationsUpdated.get("description").textValue()); + Assertions.assertEquals("fr", ampathTranslationsUpdated.get("language").textValue()); + Assertions.assertEquals("Tante", ampathTranslationsUpdated.get("translations").get("Aunt").textValue()); + Assertions.assertEquals("Oncle", ampathTranslationsUpdated.get("translations").get("Uncle").textValue()); + Assertions.assertEquals("Neveu", ampathTranslationsUpdated.get("translations").get("Nephew").textValue()); } @Test public void load_shouldThrowGivenInvalidFormAssociatedWithFormTranslations() throws Exception { - // Setup - thrown.expectMessage( - "IllegalArgumentException: Could not find a form named 'Test Form 1'. Please ensure an existing form is configured."); - // Replay - ampathFormsTranslationsLoader.loadUnsafe(Collections.emptyList(), true); + Exception e = Assertions.assertThrows(Exception.class, + () -> ampathFormsTranslationsLoader.loadUnsafe(Collections.emptyList(), true)); + MatcherAssert.assertThat(e.getMessage(), CoreMatchers.containsString( + "IllegalArgumentException: Could not find a form named 'Test Form 1'. Please ensure an existing form is configured.")); } @Test public void load_shouldThrowGivenMissingFormFieldInFormTranslationsDef() throws Exception { // Setup - thrown.expectMessage("IllegalArgumentException: 'form' property is required for AMPATH forms translations loader."); - String missingUuidTranslationDefFile = "src/test/resources/testdata/testAmpathformstranslations/invalid_form_missing_formName_translations_fr.json"; File srcFile = new File(missingUuidTranslationDefFile); File dstFile = new File( @@ -151,16 +145,16 @@ public void load_shouldThrowGivenMissingFormFieldInFormTranslationsDef() throws FileUtils.copyFile(srcFile, dstFile); // Replay - ampathFormsTranslationsLoader.loadUnsafe(Collections.emptyList(), true); + Exception e = Assertions.assertThrows(Exception.class, + () -> ampathFormsTranslationsLoader.loadUnsafe(Collections.emptyList(), true)); + MatcherAssert.assertThat(e.getMessage(), CoreMatchers.containsString( + "IllegalArgumentException: 'form' property is required for AMPATH forms translations loader.")); } @Test public void load_shouldThrowGivenMissingLanguageFieldInFormTranslationsDef() throws Exception { // Setup - thrown.expectMessage( - "IllegalArgumentException: 'language' property is required for AMPATH forms translations loader."); - String missingUuidTranslationDefFile = "src/test/resources/testdata/testAmpathformstranslations/invalid_form_missing_language_translations_fr.json"; File srcFile = new File(missingUuidTranslationDefFile); File dstFile = new File( @@ -170,7 +164,10 @@ public void load_shouldThrowGivenMissingLanguageFieldInFormTranslationsDef() thr // Replay ampathFormsLoader.load(); - ampathFormsTranslationsLoader.loadUnsafe(Collections.emptyList(), true); + Exception e = Assertions.assertThrows(Exception.class, + () -> ampathFormsTranslationsLoader.loadUnsafe(Collections.emptyList(), true)); + MatcherAssert.assertThat(e.getMessage(), CoreMatchers.containsString( + "IllegalArgumentException: 'language' property is required for AMPATH forms translations loader.")); } } diff --git a/api/src/test/java/org/openmrs/module/initializer/api/form/BahmniFormsLoaderIntegrationTest.java b/api/src/test/java/org/openmrs/module/initializer/api/form/BahmniFormsLoaderIntegrationTest.java index b7327f17d..bf2bf4ba8 100644 --- a/api/src/test/java/org/openmrs/module/initializer/api/form/BahmniFormsLoaderIntegrationTest.java +++ b/api/src/test/java/org/openmrs/module/initializer/api/form/BahmniFormsLoaderIntegrationTest.java @@ -4,10 +4,10 @@ import org.bahmni.module.bahmni.ie.apps.model.FormTranslation; import org.bahmni.module.bahmni.ie.apps.service.BahmniFormTranslationService; import org.json.JSONObject; -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.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.openmrs.Form; import org.openmrs.GlobalProperty; import org.openmrs.api.AdministrationService; @@ -42,7 +42,7 @@ public class BahmniFormsLoaderIntegrationTest extends DomainBaseModuleContextSen @Autowired private FormService formService; - @Before + @BeforeEach public void setup() { // Set default directory for saving Bahmni form and Bahmni form translation files @@ -51,7 +51,7 @@ public void setup() { .saveGlobalProperty(new GlobalProperty("bahmni.formTranslations.directory", formTranslationPath)); } - @After + @AfterEach public void clean() throws IOException { // Delete created form files @@ -68,9 +68,9 @@ public void load_shouldLoadFormAccordingToJsonFile() { Form form = formService.getForm("form1"); // Verify - Assert.assertEquals("form1", form.getName()); - Assert.assertEquals(true, form.getPublished()); - Assert.assertEquals("1", form.getVersion()); + Assertions.assertEquals("form1", form.getName()); + Assertions.assertEquals(true, form.getPublished()); + Assertions.assertEquals("1", form.getVersion()); } @Test @@ -80,7 +80,7 @@ public void load_shouldLoadAndUpdateForm() throws Exception { bahmniFormsLoader.load(); Form form = formService.getForm("form1"); - Assert.assertEquals(true, form.getPublished()); + Assertions.assertEquals(true, form.getPublished()); String test_file_updated = "src/test/resources/testdata/testBahmniforms/test_form1_updated.json"; File srcFile = new File(test_file_updated); @@ -96,9 +96,9 @@ public void load_shouldLoadAndUpdateForm() throws Exception { // Verify - Assert.assertEquals(false, updatedForm.getPublished()); + Assertions.assertEquals(false, updatedForm.getPublished()); Map labels = bahmniFormTranslation.get(0).getLabels(); - Assert.assertEquals("updated label", labels.get("LABEL_2")); + Assertions.assertEquals("updated label", labels.get("LABEL_2")); } @Test @@ -111,8 +111,8 @@ public void load_shouldNotCreateDuplicates() { bahmniFormsLoader.load(); //Verify - Assert.assertNull(formService.getForm("form1", "2")); - Assert.assertEquals(1, + Assertions.assertNull(formService.getForm("form1", "2")); + Assertions.assertEquals(1, formService.getAllForms().stream().filter(form -> form.getName().equals("form1")).toArray().length); } @@ -127,13 +127,13 @@ public void load_shouldSaveFormTranslation() { null, form.getUuid()); // Verify - Assert.assertEquals(bahmniFormTranslation.size(), 1); - Assert.assertEquals("en", bahmniFormTranslation.get(0).getLocale()); + Assertions.assertEquals(bahmniFormTranslation.size(), 1); + Assertions.assertEquals("en", bahmniFormTranslation.get(0).getLocale()); Map labels = bahmniFormTranslation.get(0).getLabels(); - Assert.assertEquals("just a label", labels.get("LABEL_2")); + Assertions.assertEquals("just a label", labels.get("LABEL_2")); Map concepts = bahmniFormTranslation.get(0).getConcepts(); - Assert.assertEquals("test_upload", concepts.get("TEST_UPLOAD_3")); - Assert.assertEquals("form1", bahmniFormTranslation.get(0).getFormName()); + Assertions.assertEquals("test_upload", concepts.get("TEST_UPLOAD_3")); + Assertions.assertEquals("form1", bahmniFormTranslation.get(0).getFormName()); } @Test @@ -146,12 +146,12 @@ public void load_shouldCreateFormJsonFile() throws IOException { Form form = formService.getForm("form1"); File testFile = new File(formFolderPath + form.getUuid() + ".json"); - Assert.assertTrue(testFile.exists()); + Assertions.assertTrue(testFile.exists()); String jsonString = FileUtils.readFileToString(testFile); JSONObject jsonObject = new JSONObject(jsonString); - Assert.assertEquals("form1", jsonObject.get("name")); + Assertions.assertEquals("form1", jsonObject.get("name")); } @Test @@ -164,14 +164,14 @@ public void load_shouldCreateFormTranslationJsonFile() throws IOException { Form form = formService.getForm("form1"); File testFile = new File(formTranslationPath + form.getUuid() + ".json"); - Assert.assertTrue(testFile.exists()); + Assertions.assertTrue(testFile.exists()); String jsonString = FileUtils.readFileToString(testFile); JSONObject fileContent = new JSONObject(jsonString); JSONObject localeContent = (JSONObject) fileContent.get("en"); - Assert.assertEquals(localeContent.get("concepts").toString(), "{\"TEST_UPLOAD_3\":\"test_upload\"}"); - Assert.assertEquals(localeContent.get("labels").toString(), "{\"LABEL_2\":\"just a label\"}"); + Assertions.assertEquals(localeContent.get("concepts").toString(), "{\"TEST_UPLOAD_3\":\"test_upload\"}"); + Assertions.assertEquals(localeContent.get("labels").toString(), "{\"LABEL_2\":\"just a label\"}"); } @Test @@ -188,8 +188,8 @@ public void load_shouldCreateFileWithSameUuidInJsonAndForm() throws IOException File testFile = new File(formFolderPath + formUuid + ".json"); - Assert.assertTrue(testFile.exists()); - Assert.assertEquals(formUuid, form.getUuid()); + Assertions.assertTrue(testFile.exists()); + Assertions.assertEquals(formUuid, form.getUuid()); } } diff --git a/api/src/test/java/org/openmrs/module/initializer/api/form/HtmlFormsLoaderIntegrationTest.java b/api/src/test/java/org/openmrs/module/initializer/api/form/HtmlFormsLoaderIntegrationTest.java index dd492f96f..8061d2432 100644 --- a/api/src/test/java/org/openmrs/module/initializer/api/form/HtmlFormsLoaderIntegrationTest.java +++ b/api/src/test/java/org/openmrs/module/initializer/api/form/HtmlFormsLoaderIntegrationTest.java @@ -5,8 +5,8 @@ import org.apache.commons.io.FileUtils; import org.apache.commons.io.IOUtils; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import org.openmrs.module.htmlformentry.FormEntryContext; import org.openmrs.module.htmlformentry.HtmlForm; import org.openmrs.module.htmlformentry.HtmlFormEntryService; @@ -32,19 +32,19 @@ public class HtmlFormsLoaderIntegrationTest extends DomainBaseModuleContextSensi public void load_shouldLoadFormWithAllAttributesSpecified() throws Exception { htmlFormsLoader.load(); HtmlForm f = htmlFormEntryService.getHtmlFormByUuid("26ddfe02-28f3-11eb-bc37-0242ac110002"); - Assert.assertNotNull(f); - Assert.assertEquals("203fa4f8-28f3-11eb-bc37-0242ac110002", f.getForm().getUuid()); - Assert.assertEquals("Test Form 1", f.getName()); - Assert.assertEquals("Test Form With All Attributes", f.getDescription()); - Assert.assertEquals("1.3", f.getForm().getVersion()); - Assert.assertEquals(Boolean.TRUE, f.getForm().getPublished()); - Assert.assertEquals(Boolean.FALSE, f.getForm().getRetired()); - Assert.assertEquals(Boolean.FALSE, f.getRetired()); - Assert.assertEquals("61ae96f4-6afe-4351-b6f8-cd4fc383cce1", f.getForm().getEncounterType().getUuid()); + Assertions.assertNotNull(f); + Assertions.assertEquals("203fa4f8-28f3-11eb-bc37-0242ac110002", f.getForm().getUuid()); + Assertions.assertEquals("Test Form 1", f.getName()); + Assertions.assertEquals("Test Form With All Attributes", f.getDescription()); + Assertions.assertEquals("1.3", f.getForm().getVersion()); + Assertions.assertEquals(Boolean.TRUE, f.getForm().getPublished()); + Assertions.assertEquals(Boolean.FALSE, f.getForm().getRetired()); + Assertions.assertEquals(Boolean.FALSE, f.getRetired()); + Assertions.assertEquals("61ae96f4-6afe-4351-b6f8-cd4fc383cce1", f.getForm().getEncounterType().getUuid()); HtmlFormSchema schema = HtmlFormEntryUtil.getHtmlFormSchema(f, FormEntryContext.Mode.VIEW); - Assert.assertEquals(1, schema.getAllFields().size()); + Assertions.assertEquals(1, schema.getAllFields().size()); String expectedFormXml = getHtmlFormResourceAsString("allAttributeForm.xml"); - Assert.assertEquals(expectedFormXml.trim(), f.getXmlData().trim()); + Assertions.assertEquals(expectedFormXml.trim(), f.getXmlData().trim()); } @Test @@ -53,13 +53,13 @@ public void load_shouldLoadAndUpdateForm() throws Exception { // Test that initial version loads in with expected values htmlFormsLoader.load(); HtmlForm f1 = htmlFormEntryService.getHtmlFormByUuid("26ddfe02-28f3-11eb-bc37-0242ac110002"); - Assert.assertNotNull(f1); - Assert.assertEquals("Test Form 1", f1.getName()); - Assert.assertEquals("Test Form With All Attributes", f1.getDescription()); - Assert.assertEquals("1.3", f1.getForm().getVersion()); - Assert.assertEquals(Boolean.TRUE, f1.getForm().getPublished()); - Assert.assertEquals(Boolean.FALSE, f1.getForm().getRetired()); - Assert.assertEquals(Boolean.FALSE, f1.getRetired()); + Assertions.assertNotNull(f1); + Assertions.assertEquals("Test Form 1", f1.getName()); + Assertions.assertEquals("Test Form With All Attributes", f1.getDescription()); + Assertions.assertEquals("1.3", f1.getForm().getVersion()); + Assertions.assertEquals(Boolean.TRUE, f1.getForm().getPublished()); + Assertions.assertEquals(Boolean.FALSE, f1.getForm().getRetired()); + Assertions.assertEquals(Boolean.FALSE, f1.getRetired()); File formFile = new File(htmlFormsLoader.getDirUtil().getDomainDirPath(), "allAttributeForm.xml"); String originalXml = f1.getXmlData(); @@ -77,13 +77,13 @@ public void load_shouldLoadAndUpdateForm() throws Exception { // Now, reload configuration and test that the form has the new values htmlFormsLoader.load(); HtmlForm f2 = htmlFormEntryService.getHtmlFormByUuid("26ddfe02-28f3-11eb-bc37-0242ac110002"); - Assert.assertNotNull(f2); - Assert.assertEquals("Revised Form Name", f2.getName()); - Assert.assertEquals("Revised Form Description", f2.getDescription()); - Assert.assertEquals("2.0", f2.getForm().getVersion()); - Assert.assertEquals(Boolean.FALSE, f1.getForm().getPublished()); - Assert.assertEquals(Boolean.TRUE, f1.getForm().getRetired()); - Assert.assertEquals(Boolean.TRUE, f1.getRetired()); + Assertions.assertNotNull(f2); + Assertions.assertEquals("Revised Form Name", f2.getName()); + Assertions.assertEquals("Revised Form Description", f2.getDescription()); + Assertions.assertEquals("2.0", f2.getForm().getVersion()); + Assertions.assertEquals(Boolean.FALSE, f1.getForm().getPublished()); + Assertions.assertEquals(Boolean.TRUE, f1.getForm().getRetired()); + Assertions.assertEquals(Boolean.TRUE, f1.getRetired()); } finally { // Clean up by putting the original file xml back @@ -98,8 +98,8 @@ public void load_shouldNotCreateDuplicates() { htmlFormsLoader.load(); int numFormsAfterSecondLoad = htmlFormEntryService.getAllHtmlForms().size(); HtmlForm f1 = htmlFormEntryService.getHtmlFormByUuid("26ddfe02-28f3-11eb-bc37-0242ac110002"); - Assert.assertNotNull(f1); - Assert.assertEquals(numFormsAfterFirstLoad, numFormsAfterSecondLoad); + Assertions.assertNotNull(f1); + Assertions.assertEquals(numFormsAfterFirstLoad, numFormsAfterSecondLoad); } protected void updateHtmlFormAttribute(Document doc, String attributeName, String attributeValue) throws Exception { diff --git a/api/src/test/java/org/openmrs/module/initializer/api/gp/GlobalPropertiesConfigDeserializerTest.java b/api/src/test/java/org/openmrs/module/initializer/api/gp/GlobalPropertiesConfigDeserializerTest.java index 910d2dc7a..8ad116d50 100644 --- a/api/src/test/java/org/openmrs/module/initializer/api/gp/GlobalPropertiesConfigDeserializerTest.java +++ b/api/src/test/java/org/openmrs/module/initializer/api/gp/GlobalPropertiesConfigDeserializerTest.java @@ -1,7 +1,8 @@ package org.openmrs.module.initializer.api.gp; -import org.junit.Assert; -import org.junit.Test; +import static org.junit.jupiter.api.Assertions.assertThrows; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import org.openmrs.module.initializer.api.InitializerSerializer; import org.openmrs.test.Verifies; @@ -16,10 +17,10 @@ public void shouldDeserializeConfig() { GlobalPropertiesConfig config = InitializerSerializer.getGlobalPropertiesConfig( getClass().getClassLoader().getResourceAsStream("org/openmrs/module/initializer/include/gp.xml")); - Assert.assertEquals("addresshierarchy.i18nSupport", config.getGlobalProperties().get(0).getProperty()); - Assert.assertEquals("true", (String) config.getGlobalProperties().get(0).getPropertyValue()); - Assert.assertEquals("locale.allowed.list", config.getGlobalProperties().get(1).getProperty()); - Assert.assertEquals("en, km_KH", (String) config.getGlobalProperties().get(1).getPropertyValue()); + Assertions.assertEquals("addresshierarchy.i18nSupport", config.getGlobalProperties().get(0).getProperty()); + Assertions.assertEquals("true", (String) config.getGlobalProperties().get(0).getPropertyValue()); + Assertions.assertEquals("locale.allowed.list", config.getGlobalProperties().get(1).getProperty()); + Assertions.assertEquals("en, km_KH", (String) config.getGlobalProperties().get(1).getPropertyValue()); } @Test @@ -29,17 +30,20 @@ public void shouldDeserializeConfigWithUnmappedFields() { GlobalPropertiesConfig config = InitializerSerializer.getGlobalPropertiesConfig(getClass().getClassLoader() .getResourceAsStream("org/openmrs/module/initializer/include/gp_unmmaped_fields.xml")); - Assert.assertEquals("addresshierarchy.i18nSupport", config.getGlobalProperties().get(0).getProperty()); - Assert.assertEquals("true", (String) config.getGlobalProperties().get(0).getPropertyValue()); - Assert.assertEquals("locale.allowed.list", config.getGlobalProperties().get(1).getProperty()); - Assert.assertEquals("en, km_KH", (String) config.getGlobalProperties().get(1).getPropertyValue()); + Assertions.assertEquals("addresshierarchy.i18nSupport", config.getGlobalProperties().get(0).getProperty()); + Assertions.assertEquals("true", (String) config.getGlobalProperties().get(0).getPropertyValue()); + Assertions.assertEquals("locale.allowed.list", config.getGlobalProperties().get(1).getProperty()); + Assertions.assertEquals("en, km_KH", (String) config.getGlobalProperties().get(1).getPropertyValue()); } - @Test(expected = XStreamException.class) + @Test @Verifies(value = "should throw XStream exception on invalid config", method = "fromXML(InputStream input)") public void shouldThrowException() { - - InitializerSerializer.getGlobalPropertiesConfig( - getClass().getClassLoader().getResourceAsStream("org/openmrs/module/initializer/include/gp_error.xml")); + assertThrows(XStreamException.class, () -> { + + InitializerSerializer.getGlobalPropertiesConfig( + getClass().getClassLoader().getResourceAsStream("org/openmrs/module/initializer/include/gp_error.xml")); + + }); } } diff --git a/api/src/test/java/org/openmrs/module/initializer/api/loaders/BaseFileLoaderTest.java b/api/src/test/java/org/openmrs/module/initializer/api/loaders/BaseFileLoaderTest.java index f70ea5a1a..2612023e1 100644 --- a/api/src/test/java/org/openmrs/module/initializer/api/loaders/BaseFileLoaderTest.java +++ b/api/src/test/java/org/openmrs/module/initializer/api/loaders/BaseFileLoaderTest.java @@ -1,8 +1,8 @@ package org.openmrs.module.initializer.api.loaders; import static org.junit.jupiter.api.Assertions.assertThrows; -import static org.mockito.Matchers.any; -import static org.mockito.Matchers.eq; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; @@ -12,7 +12,7 @@ import java.util.Collections; import java.util.List; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.mockito.Mock; @@ -30,7 +30,7 @@ public class BaseFileLoaderTest { @BeforeEach public void setup() { - MockitoAnnotations.initMocks(this); + MockitoAnnotations.openMocks(this); testLoader = new TestLoader(); List files = Arrays.asList(new File("test1.txt"), new File("test2.txt"), new File("test3.txt")); @@ -112,7 +112,7 @@ public void loadUnsafe_shouldThrowEarly() throws Exception { }); // verify - Assert.assertTrue(thrown.getMessage().endsWith("Error right from file 1.")); + Assertions.assertTrue(thrown.getMessage().endsWith("Error right from file 1.")); verify(dirUtil, times(0)).writeChecksum(any(), any()); } @@ -163,7 +163,7 @@ protected void preload(final File file) throws Exception { }); // verify - Assert.assertTrue(thrown.getMessage().endsWith("Failed to preload from file 1.")); + Assertions.assertTrue(thrown.getMessage().endsWith("Failed to preload from file 1.")); } @Test @@ -219,6 +219,6 @@ protected boolean throwingOnPreload(boolean doThrow) { }); // verify - Assert.assertFalse(thrown.getMessage().endsWith("Failed to preload from file 1.")); + Assertions.assertFalse(thrown.getMessage().endsWith("Failed to preload from file 1.")); } } diff --git a/api/src/test/java/org/openmrs/module/initializer/api/loc/LocationAttributeLineProcessorTest.java b/api/src/test/java/org/openmrs/module/initializer/api/loc/LocationAttributeLineProcessorTest.java index e4528b9ff..30ff39bd2 100644 --- a/api/src/test/java/org/openmrs/module/initializer/api/loc/LocationAttributeLineProcessorTest.java +++ b/api/src/test/java/org/openmrs/module/initializer/api/loc/LocationAttributeLineProcessorTest.java @@ -1,8 +1,8 @@ package org.openmrs.module.initializer.api.loc; +import static org.junit.jupiter.api.Assertions.assertThrows; import static org.hamcrest.Matchers.is; -import static org.mockito.Matchers.any; -import static org.mockito.Matchers.anyString; +import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; import static org.openmrs.module.initializer.api.BaseAttributeLineProcessor.HEADER_ATTRIBUTE_PREFIX; @@ -11,10 +11,10 @@ import java.util.Collection; import java.util.Properties; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.openmrs.Location; import org.openmrs.LocationAttribute; import org.openmrs.LocationAttributeType; @@ -23,16 +23,18 @@ import org.openmrs.api.context.Context; import org.openmrs.customdatatype.datatype.FreeTextDatatype; import org.openmrs.module.initializer.api.CsvLine; -import org.powermock.api.mockito.PowerMockito; -import org.powermock.core.classloader.annotations.PowerMockIgnore; -import org.powermock.core.classloader.annotations.PrepareForTest; -import org.powermock.modules.junit4.PowerMockRunner; +import org.mockito.MockedStatic; +import org.mockito.Mockito; -@RunWith(PowerMockRunner.class) -@PrepareForTest(Context.class) -@PowerMockIgnore("jdk.internal.reflect.*") public class LocationAttributeLineProcessorTest { + private MockedStatic contextMock; + + @AfterEach + public void closeStaticMocks() { + contextMock.close(); + } + private LocationService ls; private LocationAttributeLineProcessor processor; @@ -41,13 +43,13 @@ public class LocationAttributeLineProcessorTest { private static String EMAIL_ATT_TYPE_NAME = "Facility Email"; - @Before + @BeforeEach public void setup() { - PowerMockito.mockStatic(Context.class); + contextMock = Mockito.mockStatic(Context.class); DatatypeService datatypeService = mock(DatatypeService.class); when(Context.getDatatypeService()).thenReturn(datatypeService); - when(datatypeService.getDatatype(any(Class.class), anyString())).thenReturn(new FreeTextDatatype()); + when(datatypeService.getDatatype(any(), any())).thenReturn(new FreeTextDatatype()); when(Context.getRuntimeProperties()).thenReturn(new Properties()); @@ -84,11 +86,11 @@ public void fill_shouldParseLocationAttributes() { // Verify Collection attributes = loc.getActiveAttributes(); - Assert.assertEquals(2, attributes.size()); - Assert.assertTrue("Must have attribute +1 206 555 0100", - attributes.removeIf(a -> a.getValue().equals("+1 206 555 0100"))); - Assert.assertTrue("Must have attribute jdoe@example.com", - attributes.removeIf(a -> a.getValue().equals("jdoe@example.com"))); + Assertions.assertEquals(2, attributes.size()); + Assertions.assertTrue(attributes.removeIf(a -> a.getValue().equals("+1 206 555 0100")), + "Must have attribute +1 206 555 0100"); + Assertions.assertTrue(attributes.removeIf(a -> a.getValue().equals("jdoe@example.com")), + "Must have attribute jdoe@example.com"); } @Test @@ -107,23 +109,25 @@ public void fill_shouldLeaveUnspecifiedAttributesIntact() { // Verify Collection attributes = loc.getActiveAttributes(); - Assert.assertEquals(2, attributes.size()); - Assert.assertTrue("Must have attribute +1 206 555 0100", - attributes.removeIf(a -> a.getValue().equals("+1 206 555 0100"))); - Assert.assertTrue("Must have attribute janedoe@example.com", - attributes.removeIf(a -> a.getValue().equals("janedoe@example.com"))); + Assertions.assertEquals(2, attributes.size()); + Assertions.assertTrue(attributes.removeIf(a -> a.getValue().equals("+1 206 555 0100")), + "Must have attribute +1 206 555 0100"); + Assertions.assertTrue(attributes.removeIf(a -> a.getValue().equals("janedoe@example.com")), + "Must have attribute janedoe@example.com"); } - @Test(expected = IllegalArgumentException.class) + @Test public void fill_shouldFailIfAttributeTypeDoesNotExistAndAttributeValueIsNotBlank() { - // Setup - String[] headerLine = { HEADER_ATTRIBUTE_PREFIX + PHONE_ATT_TYPE_UUID, - HEADER_ATTRIBUTE_PREFIX + EMAIL_ATT_TYPE_NAME }; - String[] line = { "+1 206 555 0100", "jdoe@example.com" }; - when(ls.getLocationAttributeTypeByName(EMAIL_ATT_TYPE_NAME)).thenReturn(null); - - // Replay - processor.fill(new Location(), new CsvLine(headerLine, line)); + assertThrows(IllegalArgumentException.class, () -> { + // Setup + String[] headerLine = { HEADER_ATTRIBUTE_PREFIX + PHONE_ATT_TYPE_UUID, + HEADER_ATTRIBUTE_PREFIX + EMAIL_ATT_TYPE_NAME }; + String[] line = { "+1 206 555 0100", "jdoe@example.com" }; + when(ls.getLocationAttributeTypeByName(EMAIL_ATT_TYPE_NAME)).thenReturn(null); + + // Replay + processor.fill(new Location(), new CsvLine(headerLine, line)); + + }); } - } diff --git a/api/src/test/java/org/openmrs/module/initializer/api/loc/LocationLineProcessorTest.java b/api/src/test/java/org/openmrs/module/initializer/api/loc/LocationLineProcessorTest.java index 57451b76e..0831b29a9 100644 --- a/api/src/test/java/org/openmrs/module/initializer/api/loc/LocationLineProcessorTest.java +++ b/api/src/test/java/org/openmrs/module/initializer/api/loc/LocationLineProcessorTest.java @@ -1,15 +1,16 @@ package org.openmrs.module.initializer.api.loc; -import static org.mockito.Matchers.any; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; import java.util.HashSet; import java.util.Set; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.mockito.invocation.InvocationOnMock; import org.mockito.stubbing.Answer; import org.openmrs.Location; @@ -26,7 +27,7 @@ public class LocationLineProcessorTest { private LocationService ls = mock(LocationService.class); - @Before + @BeforeEach public void setup() { /* @@ -57,13 +58,13 @@ public void fill_shouldParseTags() { // Verif Set tags = c.getTags(); - Assert.assertEquals(2, tags.size()); + Assertions.assertEquals(2, tags.size()); Set names = new HashSet(); for (LocationTag t : tags) { names.add(t.getName()); } - Assert.assertTrue(names.contains("Login Location")); - Assert.assertTrue(names.contains("Visit Location")); + Assertions.assertTrue(names.contains("Login Location")); + Assertions.assertTrue(names.contains("Visit Location")); } @Test @@ -81,13 +82,13 @@ public void fill_shouldLeaveUnspecifiedTagsIntactWhenUsingTagPrefixHeaders() { // Verif Set tags = c.getTags(); - Assert.assertEquals(2, tags.size()); + Assertions.assertEquals(2, tags.size()); Set names = new HashSet(); for (LocationTag t : tags) { names.add(t.getName()); } - Assert.assertTrue(names.contains("Login Location")); - Assert.assertTrue(names.contains("Visit Location")); + Assertions.assertTrue(names.contains("Login Location")); + Assertions.assertTrue(names.contains("Visit Location")); } @Test @@ -104,25 +105,28 @@ public void fill_shouldClearOldTagsWhenUsingTagHeader() { // Verif Set tags = c.getTags(); - Assert.assertEquals(1, tags.size()); + Assertions.assertEquals(1, tags.size()); Set names = new HashSet(); for (LocationTag t : tags) { names.add(t.getName()); } - Assert.assertFalse(names.contains("Login Location")); - Assert.assertTrue(names.contains("Visit Location")); + Assertions.assertFalse(names.contains("Login Location")); + Assertions.assertTrue(names.contains("Visit Location")); } - @Test(expected = IllegalArgumentException.class) + @Test public void fill_shouldFailIfParentDoesNotExist() { - - // Setup - String[] headerLine = { BaseLineProcessor.HEADER_NAME, BaseLineProcessor.PARENT }; - String[] line = { "Test Location", "nonexistent_location" }; - when(ls.getLocationByUuid("nonexistent_location")).thenReturn(null); - - LocationLineProcessor locationLineProcessor = new LocationLineProcessor(ls, new LocationTagListParser(ls)); - locationLineProcessor.fill(new Location(), new CsvLine(headerLine, line)); + assertThrows(IllegalArgumentException.class, () -> { + + // Setup + String[] headerLine = { BaseLineProcessor.HEADER_NAME, BaseLineProcessor.PARENT }; + String[] line = { "Test Location", "nonexistent_location" }; + when(ls.getLocationByUuid("nonexistent_location")).thenReturn(null); + + LocationLineProcessor locationLineProcessor = new LocationLineProcessor(ls, new LocationTagListParser(ls)); + locationLineProcessor.fill(new Location(), new CsvLine(headerLine, line)); + + }); } @Test @@ -137,6 +141,6 @@ public void fill_shouldParseIfParentIsNull() { Location location = locationLineProcessor.fill(new Location(), new CsvLine(headerLine, line)); // Verif - Assert.assertTrue(location.getName().equals("Test Location")); + Assertions.assertTrue(location.getName().equals("Test Location")); } } diff --git a/api/src/test/java/org/openmrs/module/initializer/api/logging/InitializerLogConfigurator2_0Test.java b/api/src/test/java/org/openmrs/module/initializer/api/logging/InitializerLogConfigurator2_0Test.java index c704a7685..05ee57544 100644 --- a/api/src/test/java/org/openmrs/module/initializer/api/logging/InitializerLogConfigurator2_0Test.java +++ b/api/src/test/java/org/openmrs/module/initializer/api/logging/InitializerLogConfigurator2_0Test.java @@ -4,8 +4,8 @@ import org.apache.log4j.Logger; import org.apache.log4j.spi.Filter; import org.apache.log4j.varia.LevelRangeFilter; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import org.openmrs.module.initializer.InitializerActivator; import java.lang.reflect.InvocationTargetException; @@ -23,7 +23,7 @@ public void shouldSetupLoggerWithAppropriateNameAndLevel() throws ClassNotFoundE logConfigurator20.setupLogging(level, null); // verify - Assert.assertEquals(level, Logger.getLogger(InitializerActivator.class.getPackage().getName()).getLevel()); + Assertions.assertEquals(level, Logger.getLogger(InitializerActivator.class.getPackage().getName()).getLevel()); } } diff --git a/api/src/test/java/org/openmrs/module/initializer/api/ot/OrderTypeLineProcessorTest.java b/api/src/test/java/org/openmrs/module/initializer/api/ot/OrderTypeLineProcessorTest.java index ee6761f5e..ed6fb03d8 100644 --- a/api/src/test/java/org/openmrs/module/initializer/api/ot/OrderTypeLineProcessorTest.java +++ b/api/src/test/java/org/openmrs/module/initializer/api/ot/OrderTypeLineProcessorTest.java @@ -2,8 +2,8 @@ import static org.mockito.Mockito.mock; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import org.openmrs.OrderType; import org.openmrs.api.ConceptService; import org.openmrs.api.OrderService; @@ -31,9 +31,9 @@ public void fill_shouldParseOrderType() { OrderType ot = p.fill(new OrderType(), new CsvLine(headerLine, line)); // Verif - Assert.assertEquals("OT name", ot.getName()); - Assert.assertEquals("OT desc.", ot.getDescription()); - Assert.assertEquals("org.openmrs.Order", ot.getJavaClassName()); + Assertions.assertEquals("OT name", ot.getName()); + Assertions.assertEquals("OT desc.", ot.getDescription()); + Assertions.assertEquals("org.openmrs.Order", ot.getJavaClassName()); // TODO Add test metadata for order type and verify if ot.getParent().getUuid() returns '01727040-a587-484d-b66a-f0afbae6c281' here } @@ -49,8 +49,8 @@ public void fill_shouldParseWithNameAndJavaClassNameOnly() { OrderType ot = p.fill(new OrderType(), new CsvLine(headerLine, line)); // Verif - Assert.assertEquals("OT name", ot.getName()); - Assert.assertEquals("org.openmrs.Order", ot.getJavaClassName()); + Assertions.assertEquals("OT name", ot.getName()); + Assertions.assertEquals("org.openmrs.Order", ot.getJavaClassName()); } public void fill_shouldHandleMissingHeaders() { @@ -64,7 +64,7 @@ public void fill_shouldHandleMissingHeaders() { OrderType ot = p.fill(new OrderType(), new CsvLine(headerLine, line)); // Verif - Assert.assertNull(ot.getName()); - Assert.assertNull(ot.getJavaClassName()); + Assertions.assertNull(ot.getName()); + Assertions.assertNull(ot.getJavaClassName()); } } diff --git a/api/src/test/java/org/openmrs/module/initializer/api/pat/PersonAttributeTypeLineProcessorTest.java b/api/src/test/java/org/openmrs/module/initializer/api/pat/PersonAttributeTypeLineProcessorTest.java index 79473563b..1238b6ae5 100644 --- a/api/src/test/java/org/openmrs/module/initializer/api/pat/PersonAttributeTypeLineProcessorTest.java +++ b/api/src/test/java/org/openmrs/module/initializer/api/pat/PersonAttributeTypeLineProcessorTest.java @@ -1,12 +1,12 @@ package org.openmrs.module.initializer.api.pat; -import static org.mockito.Matchers.any; +import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.mockito.invocation.InvocationOnMock; import org.mockito.stubbing.Answer; import org.openmrs.PersonAttributeType; @@ -24,7 +24,7 @@ public class PersonAttributeTypeLineProcessorTest { private Helper helper = mock(Helper.class); - @Before + @BeforeEach public void setup() { when(helper.getPrivilege(any(String.class))).thenAnswer(new Answer() { @@ -53,12 +53,12 @@ public void fill_shouldParsePersonAttributeType() { PersonAttributeType pat = p.fill(new PersonAttributeType(), new CsvLine(headerLine, line)); // Verif - Assert.assertEquals("PAT name", pat.getName()); - Assert.assertEquals("PAT desc.", pat.getDescription()); - Assert.assertEquals("org.openmrs.Concept", pat.getFormat()); - Assert.assertTrue(pat.isSearchable()); - Assert.assertEquals("Edit Privilege", pat.getEditPrivilege().getName()); - Assert.assertEquals("Privilege desc.", pat.getEditPrivilege().getDescription()); + Assertions.assertEquals("PAT name", pat.getName()); + Assertions.assertEquals("PAT desc.", pat.getDescription()); + Assertions.assertEquals("org.openmrs.Concept", pat.getFormat()); + Assertions.assertTrue(pat.isSearchable()); + Assertions.assertEquals("Edit Privilege", pat.getEditPrivilege().getName()); + Assertions.assertEquals("Privilege desc.", pat.getEditPrivilege().getDescription()); } @Test @@ -74,8 +74,8 @@ public void fill_shouldParseWithNameAndFormatOnly() { PersonAttributeType pat = p.fill(new PersonAttributeType(), new CsvLine(headerLine, line)); // Verif - Assert.assertEquals("PAT name", pat.getName()); - Assert.assertEquals("java.lang.String", pat.getFormat()); + Assertions.assertEquals("PAT name", pat.getName()); + Assertions.assertEquals("java.lang.String", pat.getFormat()); } public void fill_shouldHandleMissingHeaders() { @@ -90,7 +90,7 @@ public void fill_shouldHandleMissingHeaders() { PersonAttributeType pat = p.fill(new PersonAttributeType(), new CsvLine(headerLine, line)); // Verif - Assert.assertNull(pat.getName()); - Assert.assertNull(pat.getFormat()); + Assertions.assertNull(pat.getName()); + Assertions.assertNull(pat.getFormat()); } } diff --git a/api/src/test/java/org/openmrs/module/initializer/api/patientflags/FlagsLoaderIntegrationTest.java b/api/src/test/java/org/openmrs/module/initializer/api/patientflags/FlagsLoaderIntegrationTest.java index 5c5d63e22..5ea992d8b 100644 --- a/api/src/test/java/org/openmrs/module/initializer/api/patientflags/FlagsLoaderIntegrationTest.java +++ b/api/src/test/java/org/openmrs/module/initializer/api/patientflags/FlagsLoaderIntegrationTest.java @@ -1,11 +1,11 @@ package org.openmrs.module.initializer.api.patientflags; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.openmrs.module.patientflags.Flag; import org.openmrs.module.patientflags.Priority; import org.openmrs.module.patientflags.Tag; @@ -23,7 +23,7 @@ public class FlagsLoaderIntegrationTest extends DomainBaseModuleContextSensitive @Autowired private FlagsLoader loader; - @Before + @BeforeEach public void setup() throws Exception { executeDataSet("testdata/test-concepts.xml"); diff --git a/api/src/test/java/org/openmrs/module/initializer/api/patientflags/PrioritiesLoaderIntegrationTest.java b/api/src/test/java/org/openmrs/module/initializer/api/patientflags/PrioritiesLoaderIntegrationTest.java index 8545c2d59..ace273e49 100644 --- a/api/src/test/java/org/openmrs/module/initializer/api/patientflags/PrioritiesLoaderIntegrationTest.java +++ b/api/src/test/java/org/openmrs/module/initializer/api/patientflags/PrioritiesLoaderIntegrationTest.java @@ -1,11 +1,11 @@ package org.openmrs.module.initializer.api.patientflags; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.openmrs.module.patientflags.Priority; import org.openmrs.module.patientflags.api.FlagService; import org.openmrs.module.initializer.DomainBaseModuleContextSensitiveTest; @@ -21,7 +21,7 @@ public class PrioritiesLoaderIntegrationTest extends DomainBaseModuleContextSens @Autowired private PrioritiesLoader loader; - @Before + @BeforeEach public void setup() throws Exception { executeDataSet("testdata/test-concepts.xml"); diff --git a/api/src/test/java/org/openmrs/module/initializer/api/patientflags/TagsLoaderIntegrationTest.java b/api/src/test/java/org/openmrs/module/initializer/api/patientflags/TagsLoaderIntegrationTest.java index f06c93f37..0a80c79fa 100644 --- a/api/src/test/java/org/openmrs/module/initializer/api/patientflags/TagsLoaderIntegrationTest.java +++ b/api/src/test/java/org/openmrs/module/initializer/api/patientflags/TagsLoaderIntegrationTest.java @@ -1,11 +1,11 @@ package org.openmrs.module.initializer.api.patientflags; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.openmrs.Role; import org.openmrs.api.UserService; import org.openmrs.module.patientflags.DisplayPoint; @@ -28,7 +28,7 @@ public class TagsLoaderIntegrationTest extends DomainBaseModuleContextSensitiveT @Autowired private TagsLoader loader; - @Before + @BeforeEach public void setup() throws Exception { executeDataSet("testdata/test-concepts.xml"); diff --git a/api/src/test/java/org/openmrs/module/initializer/api/systemtasks/SystemTasksCsvParserTest.java b/api/src/test/java/org/openmrs/module/initializer/api/systemtasks/SystemTasksCsvParserTest.java index c1b73d23f..5c29290c4 100644 --- a/api/src/test/java/org/openmrs/module/initializer/api/systemtasks/SystemTasksCsvParserTest.java +++ b/api/src/test/java/org/openmrs/module/initializer/api/systemtasks/SystemTasksCsvParserTest.java @@ -1,9 +1,10 @@ package org.openmrs.module.initializer.api.systemtasks; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.openmrs.module.initializer.Domain; import org.openmrs.module.initializer.api.CsvLine; import org.openmrs.module.tasks.SystemTask; @@ -36,15 +37,18 @@ public void bootstrap_shouldCreateNewSystemTaskWithUuid() { assertEquals("550e8400-e29b-41d4-a716-446655440001", task.getUuid()); } - @Test(expected = IllegalArgumentException.class) + @Test public void bootstrap_shouldThrowExceptionWhenUuidIsMissing() { - SystemTasksCsvParser parser = new TestableSystemTasksCsvParser(); - - String[] headerLine = { "Uuid", "Name", "Title" }; - String[] line = { "", "test-task", "Test Task" }; - CsvLine csvLine = new CsvLine(headerLine, line); - - parser.bootstrap(csvLine); + assertThrows(IllegalArgumentException.class, () -> { + SystemTasksCsvParser parser = new TestableSystemTasksCsvParser(); + + String[] headerLine = { "Uuid", "Name", "Title" }; + String[] line = { "", "test-task", "Test Task" }; + CsvLine csvLine = new CsvLine(headerLine, line); + + parser.bootstrap(csvLine); + + }); } /** diff --git a/api/src/test/java/org/openmrs/module/initializer/api/systemtasks/SystemTasksLineProcessorTest.java b/api/src/test/java/org/openmrs/module/initializer/api/systemtasks/SystemTasksLineProcessorTest.java index 7efe41782..9bf3a1bdb 100644 --- a/api/src/test/java/org/openmrs/module/initializer/api/systemtasks/SystemTasksLineProcessorTest.java +++ b/api/src/test/java/org/openmrs/module/initializer/api/systemtasks/SystemTasksLineProcessorTest.java @@ -1,9 +1,9 @@ package org.openmrs.module.initializer.api.systemtasks; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNull; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNull; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.openmrs.module.initializer.api.CsvLine; import org.openmrs.module.tasks.Priority; import org.openmrs.module.tasks.SystemTask; diff --git a/api/src/test/java/org/openmrs/module/initializer/liquibase/DeleteDomainChecksumsChangesetIntegrationTest.java b/api/src/test/java/org/openmrs/module/initializer/liquibase/DeleteDomainChecksumsChangesetIntegrationTest.java index c95bf0d31..7252b8762 100644 --- a/api/src/test/java/org/openmrs/module/initializer/liquibase/DeleteDomainChecksumsChangesetIntegrationTest.java +++ b/api/src/test/java/org/openmrs/module/initializer/liquibase/DeleteDomainChecksumsChangesetIntegrationTest.java @@ -1,13 +1,14 @@ package org.openmrs.module.initializer.liquibase; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; import java.io.File; import java.util.Arrays; -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.module.initializer.Domain; import org.openmrs.module.initializer.DomainBaseModuleContextSensitiveTest; import org.openmrs.module.initializer.api.InitializerService; @@ -18,7 +19,7 @@ import liquibase.database.Database; import liquibase.database.DatabaseFactory; import liquibase.database.jvm.JdbcConnection; -import liquibase.resource.ClassLoaderResourceAccessor; +import liquibase.resource.DirectoryResourceAccessor; public class DeleteDomainChecksumsChangesetIntegrationTest extends DomainBaseModuleContextSensitiveTest { @@ -30,11 +31,18 @@ public class DeleteDomainChecksumsChangesetIntegrationTest extends DomainBaseMod @Autowired private InitializerService service; - @Before + @BeforeEach public void setup() throws Exception { loader.load(); } + @AfterEach + public void deleteCommittedData() { + // The changeset commits the test's transaction, so without this the concepts loaded in setup would outlive the + // rollback and collide with the datasets of the test classes that run after this one + deleteAllData(); + } + @Test public void shouldSuccessfullyDeleteSpecifiedDomainChecksums() throws Exception { // setup @@ -61,6 +69,9 @@ private Liquibase getLiquibase(String filename) throws Exception { liquibaseConnection.setDatabaseChangeLogTableName("LIQUIBASECHANGELOG_1"); liquibaseConnection.setDatabaseChangeLogLockTableName("LIQUIBASECHANGELOGLOCK_1"); - return new Liquibase(filename, new ClassLoaderResourceAccessor(getClass().getClassLoader()), liquibaseConnection); + // Liquibase 4 rejects a changelog path found more than once on the classpath, and every module API jar on the + // test classpath ships a liquibase.xml, so only Initializer's own resources directory is made accessible + File resourcesDir = new File(getClass().getClassLoader().getResource(filename).toURI()).getParentFile(); + return new Liquibase(filename, new DirectoryResourceAccessor(resourcesDir), liquibaseConnection); } } diff --git a/api/src/test/resources/test-hibernate.cfg.xml b/api/src/test/resources/test-hibernate.cfg.xml index f49a1d7a0..8c610aed2 100644 --- a/api/src/test/resources/test-hibernate.cfg.xml +++ b/api/src/test/resources/test-hibernate.cfg.xml @@ -5,14 +5,6 @@ - - - - - - - - @@ -20,26 +12,11 @@ - - - - - - - - - - - - - - - diff --git a/api/src/test/resources/testdata/test-concepts-numeric.xml b/api/src/test/resources/testdata/test-concepts-numeric.xml index 137804b6e..112044286 100644 --- a/api/src/test/resources/testdata/test-concepts-numeric.xml +++ b/api/src/test/resources/testdata/test-concepts-numeric.xml @@ -1,7 +1,7 @@ - - + + \ No newline at end of file diff --git a/api/src/test/resources/testdata/test-metadata.xml b/api/src/test/resources/testdata/test-metadata.xml index ff11b5de6..73e432e43 100644 --- a/api/src/test/resources/testdata/test-metadata.xml +++ b/api/src/test/resources/testdata/test-metadata.xml @@ -1,15 +1,6 @@ - - - - - - - - - @@ -38,9 +29,9 @@ - - - + + + diff --git a/omod/pom.xml b/omod/pom.xml index 1cf4c1e8d..bb486c8ac 100644 --- a/omod/pom.xml +++ b/omod/pom.xml @@ -4,7 +4,7 @@ org.openmrs.module initializer - 2.13.0-SNAPSHOT + 3.0.0-SNAPSHOT initializer-omod diff --git a/omod/src/main/java/org/openmrs/module/initializer/web/controller/InitializerController.java b/omod/src/main/java/org/openmrs/module/initializer/web/controller/InitializerController.java index d00d76acd..9cb11d405 100644 --- a/omod/src/main/java/org/openmrs/module/initializer/web/controller/InitializerController.java +++ b/omod/src/main/java/org/openmrs/module/initializer/web/controller/InitializerController.java @@ -11,7 +11,7 @@ import java.util.List; -import javax.servlet.http.HttpSession; +import jakarta.servlet.http.HttpSession; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; diff --git a/pom.xml b/pom.xml index e45ca39b4..c4f30358a 100644 --- a/pom.xml +++ b/pom.xml @@ -13,7 +13,7 @@ org.openmrs.module initializer - 2.13.0-SNAPSHOT + 3.0.0-SNAPSHOT pom Initializer The OpenMRS Initializer module is an API-only module that processes the content of the configuration folder when it is found inside OpenMRS' application data directory. @@ -57,30 +57,23 @@ - 2.1.1 - 2.2.0 - 2.3.6 - 2.4.5 - 2.5.5 - 2.7.8 - 2.8.0 - - ${openmrsVersion2.1} + 3.0.0-SNAPSHOT + 21 1.2.1 1.1.0 0.93-1.1.0 - 3.5.0 + 5.0.0-SNAPSHOT 2.0.0 4.0.0 - 4.6.0 + 7.0.0-SNAPSHOT 1.2.2 - 1.3.4 + 3.0.0-SNAPSHOT 2.4.0 - 1.6.0 + 6.0.0-SNAPSHOT 1.1.0 - 2.0.2 + 4.0.0-SNAPSHOT 3.0.9 @@ -110,25 +103,6 @@ jar - - - junit - junit - 4.13.1 - test - - - org.powermock - powermock-api-mockito - 1.6.1 - test - - - org.powermock - powermock-module-junit4 - 1.6.1 - test - org.openmrs.api openmrs-api @@ -209,6 +183,13 @@ htmlformentry-api ${htmlformentryVersion} provided + + + + org.junit.vintage + junit-vintage-engine + + @@ -271,20 +252,6 @@ provided - - org.openmrs.module - fhir2-api-2.1 - ${fhir2Version} - provided - - - - org.openmrs.module - fhir2-api-2.2 - ${fhir2Version} - provided - - org.openmrs.module @@ -321,18 +288,60 @@ test - - - javax.annotation - javax.annotation-api - 1.3.2 - provided - - + + org.openmrs + openmrs-bom + ${openmrsPlatformVersion} + pom + import + + + + junit + junit + 4.13.2 + + + org.hamcrest + hamcrest-core + 3.0 + + + org.hamcrest + hamcrest-library + 2.2 + + + org.mockito + mockito-core + 5.24.0 + + + org.powermock + powermock-module-junit4 + 1.5 + + + * + * + + + + + org.powermock + powermock-api-mockito + 1.5 + + + * + * + + + org.openmrs.module openconceptlab-api @@ -347,10 +356,20 @@ org.apache.maven.plugins maven-compiler-plugin - 3.8.1 + 3.15.0 + + ${maven.compiler.release} + + + + org.apache.maven.plugins + maven-surefire-plugin - 1.8 - 1.8 + + + org.powermock:powermock-module-junit4 + org.powermock:powermock-api-mockito + @@ -386,7 +405,8 @@ org.openmrs.tools openmrs-tools - ${openmrsPlatformVersion} + + 2.1.1 diff --git a/readme/validator.md b/readme/validator.md index f8872d75f..8f272be39 100644 --- a/readme/validator.md +++ b/readme/validator.md @@ -1,5 +1,7 @@ ## Initializer Validator +**Note**: The validator has not been ported to OpenMRS Core 3.0 yet, so it is only available for Initializer 2.x. Build it from a 2.x release such as [2.12.1](https://github.com/mekomsolutions/openmrs-module-initializer/tree/2.12.1). + ### In a nutshell The Initializer Validator is a standalone fatjar to make dry runs of your OpenMRS configs and to report on any errors. This enables developers and implementers to be warned well ahead of time that a config would fail when loaded on _real_ OpenMRS instances. diff --git a/validator-first-dependency/pom.xml b/validator-first-dependency/pom.xml index 7bf394bf2..c1fc12314 100644 --- a/validator-first-dependency/pom.xml +++ b/validator-first-dependency/pom.xml @@ -5,7 +5,7 @@ org.openmrs.module initializer - 2.13.0-SNAPSHOT + 3.0.0-SNAPSHOT initializer-validator-first-dependency diff --git a/validator/pom.xml b/validator/pom.xml index 75f2ff5ea..185d85cef 100644 --- a/validator/pom.xml +++ b/validator/pom.xml @@ -5,7 +5,7 @@ org.openmrs.module initializer - 2.13.0-SNAPSHOT + 3.0.0-SNAPSHOT initializer-validator