Class ForwardChainExpectation


  • public class ForwardChainExpectation
    extends Object
    Author:
    jamesdbloom
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      org.mockserver.mock.Expectation[] error​(org.mockserver.model.HttpError httpError)
      Return error when expectation is matched
      org.mockserver.mock.Expectation[] forward​(org.mockserver.mock.action.ExpectationForwardCallback expectationForwardCallback)
      Call method on object locally or remotely (over web socket) to generate request to forward when expectation is matched
      org.mockserver.mock.Expectation[] forward​(org.mockserver.mock.action.ExpectationForwardCallback expectationForwardCallback, org.mockserver.mock.action.ExpectationForwardAndResponseCallback expectationForwardResponseCallback)
      Call method on object locally or remotely (over web socket) to generate request to forward when expectation is matched
      org.mockserver.mock.Expectation[] forward​(org.mockserver.mock.action.ExpectationForwardCallback expectationForwardCallback, org.mockserver.mock.action.ExpectationForwardAndResponseCallback expectationForwardResponseCallback, org.mockserver.model.Delay delay)
      Call method on object locally or remotely (over web socket) to generate request to forward when expectation is matched
      org.mockserver.mock.Expectation[] forward​(org.mockserver.mock.action.ExpectationForwardCallback expectationForwardCallback, org.mockserver.model.Delay delay)
      Call method on object locally or remotely (over web socket) to generate request to forward when expectation is matched
      org.mockserver.mock.Expectation[] forward​(org.mockserver.model.HttpClassCallback httpClassCallback)
      Call method on local class in same JVM implementing ExpectationResponseCallback to generate request to forward when expectation is matched
      org.mockserver.mock.Expectation[] forward​(org.mockserver.model.HttpForward httpForward)
      Forward request to the specified host and port when expectation is matched
      org.mockserver.mock.Expectation[] forward​(org.mockserver.model.HttpOverrideForwardedRequest httpOverrideForwardedRequest)
      Override fields, headers, and cookies etc in request being forwarded with specified fields, headers and cookies, etc in the specified request when expectation is matched
      org.mockserver.mock.Expectation[] forward​(org.mockserver.model.HttpTemplate httpTemplate)
      Evaluate Velocity or JavaScript template to generate request to forward when expectation is matched
      org.mockserver.mock.Expectation[] respond​(List<org.mockserver.model.HttpResponse> httpResponses)
      Set a list of responses to cycle through sequentially when expectation is matched.
      org.mockserver.mock.Expectation[] respond​(org.mockserver.mock.action.ExpectationResponseCallback expectationResponseCallback)
      Call method on object locally or remotely (over web socket) to generate response to return when expectation is matched
      org.mockserver.mock.Expectation[] respond​(org.mockserver.mock.action.ExpectationResponseCallback expectationResponseCallback, org.mockserver.model.Delay delay)
      Call method on object locally or remotely (over web socket) to generate response to return when expectation is matched
      org.mockserver.mock.Expectation[] respond​(org.mockserver.model.HttpClassCallback httpClassCallback)
      Call method on local class in same JVM implementing ExpectationResponseCallback to generate response to return when expectation is matched
      org.mockserver.mock.Expectation[] respond​(org.mockserver.model.HttpResponse httpResponse)
      Return response when expectation is matched
      org.mockserver.mock.Expectation[] respond​(org.mockserver.model.HttpTemplate httpTemplate)
      Evaluate Velocity or JavaScript template to generate response to return when expectation is matched
      org.mockserver.mock.Expectation[] respondWithBinary​(org.mockserver.model.BinaryResponse binaryResponse)  
      org.mockserver.mock.Expectation[] respondWithDns​(org.mockserver.model.DnsResponse dnsResponse)  
      org.mockserver.mock.Expectation[] respondWithGrpcStream​(org.mockserver.model.GrpcStreamResponse grpcStreamResponse)  
      org.mockserver.mock.Expectation[] respondWithSse​(org.mockserver.model.HttpSseResponse httpSseResponse)  
      org.mockserver.mock.Expectation[] respondWithWebSocket​(org.mockserver.model.HttpWebSocketResponse httpWebSocketResponse)  
      ForwardChainExpectation withAfterAction​(org.mockserver.model.AfterAction afterAction)
      Set a single after-action to execute after the primary action completes
      ForwardChainExpectation withAfterActions​(org.mockserver.model.AfterAction... afterActions)  
      ForwardChainExpectation withId​(String id)
      Set id of this expectation which can be used to update this expectation later or for clearing or verifying by expectation id.
      ForwardChainExpectation withNewScenarioState​(String newScenarioState)  
      ForwardChainExpectation withPercentage​(Integer percentage)
      Set percentage of requests this expectation should match (0-100).
      ForwardChainExpectation withPriority​(int priority)
      Set priority of this expectation which is used to determine the matching order of expectations when a request is received.
      ForwardChainExpectation withResponseMode​(org.mockserver.mock.ResponseMode responseMode)  
      ForwardChainExpectation withScenarioName​(String scenarioName)
      Set the scenario name for stateful expectation matching
      ForwardChainExpectation withScenarioState​(String scenarioState)  
    • Method Detail

      • withId

        public ForwardChainExpectation withId​(String id)

        Set id of this expectation which can be used to update this expectation later or for clearing or verifying by expectation id.

        Note: Each unique expectation must have a unique id otherwise this expectation will update a existing expectation with the same id.

        Parameters:
        id - unique string for expectation's id
      • withPriority

        public ForwardChainExpectation withPriority​(int priority)

        Set priority of this expectation which is used to determine the matching order of expectations when a request is received.

        Matching is ordered by priority (highest first) then creation (earliest first).

        Parameters:
        priority - expectation's priority
      • withPercentage

        public ForwardChainExpectation withPercentage​(Integer percentage)

        Set percentage of requests this expectation should match (0-100).

        When set, the expectation will only match the specified percentage of requests that structurally match, enabling probabilistic matching.

        Parameters:
        percentage - percentage of requests to match (0-100), or null for all requests
      • withScenarioName

        public ForwardChainExpectation withScenarioName​(String scenarioName)
        Set the scenario name for stateful expectation matching
        Parameters:
        scenarioName - the name of the scenario
      • withResponseMode

        public ForwardChainExpectation withResponseMode​(org.mockserver.mock.ResponseMode responseMode)
      • withAfterActions

        public ForwardChainExpectation withAfterActions​(org.mockserver.model.AfterAction... afterActions)
      • withAfterAction

        public ForwardChainExpectation withAfterAction​(org.mockserver.model.AfterAction afterAction)
        Set a single after-action to execute after the primary action completes
        Parameters:
        afterAction - the after-action to set
      • respond

        public org.mockserver.mock.Expectation[] respond​(org.mockserver.model.HttpResponse httpResponse)
        Return response when expectation is matched
        Parameters:
        httpResponse - response to return
        Returns:
        added or updated expectations
      • respond

        public org.mockserver.mock.Expectation[] respond​(List<org.mockserver.model.HttpResponse> httpResponses)
        Set a list of responses to cycle through sequentially when expectation is matched. Each match returns the next response in the list, cycling back to the first after the last.
        Parameters:
        httpResponses - list of responses to cycle through
        Returns:
        added or updated expectations
      • respond

        public org.mockserver.mock.Expectation[] respond​(org.mockserver.model.HttpTemplate httpTemplate)
        Evaluate Velocity or JavaScript template to generate response to return when expectation is matched
        Parameters:
        httpTemplate - Velocity or JavaScript template used to generate response
        Returns:
        added or updated expectations
      • respond

        public org.mockserver.mock.Expectation[] respond​(org.mockserver.model.HttpClassCallback httpClassCallback)
        Call method on local class in same JVM implementing ExpectationResponseCallback to generate response to return when expectation is matched

        The callback class must: - implement org.mockserver.mock.action.ExpectationResponseCallback - have a zero argument constructor - be available in the classpath of the MockServer

        Parameters:
        httpClassCallback - class to callback as a fully qualified class name, i.e. "com.foo.MyExpectationResponseCallback"
        Returns:
        added or updated expectations
      • respond

        public org.mockserver.mock.Expectation[] respond​(org.mockserver.mock.action.ExpectationResponseCallback expectationResponseCallback)
        Call method on object locally or remotely (over web socket) to generate response to return when expectation is matched
        Parameters:
        expectationResponseCallback - object to call locally or remotely to generate response
        Returns:
        added or updated expectations
      • respond

        public org.mockserver.mock.Expectation[] respond​(org.mockserver.mock.action.ExpectationResponseCallback expectationResponseCallback,
                                                         org.mockserver.model.Delay delay)
        Call method on object locally or remotely (over web socket) to generate response to return when expectation is matched
        Parameters:
        expectationResponseCallback - object to call locally or remotely to generate response
        Returns:
        added or updated expectations
      • forward

        public org.mockserver.mock.Expectation[] forward​(org.mockserver.model.HttpForward httpForward)
        Forward request to the specified host and port when expectation is matched
        Parameters:
        httpForward - host and port to forward to
        Returns:
        added or updated expectations
      • forward

        public org.mockserver.mock.Expectation[] forward​(org.mockserver.model.HttpTemplate httpTemplate)
        Evaluate Velocity or JavaScript template to generate request to forward when expectation is matched
        Parameters:
        httpTemplate - Velocity or JavaScript template used to generate response
        Returns:
        added or updated expectations
      • forward

        public org.mockserver.mock.Expectation[] forward​(org.mockserver.model.HttpClassCallback httpClassCallback)
        Call method on local class in same JVM implementing ExpectationResponseCallback to generate request to forward when expectation is matched

        The callback class must: - implement org.mockserver.mock.action.ExpectationForwardCallback or org.mockserver.mock.action.ExpectationForwardAndResponseCallback - have a zero argument constructor - be available in the classpath of the MockServer

        Parameters:
        httpClassCallback - class to callback as a fully qualified class name, i.e. "com.foo.MyExpectationResponseCallback"
        Returns:
        added or updated expectations
      • forward

        public org.mockserver.mock.Expectation[] forward​(org.mockserver.mock.action.ExpectationForwardCallback expectationForwardCallback)
        Call method on object locally or remotely (over web socket) to generate request to forward when expectation is matched
        Parameters:
        expectationForwardCallback - object to call locally or remotely to generate request
        Returns:
        added or updated expectations
      • forward

        public org.mockserver.mock.Expectation[] forward​(org.mockserver.mock.action.ExpectationForwardCallback expectationForwardCallback,
                                                         org.mockserver.mock.action.ExpectationForwardAndResponseCallback expectationForwardResponseCallback)
        Call method on object locally or remotely (over web socket) to generate request to forward when expectation is matched
        Parameters:
        expectationForwardCallback - object to call locally or remotely to generate request
        Returns:
        added or updated expectations
      • forward

        public org.mockserver.mock.Expectation[] forward​(org.mockserver.mock.action.ExpectationForwardCallback expectationForwardCallback,
                                                         org.mockserver.model.Delay delay)
        Call method on object locally or remotely (over web socket) to generate request to forward when expectation is matched
        Parameters:
        expectationForwardCallback - object to call locally or remotely to generate request
        Returns:
        added or updated expectations
      • forward

        public org.mockserver.mock.Expectation[] forward​(org.mockserver.mock.action.ExpectationForwardCallback expectationForwardCallback,
                                                         org.mockserver.mock.action.ExpectationForwardAndResponseCallback expectationForwardResponseCallback,
                                                         org.mockserver.model.Delay delay)
        Call method on object locally or remotely (over web socket) to generate request to forward when expectation is matched
        Parameters:
        expectationForwardCallback - object to call locally or remotely to generate request
        Returns:
        added or updated expectations
      • forward

        public org.mockserver.mock.Expectation[] forward​(org.mockserver.model.HttpOverrideForwardedRequest httpOverrideForwardedRequest)
        Override fields, headers, and cookies etc in request being forwarded with specified fields, headers and cookies, etc in the specified request when expectation is matched
        Parameters:
        httpOverrideForwardedRequest - contains request to override request being forwarded
        Returns:
        added or updated expectations
      • error

        public org.mockserver.mock.Expectation[] error​(org.mockserver.model.HttpError httpError)
        Return error when expectation is matched
        Parameters:
        httpError - error to return
        Returns:
        added or updated expectations
      • respondWithSse

        public org.mockserver.mock.Expectation[] respondWithSse​(org.mockserver.model.HttpSseResponse httpSseResponse)
      • respondWithWebSocket

        public org.mockserver.mock.Expectation[] respondWithWebSocket​(org.mockserver.model.HttpWebSocketResponse httpWebSocketResponse)
      • respondWithGrpcStream

        public org.mockserver.mock.Expectation[] respondWithGrpcStream​(org.mockserver.model.GrpcStreamResponse grpcStreamResponse)
      • respondWithBinary

        public org.mockserver.mock.Expectation[] respondWithBinary​(org.mockserver.model.BinaryResponse binaryResponse)
      • respondWithDns

        public org.mockserver.mock.Expectation[] respondWithDns​(org.mockserver.model.DnsResponse dnsResponse)