Class MockServerClient
- java.lang.Object
-
- org.mockserver.client.MockServerClient
-
- All Implemented Interfaces:
java.io.Closeable,java.lang.AutoCloseable,org.mockserver.stop.Stoppable
public class MockServerClient extends java.lang.Object implements org.mockserver.stop.Stoppable- Author:
- jamesdbloom
-
-
Field Summary
Fields Modifier and Type Field Description protected java.util.concurrent.CompletableFuture<java.lang.Integer>portFuture
-
Constructor Summary
Constructors Constructor Description MockServerClient(java.lang.String host, int port)Start the client communicating to a MockServer at the specified host and port for example:MockServerClient(java.lang.String host, int port, java.lang.String contextPath)Start the client communicating to a MockServer at the specified host and port and contextPath for example:MockServerClient(java.util.concurrent.CompletableFuture<java.lang.Integer> portFuture)Start the client communicating to a MockServer on localhost at the port specified with the Future
-
Method Summary
Modifier and Type Method Description java.util.List<java.lang.Integer>bind(java.lang.Integer... ports)Bind new ports to listen onMockServerClientclear(org.mockserver.model.ExpectationId expectationId)Clear all expectations and logs that match the httpMockServerClientclear(org.mockserver.model.ExpectationId expectationId, org.mockserver.model.ClearType type)Clear expectations, logs or both that match the httpMockServerClientclear(org.mockserver.model.RequestDefinition requestDefinition)Clear all expectations and logs that match the httpMockServerClientclear(org.mockserver.model.RequestDefinition requestDefinition, org.mockserver.model.ClearType type)Clear expectations, logs or both that match the httpvoidclose()java.lang.StringcontextPath()java.lang.IntegergetPort()booleanhasStarted()Returns whether MockServer has started, if called after MockServer has been stopped this method will block for 5 seconds while confirming MockServer is not startingbooleanhasStarted(int attempts, long timeout, java.util.concurrent.TimeUnit timeUnit)Returns whether server MockServer has started, by polling the MockServer a configurable amount of timesbooleanhasStopped()Returns whether MockServer has stopped, if called too quickly after starting MockServer this may return false because MockServer has not yet started, to ensure MockServer has started use hasStarted()booleanhasStopped(int attempts, long timeout, java.util.concurrent.TimeUnit timeUnit)Returns whether server MockServer has stopped, by polling the MockServer a configurable amount of times.booleanisRunning()Deprecated.use hasStopped() or hasStarted() insteadbooleanisRunning(int attempts, long timeout, java.util.concurrent.TimeUnit timeUnit)Deprecated.use hasStopped() or hasStarted() insteadbooleanisSecure()MockServerClientopenUI()Launch UI and wait the default period to allow the UI to launch and start collecting logs, this ensures that the log are visible in the UI even if MockServer is shutdown by a test shutdown function, such as After, AfterClass, AfterAll, etcMockServerClientopenUI(java.util.concurrent.TimeUnit timeUnit, long pause)Launch UI and wait a specified period to allow the UI to launch and start collecting logs, this ensures that the log are visible in the UI even if MockServer is shutdown by a test shutdown function, such as After, AfterClass, AfterAll, etcjava.net.InetSocketAddressremoteAddress()MockServerClientreset()Reset MockServer by clearing all expectationsorg.mockserver.mock.Expectation[]retrieveActiveExpectations(org.mockserver.model.RequestDefinition requestDefinition)Retrieve the active expectations match the httpRequest parameter, use null for the parameter to retrieve all expectationsjava.lang.StringretrieveActiveExpectations(org.mockserver.model.RequestDefinition requestDefinition, org.mockserver.model.Format format)Retrieve the active expectations match the httpRequest parameter, use null for the parameter to retrieve all expectationsjava.lang.StringretrieveLogMessages(org.mockserver.model.RequestDefinition requestDefinition)Retrieve the logs associated to a specific requests, this shows all logs for expectation matching, verification, clearing, etcjava.lang.String[]retrieveLogMessagesArray(org.mockserver.model.RequestDefinition requestDefinition)Retrieve the logs associated to a specific requests, this shows all logs for expectation matching, verification, clearing, etcorg.mockserver.mock.Expectation[]retrieveRecordedExpectations(org.mockserver.model.RequestDefinition requestDefinition)Retrieve the request-response combinations that have been recorded as a list of expectations, only those that match the httpRequest parameter are returned, use null to retrieve all requestsjava.lang.StringretrieveRecordedExpectations(org.mockserver.model.RequestDefinition requestDefinition, org.mockserver.model.Format format)Retrieve the request-response combinations that have been recorded as a list of expectations, only those that match the httpRequest parameter are returned, use null to retrieve all requestsorg.mockserver.model.RequestDefinition[]retrieveRecordedRequests(org.mockserver.model.RequestDefinition requestDefinition)Retrieve the recorded requests that match the httpRequest parameter, use null for the parameter to retrieve all requestsjava.lang.StringretrieveRecordedRequests(org.mockserver.model.RequestDefinition requestDefinition, org.mockserver.model.Format format)Retrieve the recorded requests that match the httpRequest parameter, use null for the parameter to retrieve all requestsorg.mockserver.model.LogEventRequestAndResponse[]retrieveRecordedRequestsAndResponses(org.mockserver.model.RequestDefinition requestDefinition)Retrieve the recorded requests and responses that match the httpRequest parameter, use null for the parameter to retrieve all requests and responsesjava.lang.StringretrieveRecordedRequestsAndResponses(org.mockserver.model.RequestDefinition requestDefinition, org.mockserver.model.Format format)Retrieve the recorded requests that match the httpRequest parameter, use null for the parameter to retrieve all requestsorg.mockserver.mock.Expectation[]sendExpectation(org.mockserver.mock.Expectation... expectations)Deprecated.this is deprecated due to unclear naming, use method upsert(Expectation...MockServerClientsetRequestOverride(org.mockserver.model.HttpRequest requestOverride)voidstop()Stop MockServer gracefully (only support for Netty version, not supported for WAR version)java.util.concurrent.Future<MockServerClient>stop(boolean ignoreFailure)Stop MockServer gracefully (only support for Netty version, not supported for WAR version)java.util.concurrent.Future<MockServerClient>stopAsync()Stop MockServer gracefully (only support for Netty version, not supported for WAR version)org.mockserver.mock.Expectation[]upsert(org.mockserver.mock.Expectation... expectations)Specify one or more expectations to be create, or updated (if the id matches).org.mockserver.mock.Expectation[]upsert(org.mockserver.mock.OpenAPIExpectation... openAPIExpectations)Specify OpenAPI and operations and responses to create matchers and example responsesMockServerClientverify(org.mockserver.model.ExpectationId... expectationIds)Verify a list of requests have been sent in the order specified for example:MockServerClientverify(org.mockserver.model.ExpectationId expectationId, org.mockserver.verify.VerificationTimes times)Verify a request has been sent for example:MockServerClientverify(org.mockserver.model.RequestDefinition... requestDefinitions)Verify a list of requests have been sent in the order specified for example:MockServerClientverify(org.mockserver.model.RequestDefinition requestDefinition, org.mockserver.verify.VerificationTimes times)Verify a request has been sent for example:MockServerClientverifyZeroInteractions()Verify no requests have been sent.ForwardChainExpectationwhen(org.mockserver.model.RequestDefinition requestDefinition)Specify an unlimited expectation that will respond regardless of the number of matching http for example:ForwardChainExpectationwhen(org.mockserver.model.RequestDefinition requestDefinition, org.mockserver.matchers.Times times)Specify a limited expectation that will respond a specified number of times when the http is matchedForwardChainExpectationwhen(org.mockserver.model.RequestDefinition requestDefinition, org.mockserver.matchers.Times times, org.mockserver.matchers.TimeToLive timeToLive)Specify a limited expectation that will respond a specified number of times when the http is matchedForwardChainExpectationwhen(org.mockserver.model.RequestDefinition requestDefinition, org.mockserver.matchers.Times times, org.mockserver.matchers.TimeToLive timeToLive, java.lang.Integer priority)Specify a limited expectation that will respond a specified number of times when the http is matched and will be matched according to priority as follows:MockServerClientwithSecure(boolean secure)
-
-
-
Constructor Detail
-
MockServerClient
public MockServerClient(java.util.concurrent.CompletableFuture<java.lang.Integer> portFuture)
Start the client communicating to a MockServer on localhost at the port specified with the Future- Parameters:
portFuture- the port for the MockServer to communicate with
-
MockServerClient
public MockServerClient(java.lang.String host, int port)Start the client communicating to a MockServer at the specified host and port for example:MockServerClient mockServerClient = new MockServerClient("localhost", 1080);
- Parameters:
host- the host for the MockServer to communicate withport- the port for the MockServer to communicate with
-
MockServerClient
public MockServerClient(java.lang.String host, int port, java.lang.String contextPath)Start the client communicating to a MockServer at the specified host and port and contextPath for example:MockServerClient mockServerClient = new MockServerClient("localhost", 1080, "/mockserver");
- Parameters:
host- the host for the MockServer to communicate withport- the port for the MockServer to communicate withcontextPath- the context path that the MockServer war is deployed to
-
-
Method Detail
-
setRequestOverride
public MockServerClient setRequestOverride(org.mockserver.model.HttpRequest requestOverride)
-
isSecure
public boolean isSecure()
-
withSecure
public MockServerClient withSecure(boolean secure)
-
remoteAddress
public java.net.InetSocketAddress remoteAddress()
-
contextPath
public java.lang.String contextPath()
-
getPort
public java.lang.Integer getPort()
-
openUI
public MockServerClient openUI()
Launch UI and wait the default period to allow the UI to launch and start collecting logs, this ensures that the log are visible in the UI even if MockServer is shutdown by a test shutdown function, such as After, AfterClass, AfterAll, etc
-
openUI
public MockServerClient openUI(java.util.concurrent.TimeUnit timeUnit, long pause)
Launch UI and wait a specified period to allow the UI to launch and start collecting logs, this ensures that the log are visible in the UI even if MockServer is shutdown by a test shutdown function, such as After, AfterClass, AfterAll, etc- Parameters:
timeUnit- TimeUnit the time unit, for example TimeUnit.SECONDSpause- the number of time units to delay before the function returns to ensure the UI is receiving logs
-
isRunning
@Deprecated public boolean isRunning()
Deprecated.use hasStopped() or hasStarted() insteadReturns whether MockServer is running, if called too quickly after starting MockServer this may return false because MockServer has not yet started, to ensure MockServer has started use hasStarted()
-
isRunning
@Deprecated public boolean isRunning(int attempts, long timeout, java.util.concurrent.TimeUnit timeUnit)Deprecated.use hasStopped() or hasStarted() insteadReturns whether server MockServer is running, by polling the MockServer a configurable amount of times. If called too quickly after starting MockServer this may return false because MockServer has not yet started, to ensure MockServer has started use hasStarted()
-
hasStopped
public boolean hasStopped()
Returns whether MockServer has stopped, if called too quickly after starting MockServer this may return false because MockServer has not yet started, to ensure MockServer has started use hasStarted()
-
hasStopped
public boolean hasStopped(int attempts, long timeout, java.util.concurrent.TimeUnit timeUnit)Returns whether server MockServer has stopped, by polling the MockServer a configurable amount of times. If called too quickly after starting MockServer this may return false because MockServer has not yet started, to ensure MockServer has started use hasStarted()
-
hasStarted
public boolean hasStarted()
Returns whether MockServer has started, if called after MockServer has been stopped this method will block for 5 seconds while confirming MockServer is not starting
-
hasStarted
public boolean hasStarted(int attempts, long timeout, java.util.concurrent.TimeUnit timeUnit)Returns whether server MockServer has started, by polling the MockServer a configurable amount of times
-
bind
public java.util.List<java.lang.Integer> bind(java.lang.Integer... ports)
Bind new ports to listen on
-
stopAsync
public java.util.concurrent.Future<MockServerClient> stopAsync()
Stop MockServer gracefully (only support for Netty version, not supported for WAR version)
-
stop
public void stop()
Stop MockServer gracefully (only support for Netty version, not supported for WAR version)- Specified by:
stopin interfaceorg.mockserver.stop.Stoppable
-
stop
public java.util.concurrent.Future<MockServerClient> stop(boolean ignoreFailure)
Stop MockServer gracefully (only support for Netty version, not supported for WAR version)
-
close
public void close()
- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.io.Closeable
-
reset
public MockServerClient reset()
Reset MockServer by clearing all expectations
-
clear
public MockServerClient clear(org.mockserver.model.RequestDefinition requestDefinition)
Clear all expectations and logs that match the http- Parameters:
requestDefinition- the http request that is matched against when deciding whether to clear each expectation if null all expectations are cleared
-
clear
public MockServerClient clear(org.mockserver.model.ExpectationId expectationId)
Clear all expectations and logs that match the http- Parameters:
expectationId- the http request that is matched against when deciding whether to clear each expectation if null all expectations are cleared
-
clear
public MockServerClient clear(org.mockserver.model.RequestDefinition requestDefinition, org.mockserver.model.ClearType type)
Clear expectations, logs or both that match the http- Parameters:
requestDefinition- the http request that is matched against when deciding whether to clear each expectation if null all expectations are clearedtype- the type to clear, EXPECTATION, LOG or BOTH
-
clear
public MockServerClient clear(org.mockserver.model.ExpectationId expectationId, org.mockserver.model.ClearType type)
Clear expectations, logs or both that match the http- Parameters:
expectationId- the http request that is matched against when deciding whether to clear each expectation if null all expectations are clearedtype- the type to clear, EXPECTATION, LOG or BOTH
-
verify
public MockServerClient verify(org.mockserver.model.RequestDefinition... requestDefinitions) throws java.lang.AssertionError
Verify a list of requests have been sent in the order specified for example:mockServerClient .verify( request() .withPath("/first_request") .withBody("some_request_body"), request() .withPath("/second_request") .withBody("some_request_body") );- Parameters:
requestDefinitions- the http requests that must be matched for this verification to pass- Throws:
java.lang.AssertionError- if the request has not been found
-
verify
public MockServerClient verify(org.mockserver.model.ExpectationId... expectationIds) throws java.lang.AssertionError
Verify a list of requests have been sent in the order specified for example:mockServerClient .verify( request() .withPath("/first_request") .withBody("some_request_body"), request() .withPath("/second_request") .withBody("some_request_body") );- Parameters:
expectationIds- the http requests that must be matched for this verification to pass- Throws:
java.lang.AssertionError- if the request has not been found
-
verify
public MockServerClient verify(org.mockserver.model.RequestDefinition requestDefinition, org.mockserver.verify.VerificationTimes times) throws java.lang.AssertionError
Verify a request has been sent for example:mockServerClient .verify( request() .withPath("/some_path") .withBody("some_request_body"), VerificationTimes.exactly(3) );VerificationTimes supports multiple static factory methods:once() - verify the request was only received once exactly(n) - verify the request was only received exactly n times atLeast(n) - verify the request was only received at least n times
- Parameters:
requestDefinition- the http request that must be matched for this verification to passtimes- the number of times this request must be matched- Throws:
java.lang.AssertionError- if the request has not been found
-
verify
public MockServerClient verify(org.mockserver.model.ExpectationId expectationId, org.mockserver.verify.VerificationTimes times) throws java.lang.AssertionError
Verify a request has been sent for example:mockServerClient .verify( request() .withPath("/some_path") .withBody("some_request_body"), VerificationTimes.exactly(3) );VerificationTimes supports multiple static factory methods:once() - verify the request was only received once exactly(n) - verify the request was only received exactly n times atLeast(n) - verify the request was only received at least n times
- Parameters:
expectationId- the http request that must be matched for this verification to passtimes- the number of times this request must be matched- Throws:
java.lang.AssertionError- if the request has not been found
-
verifyZeroInteractions
public MockServerClient verifyZeroInteractions() throws java.lang.AssertionError
Verify no requests have been sent.- Throws:
java.lang.AssertionError- if any request has been found
-
retrieveRecordedRequests
public org.mockserver.model.RequestDefinition[] retrieveRecordedRequests(org.mockserver.model.RequestDefinition requestDefinition)
Retrieve the recorded requests that match the httpRequest parameter, use null for the parameter to retrieve all requests- Parameters:
requestDefinition- the http request that is matched against when deciding whether to return each request, use null for the parameter to retrieve for all requests- Returns:
- an array of all requests that have been recorded by the MockServer in the order they have been received and including duplicates where the same request has been received multiple times
-
retrieveRecordedRequests
public java.lang.String retrieveRecordedRequests(org.mockserver.model.RequestDefinition requestDefinition, org.mockserver.model.Format format)Retrieve the recorded requests that match the httpRequest parameter, use null for the parameter to retrieve all requests- Parameters:
requestDefinition- the http request that is matched against when deciding whether to return each request, use null for the parameter to retrieve for all requestsformat- the format to retrieve the expectations, either JAVA or JSON- Returns:
- an array of all requests that have been recorded by the MockServer in the order they have been received and including duplicates where the same request has been received multiple times
-
retrieveRecordedRequestsAndResponses
public org.mockserver.model.LogEventRequestAndResponse[] retrieveRecordedRequestsAndResponses(org.mockserver.model.RequestDefinition requestDefinition)
Retrieve the recorded requests and responses that match the httpRequest parameter, use null for the parameter to retrieve all requests and responses- Parameters:
requestDefinition- the http request that is matched against when deciding whether to return each request (and its corresponding response), use null for the parameter to retrieve for all requests- Returns:
- an array of all requests and responses that have been recorded by the MockServer in the order they have been received and including duplicates where the same request has been received multiple times
-
retrieveRecordedRequestsAndResponses
public java.lang.String retrieveRecordedRequestsAndResponses(org.mockserver.model.RequestDefinition requestDefinition, org.mockserver.model.Format format)Retrieve the recorded requests that match the httpRequest parameter, use null for the parameter to retrieve all requests- Parameters:
requestDefinition- the http request that is matched against when deciding whether to return each request, use null for the parameter to retrieve for all requestsformat- the format to retrieve the expectations, either JAVA or JSON- Returns:
- an array of all requests that have been recorded by the MockServer in the order they have been received and including duplicates where the same request has been received multiple times
-
retrieveRecordedExpectations
public org.mockserver.mock.Expectation[] retrieveRecordedExpectations(org.mockserver.model.RequestDefinition requestDefinition)
Retrieve the request-response combinations that have been recorded as a list of expectations, only those that match the httpRequest parameter are returned, use null to retrieve all requests- Parameters:
requestDefinition- the http request that is matched against when deciding whether to return each request, use null for the parameter to retrieve for all requests- Returns:
- an array of all expectations that have been recorded by the MockServer in the order they have been received and including duplicates where the same request has been received multiple times
-
retrieveRecordedExpectations
public java.lang.String retrieveRecordedExpectations(org.mockserver.model.RequestDefinition requestDefinition, org.mockserver.model.Format format)Retrieve the request-response combinations that have been recorded as a list of expectations, only those that match the httpRequest parameter are returned, use null to retrieve all requests- Parameters:
requestDefinition- the http request that is matched against when deciding whether to return each request, use null for the parameter to retrieve for all requestsformat- the format to retrieve the expectations, either JAVA or JSON- Returns:
- an array of all expectations that have been recorded by the MockServer in the order they have been received and including duplicates where the same request has been received multiple times
-
retrieveLogMessages
public java.lang.String retrieveLogMessages(org.mockserver.model.RequestDefinition requestDefinition)
Retrieve the logs associated to a specific requests, this shows all logs for expectation matching, verification, clearing, etc- Parameters:
requestDefinition- the http request that is matched against when deciding whether to return each request, use null for the parameter to retrieve for all requests- Returns:
- all log messages recorded by the MockServer when creating expectations, matching expectations, performing verification, clearing logs, etc
-
retrieveLogMessagesArray
public java.lang.String[] retrieveLogMessagesArray(org.mockserver.model.RequestDefinition requestDefinition)
Retrieve the logs associated to a specific requests, this shows all logs for expectation matching, verification, clearing, etc- Parameters:
requestDefinition- the http request that is matched against when deciding whether to return each request, use null for the parameter to retrieve for all requests- Returns:
- an array of all log messages recorded by the MockServer when creating expectations, matching expectations, performing verification, clearing logs, etc
-
when
public ForwardChainExpectation when(org.mockserver.model.RequestDefinition requestDefinition)
Specify an unlimited expectation that will respond regardless of the number of matching http for example:mockServerClient .when( request() .withPath("/some_path") .withBody("some_request_body") ) .respond( response() .withBody("some_response_body") .withHeader("responseName", "responseValue") )- Parameters:
requestDefinition- the http request that must be matched for this expectation to respond- Returns:
- an Expectation object that can be used to specify the response
-
when
public ForwardChainExpectation when(org.mockserver.model.RequestDefinition requestDefinition, org.mockserver.matchers.Times times)
Specify a limited expectation that will respond a specified number of times when the http is matchedExample use:
mockServerClient .when( request() .withPath("/some_path") .withBody("some_request_body"), Times.exactly(5) ) .respond( response() .withBody("some_response_body") .withHeader("responseName", "responseValue") )- Parameters:
requestDefinition- the http request that must be matched for this expectation to respondtimes- the number of times to respond when this http is matched- Returns:
- an Expectation object that can be used to specify the response
-
when
public ForwardChainExpectation when(org.mockserver.model.RequestDefinition requestDefinition, org.mockserver.matchers.Times times, org.mockserver.matchers.TimeToLive timeToLive)
Specify a limited expectation that will respond a specified number of times when the http is matchedExample use:
mockServerClient .when( request() .withPath("/some_path") .withBody("some_request_body"), Times.exactly(5), TimeToLive.exactly(TimeUnit.SECONDS, 120) ) .respond( response() .withBody("some_response_body") .withHeader("responseName", "responseValue") )- Parameters:
requestDefinition- the http request that must be matched for this expectation to respondtimes- the number of times to respond when this http is matchedtimeToLive- the length of time from when the server receives the expectation that the expectation should be active- Returns:
- an Expectation object that can be used to specify the response
-
when
public ForwardChainExpectation when(org.mockserver.model.RequestDefinition requestDefinition, org.mockserver.matchers.Times times, org.mockserver.matchers.TimeToLive timeToLive, java.lang.Integer priority)
Specify a limited expectation that will respond a specified number of times when the http is matched and will be matched according to priority as follows:- higher priority expectation will be matched first - identical priority expectations will be match in the order they were submitted - default priority is 0
Example use:
mockServerClient .when( request() .withPath("/some_path") .withBody("some_request_body"), Times.exactly(5), TimeToLive.exactly(TimeUnit.SECONDS, 120), 10 ) .respond( response() .withBody("some_response_body") .withHeader("responseName", "responseValue") )- Parameters:
requestDefinition- the http request that must be matched for this expectation to respondtimes- the number of times to respond when this http is matchedtimeToLive- the length of time from when the server receives the expectation that the expectation should be activepriority- the priority for the expectation when matching, higher priority expectation will be matched first, identical priority expectations will be match in the order they were submitted- Returns:
- an Expectation object that can be used to specify the response
-
upsert
public org.mockserver.mock.Expectation[] upsert(org.mockserver.mock.OpenAPIExpectation... openAPIExpectations)
Specify OpenAPI and operations and responses to create matchers and example responses- Parameters:
openAPIExpectations- the OpenAPI and operations and responses to create matchers and example responses- Returns:
- upserted expectations
-
upsert
public org.mockserver.mock.Expectation[] upsert(org.mockserver.mock.Expectation... expectations)
Specify one or more expectations to be create, or updated (if the id matches).This method should be used to update existing expectation by id. All fields will be updated for expectations with a matching id as the existing expectation is deleted and recreated.
To retrieve the id(s) for existing expectation(s) the retrieveActiveExpectations(HttpRequest httpRequest) method can be used.
Typically, to create expectations this method should not be used directly instead the when(...) and response(...) or forward(...) or error(...) methods should be used for example:
mockServerClient .when( request() .withPath("/some_path") .withBody("some_request_body"), Times.exactly(5), TimeToLive.exactly(TimeUnit.SECONDS, 120) ) .respond( response() .withBody("some_response_body") .withHeader("responseName", "responseValue") )- Parameters:
expectations- one or more expectations to create or update (if the id field matches)- Returns:
- upserted expectations
-
sendExpectation
@Deprecated public org.mockserver.mock.Expectation[] sendExpectation(org.mockserver.mock.Expectation... expectations)
Deprecated.this is deprecated due to unclear naming, use method upsert(Expectation... expectations) insteadSpecify one or more expectations, normally this method should not be used directly instead the when(...) and response(...) or forward(...) or error(...) methods should be used for example:mockServerClient .when( request() .withPath("/some_path") .withBody("some_request_body"), Times.exactly(5), TimeToLive.exactly(TimeUnit.SECONDS, 120) ) .respond( response() .withBody("some_response_body") .withHeader("responseName", "responseValue") )- Parameters:
expectations- one or more expectations- Returns:
- added or updated expectations
-
retrieveActiveExpectations
public org.mockserver.mock.Expectation[] retrieveActiveExpectations(org.mockserver.model.RequestDefinition requestDefinition)
Retrieve the active expectations match the httpRequest parameter, use null for the parameter to retrieve all expectations- Parameters:
requestDefinition- the http request that is matched against when deciding whether to return each expectation, use null for the parameter to retrieve for all requests- Returns:
- an array of all expectations that have been setup and have not expired
-
retrieveActiveExpectations
public java.lang.String retrieveActiveExpectations(org.mockserver.model.RequestDefinition requestDefinition, org.mockserver.model.Format format)Retrieve the active expectations match the httpRequest parameter, use null for the parameter to retrieve all expectations- Parameters:
requestDefinition- the http request that is matched against when deciding whether to return each expectation, use null for the parameter to retrieve for all requestsformat- the format to retrieve the expectations, either JAVA or JSON- Returns:
- an array of all expectations that have been setup and have not expired
-
-