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 of OutboundInvocationTracker
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.
  • 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

      protected abstract org.springframework.http.ResponseEntity<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(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
    • 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 action act.
      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 action act.
      Returns:
      a tracker with the response specified.
    • respondWith

      protected T respondWith(org.springframework.http.ResponseEntity.HeadersBuilder builder)
    • respondWith

      protected T respondWith(org.springframework.http.ResponseEntity<Map> response)
    • respondWith

      protected T respondWith(Supplier<org.springframework.http.ResponseEntity<Map>> response)
    • internalSend

      protected org.springframework.http.ResponseEntity<Map> internalSend(SyncParameters parameters)
    • 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 as getAllInvocations().size()
    • getAllInvocations

      public List<SyncParameters> getAllInvocations()
      Retrieves all invocations of the internalSend(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

      public Collection<ItemModel> itemsFromInvocationsTo(ConsumedDestinationModel dest, 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 Collection<ItemModel> itemsFromInvocationsTo(String dest, 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 List<String> keysFromInvocationsTo(String dest, 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:
      after in class org.junit.rules.ExternalResource