### Question:
TLS2PCCoordinator implements TwoPCCoordinator { @Override public Vote vote(UUID transactionId) throws TransactionExecutionException { try { if (!this.validator.promises(transactionId)) { return Vote.NO; } } catch (Exception e) { logger.log(Level.SEVERE, "coordinator 2PC preparation failed", e); return Vote.NO; } TransactionContext.initPrecessed(); if (this.localParticipantsManager.allParticipantsVotedYes(transactionId)) { return Vote.YES; } else { return Vote.NO; } } TLS2PCCoordinator(TransactionValidator validator); @Override void beginTransaction(); @Override UUID getTransactionId(); @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_yes_if_promise_went_well() throws Exception { when(validator.promises(transactionId)).thenReturn(true); when(participants.allParticipantsVotedYes(transactionId)).thenReturn(true); TransactionManager.Vote vote = this.coordinator.vote(transactionId); assertEquals(TransactionManager.Vote.YES, vote); }
@Test public void test_nogo_if_promise_rejected() throws Exception { when(validator.promises(transactionId)).thenReturn(false); when(participants.allParticipantsVotedYes(transactionId)).thenReturn(true); TransactionManager.Vote vote = this.coordinator.vote(transactionId); assertEquals(TransactionManager.Vote.NO, vote); }