@Test
public void testRequestVoteWithOlderTerm() throws Exception {

  Candidate candidate = new Candidate(mockRaftLog, scheduler, 150, mockRaftClient);
  candidate.init(mockRaftStateContext);
  Replica mockCandidate = config.getReplica("other");
  RequestVote request =
    RequestVote.newBuilder()
      .setCandidateId(mockCandidate.toString())
      .setLastLogIndex(1L)
      .setLastLogTerm(1L)
      .setTerm(1L)
      .build();
  candidate.requestVote(mockRaftStateContext, request);
  verify(mockRaftLog).currentTerm(3L);
  verify(mockRaftLog, times(1)).currentTerm(anyLong());
  verify(mockRaftLog).votedFor(java.util.Optional.of(self));
  verify(mockRaftLog, never()).votedFor(java.util.Optional.of(mockCandidate));
  verify(mockRaftLog, times(1)).votedFor(any(Optional.class));
  verify(mockRaftLog, never()).commitIndex(anyLong());
  verify(mockRaftStateContext).setState(any(Candidate.class), eq(Raft.StateType.LEADER));
  verifyZeroInteractions(mockRaftClient);
}