Skip to content

Commit

Permalink
Replace JUnit 4 with JUnit Jupiter
Browse files Browse the repository at this point in the history
  • Loading branch information
filiphr committed Dec 13, 2024
1 parent e611059 commit 5a2febf
Show file tree
Hide file tree
Showing 18 changed files with 84 additions and 85 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,33 +14,28 @@

import static org.assertj.core.api.Assertions.assertThat;

import org.flowable.engine.impl.test.PluggableFlowableTestCase;
import org.flowable.engine.runtime.ProcessInstance;
import org.flowable.engine.test.Deployment;
import org.flowable.engine.test.FlowableRule;
import org.junit.Rule;
import org.junit.Test;

import org.junit.jupiter.api.Test;

/**
* Testcase for error in method 'propagateError' of class
* 'org.flowable.engine.impl.bpmn.helper.ErrorPropagation'.
*
* @author Fritsche
*/
public class ErrorPropagationTest {

@Rule
public FlowableRule flowableRule = new FlowableRule();
public class ErrorPropagationTest extends PluggableFlowableTestCase {

@Test
@Deployment(resources = { "org/flowable/engine/test/bpmn/event/error/catchError3.bpmn",
"org/flowable/engine/test/bpmn/event/error/catchError4.bpmn",
"org/flowable/engine/test/bpmn/event/error/throwError.bpmn" })
public void test() {
ProcessInstance processInstance = flowableRule.getRuntimeService().startProcessInstanceByKey("catchError4");
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("catchError4");
assertThat(processInstance).isNotNull();

final org.flowable.task.api.Task task = flowableRule.getTaskService().createTaskQuery().singleResult();
final org.flowable.task.api.Task task = taskService.createTaskQuery().singleResult();

assertThat(task.getName()).isEqualTo("MyErrorTaskNested");
}
Expand Down
6 changes: 3 additions & 3 deletions modules/flowable-jmx/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<dependencies>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<artifactId>mockito-junit-jupiter</artifactId>
<scope>test</scope>
</dependency>

Expand All @@ -33,8 +33,8 @@
</dependency>
<!-- Testing -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,16 @@
import javax.management.ObjectName;
import javax.management.modelmbean.RequiredModelMBean;

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.mockito.junit.jupiter.MockitoSettings;
import org.mockito.quality.Strictness;

/**
* @author Saeid Mirzaei
*/

@MockitoSettings(strictness = Strictness.LENIENT)
public class DefaultManagementAgentTest {

@Mock
Expand All @@ -49,9 +50,8 @@ public class DefaultManagementAgentTest {
ObjectName registeredObjectName;
ManagementAgent agent;

@Before
@BeforeEach
public void initMocks() throws MalformedObjectNameException {
MockitoAnnotations.initMocks(this);
sourceObjectName = new ObjectName("domain", "key", "value");
registeredObjectName = new ObjectName("domain", "key", "otherValue");
JMXConfigurator jmxConfigurator = new JMXConfigurator();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

import org.flowable.management.jmx.annotations.NotificationSenderAware;
import org.flowable.management.jmx.testMbeans.TestMbean;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.mockito.ArgumentCaptor;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
import org.flowable.engine.ProcessEngine;
import org.flowable.engine.ProcessEngineConfiguration;
import org.flowable.engine.RepositoryService;
import org.junit.Test;
import org.junit.jupiter.api.Test;

/**
* @author Saeid Mirzaei
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import javax.management.remote.JMXServiceURL;

import org.flowable.engine.ProcessEngineConfiguration;
import org.junit.Test;
import org.junit.jupiter.api.Test;

/**
* @author Saeid Mirzaei
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
package org.flowable.management.jmx;

import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;

import javax.management.JMException;
import javax.management.MBeanAttributeInfo;
Expand All @@ -28,7 +29,7 @@
import org.flowable.management.jmx.testMbeans.BadInherited;
import org.flowable.management.jmx.testMbeans.NotManagedMBean;
import org.flowable.management.jmx.testMbeans.TestMbean;
import org.junit.Test;
import org.junit.jupiter.api.Test;

/**
* @author Saeid Mirzaei
Expand Down Expand Up @@ -89,35 +90,41 @@ public void testReadAttributeInfoHappyPath() throws JMException {
assertThat(beanInfo.getOperations()).hasSize(3);
}

@Test(expected = IllegalArgumentException.class)
public void testAttributeGetterNameNotCapitial() throws JMException {
mbeanInfoAssembler.getMBeanInfo(new BadAttributeGetterNameNotCapital(), null, "someName");
@Test
public void testAttributeGetterNameNotCapitial() {
assertThatThrownBy(() -> mbeanInfoAssembler.getMBeanInfo(new BadAttributeGetterNameNotCapital(), null, "someName"))
.isInstanceOf(IllegalArgumentException.class);

}

@Test(expected = IllegalArgumentException.class)
public void testAttributePOJONamingNoGetter() throws JMException {
mbeanInfoAssembler.getMBeanInfo(new BadAttributeNameNoGetterSetter(), null, "someName");
@Test
public void testAttributePOJONamingNoGetter() {
assertThatThrownBy(() -> mbeanInfoAssembler.getMBeanInfo(new BadAttributeNameNoGetterSetter(), null, "someName"))
.isInstanceOf(IllegalArgumentException.class);
}

@Test(expected = IllegalArgumentException.class)
public void testAttributeSetterNameNotCapitial() throws JMException {
mbeanInfoAssembler.getMBeanInfo(new BadAttributeSetterNameNotCapital(), null, "someName");
@Test
public void testAttributeSetterNameNotCapitial() {
assertThatThrownBy(() -> mbeanInfoAssembler.getMBeanInfo(new BadAttributeSetterNameNotCapital(), null, "someName"))
.isInstanceOf(IllegalArgumentException.class);
}

@Test(expected = IllegalArgumentException.class)
public void testAttributeHavingParameter() throws JMException {
mbeanInfoAssembler.getMBeanInfo(new BadAttributeGetterHavinParameter(), null, "someName");
@Test
public void testAttributeHavingParameter() {
assertThatThrownBy(() -> mbeanInfoAssembler.getMBeanInfo(new BadAttributeGetterHavinParameter(), null, "someName"))
.isInstanceOf(IllegalArgumentException.class);
}

@Test(expected = IllegalArgumentException.class)
public void testAttributeSetterHavingResult() throws JMException {
mbeanInfoAssembler.getMBeanInfo(new BadAttributeSetterHavinReturn(), null, "someName");
@Test
public void testAttributeSetterHavingResult() {
assertThatThrownBy(() -> mbeanInfoAssembler.getMBeanInfo(new BadAttributeSetterHavinReturn(), null, "someName"))
.isInstanceOf(IllegalArgumentException.class);
}

@Test(expected = IllegalArgumentException.class)
public void testAttributeVoid() throws JMException {
mbeanInfoAssembler.getMBeanInfo(new BadAttributeVoid(), null, "someName");
@Test
public void testAttributeVoid() {
assertThatThrownBy(() -> mbeanInfoAssembler.getMBeanInfo(new BadAttributeVoid(), null, "someName"))
.isInstanceOf(IllegalArgumentException.class);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,15 @@
import org.flowable.job.service.impl.asyncexecutor.AsyncExecutor;
import org.flowable.management.jmx.DefaultManagementMBeanAssembler;
import org.flowable.management.jmx.ManagementMBeanAssembler;
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.mockito.junit.jupiter.MockitoSettings;

/**
* @author Saeid Mirzaei
*/

@MockitoSettings
public class JobExecutorMBeanTest {

protected JobExecutorMBean jobExecutorMbean;
Expand All @@ -48,9 +48,8 @@ public class JobExecutorMBeanTest {
@Mock
protected AsyncExecutor jobExecutor;

@Before
@BeforeEach
public void initMocks() throws MalformedObjectNameException {
MockitoAnnotations.initMocks(this);
when(processEngineConfiguration.getAsyncExecutor()).thenReturn(jobExecutor);
jobExecutorMbean = new JobExecutorMBean(processEngineConfiguration);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,16 @@
import org.flowable.engine.repository.ProcessDefinitionQuery;
import org.flowable.management.jmx.DefaultManagementMBeanAssembler;
import org.flowable.management.jmx.ManagementMBeanAssembler;
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.mockito.junit.jupiter.MockitoSettings;

/**
* @author Saeid Mirzaei
*/

@MockitoSettings
public class ProcessDefinitionsTest {

protected ProcessDefinitionsMBean processDefinitionsMBean;
Expand All @@ -71,9 +72,8 @@ public class ProcessDefinitionsTest {

protected ManagementMBeanAssembler assembler = new DefaultManagementMBeanAssembler();

@Before
@BeforeEach
public void initMocks() throws MalformedObjectNameException {
MockitoAnnotations.initMocks(this);
when(processEngineConfiguration.getRepositoryService()).thenReturn(repositoryService);
processDefinitionsMBean = new ProcessDefinitionsMBean(processEngineConfiguration);
}
Expand Down
4 changes: 2 additions & 2 deletions modules/flowable-secure-javascript/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
import org.flowable.engine.repository.Deployment;
import org.flowable.scripting.secure.SecureJavascriptConfigurator;
import org.flowable.scripting.secure.impl.SecureScriptClassShutter;
import org.junit.After;
import org.junit.Before;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;

/**
* @author Joram Barrez
Expand All @@ -46,7 +46,7 @@ public int getNumber(){
}
}

@Before
@BeforeEach
public void initProcessEngine() {

SecureJavascriptConfigurator configurator = new SecureJavascriptConfigurator()
Expand All @@ -70,7 +70,7 @@ public void initProcessEngine() {
this.taskService = processEngine.getTaskService();
}

@After
@AfterEach
public void shutdownProcessEngine() {

for (Deployment deployment : repositoryService.createDeploymentQuery().list()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import org.flowable.engine.impl.persistence.entity.ExecutionEntityImpl;
import org.flowable.engine.runtime.ProcessInstance;
import org.flowable.task.api.Task;
import org.junit.Test;
import org.junit.jupiter.api.Test;

/**
* @author Joram Barrez
Expand Down
2 changes: 1 addition & 1 deletion modules/flowable-spring/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<artifactId>mockito-junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import org.flowable.engine.repository.Deployment;
import org.flowable.engine.repository.DeploymentBuilder;
import org.junit.Before;
import org.junit.jupiter.api.BeforeEach;
import org.mockito.Mock;
import org.springframework.core.io.ByteArrayResource;
import org.springframework.core.io.ContextResource;
Expand Down Expand Up @@ -87,7 +88,7 @@ public class AbstractAutoDeploymentStrategyTest {
protected final String resourceName4 = "/opt/processes/resourceName4.zip";
protected final String resourceName5 = "/opt/processes/resourceName5.jar";

@Before
@BeforeEach
public void before() throws Exception {

when(processEngineMock.getRepositoryService()).thenReturn(repositoryServiceMock);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,22 +26,22 @@
import java.util.zip.ZipInputStream;

import org.flowable.spring.configurator.DefaultAutoDeploymentStrategy;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.junit.MockitoJUnitRunner;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.mockito.junit.jupiter.MockitoSettings;
import org.mockito.quality.Strictness;
import org.springframework.core.io.Resource;

/**
* @author Tiese Barrell
*/
@RunWith(MockitoJUnitRunner.Silent.class)
@MockitoSettings(strictness = Strictness.LENIENT)
public class DefaultAutoDeploymentStrategyTest extends AbstractAutoDeploymentStrategyTest {

private DefaultAutoDeploymentStrategy classUnderTest;

@Override
@Before
@BeforeEach
public void before() throws Exception {
super.before();
classUnderTest = new DefaultAutoDeploymentStrategy();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,17 @@
import java.util.zip.ZipInputStream;

import org.flowable.spring.configurator.ResourceParentFolderAutoDeploymentStrategy;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
import org.mockito.junit.jupiter.MockitoSettings;
import org.mockito.quality.Strictness;
import org.springframework.core.io.Resource;

/**
* @author Tiese Barrell
*/
@RunWith(MockitoJUnitRunner.class)
@MockitoSettings(strictness = Strictness.LENIENT)
public class ResourceParentFolderAutoDeploymentStrategyTest extends AbstractAutoDeploymentStrategyTest {

private ResourceParentFolderAutoDeploymentStrategy classUnderTest;
Expand All @@ -52,7 +52,7 @@ public class ResourceParentFolderAutoDeploymentStrategyTest extends AbstractAuto
private final String parentFilename2 = "parentFilename2";

@Override
@Before
@BeforeEach
public void before() throws Exception {
super.before();
classUnderTest = new ResourceParentFolderAutoDeploymentStrategy();
Expand Down
Loading

0 comments on commit 5a2febf

Please sign in to comment.