Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated test code to use latest JUnit5. #29

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
101 changes: 98 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,101 @@
.idea/
*.iml
**/target/*
.project
.settings

# Compiled class file
*.class

# Log file
*.log

# BlueJ files
*.ctxt

# Mobile Tools for Java (J2ME)
.mtj.tmp/

# Package Files #
*.jar
*.war
*.nar
*.ear
*.zip
*.tar.gz
*.rar

# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*
/.project

.metadata
bin/
tmp/
*.tmp
*.bak
*.swp
*~.nib
local.properties

# Maven
target/

# Eclipse Files
.settings/
.loadpath
.recommenders
.classpath
.project

# VSCode
.vscode/

# External tool builders
.externalToolBuilders/

# Locally stored "Eclipse launch configurations"
*.launch

# PyDev specific (Python IDE for Eclipse)
*.pydevproject

# CDT-specific (C/C++ Development Tooling)
.cproject

# CDT- autotools
.autotools

# Java annotation processor (APT)
.factorypath

# PDT-specific (PHP Development Tools)
.buildpath

# sbteclipse plugin
.target

# Tern plugin
.tern-project

# TeXlipse plugin
.texlipse

# STS (Spring Tool Suite)
.springBeans

# Code Recommenders
.recommenders/

# Annotation Processing
.apt_generated/
.apt_generated_test/

# Scala IDE specific (Scala & Java development for Eclipse)
.cache-main
.scala_dependencies
.worksheet

# Uncomment this line if you wish to ignore the project description file.
# Typically, this file would be tracked if it contains build/dependency configurations:
#.pr

# Maven artifact when using shade plugin
dependency-reduced-pom.xml
6 changes: 3 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<slf4j.version>1.7.30</slf4j.version>
<java.version>1.8</java.version>
<junit.version>4.13.1</junit.version>
<junit.version>5.9.2</junit.version>
<assertj.version>3.17.2</assertj.version>
<mockito.version>3.5.13</mockito.version>
<maven-release-plugin.version>2.5.3</maven-release-plugin.version>
Expand Down Expand Up @@ -78,8 +78,8 @@
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
Expand Down
10 changes: 5 additions & 5 deletions src/test/java/org/jeasy/flows/engine/WorkFlowEngineImplTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
import org.jeasy.flows.work.WorkReport;
import org.jeasy.flows.work.WorkStatus;
import org.jeasy.flows.workflow.*;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.mockito.Mockito;

import static org.assertj.core.api.Assertions.assertThat;
Expand All @@ -50,7 +50,7 @@ public class WorkFlowEngineImplTest {
private final WorkFlowEngine workFlowEngine = new WorkFlowEngineImpl();

@Test
public void run() {
void run() {
// given
WorkFlow workFlow = Mockito.mock(WorkFlow.class);
WorkContext workContext = Mockito.mock(WorkContext.class);
Expand All @@ -67,7 +67,7 @@ public void run() {
*/

