BusinessLocalTransactionManagerImpl implements BusinessLocalTransactionManager { void markAsRollbacked(LocalTransaction ltx,LocalTransactionStepDefinition<? extends BaseTransactionEvent> localTransactionStepDefinition) { if (!ltx.getState().equals(LocalTransaction.LocalTransactionStatus.ROLLBACKED)) { ltx.setState(LocalTransaction.LocalTransactionStatus.ROLLBACKED); localTransactionStepDefinition.accept(buildInnerLocalTxStep(Optional.of(ltx))); } localTransactionStepDefinition.accept(buildOuterLocalTxStep(Optional.of(ltx))); } BusinessLocalTransactionManagerImpl(GlobalTransactionRepository globalTransactionRepository,
			CommandOrchestrator commandOrchestrator, ApplicationEventPublisher applicationEventPublisher,
			BubbleCache bubbleCache, TransactionUtilities txUtilities); @Override void begin(final LocalTransactionStepDefinition localTransactionStepDefinition); @Override void commit(
			final LocalTransactionStepDefinition<? extends BaseTransactionEvent> localTransactionStepDefinition); @Override void rollBack(
			LocalTransactionStepDefinition<? extends BaseTransactionEvent> localTransactionStepDefinition); @Override Optional<GlobalTransaction> findGlobalTransaction(final String GTX);  }
@Test public void testMarkAsRollbacked() { final LocalTransactionStepDefinition localTransactionStepDefinition = mock(LocalTransactionStepDefinition.class); final LocalTransaction localTransaction = mock(LocalTransaction.class); when(localTransaction.getState()).thenReturn(LocalTransactionStatus.COMITTED); businessLocalTransactionManagerImplUnderTest.markAsRollbacked(localTransaction, localTransactionStepDefinition); verify(localTransactionStepDefinition,times(2)).accept(any(StepLocalTxVisitor.class)); }
@Test public void testMarkAsRollbackedWithStateRollbacked() { final LocalTransactionStepDefinition localTransactionStepDefinition = mock(LocalTransactionStepDefinition.class); final LocalTransaction localTransaction = mock(LocalTransaction.class); when(localTransaction.getState()).thenReturn(LocalTransactionStatus.ROLLBACKED); businessLocalTransactionManagerImplUnderTest.markAsRollbacked(localTransaction, localTransactionStepDefinition); verify(localTransactionStepDefinition,times(1)).accept(any(StepLocalTxVisitor.class)); }