@Test
public void testCandidateWithLesserIndex() {

    BaseState state = new EmptyState();
    RequestVote requestVote = RequestVote.newBuilder().setCandidateId(candidate.toString()).setLastLogIndex(1).setLastLogTerm(2).setTerm(2).build();
    Replica otherCandidate = Replica.fromString("localhost:8002");
    when(mockRaftLog.lastVotedFor()).thenReturn(Optional.of(otherCandidate));
    boolean shouldVote = state.shouldVoteFor(mockRaftLog, requestVote);
    assertFalse(shouldVote);
}