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