//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test void testFilteredPathEvaluation() internal virtual void TestFilteredPathEvaluation() { //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.neo4j.graphdb.PropertyContainer endNode = mock(org.neo4j.graphdb.Node.class); PropertyContainer endNode = mock(typeof(Node)); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.neo4j.graphdb.PropertyContainer alternativeEndNode = mock(org.neo4j.graphdb.Node.class); PropertyContainer alternativeEndNode = mock(typeof(Node)); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.neo4j.graphdb.Node startNode = mock(org.neo4j.graphdb.Node.class); Node startNode = mock(typeof(Node)); Evaluator evaluator = mock(typeof(Evaluator)); TraversalBranch branch = mock(typeof(TraversalBranch)); TraversalBranch alternativeBranch = mock(typeof(TraversalBranch)); when(branch.GetEnumerator()).thenAnswer(new IteratorAnswer(endNode)); when(alternativeBranch.GetEnumerator()).thenAnswer(new IteratorAnswer(alternativeEndNode)); when(alternativeBranch.StartNode()).thenReturn(startNode); when(evaluator.Evaluate(Mockito.any(typeof(Path)))).thenReturn(Evaluation.INCLUDE_AND_CONTINUE); StandardBranchCollisionDetector collisionDetector = new StandardBranchCollisionDetector(evaluator, path => alternativeEndNode.Equals(path.endNode()) && startNode.Equals(path.startNode())); ICollection <Path> incoming = collisionDetector.Evaluate(branch, Direction.INCOMING); ICollection <Path> outgoing = collisionDetector.Evaluate(branch, Direction.OUTGOING); ICollection <Path> alternativeIncoming = collisionDetector.Evaluate(alternativeBranch, Direction.INCOMING); ICollection <Path> alternativeOutgoing = collisionDetector.Evaluate(alternativeBranch, Direction.OUTGOING); assertNull(incoming); assertNull(outgoing); assertNull(alternativeIncoming); assertEquals(1, alternativeOutgoing.Count); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void delayedVoteFromPreviousElectionMustNotCauseCurrentElectionToComplete() throws Throwable //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void DelayedVoteFromPreviousElectionMustNotCauseCurrentElectionToComplete() { // Given ElectionContext context = mock(typeof(ElectionContext)); MessageHolder holder = mock(typeof(MessageHolder)); when(context.GetLog(Mockito.any())).thenReturn(NullLog.Instance); const string role = "master"; //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.neo4j.cluster.InstanceId voter = new org.neo4j.cluster.InstanceId(2); InstanceId voter = new InstanceId(2); ElectionCredentials voteCredentialComparable = mock(typeof(ElectionCredentials)); Message <ElectionMessage> vote = Message.@internal(voted, new ElectionMessage.VersionedVotedData(role, voter, voteCredentialComparable, 4)); when(context.Voted(role, voter, voteCredentialComparable, 4)).thenReturn(false); // When election.handle(context, vote, holder); verify(context).getLog(ArgumentMatchers.any()); verify(context).voted(role, voter, voteCredentialComparable, 4); // Then verifyNoMoreInteractions(context, holder); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test void shouldReportStoreSizes() throws Throwable //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: internal virtual void ShouldReportStoreSizes() { UdcInformationCollector collector = new DefaultUdcInformationCollector(Config.defaults(), _dataSourceManager, _usageData); when(_fileSystem.getFileSize(Mockito.any())).thenReturn(152L); IDictionary <string, string> udcParams = collector.UdcParams; assertThat(udcParams["storesize"], @is("152")); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void electionShouldRemainLocalIfStartedBySingleInstanceWhichIsTheRoleHolder() throws Throwable //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ElectionShouldRemainLocalIfStartedBySingleInstanceWhichIsTheRoleHolder() { /* * Ensures that when an instance is alone in the cluster, elections for roles that it holds do not set * timeouts or try to reach other instances. */ // Given ElectionContext context = mock(typeof(ElectionContext)); ClusterContext clusterContextMock = mock(typeof(ClusterContext)); when(clusterContextMock.GetLog(ArgumentMatchers.any())).thenReturn(NullLog.Instance); MessageHolder holder = mock(typeof(MessageHolder)); // These mean the election can proceed normally, by us when(context.ElectionOk()).thenReturn(true); when(context.InCluster).thenReturn(true); when(context.Elector).thenReturn(true); // Like it says on the box, we are the only instance //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.neo4j.cluster.InstanceId myInstanceId = new org.neo4j.cluster.InstanceId(1); InstanceId myInstanceId = new InstanceId(1); IDictionary <InstanceId, URI> members = new Dictionary <InstanceId, URI>(); members[myInstanceId] = URI.create("ha://me"); when(context.Members).thenReturn(members); // Any role would do, just make sure we have it const string role = "master"; ElectionContext_VoteRequest voteRequest = new ElectionContext_VoteRequest(role, 13); when(context.PossibleRoles).thenReturn(Collections.singletonList(new ElectionRole(role))); when(context.GetElected(role)).thenReturn(myInstanceId); when(context.VoteRequestForRole(new ElectionRole(role))).thenReturn(voteRequest); // Required for logging when(context.GetLog(Mockito.any())).thenReturn(NullLog.Instance); // When election.handle(context, Message.@internal(performRoleElections), holder); // Then // Make sure that we asked ourselves to vote for that role and that no timer was set verify(holder, times(1)).offer(ArgumentMatchers.argThat(new MessageArgumentMatcher <ElectionMessage>() .onMessageType(ElectionMessage.Vote).withPayload(voteRequest))); verify(context, never()).setTimeout(ArgumentMatchers.any(), ArgumentMatchers.any()); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void timeoutMakesElectionBeForgotten() throws Throwable //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void TimeoutMakesElectionBeForgotten() { // Given string coordinatorRole = "coordinator"; ElectionContext context = mock(typeof(ElectionContext)); when(context.GetLog(Mockito.any())).thenReturn(NullLog.Instance); MessageHolder holder = mock(typeof(MessageHolder)); Message <ElectionMessage> timeout = Message.timeout(ElectionMessage.ElectionTimeout, Message.@internal(performRoleElections), new ElectionState.ElectionTimeoutData(coordinatorRole, null)); // When election.handle(context, timeout, holder); // Then verify(context, times(1)).forgetElection(coordinatorRole); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void electionCompletingMakesItBeForgotten() throws Throwable //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ElectionCompletingMakesItBeForgotten() { // Given string coordinatorRole = "coordinator"; InstanceId votingInstance = new InstanceId(2); ElectionCredentials voteCredentialComparable = mock(typeof(ElectionCredentials)); ElectionContext context = mock(typeof(ElectionContext)); when(context.GetLog(Mockito.any())).thenReturn(NullLog.Instance); when(context.NeededVoteCount).thenReturn(3); when(context.GetVoteCount(coordinatorRole)).thenReturn(3); when(context.Voted(coordinatorRole, votingInstance, voteCredentialComparable, 4)).thenReturn(true); MessageHolder holder = mock(typeof(MessageHolder)); Message <ElectionMessage> vote = Message.to(ElectionMessage.Voted, URI.create("cluster://elector"), new ElectionMessage.VersionedVotedData(coordinatorRole, votingInstance, voteCredentialComparable, 4)); // When election.handle(context, vote, holder); // Then verify(context, times(1)).forgetElection(coordinatorRole); }