@Test
public void composeWorkFlowFromSeparateFlowsAndExecuteIt() {
void composeWorkFlowFromSeparateFlowsAndExecuteIt() {

PrintMessageWork work1 = new PrintMessageWork("foo");
PrintMessageWork work2 = new PrintMessageWork("hello");
Expand Down Expand Up @@ -107,7 +107,7 @@ public void composeWorkFlowFromSeparateFlowsAndExecuteIt() {
}

@Test
public void defineWorkFlowInlineAndExecuteIt() {
void defineWorkFlowInlineAndExecuteIt() {

PrintMessageWork work1 = new PrintMessageWork("foo");
PrintMessageWork work2 = new PrintMessageWork("hello");
Expand Down Expand Up @@ -141,7 +141,7 @@ public void defineWorkFlowInlineAndExecuteIt() {
}

@Test
public void useWorkContextToPassInitialParametersAndShareDataBetweenWorkUnits() {
void useWorkContextToPassInitialParametersAndShareDataBetweenWorkUnits() {
WordCountWork work1 = new WordCountWork(1);
WordCountWork work2 = new WordCountWork(2);
AggregateWordCountsWork work3 = new AggregateWordCountsWork();
Expand Down
15 changes: 8 additions & 7 deletions src/test/java/org/jeasy/flows/work/NoOpWorkTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,23 +23,24 @@
*/
package org.jeasy.flows.work;

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

import org.assertj.core.api.Assertions;
import org.junit.Assert;
import org.junit.Test;
import org.junit.jupiter.api.Test;

public class NoOpWorkTest {

private final NoOpWork work = new NoOpWork();

@Test
public void getName() {
@Test
void getName() {
Assertions.assertThat(work.getName()).isNotNull();
}

@Test
public void testExecute() {
@Test
void testExecute() {
WorkReport workReport = work.execute(new WorkContext());
Assert.assertNotNull(workReport);
assertNotNull(workReport);
Assertions.assertThat(workReport.getStatus()).isEqualTo(WorkStatus.COMPLETED);

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@
import org.jeasy.flows.work.Work;
import org.jeasy.flows.work.WorkContext;
import org.jeasy.flows.work.WorkReportPredicate;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.mockito.Mockito;

public class ConditionalFlowTest {

@Test
public void callOnPredicateSuccess() {
void callOnPredicateSuccess() {
// given
Work toExecute = Mockito.mock(Work.class);
Work nextOnPredicateSuccess = Mockito.mock(Work.class);
Expand All @@ -57,7 +57,7 @@ public void callOnPredicateSuccess() {
}

@Test
public void callOnPredicateFailure() {
void callOnPredicateFailure() {
// given
Work toExecute = Mockito.mock(Work.class);
Work nextOnPredicateSuccess = Mockito.mock(Work.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
import org.jeasy.flows.work.WorkContext;
import org.jeasy.flows.work.WorkReport;
import org.jeasy.flows.work.WorkStatus;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.mockito.Mockito;

import java.util.Arrays;
Expand All @@ -40,7 +40,7 @@
public class ParallelFlowExecutorTest {

@Test
public void testExecute() {
void testExecute() {

// given
ExecutorService executorService = Executors.newFixedThreadPool(2);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@
import org.jeasy.flows.work.DefaultWorkReport;
import org.jeasy.flows.work.WorkContext;
import org.jeasy.flows.work.WorkStatus;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

public class ParallelFlowReportTest {

private Exception exception;
private ParallelFlowReport parallelFlowReport;

@Before
@BeforeEach
public void setUp() {
exception = new Exception("test exception");
WorkContext workContext = new WorkContext();
Expand All @@ -44,18 +44,18 @@ public void setUp() {
parallelFlowReport.add(new DefaultWorkReport(WorkStatus.COMPLETED, workContext));
}

@Test
public void testGetStatus() {
@Test
void testGetStatus() {
Assertions.assertThat(parallelFlowReport.getStatus()).isEqualTo(WorkStatus.FAILED);
}

@Test
public void testGetError() {
@Test
void testGetError() {
Assertions.assertThat(parallelFlowReport.getError()).isEqualTo(exception);
}

@Test
public void testGetReports() {
@Test
void testGetReports() {
Assertions.assertThat(parallelFlowReport.getReports()).hasSize(2);
}
}
4 changes: 2 additions & 2 deletions src/test/java/org/jeasy/flows/workflow/ParallelFlowTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
import org.assertj.core.api.Assertions;
import org.jeasy.flows.work.Work;
import org.jeasy.flows.work.WorkContext;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.mockito.Mockito;

import java.util.Arrays;
Expand All @@ -35,7 +35,7 @@
public class ParallelFlowTest {

@Test
public void testExecute() {
void testExecute() {
// given
Work work1 = Mockito.mock(Work.class);
Work work2 = Mockito.mock(Work.class);
Expand Down
6 changes: 3 additions & 3 deletions src/test/java/org/jeasy/flows/workflow/RepeatFlowTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@
import org.jeasy.flows.work.Work;
import org.jeasy.flows.work.WorkContext;
import org.jeasy.flows.work.WorkReportPredicate;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.mockito.Mockito;

public class RepeatFlowTest {

@Test
public void testRepeatUntil() {
void testRepeatUntil() {
// given
Work work = Mockito.mock(Work.class);
WorkContext workContext = Mockito.mock(WorkContext.class);
Expand All @@ -50,7 +50,7 @@ public void testRepeatUntil() {
}

@Test
public void testRepeatTimes() {
void testRepeatTimes() {
// given
Work work = Mockito.mock(Work.class);
WorkContext workContext = Mockito.mock(WorkContext.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,14 @@

import org.jeasy.flows.work.Work;
import org.jeasy.flows.work.WorkContext;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.mockito.InOrder;
import org.mockito.Mockito;

public class SequentialFlowTest {

@Test
public void testExecute() {
void testExecute() {
// given
Work work1 = Mockito.mock(Work.class);
Work work2 = Mockito.mock(Work.class);
Expand All @@ -59,7 +59,7 @@ public void testExecute() {
}

@Test
public void testPassingMultipleWorkUnitsAtOnce() {
void testPassingMultipleWorkUnitsAtOnce() {
// given
Work work1 = Mockito.mock(Work.class);
Work work2 = Mockito.mock(Work.class);
Expand Down