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 forFlushStrategy
that provides ways to verify interactions withFlushStrategy.WriteEventsListener
and 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 thisFlushStrategy
was applied.- Returns:
FlushStrategy.FlushSender
provided toapply(FlushSender)
.
-
verifyWriteStarted
public void verifyWriteStarted()
Verifies whetherFlushStrategy.WriteEventsListener.writeStarted()
was called for theFlushStrategy.WriteEventsListener
returned fromapply(FlushSender)
.
-
verifyItemWritten
public void verifyItemWritten(int count)
Verifies whetherFlushStrategy.WriteEventsListener.itemWritten(Object)
was called for theFlushStrategy.WriteEventsListener
returned 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.WriteEventsListener
returned fromapply(FlushSender)
.
-
verifyWriteCancelled
public void verifyWriteCancelled()
Verifies whetherFlushStrategy.WriteEventsListener.writeCancelled()
was called for theFlushStrategy.WriteEventsListener
returned fromapply(FlushSender)
.
-
verifyNoMoreInteractions
public void verifyNoMoreInteractions()
Verifies there were no more interactions with theFlushStrategy.WriteEventsListener
returned fromapply(FlushSender)
.
-
apply
public FlushStrategy.WriteEventsListener apply(FlushStrategy.FlushSender sender)
Description copied from interface:FlushStrategy
Every time a new write that requires custom flushes is initiated, this method is invoked. PassedFlushStrategy.FlushSender
is used tosignal
to the connection that writes should now be flushed.- Specified by:
apply
in interfaceFlushStrategy
- Parameters:
sender
-FlushStrategy.FlushSender
to signal flushes to the connection.- Returns:
FlushStrategy.WriteEventsListener
that 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
- AConsumer
that is given theFlushStrategy.FlushSender
afterFlushStrategy.WriteEventsListener.itemWritten(Object)
.
-
-