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 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: RemoteSystemClient
      Performs POST request to the remote system.
      Specified by:
      post in interface RemoteSystemClient
      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: RemoteSystemClient
      Performs POST request to the remote system with a parametrized response type.
      Specified by:
      post in interface RemoteSystemClient
      Type Parameters:
      T - Type of response entity
      U - 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: RemoteSystemClient
      Performs POST request to the remote system with a parametrized response type.
      Specified by:
      post in interface RemoteSystemClient
      Type Parameters:
      T - Type of response entity
      U - 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
      additionalPath - additional request path added to the destination URL
      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 as getAllInvocations().size()
    • getAllInvocations

      public List<org.apache.commons.lang3.tuple.Pair<ConsumedDestinationModel,Object>> getAllInvocations()
      Retrieves all invocations of the post(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

      public TestRemoteSystemClient respondWith(org.springframework.http.ResponseEntity<String> response)
    • 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 the RemoteSystemClient otherwise 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

      protected org.springframework.http.ResponseEntity<String> createDefaultResponse()
    • after

      protected void after()
      Overrides:
      after in class org.junit.rules.ExternalResource