Class OutboundInvocationTracker<T extends OutboundInvocationTracker<T>>
java.lang.Object
org.junit.rules.ExternalResource
de.hybris.platform.outboundservices.util.OutboundInvocationTracker<T>
- Type Parameters:
T- type of the subclass ofOutboundInvocationTracker
- All Implemented Interfaces:
org.junit.rules.TestRule
- Direct Known Subclasses:
TestDeleteRequestSender,TestOutboundFacade
public abstract class OutboundInvocationTracker<T extends OutboundInvocationTracker<T>>
extends org.junit.rules.ExternalResource
A base
ExternalResource rule for keeping track of a service invocation.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static classprotected static class -
Constructor Summary
ConstructorsConstructorDescriptionInstantiates this facade, which by default, if nothing else is specified will respond with the CREATED status and an empty body. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidafter()protected abstract org.springframework.http.ResponseEntity<Map>Creates an instance of the response to be used by default.Retrieves all invocations of theinternalSend(SyncParameters)methodprotected org.springframework.http.ResponseEntity<Map>internalSend(SyncParameters parameters) intRetrieves number of invocations captured by this tracker.itemsFromInvocationsTo(ConsumedDestinationModel dest, String ioCode) Retrieves items captured by this facade.itemsFromInvocationsTo(String dest, String ioCode) Retrieves items captured by this facade.keysFromInvocationsTo(String dest, String ioCode) Retrieves integration key for the deleted items that went through this service.performRunnableAndRespondWith(Runnable act, org.springframework.http.ResponseEntity.BodyBuilder builder) Specifies to perform an action before return the specified response from the send method.performRunnableAndRespondWith(Runnable act, org.springframework.http.ResponseEntity<Map> response) Specifies to perform an action before return the specified response from the send method.protected TrespondWith(Supplier<org.springframework.http.ResponseEntity<Map>> response) protected TrespondWith(org.springframework.http.ResponseEntity.HeadersBuilder builder) protected TrespondWith(org.springframework.http.ResponseEntity<Map> response) Specifies to throw an exception when the send method is called.Methods inherited from class org.junit.rules.ExternalResource
apply, before
-
Constructor Details
-
OutboundInvocationTracker
public OutboundInvocationTracker()Instantiates this facade, which by default, if nothing else is specified will respond with the CREATED status and an empty body.
-
-
Method Details
-
createDefaultResponse
Creates an instance of the response to be used by default.- Returns:
- a response that should be returned from the send invocations when explicit response was not specified.
-
throwException
Specifies to throw an exception when the send method is called.- Parameters:
e- an exception to throw- Returns:
- tracker with the behavior applied
-
performRunnableAndRespondWith
public T performRunnableAndRespondWith(Runnable act, org.springframework.http.ResponseEntity.BodyBuilder builder) Specifies to perform an action before return the specified response from the send method.- Parameters:
act- an action to perform before the response is returned. This allows to inject time-sensitive behavior to the test to call certain code when a desired item is being processed instead of relying on guessing the right time to execute that code in parallel.builder- a response builder to use to create the response after performing the actionact.- Returns:
- a tracker with the response specified.
-
performRunnableAndRespondWith
public T performRunnableAndRespondWith(Runnable act, org.springframework.http.ResponseEntity<Map> response) Specifies to perform an action before return the specified response from the send method.- Parameters:
act- an action to perform before the response is returned. This allows to inject time-sensitive behavior to the test to call certain code when a desired item is being processed instead of relying on guessing the right time to execute that code in parallel.response- response to return after performing the actionact.- Returns:
- a tracker with the response specified.
-
respondWith
-
respondWith
-
respondWith
-
internalSend
-
invocations
public int invocations()Retrieves number of invocations captured by this tracker.- Returns:
- number of times the
internalSend(SyncParameters)method has been invoked. This is the same value asgetAllInvocations().size()
-
getAllInvocations
Retrieves all invocations of theinternalSend(SyncParameters)method- Returns:
- a list of parameters passed to this tracker invocations in their chronological order or an empty list,
if the
internalSend(SyncParameters)was not invoked.
-
itemsFromInvocationsTo
Retrieves items captured by this facade.- Parameters:
dest- consumed destination, to which the items should have been sent.ioCode- code of IntegrationObject used for the items sent.- Returns:
- a collection of items send to the specified destination with the specified IntegrationObject code or an empty collection, if no items were sent with the specified parameters.
-
itemsFromInvocationsTo
Retrieves items captured by this facade.- Parameters:
dest- specifies consumed destination ID, to which the items should have been sent.ioCode- code of IntegrationObject used for the items sent.- Returns:
- a collection of items send to the specified destination with the specified IntegrationObject code or an empty collection, if no items were sent with the specified parameters.
-
keysFromInvocationsTo
Retrieves integration key for the deleted items that went through this service.- Parameters:
dest- specifies consumed destination ID, to which the items should have been sent.ioCode- code of IntegrationObject used for the items sent.- Returns:
- a collection of integration keys for the items deleted through this service in the specified destination or an empty collection, if no items were sent with the specified parameters.
-
after
protected void after()- Overrides:
afterin classorg.junit.rules.ExternalResource
-