//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldStopJob() throws Throwable //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldStopJob() { // given BatchingMessageHandler batchHandler = new BatchingMessageHandler(_downstreamHandler, _inQueueConfig, _batchConfig, _jobSchedulerFactory, NullLogProvider.Instance); // when batchHandler.Stop(); // then Mockito.verify(_mockJob).stop(); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldStartJob() throws Throwable //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldStartJob() { // given BatchingMessageHandler batchHandler = new BatchingMessageHandler(_downstreamHandler, _inQueueConfig, _batchConfig, _jobSchedulerFactory, NullLogProvider.Instance); ClusterId clusterId = new ClusterId(System.Guid.randomUUID()); // when batchHandler.Start(clusterId); // then Mockito.verify(_mockJob).start(); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldDropMessagesAfterBeingStopped() throws Throwable //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldDropMessagesAfterBeingStopped() { // given AssertableLogProvider logProvider = new AssertableLogProvider(); BatchingMessageHandler batchHandler = new BatchingMessageHandler(_downstreamHandler, _inQueueConfig, _batchConfig, _jobSchedulerFactory, logProvider); NewEntry.Request message = new NewEntry.Request(null, null); batchHandler.Stop(); // when batchHandler.Handle(Wrap(message)); batchHandler.Run(); // then verify(_downstreamHandler, never()).handle(ArgumentMatchers.any(typeof(RaftMessages_ReceivedInstantClusterIdAwareMessage))); logProvider.AssertAtLeastOnce(AssertableLogProvider.inLog(typeof(BatchingMessageHandler)).debug("This handler has been stopped, dropping the message: %s", Wrap(message))); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldInvokeInnerHandlerWhenRun() public virtual void ShouldInvokeInnerHandlerWhenRun() { // given BatchingMessageHandler batchHandler = new BatchingMessageHandler(_downstreamHandler, _inQueueConfig, _batchConfig, _jobSchedulerFactory, NullLogProvider.Instance); NewEntry.Request message = new NewEntry.Request(null, Content("dummy")); batchHandler.Handle(Wrap(message)); verifyZeroInteractions(_downstreamHandler); // when batchHandler.Run(); // then NewEntry.BatchRequest expected = new NewEntry.BatchRequest(singletonList(new ReplicatedString("dummy"))); verify(_downstreamHandler).handle(Wrap(expected)); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldBatchMultipleEntryAppendEntries() public virtual void ShouldBatchMultipleEntryAppendEntries() { BatchingMessageHandler batchHandler = new BatchingMessageHandler(_downstreamHandler, _inQueueConfig, _batchConfig, _jobSchedulerFactory, NullLogProvider.Instance); long leaderTerm = 1; long prevLogIndex = -1; long prevLogTerm = -1; long leaderCommit = 0; RaftLogEntry[] entriesA = Entries(0, 0, 2); RaftLogEntry[] entriesB = Entries(1, 3, 3); RaftLogEntry[] entriesC = Entries(2, 4, 8); RaftLogEntry[] entriesD = Entries(3, 9, 15); AppendEntries.Request appendA = new AppendEntries.Request(_leader, leaderTerm, prevLogIndex, prevLogTerm, entriesA, leaderCommit); prevLogIndex += appendA.entries().length; prevLogTerm = lastOf(appendA.entries()).term(); leaderCommit += 2; // arbitrary AppendEntries.Request appendB = new AppendEntries.Request(_leader, leaderTerm, prevLogIndex, prevLogTerm, entriesB, leaderCommit); prevLogIndex += appendB.entries().length; prevLogTerm = lastOf(appendB.entries()).term(); leaderCommit += 5; // arbitrary AppendEntries.Request appendC = new AppendEntries.Request(_leader, leaderTerm, prevLogIndex, prevLogTerm, ArrayUtil.concat(entriesC, entriesD), leaderCommit); batchHandler.Handle(Wrap(appendA)); batchHandler.Handle(Wrap(appendB)); batchHandler.Handle(Wrap(appendC)); verifyZeroInteractions(_downstreamHandler); // when batchHandler.Run(); // then AppendEntries.Request expected = new AppendEntries.Request(_leader, leaderTerm, -1, -1, ArrayUtil.concatArrays(entriesA, entriesB, entriesC, entriesD), leaderCommit); verify(_downstreamHandler).handle(Wrap(expected)); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldBatchUsingReceivedInstantOfFirstReceivedMessage() public virtual void ShouldBatchUsingReceivedInstantOfFirstReceivedMessage() { // given BatchingMessageHandler batchHandler = new BatchingMessageHandler(_downstreamHandler, _inQueueConfig, _batchConfig, _jobSchedulerFactory, NullLogProvider.Instance); ReplicatedString content = new ReplicatedString("A"); NewEntry.Request messageA = new NewEntry.Request(null, content); Instant firstReceived = Instant.ofEpochMilli(1L); Instant secondReceived = firstReceived.plusMillis(1L); batchHandler.Handle(Wrap(firstReceived, messageA)); batchHandler.Handle(Wrap(secondReceived, messageA)); // when batchHandler.Run(); // then NewEntry.BatchRequest batchRequest = new NewEntry.BatchRequest(asList(content, content)); verify(_downstreamHandler).handle(Wrap(firstReceived, batchRequest)); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldBatchRequests() public virtual void ShouldBatchRequests() { // given BatchingMessageHandler batchHandler = new BatchingMessageHandler(_downstreamHandler, _inQueueConfig, _batchConfig, _jobSchedulerFactory, NullLogProvider.Instance); ReplicatedString contentA = new ReplicatedString("A"); ReplicatedString contentB = new ReplicatedString("B"); NewEntry.Request messageA = new NewEntry.Request(null, contentA); NewEntry.Request messageB = new NewEntry.Request(null, contentB); batchHandler.Handle(Wrap(messageA)); batchHandler.Handle(Wrap(messageB)); verifyZeroInteractions(_downstreamHandler); // when batchHandler.Run(); // then NewEntry.BatchRequest expected = new NewEntry.BatchRequest(asList(contentA, contentB)); verify(_downstreamHandler).handle(Wrap(expected)); }