BusinessGlobalTransactionManagerImpl implements BusinessGlobalTransactionManager { @Override public void begin(GlobalTransactionStepDefinition pipeline) { Optional<RequestGlobalTransaction> orgt = globalTransactionMapper.mapTo(pipeline); GlobalTransaction globalTransaction = businessGlobalTransactionService.participateToGlobalTransaction(orgt); globalTransactionRepository.save(globalTransaction); if (globalTransaction.isNew()) { pipeline.accept(buildInnerGlobalTxStep(Optional.of(globalTransaction))); } } @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);  }
@Test public void testBeginWhenNewGlobalTx() { when(globalTransaction.isNew()).thenReturn(true); businessGlobalTransactionManagerImplUnderTest.begin(pipeline); verify(mockGlobalTransactionRepository).save(same(globalTransaction)); verify(pipeline).accept(any()); }
@Test public void testBeginWhenGlobalTxNotNew() { when(globalTransaction.isNew()).thenReturn(false); businessGlobalTransactionManagerImplUnderTest.begin(pipeline); verify(mockGlobalTransactionRepository).save(same(globalTransaction)); verify(pipeline, never()).accept(any()); }