Class TestRemoteSystemClient
java.lang.Object
org.junit.rules.ExternalResource
de.hybris.platform.outboundservices.util.TestRemoteSystemClient
- All Implemented Interfaces:
RemoteSystemClient,org.junit.rules.TestRule
public class TestRemoteSystemClient
extends org.junit.rules.ExternalResource
implements RemoteSystemClient
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidafter()protected org.springframework.http.ResponseEntity<String>List<org.apache.commons.lang3.tuple.Pair<ConsumedDestinationModel,Object>> Retrieves all invocations of thepost(ConsumedDestinationModel, HttpEntity, Class)(ConsumedDestinationModel, HttpEntity, Class)} (SyncParameters)} methodintRetrieves number of invocations captured by this tracker.org.springframework.http.ResponseEntity<Map>post(ConsumedDestinationModel destination, org.springframework.http.HttpEntity<Map<String, Object>> entity) Performs POST request to the remote system.<T,U> org.springframework.http.ResponseEntity<T> post(ConsumedDestinationModel destination, org.springframework.http.HttpEntity<U> entity, Class<T> responseType) Performs POST request to the remote system with a parametrized response type.<T,U> org.springframework.http.ResponseEntity<T> post(ConsumedDestinationModel destination, org.springframework.http.HttpEntity<U> entity, Class<T> responseType, String additionalPath) Performs POST request to the remote system with a parametrized response type.respondWith(org.springframework.http.ResponseEntity<String> response) voidrespondWithBatch(Function<List<String>, org.springframework.http.ResponseEntity<String>> generatorBlock) For the batch request, a code block will be input showing how the mocked batch response is generated.Methods inherited from class org.junit.rules.ExternalResource
apply, before
-
Constructor Details
-
TestRemoteSystemClient
public TestRemoteSystemClient()
-
-
Method Details
-
post
public org.springframework.http.ResponseEntity<Map> post(ConsumedDestinationModel destination, org.springframework.http.HttpEntity<Map<String, Object>> entity) Description copied from interface:RemoteSystemClientPerforms POST request to the remote system.- Specified by:
postin interfaceRemoteSystemClient- Parameters:
destination- a remote system info, e.g. URL, to which the request has to be sent.entity- an entity to use for the POST request body.- Returns:
- result of the POST request.
-
post
public <T,U> org.springframework.http.ResponseEntity<T> post(ConsumedDestinationModel destination, org.springframework.http.HttpEntity<U> entity, Class<T> responseType) Description copied from interface:RemoteSystemClientPerforms POST request to the remote system with a parametrized response type.- Specified by:
postin interfaceRemoteSystemClient- Type Parameters:
T- Type of response entityU- Type of request entity- Parameters:
destination- a remote system info, e.g. URL, to which the request has to be sent.entity- an entity to use for the POST request body.responseType- the class type that the HTTP response will contain- Returns:
- A ResponseEntity with the contents of the REST call response
-
post
public <T,U> org.springframework.http.ResponseEntity<T> post(ConsumedDestinationModel destination, org.springframework.http.HttpEntity<U> entity, Class<T> responseType, String additionalPath) Description copied from interface:RemoteSystemClientPerforms POST request to the remote system with a parametrized response type.- Specified by:
postin interfaceRemoteSystemClient- Type Parameters:
T- Type of response entityU- Type of request entity- Parameters:
destination- a remote system info, e.g. URL, to which the request has to be sent.entity- an entity to use for the POST request body.responseType- the class type that the HTTP response will containadditionalPath- additional request path added to thedestinationURL- Returns:
- A ResponseEntity with the contents of the REST call response
-
invocations
public int invocations()Retrieves number of invocations captured by this tracker.- Returns:
- number of times the
post(ConsumedDestinationModel, HttpEntity, Class)(ConsumedDestinationModel, HttpEntity, Class)} method has been invoked. This is the same value asgetAllInvocations().size()
-
getAllInvocations
public List<org.apache.commons.lang3.tuple.Pair<ConsumedDestinationModel,Object>> getAllInvocations()Retrieves all invocations of thepost(ConsumedDestinationModel, HttpEntity, Class)(ConsumedDestinationModel, HttpEntity, Class)} (SyncParameters)} method- Returns:
- a list of parameters passed to this tracker invocations in their chronological order or an empty list,
if the
post(ConsumedDestinationModel, HttpEntity, Class)(ConsumedDestinationModel, HttpEntity, Class)} (SyncParameters)} was not invoked.
-
respondWith
-
respondWithBatch
public void respondWithBatch(Function<List<String>, org.springframework.http.ResponseEntity<String>> generatorBlock) For the batch request, a code block will be input showing how the mocked batch response is generated. It takes a list of content-id as input parameters. The contentIds of a batchResponse can be known and mocked only after the facade calls the batch generator and send the generated batch request to theRemoteSystemClientotherwise response's content-id won't match the randomly generated content-id of a request. This method postpones the creation of mocked batch response to that time it's sent to the client in order to get randomly generated content-id.- Parameters:
generatorBlock- the code block showing how will the batch response be mocked along with the contentIds
-
createDefaultResponse
-
after
protected void after()- Overrides:
afterin classorg.junit.rules.ExternalResource
-