Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions omod/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,20 @@
</dependency>

<!-- End OpenMRS core -->

<!-- Force aligned JUnit Platform versions to match JUnit Jupiter 6.0.3 -->
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-suite-engine</artifactId>
<version>6.0.3</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-launcher</artifactId>
<version>6.0.3</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.openmrs.contrib</groupId>
Expand Down
12 changes: 6 additions & 6 deletions omod/src/test/java/org/openmrs/layout/AddressSupportTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@
import java.util.List;

import org.apache.commons.lang3.StringUtils;
import org.junit.Assert;
import org.junit.Test;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.openmrs.api.context.Context;
import org.openmrs.layout.address.AddressSupport;
import org.openmrs.layout.address.AddressTemplate;
import org.openmrs.test.Verifies;
import org.openmrs.util.OpenmrsConstants;
import org.openmrs.web.test.BaseModuleWebContextSensitiveTest;
import org.openmrs.web.test.jupiter.BaseModuleWebContextSensitiveTest;

public class AddressSupportTest extends BaseModuleWebContextSensitiveTest {

Expand All @@ -41,12 +41,12 @@ public void getAddressTemplate_shouldSucceedEvenIfDBAddressTemplateClassHasChang
//(in the 'web' package differs from the updated classname in the DB
String newAddressTemplateClass = "org.openmrs.layout.address.AddressTemplate";
String xml = Context.getAdministrationService().getGlobalProperty(OpenmrsConstants.GLOBAL_PROPERTY_ADDRESS_TEMPLATE);
Assert.assertTrue(StringUtils.contains(xml, newAddressTemplateClass));
Assert.assertEquals(newAddressTemplateClass, AddressTemplate.class.getName());
Assertions.assertTrue(StringUtils.contains(xml, newAddressTemplateClass));
Assertions.assertEquals(newAddressTemplateClass, AddressTemplate.class.getName());

AddressSupport addressSupport = AddressSupport.getInstance();
List<AddressTemplate> addressTemplates = addressSupport.getAddressTemplate();
Assert.assertNotNull(addressTemplates.get(0));
Assertions.assertNotNull(addressTemplates.get(0));
}

}
12 changes: 6 additions & 6 deletions omod/src/test/java/org/openmrs/layout/NameSupportTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
*/
package org.openmrs.layout;

import org.junit.Assert;
import org.junit.Test;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.openmrs.layout.name.NameSupport;
import org.openmrs.test.Verifies;
import org.openmrs.web.test.BaseModuleWebContextSensitiveTest;
import org.openmrs.web.test.jupiter.BaseModuleWebContextSensitiveTest;

