java.lang.Object
io.helidon.messaging.connectors.mock.MockOutgoing<P>
- Type Parameters:
P
- type of the payload
Mock-able outgoing channel connected to the mock connector.
-
Method Summary
Modifier and TypeMethodDescription<T> MockOutgoing
<P> assertData
(Function<Message<P>, P> mapper, org.hamcrest.Matcher<? super T> matcher) Assert if matching data has been received.final MockOutgoing
<P> Assert if matching messages has been received.<T> MockOutgoing
<P> assertPayloads
(org.hamcrest.Matcher<? super T> matcher) Assert if matching payloads has been received.final MockOutgoing
<P> assertPayloads
(P... expected) Assert if matching payloads has been received.awaitComplete
(Duration timeout) Block current thread until channel gets terminated with complete signal.awaitCount
(Duration timeout, int count) Block current thread until expected number of items is received.Block current thread until expected messages are received.Block current thread until expected message is received.final MockOutgoing
<P> awaitPayloads
(Duration timeout, P... expectedItems) Block current thread until expected payloads are received.data()
Get all received data at this moment.request
(long n) Control backpressure manually and requestn
items from upstream.Requestunbounded
number of items from upstream and effectively turn off backpressure.Returns single which is completed when the terminates with the complete signal.
-
Method Details
-
request
Control backpressure manually and requestn
items from upstream.- Parameters:
n
- number of items requested from upstream- Returns:
- this mocker
-
requestMax
Requestunbounded
number of items from upstream and effectively turn off backpressure.- Returns:
- this mocker
-
whenComplete
Returns single which is completed when the terminates with the complete signal.- Returns:
- this mocker
-
awaitComplete
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 cancelledCompletionException
- if the future completed exceptionally, was interrupted while waiting or the wait timed out
-
awaitCount
Block current thread until expected number of items is received.- Parameters:
timeout
- timeout when reached before specified number of items is received, Completion exception is thrown.count
- number of items to be received for releasing current thread- Returns:
- this mocker
- Throws:
CancellationException
- if the future was cancelledCompletionException
- if the future completed exceptionally, was interrupted while waiting or the wait timed out
-
awaitMessage
Block current thread until expected message is received.- Parameters:
timeout
- timeout when reached before expected item is received, Completion exception is thrown.waitingFor
- function for comparing each received message, when true is returned, wait is over.- Returns:
- this mocker
- Throws:
CancellationException
- if the future was cancelledCompletionException
- 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:
timeout
- timeout when reached before expected item is received, Completion exception is thrown.mapper
- to be used for unwrapping the message for comparison with expected valuesexpectedItems
- one or more expected values- Returns:
- this mocker
- Throws:
CancellationException
- if the future was cancelledCompletionException
- if the future completed exceptionally, was interrupted while waiting or the wait timed out
-
awaitPayloads
Block current thread until expected payloads are received.- Parameters:
timeout
- timeout when reached before expected item is received, Completion exception is thrown.expectedItems
- one or more expected payload values- Returns:
- this mocker
- Throws:
CancellationException
- if the future was cancelledCompletionException
- 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 matchingmatcher
- 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 cancelledCompletionException
- if the future completed exceptionally, was interrupted while waiting or the wait timed out
-
assertPayloads
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
Assert if matching payloads has been received.- Parameters:
expected
- applied on the whole collection of the received payloads- Returns:
- this mocker
-
assertData
Assert if matching messages has been received.- Parameters:
mapper
- to be used for unwrapping each message before comparisonitems
- applied on the whole collection of the received payloads- Returns:
- this mocker
-
data
Get all received data at this moment.- Returns:
- All received data at this moment in unmodifiable list
-