use of io.seata.saga.statelang.domain.StateMachineInstance in project seata by seata.
the class StateMachineAsyncTests method testCompensationStateMachine.
@Test
public void testCompensationStateMachine() {
long start = System.currentTimeMillis();
Map<String, Object> paramMap = new HashMap<>(1);
paramMap.put("a", 1);
paramMap.put("barThrowException", "true");
String stateMachineName = "simpleCompensationStateMachine";
StateMachineInstance inst = stateMachineEngine.startAsync(stateMachineName, null, paramMap, callback);
waittingForFinish(inst);
long cost = System.currentTimeMillis() - start;
System.out.println("====== cost :" + cost);
Assertions.assertTrue(ExecutionStatus.UN.equals(inst.getStatus()));
Assertions.assertTrue(ExecutionStatus.SU.equals(inst.getCompensationStatus()));
}
use of io.seata.saga.statelang.domain.StateMachineInstance in project seata by seata.
the class StateMachineAsyncTests method testSimpleStateMachineWithAsyncState.
@Test
public void testSimpleStateMachineWithAsyncState() {
long start = System.currentTimeMillis();
Map<String, Object> paramMap = new HashMap<>(1);
paramMap.put("a", 1);
String stateMachineName = "simpleStateMachineWithAsyncState";
StateMachineInstance inst = stateMachineEngine.startAsync(stateMachineName, null, paramMap, callback);
waittingForFinish(inst);
long cost = System.currentTimeMillis() - start;
System.out.println("====== cost :" + cost);
Assertions.assertTrue(ExecutionStatus.SU.equals(inst.getStatus()));
try {
Thread.sleep(500);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
use of io.seata.saga.statelang.domain.StateMachineInstance in project seata by seata.
the class StateMachineAsyncTests method testStateMachineWithComplexParams.
@Test
public void testStateMachineWithComplexParams() {
long start = System.currentTimeMillis();
Map<String, Object> paramMap = new HashMap<>(1);
People people = new People();
people.setName("lilei");
people.setAge(18);
paramMap.put("people", people);
String stateMachineName = "simpleStateMachineWithComplexParams";
StateMachineInstance inst = stateMachineEngine.startAsync(stateMachineName, null, paramMap, callback);
waittingForFinish(inst);
long cost = System.currentTimeMillis() - start;
People peopleResult = (People) inst.getEndParams().get("complexParameterMethodResult");
Assertions.assertNotNull(peopleResult);
Assertions.assertTrue(people.getName().equals(people.getName()));
System.out.println("====== cost :" + cost);
Assertions.assertTrue(ExecutionStatus.SU.equals(inst.getStatus()));
}
use of io.seata.saga.statelang.domain.StateMachineInstance in project seata by seata.
the class StateMachineAsyncTests method testSimpleRetryStateMachine.
@Test
public void testSimpleRetryStateMachine() {
long start = System.currentTimeMillis();
Map<String, Object> paramMap = new HashMap<>(1);
paramMap.put("a", 1);
paramMap.put("barThrowException", "true");
String stateMachineName = "simpleRetryStateMachine";
StateMachineInstance inst = stateMachineEngine.startAsync(stateMachineName, null, paramMap, callback);
waittingForFinish(inst);
long cost = System.currentTimeMillis() - start;
System.out.println("====== cost :" + cost);
Assertions.assertNotNull(inst.getException());
Assertions.assertTrue(ExecutionStatus.FA.equals(inst.getStatus()));
}
use of io.seata.saga.statelang.domain.StateMachineInstance in project seata by seata.
the class StateMachineAsyncTests method testCompensationAndSubStateMachineWithLayout.
@Test
public void testCompensationAndSubStateMachineWithLayout() {
long start = System.currentTimeMillis();
Map<String, Object> paramMap = new HashMap<>(1);
paramMap.put("a", 2);
paramMap.put("barThrowException", "true");
String stateMachineName = "simpleStateMachineWithCompensationAndSubMachine_layout";
StateMachineInstance inst = stateMachineEngine.startAsync(stateMachineName, null, paramMap, callback);
waittingForFinish(inst);
long cost = System.currentTimeMillis() - start;
System.out.println("====== cost :" + cost);
Assertions.assertTrue(ExecutionStatus.UN.equals(inst.getStatus()));
}
Aggregations