@Test public void testStartGlobalTransactionWhenNotSynchronizedVote() { final RequestGlobalTransaction rgt = mock(RequestGlobalTransaction.class); final InboundCommand command = mock(InboundCommand.class); final String traceId = "traceId"; final String name = "trxname"; final String parent = "parent"; final GlobalTransaction globalTransaction = mock(GlobalTransaction.class); setupStartTrx(rgt, command, traceId, name, parent, globalTransaction); when(command.getStatus()).thenReturn(InboundCommand.Status.STARTED); GlobalTransaction result = businessGlobalTransactionServiceImplUnderTest.startNewGlobalTransaction(rgt); verify(globalTransaction).setStatus(same(GlobalTransaction.GlobalTransactionStatus.STARTED)); verify(globalTransaction).setParent(same(parent)); assertEquals(result, globalTransaction); }
GlobalTransaction startNewGlobalTransaction(RequestGlobalTransaction rgt) { String traceId = null; if (rgt.getGTX() != null) { throw new BusinessGlobalTransactionInstableException(rgt); } traceId = trace(rgt); GlobalTransaction globalTransaction = GlobalTransaction.create(rgt.getName(), traceId); if (this.isSynchronizedVote(rgt)) { globalTransaction.setStatus(GlobalTransaction.GlobalTransactionStatus.PREPARED); } else { globalTransaction.setStatus(GlobalTransaction.GlobalTransactionStatus.STARTED); } globalTransaction.setParent(rgt.getParent()); return globalTransaction; }
BusinessGlobalTransactionServiceImpl implements BusinessGlobalTransactionService { GlobalTransaction startNewGlobalTransaction(RequestGlobalTransaction rgt) { String traceId = null; if (rgt.getGTX() != null) { throw new BusinessGlobalTransactionInstableException(rgt); } traceId = trace(rgt); GlobalTransaction globalTransaction = GlobalTransaction.create(rgt.getName(), traceId); if (this.isSynchronizedVote(rgt)) { globalTransaction.setStatus(GlobalTransaction.GlobalTransactionStatus.PREPARED); } else { globalTransaction.setStatus(GlobalTransaction.GlobalTransactionStatus.STARTED); } globalTransaction.setParent(rgt.getParent()); return globalTransaction; } }
BusinessGlobalTransactionServiceImpl implements BusinessGlobalTransactionService { GlobalTransaction startNewGlobalTransaction(RequestGlobalTransaction rgt) { String traceId = null; if (rgt.getGTX() != null) { throw new BusinessGlobalTransactionInstableException(rgt); } traceId = trace(rgt); GlobalTransaction globalTransaction = GlobalTransaction.create(rgt.getName(), traceId); if (this.isSynchronizedVote(rgt)) { globalTransaction.setStatus(GlobalTransaction.GlobalTransactionStatus.PREPARED); } else { globalTransaction.setStatus(GlobalTransaction.GlobalTransactionStatus.STARTED); } globalTransaction.setParent(rgt.getParent()); return globalTransaction; } BusinessGlobalTransactionServiceImpl(); @Autowired  BusinessGlobalTransactionServiceImpl(GlobalTransactionRepository globalTransactionRepository,
												Tracer tracer,
												ApplicationEventPublisher publisher); }
BusinessGlobalTransactionServiceImpl implements BusinessGlobalTransactionService { GlobalTransaction startNewGlobalTransaction(RequestGlobalTransaction rgt) { String traceId = null; if (rgt.getGTX() != null) { throw new BusinessGlobalTransactionInstableException(rgt); } traceId = trace(rgt); GlobalTransaction globalTransaction = GlobalTransaction.create(rgt.getName(), traceId); if (this.isSynchronizedVote(rgt)) { globalTransaction.setStatus(GlobalTransaction.GlobalTransactionStatus.PREPARED); } else { globalTransaction.setStatus(GlobalTransaction.GlobalTransactionStatus.STARTED); } globalTransaction.setParent(rgt.getParent()); 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); }
BusinessGlobalTransactionServiceImpl implements BusinessGlobalTransactionService { GlobalTransaction startNewGlobalTransaction(RequestGlobalTransaction rgt) { String traceId = null; if (rgt.getGTX() != null) { throw new BusinessGlobalTransactionInstableException(rgt); } traceId = trace(rgt); GlobalTransaction globalTransaction = GlobalTransaction.create(rgt.getName(), traceId); if (this.isSynchronizedVote(rgt)) { globalTransaction.setStatus(GlobalTransaction.GlobalTransactionStatus.PREPARED); } else { globalTransaction.setStatus(GlobalTransaction.GlobalTransactionStatus.STARTED); } globalTransaction.setParent(rgt.getParent()); 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);  }