//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void learnerShouldAskAllAliveInstancesAndTheseOnlyForMissingValue() throws Throwable //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void LearnerShouldAskAllAliveInstancesAndTheseOnlyForMissingValue() { // Given IList <URI> allMembers = new List <URI>(3); URI instance1 = URI.create("c:/1"); // this one is failed URI instance2 = URI.create("c:/2"); // this one is ok and will respond URI instance3 = URI.create("c:/3"); // this one is the requesting instance URI instance4 = URI.create("c:/4"); // and this one is ok and will respond too allMembers.Add(instance1); allMembers.Add(instance2); allMembers.Add(instance3); allMembers.Add(instance4); ISet <Org.Neo4j.cluster.InstanceId> aliveInstanceIds = new HashSet <Org.Neo4j.cluster.InstanceId>(); Org.Neo4j.cluster.InstanceId id2 = new Org.Neo4j.cluster.InstanceId(2); Org.Neo4j.cluster.InstanceId id4 = new Org.Neo4j.cluster.InstanceId(4); aliveInstanceIds.Add(id2); aliveInstanceIds.Add(id4); LearnerState state = LearnerState.Learner; LearnerContext ctx = mock(typeof(LearnerContext)); MessageHolder outgoing = mock(typeof(MessageHolder)); InstanceId paxosInstanceIdIAskedFor = new InstanceId(4); when(ctx.LastDeliveredInstanceId).thenReturn(3L); when(ctx.LastKnownLearnedInstanceInCluster).thenReturn(5L); when(ctx.MemberURIs).thenReturn(allMembers); when(ctx.Alive).thenReturn(aliveInstanceIds); when(ctx.GetUriForId(id2)).thenReturn(instance2); when(ctx.GetUriForId(id4)).thenReturn(instance4); when(ctx.GetPaxosInstance(paxosInstanceIdIAskedFor)).thenReturn(new PaxosInstance(mock(typeof(PaxosInstanceStore)), paxosInstanceIdIAskedFor)); Message <LearnerMessage> theCause = Message.to(LearnerMessage.CatchUp, instance2); // could be anything, really // When state.handle(ctx, Message.timeout(LearnerMessage.LearnTimedout, theCause), outgoing); // Then //JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET: //ORIGINAL LINE: verify(outgoing, times(1)).offer(org.mockito.ArgumentMatchers.argThat<org.neo4j.cluster.com.message.Message<? extends org.neo4j.cluster.com.message.MessageType>>(new org.neo4j.cluster.protocol.MessageArgumentMatcher() verify(outgoing, times(1)).offer(ArgumentMatchers.argThat <Message <MessageType> >(new MessageArgumentMatcher() .onMessageType(LearnerMessage.LearnRequest).to(instance2))); //JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET: //ORIGINAL LINE: verify(outgoing, times(1)).offer(org.mockito.ArgumentMatchers.argThat<org.neo4j.cluster.com.message.Message<? extends org.neo4j.cluster.com.message.MessageType>>(new org.neo4j.cluster.protocol.MessageArgumentMatcher() verify(outgoing, times(1)).offer(ArgumentMatchers.argThat <Message <MessageType> >(new MessageArgumentMatcher() .onMessageType(LearnerMessage.LearnRequest).to(instance4))); verifyNoMoreInteractions(outgoing); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldUseLastKnownOnlineClusterMemberAndSetTimeoutForCatchup() throws Throwable //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldUseLastKnownOnlineClusterMemberAndSetTimeoutForCatchup() { // Given LearnerState state = LearnerState.Learner; LearnerContext ctx = mock(typeof(LearnerContext)); MessageHolder outgoing = mock(typeof(MessageHolder)); Org.Neo4j.cluster.InstanceId upToDateClusterMember = new Org.Neo4j.cluster.InstanceId(1); // What we know when(ctx.LastLearnedInstanceId).thenReturn(0L); when(ctx.GetPaxosInstance(new Org.Neo4j.cluster.protocol.atomicbroadcast.multipaxos.InstanceId(1L))).thenReturn(new PaxosInstance(null, new Org.Neo4j.cluster.protocol.atomicbroadcast.multipaxos.InstanceId(1L))); when(ctx.LastKnownAliveUpToDateInstance).thenReturn(upToDateClusterMember); when(ctx.GetUriForId(upToDateClusterMember)).thenReturn(new URI("c:/1")); // What we know the cluster knows when(ctx.LastKnownLearnedInstanceInCluster).thenReturn(1L); // When Message <LearnerMessage> message = Message.to(LearnerMessage.CatchUp, new URI("c:/2"), 2L).setHeader(Message.HEADER_FROM, "c:/2").setHeader(Message.HEADER_INSTANCE_ID, "2"); State newState = state.handle(ctx, message, outgoing); // Then assertThat(newState, equalTo(LearnerState.Learner)); verify(outgoing).offer(Message.to(LearnerMessage.LearnRequest, new URI("c:/1"), new LearnerMessage.LearnRequestState()).setHeader(Org.Neo4j.cluster.protocol.atomicbroadcast.multipaxos.InstanceId.INSTANCE, Convert.ToString(1L))); verify(ctx).setTimeout("learn", Message.timeout(LearnerMessage.LearnTimedout, message)); }