public void testBecomeLeaderOnReceivingMajorityVotesWithNonVotingPeers(){
ElectionTerm mockElectionTerm = Mockito.mock(ElectionTerm.class);
Mockito.doReturn(1L).when(mockElectionTerm).getCurrentTerm();
+ Mockito.doNothing().when(mockElectionTerm).updateAndPersist(Mockito.any(long.class), Mockito.any(String.class));
+
RaftActorContext raftActorContext = new RaftActorContextImpl(candidateActor, candidateActor.actorContext(),
"candidate", mockElectionTerm, -1, -1, setupPeers(4), new DefaultConfigParamsImpl(),
new NonPersistentDataProvider(), LOG);
// Send an unknown message so that the state of the RaftActor remains unchanged
RaftActorBehavior expected = behavior.handleMessage(candidateActor, "unknown");
+ assertTrue(expected instanceof Candidate);
RaftActorBehavior raftBehavior = behavior.handleMessage(candidateActor, appendEntries);
return new MockRaftActorContext("candidate", getSystem(), candidateActor);
}
+ @SuppressWarnings("unchecked")
private Map<String, String> setupPeers(int count) {
Map<String, String> peerMap = new HashMap<>();
peerActors = new TestActorRef[count];