Class HttpClientVerifyBuilder
- java.lang.Object
-
- com.github.paweladamski.httpclientmock.HttpClientVerifyBuilder
-
public class HttpClientVerifyBuilder extends Object
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcalled()Verifies if there was exactly one request matching defined conditions.voidcalled(int numberOfCalls)Verifies number of request matching defined conditions.voidcalled(org.hamcrest.Matcher<Integer> numberOfCalls)Verifies number of request matching defined conditions.voidnotCalled()Verifies if there were no request matching defined conditions.HttpClientVerifyBuilderwith(Condition condition)Adds custom conditions.HttpClientVerifyBuilderwithBody(org.hamcrest.Matcher<String> matcher)Adds body condition.HttpClientVerifyBuilderwithExtraFormParameters()Allows extra parameters (not defined in condition) in form.HttpClientVerifyBuilderwithExtraParameters()Allows extra parameters (not defined in condition) in query.HttpClientVerifyBuilderwithFormParameter(String name, String value)Request body must contain the given URL-encoded form parameter (typically found in POST requests).HttpClientVerifyBuilderwithFormParameter(String name, org.hamcrest.Matcher<String> matcher)Request body must contain the given URL-encoded form parameter (typically found in POST requests).HttpClientVerifyBuilderwithFormParameters(ParametersMatcher parameters)Request body must contain the given URL-encoded form parameters (typically used in POST requests).HttpClientVerifyBuilderwithHeader(String header, String value)Adds header condition.HttpClientVerifyBuilderwithHeader(String header, org.hamcrest.Matcher<String> matcher)Adds header condition.HttpClientVerifyBuilderwithHost(String host)Adds host condition.HttpClientVerifyBuilderwithoutExtraFormParameters()Disallows extra parameters (not defined in condition) in form.HttpClientVerifyBuilderwithoutExtraParameters()Disallows extra parameters (not defined in condition) in query.HttpClientVerifyBuilderwithParameter(String name, String value)Adds parameter condition.HttpClientVerifyBuilderwithParameter(String name, org.hamcrest.Matcher<String> matcher)Adds parameter condition.HttpClientVerifyBuilderwithPath(String path)Adds path condition.HttpClientVerifyBuilderwithPath(org.hamcrest.Matcher<String> matcher)Adds path condition.
-
-
-
Method Detail
-
withHeader
public HttpClientVerifyBuilder withHeader(String header, String value)
Adds header condition. Header must be equal to provided value.- Parameters:
header- header namevalue- expected value- Returns:
- verification builder
-
withHeader
public HttpClientVerifyBuilder withHeader(String header, org.hamcrest.Matcher<String> matcher)
Adds header condition. Header must be equal to provided value.- Parameters:
header- header namematcher- header value matcher- Returns:
- verification builder
-
withParameter
public HttpClientVerifyBuilder withParameter(String name, String value)
Adds parameter condition. Parameter must be equal to provided value.- Parameters:
name- parameter namevalue- expected parameter value- Returns:
- verification builder
-
withParameter
public HttpClientVerifyBuilder withParameter(String name, org.hamcrest.Matcher<String> matcher)
Adds parameter condition. Parameter value must match.- Parameters:
name- parameter namematcher- parameter value matcher- Returns:
- verification builder
-
withFormParameter
public HttpClientVerifyBuilder withFormParameter(String name, String value)
Request body must contain the given URL-encoded form parameter (typically found in POST requests). Alternatively, parameters may be specified all at once usingwithFormParameters(ParametersMatcher).- Parameters:
name- parameter namevalue- expected parameter value- Returns:
- verification builder
-
withFormParameter
public HttpClientVerifyBuilder withFormParameter(String name, org.hamcrest.Matcher<String> matcher)
Request body must contain the given URL-encoded form parameter (typically found in POST requests). Alternatively, parameters may be specified all at once usingwithFormParameters(ParametersMatcher).- Parameters:
name- parameter namematcher- parameter value matcher- Returns:
- verification builder
-
withFormParameters
public HttpClientVerifyBuilder withFormParameters(ParametersMatcher parameters)
Request body must contain the given URL-encoded form parameters (typically used in POST requests). Alternatively, parameters may be specified individually usingwithFormParameter(String, Matcher).- Parameters:
parameters- the parameters- Returns:
- condition builder
-
with
public HttpClientVerifyBuilder with(Condition condition)
Adds custom conditions.- Parameters:
condition- custom condition- Returns:
- verification builder
-
withBody
public HttpClientVerifyBuilder withBody(org.hamcrest.Matcher<String> matcher)
Adds body condition. Request body must match provided matcher.- Parameters:
matcher- custom condition- Returns:
- verification builder
-
withHost
public HttpClientVerifyBuilder withHost(String host)
Adds host condition. Request host must be equal to provided value.- Parameters:
host- expected host- Returns:
- verification builder
-
withPath
public HttpClientVerifyBuilder withPath(String path)
Adds path condition. Request path must be equal to provided value.- Parameters:
path- expected path- Returns:
- verification builder
-
withPath
public HttpClientVerifyBuilder withPath(org.hamcrest.Matcher<String> matcher)
Adds path condition. Request path must match.- Parameters:
matcher- path matcher- Returns:
- verification builder
-
withExtraParameters
public HttpClientVerifyBuilder withExtraParameters()
Allows extra parameters (not defined in condition) in query.- Returns:
- verification builder
-
withoutExtraParameters
public HttpClientVerifyBuilder withoutExtraParameters()
Disallows extra parameters (not defined in condition) in query.- Returns:
- condition builder
-
withExtraFormParameters
public HttpClientVerifyBuilder withExtraFormParameters()
Allows extra parameters (not defined in condition) in form.- Returns:
- verification builder
-
withoutExtraFormParameters
public HttpClientVerifyBuilder withoutExtraFormParameters()
Disallows extra parameters (not defined in condition) in form.- Returns:
- verification builder
-
notCalled
public void notCalled()
Verifies if there were no request matching defined conditions.
-
called
public void called()
Verifies if there was exactly one request matching defined conditions.
-
called
public void called(int numberOfCalls)
Verifies number of request matching defined conditions.- Parameters:
numberOfCalls- expected number of calls
-
called
public void called(org.hamcrest.Matcher<Integer> numberOfCalls)
Verifies number of request matching defined conditions.- Parameters:
numberOfCalls- expected number of calls
-
-