BusinessGlobalTransactionServiceImpl implements BusinessGlobalTransactionService { @Override public GlobalTransaction participateToGlobalTransaction(Optional<RequestGlobalTransaction> orgt) { GlobalTransaction globalTransaction = null; if (orgt.isPresent()) { RequestGlobalTransaction rgt = orgt.get(); Optional<GlobalTransaction> ogtx = globalTransactionRepository.findByNameAndParentAndStatus(rgt.getName(), rgt.getParent(), GlobalTransaction.GlobalTransactionStatus.PREPARED); if (ogtx.isPresent()) { globalTransaction = ogtx.get(); globalTransaction.setStatus(GlobalTransaction.GlobalTransactionStatus.STARTED); } else { globalTransaction = this.startNewGlobalTransaction(rgt); } } return globalTransaction; } BusinessGlobalTransactionServiceImpl(); @Autowired  BusinessGlobalTransactionServiceImpl(GlobalTransactionRepository globalTransactionRepository,
												Tracer tracer,
												ApplicationEventPublisher publisher); @Override Optional<GlobalTransaction> findGlobalTransaction(final String id); @Override GlobalTransaction participateToGlobalTransaction(Optional<RequestGlobalTransaction> orgt); @Override Optional<GlobalTransaction> retrieveGlobalTransaction(Optional<RequestGlobalTransaction> orgt);  }
@Test public void testParticipateToGlobalTransactionWhenRequestGlobalTransactionNotPresent() { final Optional<RequestGlobalTransaction> orgt = Optional.empty(); final GlobalTransaction result = businessGlobalTransactionServiceImplUnderTest.participateToGlobalTransaction(orgt); assertEquals(null, result); }