BusinessLocalTransactionManagerImpl implements BusinessLocalTransactionManager { void updateLTX(LocalTransactionStepDefinition pipeline, LocalTransaction ltx) { Optional<List<String>> businessKey = pipeline.getBusinessKey(); ltx.addBusinessKey(businessKey); Optional<BubbleMessage> bubbleMessage = txUtilities.getBubleMessage(pipeline); bubbleMessage.ifPresent(msg -> ltx.setFLTX(msg.getFLTX())); } 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 testUpdateLTXWhenMessageExist() { final LocalTransactionStepDefinition pipeline = mock(LocalTransactionStepDefinition.class); final LocalTransaction ltx = mock(LocalTransaction.class); final BubbleMessage bubbleMessage = mock(BubbleMessage.class); final String fltx = "fltx"; when(mockTxUtilities.getBubleMessage(pipeline)).thenReturn(Optional.of(bubbleMessage)); when(bubbleMessage.getFLTX()).thenReturn(fltx); businessLocalTransactionManagerImplUnderTest.updateLTX(pipeline, ltx); verify(ltx).setFLTX(fltx); }
@Test public void testUpdateLTXWhenMessageNotExist() { final LocalTransactionStepDefinition pipeline = mock(LocalTransactionStepDefinition.class); final LocalTransaction ltx = mock(LocalTransaction.class); final BubbleMessage bubbleMessage = mock(BubbleMessage.class); when(mockTxUtilities.getBubleMessage(pipeline)).thenReturn(Optional.empty()); businessLocalTransactionManagerImplUnderTest.updateLTX(pipeline, ltx); verify(ltx, never()).setFLTX(anyString()); }