public class HttpClientMockBuilder extends Object
| Modifier and Type | Method and Description |
|---|---|
HttpClientResponseBuilder |
doAction(Action action)
Adds custom action.
|
HttpClientResponseBuilder |
doReturn(int statusCode,
String response)
Adds action which returns provided response and status in UTF-8.
|
HttpClientResponseBuilder |
doReturn(int statusCode,
String response,
Charset charset)
Adds action which returns provided response in provided charset and status.
|
HttpClientResponseBuilder |
doReturn(String response)
Adds action which returns provided response in UTF-8 and status 200.
|
HttpClientResponseBuilder |
doReturn(String response,
Charset charset)
Adds action which returns provided response in provided charset and status 200.
|
HttpClientResponseBuilder |
doReturn(String response,
Charset charset,
org.apache.http.entity.ContentType contentType)
Adds action which returns provided response in provided charset, content-type and status 200.
|
HttpClientResponseBuilder |
doReturnFormParams(Collection<org.apache.http.NameValuePair> parameters)
Adds action which returns provided URL-encoded parameter response in UTF-8 and status 200.
|
HttpClientResponseBuilder |
doReturnFormParams(Collection<org.apache.http.NameValuePair> parameters,
Charset charset)
Adds action which returns provided URL-encoded parameter response in provided charset and status 200.
|
HttpClientResponseBuilder |
doReturnJSON(String response)
Adds action which returns provided JSON in UTF-8 and status 200.
|
HttpClientResponseBuilder |
doReturnJSON(String response,
Charset charset)
Adds action which returns provided JSON in provided charset and status 200.
|
HttpClientResponseBuilder |
doReturnStatus(int statusCode)
Adds action which returns empty message and provided status.
|
HttpClientResponseBuilder |
doReturnXML(String response)
Adds action which returns provided XML in UTF-8 and status 200.
|
HttpClientResponseBuilder |
doReturnXML(String response,
Charset charset)
Adds action which returns provided XML in provided charset and status 200.
|
HttpClientResponseBuilder |
doThrowException(IOException exception)
Adds action which throws provided exception.
|
HttpClientMockBuilder |
with(Condition condition)
Adds custom conditions.
|
HttpClientMockBuilder |
withBody(org.hamcrest.Matcher<String> matcher)
Adds body condition.
|
HttpClientMockBuilder |
withExtraFormParameters()
Allows extra parameters (not defined in condition) in form.
|
HttpClientMockBuilder |
withExtraParameters()
Allows extra parameters (not defined in condition) in query.
|
HttpClientMockBuilder |
withFormParameter(String name,
org.hamcrest.Matcher<String> matcher)
Request body must contain the given URL-encoded form parameter (typically found in POST requests).
|
HttpClientMockBuilder |
withFormParameter(String name,
String value)
Request body must contain the given URL-encoded form parameter (typically found in POST requests).
|
HttpClientMockBuilder |
withFormParameters(ParametersMatcher parameters)
Request body must contain the given URL-encoded form parameters (typically used in POST requests).
|
HttpClientMockBuilder |
withHeader(String header,
org.hamcrest.Matcher<String> matcher)
Adds header condition.
|
HttpClientMockBuilder |
withHeader(String header,
String value)
Adds header condition.
|
HttpClientMockBuilder |
withHost(String host)
Adds host condition.
|
HttpClientMockBuilder |
withoutExtraFormParameters()
Disallows extra parameters (not defined in condition) in form.
|
HttpClientMockBuilder |
withoutExtraParameters()
Disallows extra parameters (not defined in condition) in query.
|
HttpClientMockBuilder |
withParameter(String name,
org.hamcrest.Matcher<String> matcher)
Adds parameter condition.
|
HttpClientMockBuilder |
withParameter(String name,
String value)
Adds parameter condition.
|
HttpClientMockBuilder |
withPath(org.hamcrest.Matcher<String> matcher)
Adds path condition.
|
HttpClientMockBuilder |
withPath(String path)
Adds path condition.
|
HttpClientMockBuilder |
withReference(org.hamcrest.Matcher<String> matcher)
Adds reference condition.
|
HttpClientMockBuilder |
withReference(String reference)
Adds reference condition.
|
public HttpClientMockBuilder withHeader(String header, String value)
header - header namevalue - expected valuepublic HttpClientMockBuilder withHeader(String header, org.hamcrest.Matcher<String> matcher)
header - header namematcher - header value matcherpublic HttpClientMockBuilder withReference(String reference)
reference - expected referencepublic HttpClientMockBuilder withReference(org.hamcrest.Matcher<String> matcher)
matcher - reference matcherpublic HttpClientMockBuilder withParameter(String name, String value)
name - parameter namevalue - expected parameter valuepublic HttpClientMockBuilder withParameter(String name, org.hamcrest.Matcher<String> matcher)
name - parameter namematcher - parameter value matcherpublic HttpClientMockBuilder withFormParameter(String name, String value)
withFormParameters(ParametersMatcher).name - parameter namevalue - expected parameter valuepublic HttpClientMockBuilder withFormParameter(String name, org.hamcrest.Matcher<String> matcher)
withFormParameters(ParametersMatcher).name - parameter namematcher - parameter value matcherpublic HttpClientMockBuilder withFormParameters(ParametersMatcher parameters)
withFormParameter(String, Matcher).parameters - the parameterspublic HttpClientMockBuilder with(Condition condition)
condition - custom conditionpublic HttpClientMockBuilder withBody(org.hamcrest.Matcher<String> matcher)
matcher - custom conditionpublic HttpClientMockBuilder withHost(String host)
host - expected hostpublic HttpClientMockBuilder withPath(String path)
path - expected pathpublic HttpClientMockBuilder withPath(org.hamcrest.Matcher<String> matcher)
matcher - path matcherpublic HttpClientMockBuilder withExtraParameters()
public HttpClientMockBuilder withoutExtraParameters()
public HttpClientMockBuilder withExtraFormParameters()
public HttpClientMockBuilder withoutExtraFormParameters()
public HttpClientResponseBuilder doAction(Action action)
action - custom actionpublic HttpClientResponseBuilder doReturn(String response)
response - response to returnpublic HttpClientResponseBuilder doReturn(int statusCode, String response)
statusCode - status to returnresponse - response to returnpublic HttpClientResponseBuilder doReturn(String response, Charset charset)
response - response to returncharset - charset to returnpublic HttpClientResponseBuilder doReturn(int statusCode, String response, Charset charset)
statusCode - status to returnresponse - response to returncharset - the charsetpublic HttpClientResponseBuilder doReturn(String response, Charset charset, org.apache.http.entity.ContentType contentType)
response - response to returnpublic HttpClientResponseBuilder doReturnStatus(int statusCode)
statusCode - status to returnpublic HttpClientResponseBuilder doThrowException(IOException exception)
exception - exception to be thrownpublic HttpClientResponseBuilder doReturnJSON(String response)
response - JSON to returnpublic HttpClientResponseBuilder doReturnJSON(String response, Charset charset)
response - JSON to returnpublic HttpClientResponseBuilder doReturnXML(String response)
response - JSON to returnpublic HttpClientResponseBuilder doReturnXML(String response, Charset charset)
response - JSON to returnpublic HttpClientResponseBuilder doReturnFormParams(Collection<org.apache.http.NameValuePair> parameters)
parameters - parameters to returnpublic HttpClientResponseBuilder doReturnFormParams(Collection<org.apache.http.NameValuePair> parameters, Charset charset)
parameters - parameters to returnCopyright © 2020. All rights reserved.