R
- The reply class of the message generated by this endpoint. (Reply Class)I
- The incoming message class for this endpoint. (Request Class)public abstract class AbstractMatsTestEndpoint<R,I>
extends java.lang.Object
MatsEndpoint
which processor can be modified on the fly. Also provides utility methods to extract
incoming requests and verify that endpoint har or hasn't been invoked.Modifier and Type | Field and Description |
---|---|
protected MatsFactory |
_matsFactory |
protected MatsEndpoint.ProcessSingleLambda<R,I> |
_processLambda |
Modifier | Constructor and Description |
---|---|
protected |
AbstractMatsTestEndpoint(java.lang.String endpointId,
java.lang.Class<R> replyMsgClass,
java.lang.Class<I> incomingMsgClass)
Base constructor for
AbstractMatsTestEndpoint , takes all values needed to setup the test endpoint. |
Modifier and Type | Method and Description |
---|---|
void |
after()
Shutdown and remove the endpoint from the
MatsFactory after test and remove reference to endpoint from
field. |
void |
before()
Registers a
MatsEndpoint with the provided MatsFactory , notice that the MatsFactory is
not set or provided directly through this class through the use of the constructor or a method. |
protected java.lang.String |
idThis() |
abstract AbstractMatsTestEndpoint<R,I> |
setMatsFactory(MatsFactory matsFactory)
Set the
MatsFactory of this class _matsFactory . |
abstract AbstractMatsTestEndpoint<R,I> |
setProcessLambda(MatsEndpoint.ProcessSingleLambda<R,I> processLambda)
Specify the processing lambda to be executed by the endpoint aka the endpoint logic.
|
void |
verifyNotInvoked()
Verifies that this endpoint has not been invoked.
|
I |
waitForRequest()
Blocks and waits for the endpoint to be invoked, then returns the incoming message DTO of the type
(
I ). |
I |
waitForRequest(long millisToWait)
Blocks and waits for the endpoint to be invoked, then returns the incoming message DTO of the type
(
I ). |
java.util.List<I> |
waitForRequests(int expectedNumberOfRequests)
Blocks and waits for the endpoint to be invoked x number of times, then returns the x number of corresponding
incoming message DTO's of the type (
I ). |
java.util.List<I> |
waitForRequests(int expectedNumberOfRequests,
long millisToWait)
Blocks and waits for the endpoint to be invoked x number of times, then returns the x number of corresponding
incoming message DTO's of the type (
I ). |
protected MatsFactory _matsFactory
protected MatsEndpoint.ProcessSingleLambda<R,I> _processLambda
protected AbstractMatsTestEndpoint(java.lang.String endpointId, java.lang.Class<R> replyMsgClass, java.lang.Class<I> incomingMsgClass)
AbstractMatsTestEndpoint
, takes all values needed to setup the test endpoint.endpointId
- Identifier of the endpoint being created.replyMsgClass
- Class of the reply message.incomingMsgClass
- Class of the incoming message. (Request)public abstract AbstractMatsTestEndpoint<R,I> setMatsFactory(MatsFactory matsFactory)
MatsFactory
of this class _matsFactory
. Shall be implemented by the extending class.matsFactory
- instance to store internally.this
for chaining.public abstract AbstractMatsTestEndpoint<R,I> setProcessLambda(MatsEndpoint.ProcessSingleLambda<R,I> processLambda)
processLambda
- which the endpoint should execute on an incoming request.public I waitForRequest()
I
). Will use a default timout value of 30 seconds.public I waitForRequest(long millisToWait)
I
).millisToWait
- time to wait before timing out.public java.util.List<I> waitForRequests(int expectedNumberOfRequests)
I
). Will utilize a default timeout value of 30 seconds.expectedNumberOfRequests
- the number of requests before unblocking and returning the received objects.public java.util.List<I> waitForRequests(int expectedNumberOfRequests, long millisToWait)
I
).expectedNumberOfRequests
- the number of requests before unblocking and returning the received objects.millisToWait
- time to wait before timing out.public void verifyNotInvoked()
UnexpectedMatsTestEndpointInvocationError
- exception thrown if the endpoint has been invoked.protected java.lang.String idThis()
public void before()
MatsEndpoint
with the provided MatsFactory
, notice that the MatsFactory
is
not set or provided directly through this class through the use of the constructor or a method. It is up to the
extending class to provide this factory.
The created endpoint is created as a MatsFactory.staged(java.lang.String, java.lang.Class<R>, java.lang.Class<S>)
endpoint, the reason behind this is that a staged
endpoint does not require a return unlike a MatsFactory.single(java.lang.String, java.lang.Class<R>, java.lang.Class<I>, io.mats3.MatsEndpoint.ProcessSingleLambda<R, I>)
.
This method should be called as a result of the following life cycle events for either JUnit or Jupiter:
public void after()
MatsFactory
after test and remove reference to endpoint from
field.
This method should be called as a result of the following life cycle events for either JUnit or Jupiter: