diff --git a/pom.xml b/pom.xml index 48fa6fdcf..8b00646c5 100644 --- a/pom.xml +++ b/pom.xml @@ -41,8 +41,8 @@ 2.0.14.RELEASE 1.4.190 4.12 - 5.5.2 - ${junit.version}.2 + 5.7.1 + ${junit-jupiter.version} 1.0.2 3.8.1 0.8.6 @@ -274,12 +274,6 @@ camel-stream ${camel.version} - - junit - junit - ${junit.version} - test - org.junit.jupiter junit-jupiter-api diff --git a/saga/pom.xml b/saga/pom.xml index 07d327885..80eb70f75 100644 --- a/saga/pom.xml +++ b/saga/pom.xml @@ -35,11 +35,6 @@ saga - - junit - junit - test - org.junit.jupiter junit-jupiter-engine diff --git a/saga/src/test/java/com/iluwatar/saga/choreography/SagaApplicationTest.java b/saga/src/test/java/com/iluwatar/saga/choreography/SagaApplicationTest.java index 52b407b57..67ac0f2fa 100644 --- a/saga/src/test/java/com/iluwatar/saga/choreography/SagaApplicationTest.java +++ b/saga/src/test/java/com/iluwatar/saga/choreography/SagaApplicationTest.java @@ -23,18 +23,19 @@ package com.iluwatar.saga.choreography; -import com.iluwatar.saga.orchestration.SagaApplication; -import org.junit.Test; - import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; +import com.iluwatar.saga.orchestration.SagaApplication; +import org.junit.jupiter.api.Test; + /*** * empty test */ -public class SagaApplicationTest { +class SagaApplicationTest { + @Test - public void shouldExecuteWithoutException() { + void shouldExecuteWithoutException() { assertDoesNotThrow(() -> SagaApplication.main(new String[]{})); } -} \ No newline at end of file +} diff --git a/saga/src/test/java/com/iluwatar/saga/choreography/SagaChoreographyTest.java b/saga/src/test/java/com/iluwatar/saga/choreography/SagaChoreographyTest.java index b1ddcf13f..749a66ac5 100644 --- a/saga/src/test/java/com/iluwatar/saga/choreography/SagaChoreographyTest.java +++ b/saga/src/test/java/com/iluwatar/saga/choreography/SagaChoreographyTest.java @@ -23,24 +23,25 @@ package com.iluwatar.saga.choreography; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; /** * test to check choreography saga */ -public class SagaChoreographyTest { +class SagaChoreographyTest { @Test - public void executeTest() { + void executeTest() { var sd = serviceDiscovery(); var service = sd.findAny(); var badOrderSaga = service.execute(newSaga("bad_order")); var goodOrderSaga = service.execute(newSaga("good_order")); - Assert.assertEquals(badOrderSaga.getResult(), Saga.SagaResult.ROLLBACKED); - Assert.assertEquals(goodOrderSaga.getResult(), Saga.SagaResult.FINISHED); + assertEquals(Saga.SagaResult.ROLLBACKED, badOrderSaga.getResult()); + assertEquals(Saga.SagaResult.FINISHED, goodOrderSaga.getResult()); } private static Saga newSaga(Object value) { diff --git a/saga/src/test/java/com/iluwatar/saga/orchestration/SagaApplicationTest.java b/saga/src/test/java/com/iluwatar/saga/orchestration/SagaApplicationTest.java index 1ebb9de44..29a2f7eb6 100644 --- a/saga/src/test/java/com/iluwatar/saga/orchestration/SagaApplicationTest.java +++ b/saga/src/test/java/com/iluwatar/saga/orchestration/SagaApplicationTest.java @@ -23,15 +23,15 @@ package com.iluwatar.saga.orchestration; -import org.junit.Test; +import org.junit.jupiter.api.Test; /** * empty test */ -public class SagaApplicationTest { +class SagaApplicationTest { @Test - public void mainTest() { + void mainTest() { SagaApplication.main(new String[]{}); } -} \ No newline at end of file +} diff --git a/saga/src/test/java/com/iluwatar/saga/orchestration/SagaOrchestratorInternallyTest.java b/saga/src/test/java/com/iluwatar/saga/orchestration/SagaOrchestratorInternallyTest.java index 6a1a257df..23635d1e6 100644 --- a/saga/src/test/java/com/iluwatar/saga/orchestration/SagaOrchestratorInternallyTest.java +++ b/saga/src/test/java/com/iluwatar/saga/orchestration/SagaOrchestratorInternallyTest.java @@ -23,28 +23,30 @@ package com.iluwatar.saga.orchestration; +import org.junit.jupiter.api.Test; + import static com.iluwatar.saga.orchestration.Saga.Result; +import static org.junit.jupiter.api.Assertions.assertArrayEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import java.util.ArrayList; import java.util.List; -import org.junit.Assert; -import org.junit.Test; /** * test to test orchestration logic */ -public class SagaOrchestratorInternallyTest { +class SagaOrchestratorInternallyTest { private final List records = new ArrayList<>(); @Test - public void executeTest() { + void executeTest() { var sagaOrchestrator = new SagaOrchestrator(newSaga(), serviceDiscovery()); var result = sagaOrchestrator.execute(1); - Assert.assertEquals(result, Result.ROLLBACK); - Assert.assertArrayEquals( - records.toArray(new String[]{}), - new String[]{"+1", "+2", "+3", "+4", "-4", "-3", "-2", "-1"}); + assertEquals(Result.ROLLBACK, result); + assertArrayEquals( + new String[]{"+1", "+2", "+3", "+4", "-4", "-3", "-2", "-1"}, + records.toArray(new String[]{})); } private static Saga newSaga() { diff --git a/saga/src/test/java/com/iluwatar/saga/orchestration/SagaOrchestratorTest.java b/saga/src/test/java/com/iluwatar/saga/orchestration/SagaOrchestratorTest.java index 7dd4c3180..2a1da9981 100644 --- a/saga/src/test/java/com/iluwatar/saga/orchestration/SagaOrchestratorTest.java +++ b/saga/src/test/java/com/iluwatar/saga/orchestration/SagaOrchestratorTest.java @@ -23,22 +23,23 @@ package com.iluwatar.saga.orchestration; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; /** * test to check general logic */ -public class SagaOrchestratorTest { +class SagaOrchestratorTest { @Test - public void execute() { + void execute() { SagaOrchestrator sagaOrchestrator = new SagaOrchestrator(newSaga(), serviceDiscovery()); Saga.Result badOrder = sagaOrchestrator.execute("bad_order"); Saga.Result crashedOrder = sagaOrchestrator.execute("crashed_order"); - Assert.assertEquals(badOrder, Saga.Result.ROLLBACK); - Assert.assertEquals(crashedOrder, Saga.Result.CRASHED); + assertEquals(Saga.Result.ROLLBACK, badOrder); + assertEquals(Saga.Result.CRASHED, crashedOrder); } private static Saga newSaga() { diff --git a/trampoline/src/main/java/com/iluwatar/trampoline/Trampoline.java b/trampoline/src/main/java/com/iluwatar/trampoline/Trampoline.java index b28a14803..1d2ea91d3 100644 --- a/trampoline/src/main/java/com/iluwatar/trampoline/Trampoline.java +++ b/trampoline/src/main/java/com/iluwatar/trampoline/Trampoline.java @@ -98,7 +98,7 @@ public interface Trampoline { return trampoline(this); } - private T trampoline(final Trampoline trampoline) { + T trampoline(final Trampoline trampoline) { return Stream.iterate(trampoline, Trampoline::jump) .filter(Trampoline::complete) .findFirst() diff --git a/update-method/pom.xml b/update-method/pom.xml index b49ab3c07..b70520a99 100644 --- a/update-method/pom.xml +++ b/update-method/pom.xml @@ -35,10 +35,6 @@ update-method - - junit - junit - org.junit.jupiter junit-jupiter-engine diff --git a/update-method/src/test/java/com/iluwatar/updatemethod/AppTest.java b/update-method/src/test/java/com/iluwatar/updatemethod/AppTest.java index 6158e7491..9c5c2a1e2 100644 --- a/update-method/src/test/java/com/iluwatar/updatemethod/AppTest.java +++ b/update-method/src/test/java/com/iluwatar/updatemethod/AppTest.java @@ -23,14 +23,14 @@ package com.iluwatar.updatemethod; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; -public class AppTest { +class AppTest { @Test - public void shouldExecuteApplicationWithoutException() { + void shouldExecuteApplicationWithoutException() { assertDoesNotThrow(() -> App.main(new String[]{})); } } diff --git a/update-method/src/test/java/com/iluwatar/updatemethod/SkeletonTest.java b/update-method/src/test/java/com/iluwatar/updatemethod/SkeletonTest.java index 2562180b8..a30dd26cb 100644 --- a/update-method/src/test/java/com/iluwatar/updatemethod/SkeletonTest.java +++ b/update-method/src/test/java/com/iluwatar/updatemethod/SkeletonTest.java @@ -23,56 +23,60 @@ package com.iluwatar.updatemethod; -import org.junit.After; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; -public class SkeletonTest { +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; - private Skeleton skeleton; - @Before - public void setup() { +class SkeletonTest { + + private static Skeleton skeleton; + + @BeforeAll + public static void setup() { skeleton = new Skeleton(1); } - @After - public void tearDown() { + @AfterAll + public static void tearDown() { skeleton = null; } @Test - public void testUpdateForPatrollingLeft() { + void testUpdateForPatrollingLeft() { skeleton.patrollingLeft = true; skeleton.setPosition(50); skeleton.update(); - Assert.assertEquals(49, skeleton.getPosition()); + assertEquals(49, skeleton.getPosition()); } @Test - public void testUpdateForPatrollingRight() { + void testUpdateForPatrollingRight() { skeleton.patrollingLeft = false; skeleton.setPosition(50); skeleton.update(); - Assert.assertEquals(51, skeleton.getPosition()); + assertEquals(51, skeleton.getPosition()); } @Test - public void testUpdateForReverseDirectionFromLeftToRight() { + void testUpdateForReverseDirectionFromLeftToRight() { skeleton.patrollingLeft = true; skeleton.setPosition(1); skeleton.update(); - Assert.assertEquals(0, skeleton.getPosition()); - Assert.assertEquals(false, skeleton.patrollingLeft); + assertEquals(0, skeleton.getPosition()); + assertFalse(skeleton.patrollingLeft); } @Test - public void testUpdateForReverseDirectionFromRightToLeft() { + void testUpdateForReverseDirectionFromRightToLeft() { skeleton.patrollingLeft = false; skeleton.setPosition(99); skeleton.update(); - Assert.assertEquals(100, skeleton.getPosition()); - Assert.assertEquals(true, skeleton.patrollingLeft); + assertEquals(100, skeleton.getPosition()); + assertTrue(skeleton.patrollingLeft); } } diff --git a/update-method/src/test/java/com/iluwatar/updatemethod/StatueTest.java b/update-method/src/test/java/com/iluwatar/updatemethod/StatueTest.java index eea6bbeb1..3b28ffd5d 100644 --- a/update-method/src/test/java/com/iluwatar/updatemethod/StatueTest.java +++ b/update-method/src/test/java/com/iluwatar/updatemethod/StatueTest.java @@ -23,36 +23,37 @@ package com.iluwatar.updatemethod; -import org.junit.After; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; -public class StatueTest { +import static org.junit.jupiter.api.Assertions.assertEquals; - private Statue statue; +class StatueTest { - @Before - public void setup() { + private static Statue statue; + + @BeforeAll + public static void setup() { statue = new Statue(1, 20); } - @After - public void tearDown() { + @AfterAll + public static void tearDown() { statue = null; } @Test - public void testUpdateForPendingShoot() { + void testUpdateForPendingShoot() { statue.frames = 10; statue.update(); - Assert.assertEquals(11, statue.frames); + assertEquals(11, statue.frames); } @Test - public void testUpdateForShooting() { + void testUpdateForShooting() { statue.frames = 19; statue.update(); - Assert.assertEquals(0, statue.frames); + assertEquals(0, statue.frames); } } diff --git a/update-method/src/test/java/com/iluwatar/updatemethod/WorldTest.java b/update-method/src/test/java/com/iluwatar/updatemethod/WorldTest.java index b8d95f140..843c4a654 100644 --- a/update-method/src/test/java/com/iluwatar/updatemethod/WorldTest.java +++ b/update-method/src/test/java/com/iluwatar/updatemethod/WorldTest.java @@ -23,41 +23,44 @@ package com.iluwatar.updatemethod; -import org.junit.After; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; -public class WorldTest { +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; - private World world; +class WorldTest { - @Before - public void setup() { + private static World world; + + @BeforeAll + public static void setup() { world = new World(); } - @After - public void tearDown() { + @AfterAll + public static void tearDown() { world = null; } @Test - public void testRun() { + void testRun() { world.run(); - Assert.assertEquals(true, world.isRunning); + assertTrue(world.isRunning); } @Test - public void testStop() { + void testStop() { world.stop(); - Assert.assertEquals(false, world.isRunning); + assertFalse(world.isRunning); } @Test - public void testAddEntity() { + void testAddEntity() { var entity = new Skeleton(1); world.addEntity(entity); - Assert.assertEquals(entity, world.entities.get(0)); + assertEquals(entity, world.entities.get(0)); } }