RollBackGlobalWorker extends LocalTransactionWorker<GlobalRollbackOccured, GlobalTransactionLevelRollbacked, ErrorGlobalOccured> { @Override @BusinessLocalTransactional public LocalTransactionStepDefinition onStart(GlobalRollbackOccured globalRollbackOccured) { WorkerMeta workerMeta = new WorkerMeta(this.meta.getTransactionName(), globalRollbackOccured.getTrxChildOf()); Stream<BaseTransactionCommand> sourceStream = null; if (kermossProperties != null) { sourceStream = kermossProperties.getSources().keySet().stream() .map(c -> new RollBackGlobalCommand("rollback-global", null, null, c)); } return LocalTransactionStepDefinition.builder().in(globalRollbackOccured).send(sourceStream) .blow(Stream.of(new ErrorLocalOccured(), new GlobalTransactionLevelRollbacked(globalRollbackOccured.getTrxChildOf()))) .meta(workerMeta).build(); } RollBackGlobalWorker(); @PostConstruct void init(); @Override @BusinessLocalTransactional LocalTransactionStepDefinition onStart(GlobalRollbackOccured globalRollbackOccured); @Override @SwitchBusinessLocalTransactional LocalTransactionStepDefinition onNext(GlobalTransactionLevelRollbacked globalTransactionLevelRollbacked); @Override @RollBackBusinessLocalTransactional LocalTransactionStepDefinition onError(ErrorGlobalOccured errorGlobalOccured);  }
@Test public void testOnStart(){ when(kermossProperties.getSources()).thenReturn(mock(HashMap.class)); LocalTransactionStepDefinition onStart = rollBackGlobalWorkerUnderTest.onStart(new GlobalRollbackOccured()); verify(kermossProperties.getSources(),times(1)).keySet(); assertThat(onStart.getMeta().getTransactionName()).isEqualTo("RollBackGlobalService"); }