@Test
public void testCandidateWithLesserTerm() {

  BaseState state = new EmptyState(mockRaftLog);
  RequestVote requestVote = RequestVote.newBuilder()
    .setCandidateId(candidate.toString())
    .setLastLogIndex(2)
    .setLastLogTerm(1)
    .setTerm(2)
    .build();
  Replica otherCandidate = config.getReplica("other");
  when(mockRaftLog.votedFor()).thenReturn(Optional.of(otherCandidate));
  boolean shouldVote = state.shouldVoteFor(mockRaftLog, requestVote);
  assertFalse(shouldVote);
}