Class OutboundInvocationTracker<T extends 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 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 void after()  
      protected abstract org.springframework.http.ResponseEntity<java.util.Map> createDefaultResponse()
      Creates an instance of the response to be used by default.
      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.
      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.
      protected org.springframework.http.ResponseEntity<java.util.Map> internalSend​(SyncParameters parameters)  
      int invocations()  
      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 T respondWith​(java.util.function.Supplier<org.springframework.http.ResponseEntity<java.util.Map>> response)  
      protected T respondWith​(org.springframework.http.ResponseEntity<java.util.Map> response)  
      T throwException​(java.lang.RuntimeException e)
      Specifies to throw an exception when the send method is called.
      • Methods inherited from class org.junit.rules.ExternalResource

        apply, before
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • 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 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 action act.
        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 action act.
        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:
        after in class org.junit.rules.ExternalResource