Class MockOutgoing<P>

java.lang.Object
io.helidon.messaging.connectors.mock.MockOutgoing<P>
Type Parameters:
P - type of the payload

public class MockOutgoing<P> extends Object
Mock-able outgoing channel connected to the mock connector.
  • Method Details

    • request

      public MockOutgoing<P> request(long n)
      Control backpressure manually and request n items from upstream.
      Parameters:
      n - number of items requested from upstream
      Returns:
      this mocker
    • requestMax

      public MockOutgoing<P> requestMax()
      Request unbounded number of items from upstream and effectively turn off backpressure.
      Returns:
      this mocker
    • whenComplete

      public Single<Void> whenComplete()
      Returns single which is completed when the terminates with the complete signal.
      Returns:
      this mocker
    • awaitComplete

      public MockOutgoing<P> awaitComplete(Duration timeout)
      Block current thread until channel gets terminated with complete signal.
      Parameters:
      timeout - timeout when reached before complete signal is received, Completion exception is thrown.
      Returns:
      this mocker
      Throws:
      CancellationException - if the future was cancelled
      CompletionException - if the future completed exceptionally, was interrupted while waiting or the wait timed out
    • awaitCount

      public MockOutgoing<P> awaitCount(Duration timeout, int count)
      Block current thread until expected number of items is received.
      Parameters:
      count - number of items to be received for releasing current thread
      timeout - timeout when reached before specified number of items is received, Completion exception is thrown.
      Returns:
      this mocker
      Throws:
      CancellationException - if the future was cancelled
      CompletionException - if the future completed exceptionally, was interrupted while waiting or the wait timed out
    • awaitMessage

      public MockOutgoing<P> awaitMessage(Duration timeout, Function<Message<P>,Boolean> waitingFor)
      Block current thread until expected message is received.
      Parameters:
      waitingFor - function for comparing each received message, when true is returned, wait is over.
      timeout - timeout when reached before expected item is received, Completion exception is thrown.
      Returns:
      this mocker
      Throws:
      CancellationException - if the future was cancelled
      CompletionException - if the future completed exceptionally, was interrupted while waiting or the wait timed out
    • awaitData

      public MockOutgoing<P> awaitData(Duration timeout, Function<Message<P>,P> mapper, P... expectedItems)
      Block current thread until expected messages are received.
      Parameters:
      mapper - to be used for unwrapping the message for comparison with expected values
      expectedItems - one or more expected values
      timeout - timeout when reached before expected item is received, Completion exception is thrown.
      Returns:
      this mocker
      Throws:
      CancellationException - if the future was cancelled
      CompletionException - if the future completed exceptionally, was interrupted while waiting or the wait timed out
    • awaitPayloads

      @SafeVarargs public final MockOutgoing<P> awaitPayloads(Duration timeout, P... expectedItems)
      Block current thread until expected payloads are received.
      Parameters:
      expectedItems - one or more expected payload values
      timeout - timeout when reached before expected item is received, Completion exception is thrown.
      Returns:
      this mocker
      Throws:
      CancellationException - if the future was cancelled
      CompletionException - if the future completed exceptionally, was interrupted while waiting or the wait timed out
    • assertData

      public <T> MockOutgoing<P> assertData(Function<Message<P>,P> mapper, org.hamcrest.Matcher<? super T> matcher)
      Assert if matching data has been received.
      Type Parameters:
      T - matching type
      Parameters:
      mapper - to be used for unwrapping the messages for matching
      matcher - matcher to be used for asserting whole collection of the received and with provided mapper unwrapped data.
      Returns:
      this mocker
      Throws:
      CancellationException - if the future was cancelled
      CompletionException - if the future completed exceptionally, was interrupted while waiting or the wait timed out
    • assertPayloads

      public <T> MockOutgoing<P> assertPayloads(org.hamcrest.Matcher<? super T> matcher)
      Assert if matching payloads has been received.
      Type Parameters:
      T - matching type
      Parameters:
      matcher - applied on the whole collection of the received payloads
      Returns:
      this mocker
    • assertPayloads

      @SafeVarargs public final MockOutgoing<P> assertPayloads(P... expected)
      Assert if matching payloads has been received.
      Parameters:
      expected - applied on the whole collection of the received payloads
      Returns:
      this mocker
    • assertData

      @SafeVarargs public final MockOutgoing<P> assertData(Function<Message<P>,P> mapper, P... items)
      Assert if matching messages has been received.
      Parameters:
      mapper - to be used for unwrapping each message before comparison
      items - applied on the whole collection of the received payloads
      Returns:
      this mocker
    • data

      public List<Message<P>> data()
      Get all received data at this moment.
      Returns:
      All received data at this moment in unmodifiable list