@Test public void test_vote_no_on_any_nogood() throws Exception { when(this.participantsManager.allParticipantsVotedYes(any(UUID.class))).thenReturn(false); TwoPCLocalStatus statusManager = mock(TwoPCLocalStatus.class); when(statusManager.getStatus(txId)).thenReturn(TwoPCLocalStatus.LocalStatus.GOOD); ReflectionTestUtil.setField(this.txManager, "localStatusManager", statusManager); TransactionManager.Vote result = txManager.vote(txId); assertEquals(TransactionManager.Vote.NO, result); }
@Override public Vote vote(UUID transactionId) throws TransactionExecutionException { LocalStatus status = this.localStatusManager.getStatus(transactionId); switch (status) { case YESVOTED: return Vote.YES; case NOVOTED: return Vote.NO; case BAD: case UNCERTAIN: this.localStatusManager.setStatus(transactionId, LocalStatus.NOVOTED); return Vote.NO; case GOOD: if (this.isLocalPromised(transactionId) && this.localParticipantsManager.allParticipantsVotedYes(transactionId)) { this.localStatusManager.setStatus(transactionId, LocalStatus.YESVOTED); return Vote.YES; } else { this.localStatusManager.setStatus(transactionId, LocalStatus.NOVOTED); return Vote.NO; } default: throw new IllegalStateException("illegal 2PC local status: " + status.toString()); } }
TLSTransactionManager implements TransactionManager, Serializable { @Override public Vote vote(UUID transactionId) throws TransactionExecutionException { LocalStatus status = this.localStatusManager.getStatus(transactionId); switch (status) { case YESVOTED: return Vote.YES; case NOVOTED: return Vote.NO; case BAD: case UNCERTAIN: this.localStatusManager.setStatus(transactionId, LocalStatus.NOVOTED); return Vote.NO; case GOOD: if (this.isLocalPromised(transactionId) && this.localParticipantsManager.allParticipantsVotedYes(transactionId)) { this.localStatusManager.setStatus(transactionId, LocalStatus.YESVOTED); return Vote.YES; } else { this.localStatusManager.setStatus(transactionId, LocalStatus.NOVOTED); return Vote.NO; } default: throw new IllegalStateException("illegal 2PC local status: " + status.toString()); } } }
TLSTransactionManager implements TransactionManager, Serializable { @Override public Vote vote(UUID transactionId) throws TransactionExecutionException { LocalStatus status = this.localStatusManager.getStatus(transactionId); switch (status) { case YESVOTED: return Vote.YES; case NOVOTED: return Vote.NO; case BAD: case UNCERTAIN: this.localStatusManager.setStatus(transactionId, LocalStatus.NOVOTED); return Vote.NO; case GOOD: if (this.isLocalPromised(transactionId) && this.localParticipantsManager.allParticipantsVotedYes(transactionId)) { this.localStatusManager.setStatus(transactionId, LocalStatus.YESVOTED); return Vote.YES; } else { this.localStatusManager.setStatus(transactionId, LocalStatus.NOVOTED); return Vote.NO; } default: throw new IllegalStateException("illegal 2PC local status: " + status.toString()); } }  }
TLSTransactionManager implements TransactionManager, Serializable { @Override public Vote vote(UUID transactionId) throws TransactionExecutionException { LocalStatus status = this.localStatusManager.getStatus(transactionId); switch (status) { case YESVOTED: return Vote.YES; case NOVOTED: return Vote.NO; case BAD: case UNCERTAIN: this.localStatusManager.setStatus(transactionId, LocalStatus.NOVOTED); return Vote.NO; case GOOD: if (this.isLocalPromised(transactionId) && this.localParticipantsManager.allParticipantsVotedYes(transactionId)) { this.localStatusManager.setStatus(transactionId, LocalStatus.YESVOTED); return Vote.YES; } else { this.localStatusManager.setStatus(transactionId, LocalStatus.NOVOTED); return Vote.NO; } default: throw new IllegalStateException("illegal 2PC local status: " + status.toString()); } }  void setValidator(TransactionValidator validator); @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); }
TLSTransactionManager implements TransactionManager, Serializable { @Override public Vote vote(UUID transactionId) throws TransactionExecutionException { LocalStatus status = this.localStatusManager.getStatus(transactionId); switch (status) { case YESVOTED: return Vote.YES; case NOVOTED: return Vote.NO; case BAD: case UNCERTAIN: this.localStatusManager.setStatus(transactionId, LocalStatus.NOVOTED); return Vote.NO; case GOOD: if (this.isLocalPromised(transactionId) && this.localParticipantsManager.allParticipantsVotedYes(transactionId)) { this.localStatusManager.setStatus(transactionId, LocalStatus.YESVOTED); return Vote.YES; } else { this.localStatusManager.setStatus(transactionId, LocalStatus.NOVOTED); return Vote.NO; } default: throw new IllegalStateException("illegal 2PC local status: " + status.toString()); } }  void setValidator(TransactionValidator validator); @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);  }