Updated update-method module to JUnit 5 (#1542)

* Updated saga to JUnit 5

* Update fix for CI job in trampoline module

* Updated update-method module to JUnit 5

* Upgraded to latest JUnit Jupiter
JUnit 4 is not needed when using JUnit-Vintage

* Reverted change to access modifier on Trampoline

* Cleanup to resolve code smells

* Formatting

* Formatting

Co-authored-by: Subhrodip Mohanta <hello@subho.xyz>
This commit is contained in:
CF
2021-03-04 00:19:31 -05:00
committed by GitHub
parent c3c90e2bd4
commit 903453229c
13 changed files with 99 additions and 101 deletions

View File

@ -35,11 +35,6 @@
<artifactId>saga</artifactId>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>

View File

@ -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[]{}));
}
}
}

View File

@ -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) {

View File

@ -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[]{});
}
}
}

View File

@ -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<String> 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() {

View File

@ -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() {