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.ExternalResourceA baseExternalResourcerule for keeping track of a service invocation.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static classOutboundInvocationTracker.EntityResponse<R>protected static classOutboundInvocationTracker.ExceptionResponseprotected static classOutboundInvocationTracker.Invocation
-
Field Summary
Fields Modifier and Type Field Description protected java.util.Collection<OutboundInvocationTracker.Invocation>invocations
-
Constructor Summary
Constructors Constructor Description OutboundInvocationTracker()Instantiates this facade, which by default, if nothing else is specified will respond with the CREATED status and an empty body.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected voidafter()protected abstract org.springframework.http.ResponseEntity<java.util.Map>createDefaultResponse()Creates an instance of the response to be used by default.TdoAndRespondWith(org.springframework.http.ResponseEntity.BodyBuilder builder, java.lang.Runnable act)Specifies to perform an action before return the specified response from the send method.TdoAndRespondWith(org.springframework.http.ResponseEntity<java.util.Map> response, java.lang.Runnable act)Specifies to perform an action before return the specified response from the send method.protected org.springframework.http.ResponseEntity<java.util.Map>internalSend(SyncParameters parameters)intinvocations()java.util.Collection<ItemModel>itemsFromInvocationsTo(ConsumedDestinationModel dest, java.lang.String ioCode)Retrieves items captured by this facade.java.util.Collection<ItemModel>itemsFromInvocationsTo(java.lang.String dest, java.lang.String ioCode)Retrieves items captured by this facade.java.util.List<java.lang.String>keysFromInvocationsTo(java.lang.String dest, java.lang.String ioCode)Retrieves integration key for the deleted items that went through this service.protected TrespondWith(java.util.function.Supplier<org.springframework.http.ResponseEntity<java.util.Map>> response)protected TrespondWith(org.springframework.http.ResponseEntity<java.util.Map> response)TthrowException(java.lang.RuntimeException e)Specifies to throw an exception when the send method is called.
-
-
-
Field Detail
-
invocations
protected final java.util.Collection<OutboundInvocationTracker.Invocation> invocations
-
-
Method Detail
-
createDefaultResponse
protected abstract org.springframework.http.ResponseEntity<java.util.Map> 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
public T throwException(java.lang.RuntimeException e)
Specifies to throw an exception when the send method is called.- Parameters:
e- an exception to throw- Returns:
- tracker with the behavior applied
-
doAndRespondWith
public T doAndRespondWith(org.springframework.http.ResponseEntity.BodyBuilder builder, java.lang.Runnable act)
Specifies to perform an action before return the specified response from the send method.- Parameters:
builder- a response builder to use to create the response after performing the actionact.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.- Returns:
- a tracker with the response specified.
-
doAndRespondWith
public T doAndRespondWith(org.springframework.http.ResponseEntity<java.util.Map> response, java.lang.Runnable act)
Specifies to perform an action before return the specified response from the send method.- Parameters:
response- response to return after performing the actionact.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.- Returns:
- a tracker with the response specified.
-
respondWith
protected T respondWith(org.springframework.http.ResponseEntity<java.util.Map> response)
-
respondWith
protected T respondWith(java.util.function.Supplier<org.springframework.http.ResponseEntity<java.util.Map>> response)
-
internalSend
protected org.springframework.http.ResponseEntity<java.util.Map> internalSend(SyncParameters parameters)
-
invocations
public int invocations()
-
itemsFromInvocationsTo
public java.util.Collection<ItemModel> itemsFromInvocationsTo(ConsumedDestinationModel dest, java.lang.String ioCode)
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
public java.util.Collection<ItemModel> itemsFromInvocationsTo(java.lang.String dest, java.lang.String ioCode)
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
public java.util.List<java.lang.String> keysFromInvocationsTo(java.lang.String dest, java.lang.String ioCode)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
-
-