public class NameSupportTest extends BaseModuleWebContextSensitiveTest {

Expand All @@ -28,10 +28,10 @@ public class NameSupportTest extends BaseModuleWebContextSensitiveTest {
@Verifies(value = "getInstance() should return a layout.web.name.NameSupport instance", method = "getInstance()")
public void getInstance_shouldFindNameSupportBean() throws Exception {
NameSupport nameSupport = NameSupport.getInstance();
Assert.assertNotNull(nameSupport);
Assert.assertNotNull(nameSupport.getDefaultLayoutFormat());
Assertions.assertNotNull(nameSupport);
Assertions.assertNotNull(nameSupport.getDefaultLayoutFormat());
//make sure that all 5 layout templates defined at the time of the package change continue to work
Assert.assertTrue(nameSupport.getLayoutTemplates().size() >= 5);
Assertions.assertTrue(nameSupport.getLayoutTemplates().size() >= 5);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
import java.util.Arrays;
import java.util.List;

import junit.framework.Assert;
import org.junit.jupiter.api.Assertions;

import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.openmrs.module.Module;

public class ModuleListControllerTest {
Expand All @@ -34,10 +34,10 @@ public void sortStartupOrder_shouldSortModulesCorrectly() throws Exception {

List<Module> list = new ModuleListController().sortStartupOrder(Arrays.asList(appframework, kenyaemr, kenyaemr,
uilibrary));
Assert.assertSame(uilibrary, list.get(0));
Assert.assertSame(appframework, list.get(1));
Assert.assertSame(kenyaemr, list.get(2));
Assert.assertSame(kenyaemr, list.get(3));
Assertions.assertSame(uilibrary, list.get(0));
Assertions.assertSame(appframework, list.get(1));
Assertions.assertSame(kenyaemr, list.get(2));
Assertions.assertSame(kenyaemr, list.get(3));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
*/
package org.openmrs.module.web.extension;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.mockStatic;
import static org.mockito.Mockito.when;
Expand All @@ -21,7 +21,7 @@
import java.util.List;
import java.util.Set;

import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.MockedStatic;
import org.mockito.junit.jupiter.MockitoExtension;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
*/
package org.openmrs.scheduler.web.controller;

import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;

import java.text.SimpleDateFormat;
import java.util.Calendar;
Expand All @@ -19,15 +19,15 @@
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;

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.scheduler.SchedulerService;
import org.openmrs.scheduler.Task;
import org.openmrs.scheduler.TaskDefinition;
import org.openmrs.test.Verifies;
import org.openmrs.web.test.BaseModuleWebContextSensitiveTest;
import org.openmrs.web.test.jupiter.BaseModuleWebContextSensitiveTest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.mock.web.MockHttpServletRequest;
import org.springframework.mock.web.MockHttpServletResponse;
Expand Down Expand Up @@ -56,7 +56,7 @@ public class SchedulerFormControllerTest extends BaseModuleWebContextSensitiveTe
// in applicationContext-service.xml at the time of coding (Jan 2013)
private SchedulerService service;

@Before
@BeforeEach
public void setUpSchedulerService() throws Exception {
executeDataSet(INITIAL_SCHEDULER_TASK_CONFIG_XML);

Expand Down Expand Up @@ -86,7 +86,7 @@ public void onSubmit_shouldRescheduleACurrentlyScheduledTask() throws Exception
assertNotNull(mav);
assertTrue(mav.getModel().isEmpty());

Assert.assertNotSame(oldTaskInstance, task.getTaskInstance());
Assertions.assertNotSame(oldTaskInstance, task.getTaskInstance());
}

/**
Expand All @@ -106,7 +106,7 @@ public void onSubmit_shouldNotRescheduleATaskThatIsNotCurrentlyScheduled() throw
assertNotNull(mav);
assertTrue(mav.getModel().isEmpty());

Assert.assertSame(oldTaskInstance, task.getTaskInstance());
Assertions.assertSame(oldTaskInstance, task.getTaskInstance());
}

/**
Expand All @@ -126,7 +126,7 @@ public void onSubmit_shouldNotRescheduleATaskIfTheStartTimeHasPassed() throws Ex
assertNotNull(mav);
assertTrue(mav.getModel().isEmpty());

Assert.assertSame(oldTaskInstance, task.getTaskInstance());
Assertions.assertSame(oldTaskInstance, task.getTaskInstance());
}

/**
Expand All @@ -148,7 +148,7 @@ public void onSubmit_shouldNotRescheduleAnExecutingTask() throws Exception {
assertNotNull(mav);
assertTrue(mav.getModel().isEmpty());

Assert.assertSame(oldTaskInstance, task.getTaskInstance());
Assertions.assertSame(oldTaskInstance, task.getTaskInstance());
deleteAllData();
}

Expand All @@ -167,9 +167,9 @@ public void processFormSubmission_shouldNotThrowNullPointerExceptionIfRepeatInte

ModelAndView mav = controller.handleRequest(mockRequest, new MockHttpServletResponse());
assertNotNull(mav);
Assert.assertNotNull(task.getRepeatInterval());
Assertions.assertNotNull(task.getRepeatInterval());
Long interval = 0L;
Assert.assertEquals(interval, task.getRepeatInterval());
Assertions.assertEquals(interval, task.getRepeatInterval());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@
*/
package org.openmrs.scheduler.web.controller;

import static org.junit.Assert.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertNotNull;

import jakarta.servlet.http.HttpServletRequest;

import org.junit.Test;
import org.openmrs.web.test.BaseModuleWebContextSensitiveTest;
import org.junit.jupiter.api.Test;
import org.openmrs.web.test.jupiter.BaseModuleWebContextSensitiveTest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.mock.web.MockHttpServletRequest;
import org.springframework.mock.web.MockHttpServletResponse;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@
import java.util.Date;
import java.util.concurrent.TimeoutException;

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.scheduler.SchedulerException;
import org.openmrs.scheduler.SchedulerService;
import org.openmrs.scheduler.TaskDefinition;
import org.openmrs.web.test.BaseModuleWebContextSensitiveTest;
import org.openmrs.web.test.jupiter.BaseModuleWebContextSensitiveTest;

public class TaskHelperTest extends BaseModuleWebContextSensitiveTest {

Expand All @@ -32,7 +32,7 @@ public class TaskHelperTest extends BaseModuleWebContextSensitiveTest {

private TaskHelper taskHelper;

@Before
@BeforeEach
public void setUp() throws Exception {
executeDataSet(INITIAL_SCHEDULER_TASK_CONFIG_XML);

Expand All @@ -47,7 +47,7 @@ public void setUp() throws Exception {
@Test
public void getTime_shouldGetATimeInTheFuture() throws Exception {
Date then = taskHelper.getTime(Calendar.SECOND, 123);
Assert.assertTrue(then.after(new Date()));
Assertions.assertTrue(then.after(new Date()));
}

/**
Expand All @@ -57,7 +57,7 @@ public void getTime_shouldGetATimeInTheFuture() throws Exception {
@Test
public void getTime_shouldGetATimeInThePast() throws Exception {
Date then = taskHelper.getTime(Calendar.SECOND, -123);
Assert.assertTrue(then.before(new Date()));
Assertions.assertTrue(then.before(new Date()));
}

/**
Expand All @@ -68,7 +68,7 @@ public void getTime_shouldGetATimeInThePast() throws Exception {
public void getScheduledTaskDefinition_shouldReturnATaskThatHasBeenStarted() throws Exception {
Date time = taskHelper.getTime(Calendar.SECOND, 1);
TaskDefinition task = taskHelper.getScheduledTaskDefinition(time);
Assert.assertTrue(task.getStarted());
Assertions.assertTrue(task.getStarted());
}

/**
Expand All @@ -79,7 +79,7 @@ public void getScheduledTaskDefinition_shouldReturnATaskThatHasBeenStarted() thr
public void getUnscheduledTaskDefinition_shouldReturnATaskThatHasNotBeenStarted() throws Exception {
Date time = taskHelper.getTime(Calendar.SECOND, 1);
TaskDefinition task = taskHelper.getUnscheduledTaskDefinition(time);
Assert.assertFalse(task.getStarted());
Assertions.assertFalse(task.getStarted());
}

/**
Expand All @@ -92,19 +92,21 @@ public void waitUntilTaskIsExecuting_shouldWaitUntilTaskIsExecuting() throws Exc
TaskDefinition task = taskHelper.getScheduledTaskDefinition(time);
taskHelper.waitUntilTaskIsExecuting(task, MAX_WAIT_TIME_IN_MILLISECONDS);

Assert.assertTrue(task.getTaskInstance().isExecuting());
Assertions.assertTrue(task.getTaskInstance().isExecuting());
deleteAllData();
}

/**
* @verifies raise a timeout exception when the timeout is exceeded
* @see TaskHelper#waitUntilTaskIsExecuting(org.openmrs.scheduler.TaskDefinition, long)
*/
@Test(expected = TimeoutException.class)
@Test
public void waitUntilTaskIsExecuting_shouldRaiseATimeoutExceptionWhenTheTimeoutIsExceeded() throws SchedulerException,
TimeoutException, InterruptedException {
Date time = taskHelper.getTime(Calendar.MINUTE, 1);
TaskDefinition task = taskHelper.getScheduledTaskDefinition(time);
taskHelper.waitUntilTaskIsExecuting(task, 10);
InterruptedException {
Assertions.assertThrows(TimeoutException.class, () -> {
Date time = taskHelper.getTime(Calendar.MINUTE, 1);
TaskDefinition task = taskHelper.getScheduledTaskDefinition(time);
taskHelper.waitUntilTaskIsExecuting(task, 10);
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@
*/
package org.openmrs.web.attribute.handler;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.eq;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;

import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.openmrs.Location;
import org.openmrs.customdatatype.CustomDatatype;
import org.openmrs.customdatatype.datatype.MockLocationDatatype;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,15 @@
*/
package org.openmrs.web.attribute.handler;

import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.is;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertThat;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.hamcrest.MatcherAssert.assertThat;

import jakarta.servlet.http.HttpServletRequest;

import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.junit.jupiter.api.Test;
import org.openmrs.customdatatype.CustomDatatype;
import org.openmrs.customdatatype.InvalidCustomValueException;
import org.openmrs.customdatatype.datatype.RegexValidatedTextDatatype;
Expand All @@ -29,9 +28,6 @@
*/
public class RegexValidatedTextDatatypeHandlerTest {

@Rule
public ExpectedException expectedException = ExpectedException.none();

private final RegexValidatedTextDatatypeHandler handler = new RegexValidatedTextDatatypeHandler();

/**
Expand Down Expand Up @@ -71,9 +67,9 @@ public void getValue_shouldThrowInvalidCustomValueExceptionIfAttributeValueFromR
RegexValidatedTextDatatype datatype = new RegexValidatedTextDatatype();
datatype.setConfiguration("^[012]$");

expectedException.expect(InvalidCustomValueException.class);
expectedException.expectMessage("Invalid value: " + invalidFieldValue);
handler.getValue(datatype, request, fieldName);
InvalidCustomValueException ex = org.junit.jupiter.api.Assertions.assertThrows(InvalidCustomValueException.class,
() -> handler.getValue(datatype, request, fieldName));
assertThat(ex.getMessage(), containsString("Invalid value: " + invalidFieldValue));
}

/**
Expand Down
Loading