Class MockFlushStrategy
- java.lang.Object
-
- io.servicetalk.transport.netty.internal.MockFlushStrategy
-
- All Implemented Interfaces:
FlushStrategy
public final class MockFlushStrategy extends java.lang.Object implements FlushStrategy
A mocking setup forFlushStrategythat provides ways to verify interactions withFlushStrategy.WriteEventsListenerand also provides access toFlushStrategy.FlushSender.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface io.servicetalk.transport.netty.internal.FlushStrategy
FlushStrategy.FlushSender, FlushStrategy.WriteEventsListener
-
-
Constructor Summary
Constructors Constructor Description MockFlushStrategy()New instance.
-
Method Summary
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface io.servicetalk.transport.netty.internal.FlushStrategy
shouldFlushOnUnwritable
-
-
-
-
Method Detail
-
verifyApplied
public FlushStrategy.FlushSender verifyApplied()
Verifies that thisFlushStrategywas applied.- Returns:
FlushStrategy.FlushSenderprovided toapply(FlushSender).
-
verifyWriteStarted
public void verifyWriteStarted()
Verifies whetherFlushStrategy.WriteEventsListener.writeStarted()was called for theFlushStrategy.WriteEventsListenerreturned fromapply(FlushSender).
-
verifyItemWritten
public void verifyItemWritten(int count)
Verifies whetherFlushStrategy.WriteEventsListener.itemWritten(Object)was called for theFlushStrategy.WriteEventsListenerreturned fromapply(FlushSender).- Parameters:
count- Number of timesFlushStrategy.WriteEventsListener.itemWritten(Object)is expected to be called.
-
verifyWriteTerminated
public void verifyWriteTerminated()
Verifies whetherFlushStrategy.WriteEventsListener.writeTerminated()was called for theFlushStrategy.WriteEventsListenerreturned fromapply(FlushSender).
-
verifyWriteCancelled
public void verifyWriteCancelled()
Verifies whetherFlushStrategy.WriteEventsListener.writeCancelled()was called for theFlushStrategy.WriteEventsListenerreturned fromapply(FlushSender).
-
verifyNoMoreInteractions
public void verifyNoMoreInteractions()
Verifies there were no more interactions with theFlushStrategy.WriteEventsListenerreturned fromapply(FlushSender).
-
apply
public FlushStrategy.WriteEventsListener apply(FlushStrategy.FlushSender sender)
Description copied from interface:FlushStrategyEvery time a new write that requires custom flushes is initiated, this method is invoked. PassedFlushStrategy.FlushSenderis used tosignalto the connection that writes should now be flushed.- Specified by:
applyin interfaceFlushStrategy- Parameters:
sender-FlushStrategy.FlushSenderto signal flushes to the connection.- Returns:
FlushStrategy.WriteEventsListenerthat would listen to write events on the connection for which custom flushes are required.
-
afterFirstWrite
public void afterFirstWrite(java.util.function.Consumer<FlushStrategy.FlushSender> senderConsumer)
Invoke some code on the first invocation ofFlushStrategy.WriteEventsListener.itemWritten(Object).- Parameters:
senderConsumer- AConsumerthat is given theFlushStrategy.FlushSenderafterFlushStrategy.WriteEventsListener.itemWritten(Object).
-
-