@NotThreadSafe public class DefaultRequestExpectationBuilder extends Object implements RequestExpectationBuilder
RequestExpectationBuilder.
TODO Test.
| Modifier | Constructor and Description |
|---|---|
protected |
DefaultRequestExpectationBuilder()
Creates new builder instance.
|
| Modifier and Type | Method and Description |
|---|---|
RequestExpectationBuilder |
andResponse(ResponseBuilder responseBuilder)
Specifies response builder to provide a response on the actual request.
|
RequestExpectation |
build()
Builds request expectation.
|
ResponseBuilder |
getResponseBuilder()
Gets response builder to provide a response on the actual request.
|
RequestExpectationBuilder |
withBody(ValueExpectation valueExpectation)
Specifies expected request body.
|
RequestExpectationBuilder |
withHeader(String headerName)
Specifies expected request header without any expectations on its value.
|
RequestExpectationBuilder |
withHeader(String headerName,
int valueIndex,
ValueExpectation valueExpectation)
Specifies expected request header with its value and position in the list
of header values.
|
RequestExpectationBuilder |
withHeader(String headerName,
ValueExpectation valueExpectation)
Specifies expected request header with its value, but without position in
the list of header values.
|
RequestExpectationBuilder |
withMethod(ValueExpectation valueExpectation)
Specifies expected request method.
|
RequestExpectationBuilder |
withoutHeader(String headerName)
Specifies that request is not expected to have this header.
|
RequestExpectationBuilder |
withPath(ValueExpectation valueExpectation)
Specifies expected request path.
|
protected RequestExpectationBuilder |
withRequestAttribute(Function<HttpRequest,Object> attributeProvider,
String matcherName,
ValueExpectation valueExpectation)
Sets expectation on the value of a request attribute.
|
RequestExpectationBuilder |
withStrictHeaders()
If the property
strict headers is enabled, this expectation
allows only headers specified explicitly by RequestExpectationBuilder.withHeader(java.lang.String) method. |
protected DefaultRequestExpectationBuilder()
New instance matches any request and provides default response from
DefaultResponseBuilder.
End user is not supposed to call this constructor and instead should call
AbstractRequestExpectationListBuilder.request() when implementing
RequestExpectationListBuilder.build().
public RequestExpectation build()
RequestExpectationBuilderbuild in interface RequestExpectationBuilderpublic ResponseBuilder getResponseBuilder()
RequestExpectationBuildergetResponseBuilder in interface RequestExpectationBuilderprotected RequestExpectationBuilder withRequestAttribute(Function<HttpRequest,Object> attributeProvider, String matcherName, ValueExpectation valueExpectation)
Adds a Matcher that verifies the given request attribute.
attributeProvider - Provider of a request attribute, takes the
request on input.matcherName - Name of the matcher to be used in a mismatch
description.valueExpectation - Expected attribute value.public RequestExpectationBuilder withMethod(ValueExpectation valueExpectation)
RequestExpectationBuilderwithMethod in interface RequestExpectationBuildervalueExpectation - Expected method.public RequestExpectationBuilder withPath(ValueExpectation valueExpectation)
RequestExpectationBuilderwithPath in interface RequestExpectationBuildervalueExpectation - Expected path.public RequestExpectationBuilder withBody(ValueExpectation valueExpectation)
RequestExpectationBuilderwithBody in interface RequestExpectationBuildervalueExpectation - Expected body.public RequestExpectationBuilder withHeader(String headerName)
RequestExpectationBuilderwithHeader in interface RequestExpectationBuilderheaderName - Header name.public RequestExpectationBuilder withHeader(String headerName, ValueExpectation valueExpectation)
RequestExpectationBuilderwithHeader in interface RequestExpectationBuilderheaderName - Header name.valueExpectation - Expected header value.public RequestExpectationBuilder withHeader(String headerName, int valueIndex, ValueExpectation valueExpectation)
RequestExpectationBuilderwithHeader in interface RequestExpectationBuilderheaderName - Header name.valueIndex - Header value index in the list of header values.valueExpectation - Expected header value.public RequestExpectationBuilder withoutHeader(String headerName)
RequestExpectationBuilderwithoutHeader in interface RequestExpectationBuilderheaderName - Header name.public RequestExpectationBuilder withStrictHeaders()
RequestExpectationBuilderstrict headers is enabled, this expectation
allows only headers specified explicitly by RequestExpectationBuilder.withHeader(java.lang.String) method.
By default this property is disabled.
withStrictHeaders in interface RequestExpectationBuilderpublic RequestExpectationBuilder andResponse(ResponseBuilder responseBuilder)
RequestExpectationBuilderandResponse in interface RequestExpectationBuilderresponseBuilder - Response builder.Copyright © 2016. All rights reserved.