mirror of
https://github.com/tiennm99/java-design-patterns.git
synced 2026-05-21 04:24:12 +00:00
Java 11 migrate all remaining s (#1120)
* Moves saga to Java 11 * Moves semaphore to Java 11 * Moves servant to Java 11 * Moves serverless to Java 11 * Moves service-layer to Java 11 * Moves service-locator to Java 11 * Moves sharding to Java 11 * Moves singleton to Java 11 * Moves spatial-partition to Java 11 * Moves specification to Java 11 * Moves state to Java 11 * Moves step-builder to Java 11 * Moves strategy to Java 11 * Moves subclass-sandbox to Java 11 * Fixes checkstyle issues
This commit is contained in:
committed by
Ilkka Seppälä
parent
310ae50248
commit
cd2a2e7711
@@ -33,10 +33,10 @@ public class SagaChoreographyTest {
|
||||
|
||||
@Test
|
||||
public void executeTest() {
|
||||
ServiceDiscoveryService sd = serviceDiscovery();
|
||||
ChoreographyChapter service = sd.findAny();
|
||||
Saga badOrderSaga = service.execute(newSaga("bad_order"));
|
||||
Saga goodOrderSaga = service.execute(newSaga("good_order"));
|
||||
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);
|
||||
@@ -52,7 +52,7 @@ public class SagaChoreographyTest {
|
||||
}
|
||||
|
||||
private static ServiceDiscoveryService serviceDiscovery() {
|
||||
ServiceDiscoveryService sd = new ServiceDiscoveryService();
|
||||
var sd = new ServiceDiscoveryService();
|
||||
return sd
|
||||
.discover(new OrderService(sd))
|
||||
.discover(new FlyBookingService(sd))
|
||||
|
||||
@@ -24,8 +24,6 @@ package com.iluwatar.saga.orchestration;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* empty test
|
||||
*/
|
||||
|
||||
+12
-13
@@ -22,11 +22,12 @@
|
||||
*/
|
||||
package com.iluwatar.saga.orchestration;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import static com.iluwatar.saga.orchestration.Saga.Result;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* test to test orchestration logic
|
||||
@@ -37,17 +38,16 @@ public class SagaOrchestratorInternallyTest {
|
||||
|
||||
@Test
|
||||
public void executeTest() {
|
||||
SagaOrchestrator sagaOrchestrator = new SagaOrchestrator(newSaga(), serviceDiscovery());
|
||||
Saga.Result result = sagaOrchestrator.execute(1);
|
||||
Assert.assertEquals(result, Saga.Result.ROLLBACK);
|
||||
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"});
|
||||
}
|
||||
|
||||
private static Saga newSaga() {
|
||||
return Saga
|
||||
.create()
|
||||
return Saga.create()
|
||||
.chapter("1")
|
||||
.chapter("2")
|
||||
.chapter("3")
|
||||
@@ -55,12 +55,11 @@ public class SagaOrchestratorInternallyTest {
|
||||
}
|
||||
|
||||
private ServiceDiscoveryService serviceDiscovery() {
|
||||
return
|
||||
new ServiceDiscoveryService()
|
||||
.discover(new Service1())
|
||||
.discover(new Service2())
|
||||
.discover(new Service3())
|
||||
.discover(new Service4());
|
||||
return new ServiceDiscoveryService()
|
||||
.discover(new Service1())
|
||||
.discover(new Service2())
|
||||
.discover(new Service3())
|
||||
.discover(new Service4());
|
||||
}
|
||||
|
||||
class Service1 extends Service<Integer> {
|
||||
|
||||
Reference in New Issue
Block a user