//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldStayAsCandidateOnReceivingDeniedVoteResponseWithCurrentTerm() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldStayAsCandidateOnReceivingDeniedVoteResponseWithCurrentTerm() { // given RaftState state = NewState(); // when Outcome outcome = CANDIDATE.handler.handle(voteResponse().term(state.Term()).from(_member1).deny().build(), state, Log()); // then assertEquals(CANDIDATE, outcome.Role); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldDeclinePreVoteFromSameTerm() throws Throwable //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldDeclinePreVoteFromSameTerm() { // given RaftState raftState = raftState().myself(_myself).supportsPreVoting(true).build(); // when Outcome outcome = CANDIDATE.handler.handle(preVoteRequest().candidate(_member1).from(_member1).term(raftState.Term()).build(), raftState, Log()); // then assertThat(outcome.OutgoingMessages, hasItem(new Org.Neo4j.causalclustering.core.consensus.RaftMessages_Directed(_member1, preVoteResponse().term(raftState.Term()).from(_myself).deny().build()))); assertEquals(Role.Candidate, outcome.Role); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldBeElectedLeaderOnReceivingGrantedVoteResponseWithCurrentTerm() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldBeElectedLeaderOnReceivingGrantedVoteResponseWithCurrentTerm() { // given RaftState state = RaftStateBuilder.raftState().term(1).myself(_myself).votingMembers(_member1, _member2).replicationMembers(_member1, _member2).build(); // when Outcome outcome = CANDIDATE.handler.handle(voteResponse().term(state.Term()).from(_member1).grant().build(), state, Log()); // then assertEquals(LEADER, outcome.Role); assertTrue(outcome.ElectionTimeoutRenewed()); assertThat(outcome.LogCommands, hasItem(new AppendLogEntry(0, new RaftLogEntry(state.Term(), new NewLeaderBarrier())))); assertThat(outcome.OutgoingMessages, hasItems(new Org.Neo4j.causalclustering.core.consensus.RaftMessages_Directed(_member1, new Org.Neo4j.causalclustering.core.consensus.RaftMessages_Heartbeat(_myself, state.Term(), -1, -1)), new Org.Neo4j.causalclustering.core.consensus.RaftMessages_Directed(_member2, new Org.Neo4j.causalclustering.core.consensus.RaftMessages_Heartbeat(_myself, state.Term(), -1, -1)))); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldRejectVoteRequestFromPreviousTerm() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldRejectVoteRequestFromPreviousTerm() { RaftState state = NewState(); // when //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final long candidateTerm = state.term() - 1; long candidateTerm = state.Term() - 1; Outcome outcome = Role.handler.handle(voteRequest().from(_member1).term(candidateTerm).lastLogIndex(0).lastLogTerm(-1).build(), state, Log()); // then assertFalse(((Org.Neo4j.causalclustering.core.consensus.RaftMessages_Vote_Response)messageFor(outcome, _member1)).voteGranted()); assertEquals(Role, outcome.Role); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldDenyForCandidateInLaterTermWhenPreVoteNotActive() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldDenyForCandidateInLaterTermWhenPreVoteNotActive() { // given RaftState state = NewState(); // when //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final long candidateTerm = state.term() + 1; long candidateTerm = state.Term() + 1; Outcome outcome = Role.handler.handle(preVoteRequest().from(_member1).term(candidateTerm).lastLogIndex(0).lastLogTerm(-1).build(), state, Log()); // then assertFalse(((Org.Neo4j.causalclustering.core.consensus.RaftMessages_PreVote_Response)messageFor(outcome, _member1)).voteGranted()); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldUpdateTermIfRequestIsFromLaterTerm() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldUpdateTermIfRequestIsFromLaterTerm() { // given RaftState state = NewState(); // when //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final long candidateTerm = state.term() + 1; long candidateTerm = state.Term() + 1; Outcome outcome = Role.handler.handle(preVoteRequest().from(_member1).term(candidateTerm).lastLogIndex(0).lastLogTerm(-1).build(), state, Log()); // then assertEquals(candidateTerm, outcome.Term); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldRejectVoteResponseWithOldTerm() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldRejectVoteResponseWithOldTerm() { // given RaftState state = NewState(); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final long voterTerm = state.term() - 1; long voterTerm = state.Term() - 1; // when Outcome outcome = CANDIDATE.handler.handle(voteResponse().term(voterTerm).from(_member1).grant().build(), state, Log()); // then assertEquals(CANDIDATE, outcome.Role); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldBecomeFollowerIfReceivePreVoteRequestFromLaterTerm() throws Throwable //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldBecomeFollowerIfReceivePreVoteRequestFromLaterTerm() { // given RaftState raftState = raftState().myself(_myself).supportsPreVoting(true).build(); long newTerm = raftState.Term() + 1; // when Outcome outcome = CANDIDATE.handler.handle(preVoteRequest().candidate(_member1).from(_member1).term(newTerm).build(), raftState, Log()); // then assertEquals(newTerm, outcome.Term); assertEquals(Role.Follower, outcome.Role); assertThat(outcome.VotesForMe, empty()); assertThat(outcome.OutgoingMessages, hasItem(new Org.Neo4j.causalclustering.core.consensus.RaftMessages_Directed(_member1, preVoteResponse().term(newTerm).from(_myself).deny().build()))); }