//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldCorrectlySetTheInstanceIdHeaderInTheGeneratedHeartbeat() public virtual void ShouldCorrectlySetTheInstanceIdHeaderInTheGeneratedHeartbeat() { //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final java.util.List<org.neo4j.cluster.com.message.Message> sentOut = new java.util.LinkedList<>(); IList <Message> sentOut = new LinkedList <Message>(); // Given MessageHolder holder = mock(typeof(MessageHolder)); // The sender, which adds messages outgoing to the list above. doAnswer(invocation => { sentOut.Add(invocation.getArgument(0)); return(null); }).when(holder).offer(ArgumentMatchers.any <Message <MessageType> >()); ClusterContext mockContext = mock(typeof(ClusterContext)); ClusterConfiguration mockConfiguration = mock(typeof(ClusterConfiguration)); when(mockConfiguration.Members).thenReturn(new HashMapAnonymousInnerClass5(this)); when(mockContext.Configuration).thenReturn(mockConfiguration); HeartbeatIAmAliveProcessor processor = new HeartbeatIAmAliveProcessor(holder, mockContext); Message incoming = Message.to(mock(typeof(MessageType)), URI.create("ha://someAwesomeInstanceInJapan")).setHeader(Message.HEADER_INSTANCE_ID, "2").setHeader(Message.HEADER_FROM, "ha://2"); // WHEN processor.Process(incoming); // THEN assertEquals(1, sentOut.Count); assertEquals(HeartbeatMessage.IAmAlive, sentOut[0].MessageType); assertEquals(new InstanceId(2), ((HeartbeatMessage.IAmAliveState)sentOut[0].Payload).Server); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldNotCreateHeartbeatsForNonExistingInstances() public virtual void ShouldNotCreateHeartbeatsForNonExistingInstances() { // GIVEN MessageHolder outgoing = mock(typeof(MessageHolder)); ClusterContext mockContext = mock(typeof(ClusterContext)); ClusterConfiguration mockConfiguration = mock(typeof(ClusterConfiguration)); when(mockConfiguration.Members).thenReturn(new HashMapAnonymousInnerClass(this)); when(mockContext.Configuration).thenReturn(mockConfiguration); HeartbeatIAmAliveProcessor processor = new HeartbeatIAmAliveProcessor(outgoing, mockContext); Message incoming = Message.to(mock(typeof(MessageType)), URI.create("ha://someAwesomeInstanceInJapan")).setHeader(Message.HEADER_FROM, "some://value").setHeader(Message.HEADER_INSTANCE_ID, "5"); // WHEN processor.Process(incoming); // THEN verifyZeroInteractions(outgoing); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldNotProcessMessagesWithEqualFromAndToHeaders() public virtual void ShouldNotProcessMessagesWithEqualFromAndToHeaders() { URI to = URI.create("ha://someAwesomeInstanceInJapan"); // GIVEN MessageHolder outgoing = mock(typeof(MessageHolder)); ClusterContext mockContext = mock(typeof(ClusterContext)); ClusterConfiguration mockConfiguration = mock(typeof(ClusterConfiguration)); when(mockConfiguration.Members).thenReturn(new HashMapAnonymousInnerClass2(this)); when(mockContext.Configuration).thenReturn(mockConfiguration); HeartbeatIAmAliveProcessor processor = new HeartbeatIAmAliveProcessor(outgoing, mockContext); Message incoming = Message.to(mock(typeof(MessageType)), to).setHeader(Message.HEADER_FROM, to.toASCIIString()).setHeader(Message.HEADER_INSTANCE_ID, "1"); // WHEN processor.Process(incoming); // THEN verifyZeroInteractions(outgoing); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldNotGenerateHeartbeatsForHeartbeats() public virtual void ShouldNotGenerateHeartbeatsForHeartbeats() { URI to = URI.create("ha://1"); // GIVEN MessageHolder outgoing = mock(typeof(MessageHolder)); ClusterContext mockContext = mock(typeof(ClusterContext)); ClusterConfiguration mockConfiguration = mock(typeof(ClusterConfiguration)); when(mockConfiguration.Members).thenReturn(new HashMapAnonymousInnerClass4(this)); when(mockContext.Configuration).thenReturn(mockConfiguration); HeartbeatIAmAliveProcessor processor = new HeartbeatIAmAliveProcessor(outgoing, mockContext); Message incoming = Message.to(HeartbeatMessage.IAmAlive, to).setHeader(Message.HEADER_FROM, to.toASCIIString()).setHeader(Message.HEADER_INSTANCE_ID, "1"); assertEquals(HeartbeatMessage.IAmAlive, incoming.MessageType); // WHEN processor.Process(incoming); // THEN verifyZeroInteractions(outgoing); }