### Question:
ExtResourceTransactionManager implements TransactionManager, Serializable { @Override public Vote vote(UUID transactionId) throws TransactionExecutionException { Vote vote = this.internalTransactionManager.vote(transactionId); if (vote.equals(Vote.YES)) { Vote voteExtResource = this.getBusinessObject(transactionId).vote(transactionId); if (!Vote.YES.equals(voteExtResource)) { logger.log(Level.WARNING, "inconsistent resource state; transaction aborted."); this.internalTransactionManager.abort(transactionId); vote = Vote.NO; } } return vote; } ExtResourceTransactionManager(
            SandboxProvider sandboxProvider, TransactionManager internalTransactionManager); @Override void join(UUID transactionId); @Override void leave(UUID transactionId); @Override Vote vote(UUID transactionId); @Override void commit(UUID transactionId); @Override void abort(UUID transactionId);  }### Answer:
@Test public void test_vote_yes_if_both_yes() throws Exception { when(businessObject.vote(transcationId)).thenReturn(TransactionManager.Vote.YES); when(intTxManager.vote(transcationId)).thenReturn(TransactionManager.Vote.YES); TransactionManager.Vote vote = txMgr.vote(transcationId); assertEquals(TransactionManager.Vote.YES, vote); }
@Test public void test_vote_no_if_extResource_fails() throws Exception { when(intTxManager.vote(transcationId)).thenReturn(TransactionManager.Vote.YES); when(businessObject.vote(transcationId)).thenReturn(TransactionManager.Vote.UNCERTIAN); TransactionManager.Vote vote = txMgr.vote(transcationId); assertEquals(TransactionManager.Vote.NO, vote); }