context.getTermInformation().update(2, "test");
// Send an unknown message so that the state of the RaftActor remains unchanged
- RaftActorBehavior expected = behavior.handleMessage(candidateActor, "unknown");
+ behavior.handleMessage(candidateActor, "unknown");
RaftActorBehavior raftBehavior = behavior.handleMessage(candidateActor, appendEntries);
return new MockRaftActorContext("candidate", getSystem(), candidateActor);
}
+ @SuppressWarnings("unchecked")
private Map<String, String> setupPeers(final int count) {
Map<String, String> peerMap = new HashMap<>();
peerActors = new TestActorRef[count];
protected void assertStateChangesToFollowerWhenRaftRPCHasNewerTerm(final MockRaftActorContext actorContext,
final ActorRef actorRef, final RaftRPC rpc) throws Exception {
super.assertStateChangesToFollowerWhenRaftRPCHasNewerTerm(actorContext, actorRef, rpc);
- assertEquals("New votedFor", null, actorContext.getTermInformation().getVotedFor());
+ if(rpc instanceof RequestVote) {
+ assertEquals("New votedFor", ((RequestVote)rpc).getCandidateId(), actorContext.getTermInformation().getVotedFor());
+ } else {
+ assertEquals("New votedFor", null, actorContext.getTermInformation().getVotedFor());
+ }
}
}