BusinessGlobalTransactionServiceImpl implements BusinessGlobalTransactionService { @Override public Optional<GlobalTransaction> findGlobalTransaction(final String id) { return Optional.ofNullable(this.globalTransactionRepository.findOne(id)); } 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 testFindGlobalTransactionWhenGlobalTxExist() { final String id = "id"; final GlobalTransaction globalTransaction = mock(GlobalTransaction.class); when(mockGlobalTransactionRepository.findOne(id)).thenReturn(globalTransaction); final Optional<GlobalTransaction> result = businessGlobalTransactionServiceImplUnderTest.findGlobalTransaction(id); assertEquals(Optional.of(globalTransaction), result); }
@Test public void testFindGlobalTransactionWhenGlobalTxNotExist() { final String id = "id"; when(mockGlobalTransactionRepository.findOne(id)).thenReturn(null); final Optional<GlobalTransaction> result = businessGlobalTransactionServiceImplUnderTest.findGlobalTransaction(id); assertEquals(Optional.empty(), result); }