@Test public void testCommitWhenGlobalTxNotStarted() { when(mockBusinessGlobalTransactionService.retrieveGlobalTransaction(Optional.of(requestGlobalTransaction))).thenReturn(Optional.of(globalTransaction)); when(globalTransaction.getStatus()).thenReturn(GlobalTransaction.GlobalTransactionStatus.COMITTED); businessGlobalTransactionManagerImplUnderTest.commit(pipeline); verify(globalTransaction, never()).setStatus(same(GlobalTransaction.GlobalTransactionStatus.COMITTED)); verify(mockGlobalTransactionRepository, never()).save(same(globalTransaction)); verify(pipeline).accept(any()); }
@Override public void commit(GlobalTransactionStepDefinition pipeline) { Optional<RequestGlobalTransaction> orgt = globalTransactionMapper.mapTo(pipeline); Optional<GlobalTransaction> gtx = businessGlobalTransactionService.retrieveGlobalTransaction(orgt); gtx.ifPresent(globalTransaction -> { if (globalTransaction.getStatus().equals(GlobalTransaction.GlobalTransactionStatus.STARTED)) { globalTransaction.setStatus(GlobalTransaction.GlobalTransactionStatus.COMITTED); this.globalTransactionRepository.save(globalTransaction); } }); gtx.orElseThrow(() -> new BusinessGlobalTransactionNotFoundException(pipeline)); pipeline.accept(buildInnerGlobalTxStep(gtx)); }
BusinessGlobalTransactionManagerImpl implements BusinessGlobalTransactionManager { @Override public void commit(GlobalTransactionStepDefinition pipeline) { Optional<RequestGlobalTransaction> orgt = globalTransactionMapper.mapTo(pipeline); Optional<GlobalTransaction> gtx = businessGlobalTransactionService.retrieveGlobalTransaction(orgt); gtx.ifPresent(globalTransaction -> { if (globalTransaction.getStatus().equals(GlobalTransaction.GlobalTransactionStatus.STARTED)) { globalTransaction.setStatus(GlobalTransaction.GlobalTransactionStatus.COMITTED); this.globalTransactionRepository.save(globalTransaction); } }); gtx.orElseThrow(() -> new BusinessGlobalTransactionNotFoundException(pipeline)); pipeline.accept(buildInnerGlobalTxStep(gtx)); } }
BusinessGlobalTransactionManagerImpl implements BusinessGlobalTransactionManager { @Override public void commit(GlobalTransactionStepDefinition pipeline) { Optional<RequestGlobalTransaction> orgt = globalTransactionMapper.mapTo(pipeline); Optional<GlobalTransaction> gtx = businessGlobalTransactionService.retrieveGlobalTransaction(orgt); gtx.ifPresent(globalTransaction -> { if (globalTransaction.getStatus().equals(GlobalTransaction.GlobalTransactionStatus.STARTED)) { globalTransaction.setStatus(GlobalTransaction.GlobalTransactionStatus.COMITTED); this.globalTransactionRepository.save(globalTransaction); } }); gtx.orElseThrow(() -> new BusinessGlobalTransactionNotFoundException(pipeline)); pipeline.accept(buildInnerGlobalTxStep(gtx)); } @Autowired  BusinessGlobalTransactionManagerImpl(GlobalTransactionRepository globalTransactionRepository,
			CommandOrchestrator commandOrchestrator, ApplicationEventPublisher applicationEventPublisher,
			BubbleCache bubbleCache , BusinessGlobalTransactionService businessGlobalTransactionService , GlobalTransactionMapper globalTransactionMapper, TransactionUtilities utilities); }
BusinessGlobalTransactionManagerImpl implements BusinessGlobalTransactionManager { @Override public void commit(GlobalTransactionStepDefinition pipeline) { Optional<RequestGlobalTransaction> orgt = globalTransactionMapper.mapTo(pipeline); Optional<GlobalTransaction> gtx = businessGlobalTransactionService.retrieveGlobalTransaction(orgt); gtx.ifPresent(globalTransaction -> { if (globalTransaction.getStatus().equals(GlobalTransaction.GlobalTransactionStatus.STARTED)) { globalTransaction.setStatus(GlobalTransaction.GlobalTransactionStatus.COMITTED); this.globalTransactionRepository.save(globalTransaction); } }); gtx.orElseThrow(() -> new BusinessGlobalTransactionNotFoundException(pipeline)); pipeline.accept(buildInnerGlobalTxStep(gtx)); } @Autowired  BusinessGlobalTransactionManagerImpl(GlobalTransactionRepository globalTransactionRepository,
			CommandOrchestrator commandOrchestrator, ApplicationEventPublisher applicationEventPublisher,
			BubbleCache bubbleCache , BusinessGlobalTransactionService businessGlobalTransactionService , GlobalTransactionMapper globalTransactionMapper, TransactionUtilities utilities); @Override void begin(GlobalTransactionStepDefinition pipeline); @Override void commit(GlobalTransactionStepDefinition pipeline); }
BusinessGlobalTransactionManagerImpl implements BusinessGlobalTransactionManager { @Override public void commit(GlobalTransactionStepDefinition pipeline) { Optional<RequestGlobalTransaction> orgt = globalTransactionMapper.mapTo(pipeline); Optional<GlobalTransaction> gtx = businessGlobalTransactionService.retrieveGlobalTransaction(orgt); gtx.ifPresent(globalTransaction -> { if (globalTransaction.getStatus().equals(GlobalTransaction.GlobalTransactionStatus.STARTED)) { globalTransaction.setStatus(GlobalTransaction.GlobalTransactionStatus.COMITTED); this.globalTransactionRepository.save(globalTransaction); } }); gtx.orElseThrow(() -> new BusinessGlobalTransactionNotFoundException(pipeline)); pipeline.accept(buildInnerGlobalTxStep(gtx)); } @Autowired  BusinessGlobalTransactionManagerImpl(GlobalTransactionRepository globalTransactionRepository,
			CommandOrchestrator commandOrchestrator, ApplicationEventPublisher applicationEventPublisher,
			BubbleCache bubbleCache , BusinessGlobalTransactionService businessGlobalTransactionService , GlobalTransactionMapper globalTransactionMapper, TransactionUtilities utilities); @Override void begin(GlobalTransactionStepDefinition pipeline); @Override void commit(GlobalTransactionStepDefinition pipeline);  }