Class Request
- java.lang.Object
-
- org.springframework.cloud.contract.spec.internal.Common
-
- org.springframework.cloud.contract.spec.internal.Request
-
public class Request extends Common
Represents the request side of the HTTP communication.- Since:
- 1.0.0
- Author:
- Marcin Grzejszczak, Tim Ysewyn
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description DslProperty$(Pattern client)Allows to set a dynamic value for the given Pattern element.DslProperty$(ClientDslProperty client)Allows to set a dynamic value for the given element.DslProperty$(RegexProperty property)Allows to set a dynamic value for the given regular expression element.ClientDslPropertyaBoolean()MatchingStrategyabsent()Sets absence check to the given query parameter.ClientDslPropertyanyAlphaNumeric()ClientDslPropertyanyAlphaUnicode()ClientDslPropertyanyDate()ClientDslPropertyanyDateTime()ClientDslPropertyanyDouble()ClientDslPropertyanyEmail()ClientDslPropertyanyHex()ClientDslPropertyanyHostname()ClientDslPropertyanyHttpsUrl()ClientDslPropertyanyInteger()ClientDslPropertyanyIpAddress()ClientDslPropertyanyIso8601WithOffset()ClientDslPropertyanyNonBlankString()ClientDslPropertyanyNonEmptyString()ClientDslPropertyanyNumber()ClientDslPropertyanyOf(String... values)ClientDslPropertyanyPositiveInt()ClientDslPropertyanyTime()ClientDslPropertyanyUrl()ClientDslPropertyanyUuid()voidassertThatSidesMatch(Object stubSide, Object testSide)voidbody(Object bodyAsValue)Allows set an HTTP body.voidbody(List body)Allows set an HTTP body.voidbody(Map<String,Object> body)Allows set an HTTP body.voidbody(DslProperty dslProperty)Allows set an HTTP body.voidbody(MatchingStrategy matchingStrategy)Allows set an HTTP body.voidbodyMatchers(groovy.lang.Closure consumer)Allows to set matchers for the body.voidbodyMatchers(Consumer<BodyMatchers> consumer)Allows to set matchers for the body.MatchingStrategycontaining(Object value)Sets the containing check to the given query parameter.voidcookies(groovy.lang.Closure consumer)Allows to configure HTTP cookies.voidcookies(Consumer<Cookies> consumer)Allows to configure HTTP cookies.StringDELETE()booleanequals(Object o)MatchingStrategyequalTo(Object value)Sets the equality check to the given query parameter.MatchingStrategyequalToJson(Object value)Sets the JSON equality check to the body.MatchingStrategyequalToXml(Object value)Sets the XML equality check to the body.StringGET()BodygetBody()BodyMatchersgetBodyMatchers()CookiesgetCookies()HeadersgetHeaders()DslPropertygetMethod()MultipartgetMultipart()org.springframework.cloud.contract.spec.internal.Request.ClientPatternValueDslPropertygetProperty()UrlgetUrl()UrlPathgetUrlPath()inthashCode()StringHEAD()voidheaders(groovy.lang.Closure consumer)Allows to configure HTTP headers.voidheaders(Consumer<Headers> consumer)Allows to configure HTTP headers.MatchingStrategymatching(Object value)Sets the matching check to the given query parameter.voidmethod(String method)Name of the HTTP method.voidmethod(DslProperty method)Name of the HTTP method.voidmultipart(Object multipartAsValue)Allows to set multipart value.voidmultipart(List multipartAsList)Allows to set multipart via lists.voidmultipart(Map<String,Object> body)Allows to set multipart via the map notation.voidmultipart(DslProperty dslProperty)Allows to set multipart value.MatchingStrategynotMatching(Object value)Sets the not matching check to the given query parameter.StringOPTIONS()StringPATCH()StringPOST()StringPUT()RegexPropertyregexProperty(Object object)voidsetBody(Body body)voidsetBodyMatchers(BodyMatchers bodyMatchers)voidsetCookies(Cookies cookies)voidsetHeaders(Headers headers)voidsetMethod(DslProperty method)voidsetMultipart(Multipart multipart)voidsetProperty(org.springframework.cloud.contract.spec.internal.Request.ClientPatternValueDslProperty property)voidsetUrl(Url url)voidsetUrlPath(UrlPath urlPath)StringtoString()StringTRACE()voidurl(Object url)voidurl(Object url, groovy.lang.Closure consumer)The URL of the contract.voidurl(Object url, Consumer<Url> consumer)The URL of the contract.voidurl(DslProperty url)voidurl(DslProperty url, groovy.lang.Closure consumer)URL to which the request will be sent.voidurl(DslProperty url, Consumer<Url> consumer)URL to which the request will be sent.voidurlPath(Object path)voidurlPath(String path)voidurlPath(String path, groovy.lang.Closure consumer)URL to which the request will be sent.voidurlPath(String path, Consumer<UrlPath> consumer)URL to which the request will be sent.voidurlPath(DslProperty path)voidurlPath(DslProperty path, groovy.lang.Closure consumer)URL to which the request will be sent.voidurlPath(DslProperty path, Consumer<UrlPath> consumer)URL to which the request will be sent.DslPropertyvalue(Pattern client)Allows to set a dynamic value for the Pattern element.DslPropertyvalue(ClientDslProperty client)Allows to set a dynamic value for the given element.DslPropertyvalue(ClientDslProperty client, ServerDslProperty server)Allows to set a dynamic value for client and server side.DslPropertyvalue(RegexProperty property)Allows to set a dynamic value for the given regular expression element.DslPropertyvalue(ServerDslProperty server, ClientDslProperty client)Allows to set a dynamic value for client and server side.-
Methods inherited from class org.springframework.cloud.contract.spec.internal.Common
$, $, $, $, aDouble, alphaNumeric, anInteger, anyBoolean, c, client, consumer, convertObjectsToDslProperties, convertObjectsToDslProperties, email, execute, file, file, fileAsBytes, hostname, httpsUrl, ipAddress, iso8601WithOffset, isoDate, isoDateTime, isoTime, named, named, named, nonBlank, nonEmpty, number, onlyAlphaUnicode, optional, p, positiveInt, producer, regex, regex, regex, server, stub, test, toDslProperty, toDslProperty, toDslProperty, toDslProperty, url, uuid, value, value
-
-
-
-
Constructor Detail
-
Request
public Request()
-
Request
public Request(Request request)
-
-
Method Detail
-
method
public void method(String method)
Name of the HTTP method.- Parameters:
method- HTTP method name
-
method
public void method(DslProperty method)
Name of the HTTP method.- Parameters:
method- HTTP method name
-
url
public void url(Object url)
- Parameters:
url- URL to which the request will be sent
-
url
public void url(DslProperty url)
- Parameters:
url- URL to which the request will be sent
-
urlPath
public void urlPath(String path)
- Parameters:
path- URL to which the request will be sent
-
urlPath
public void urlPath(Object path)
- Parameters:
path- URL to which the request will be sent
-
urlPath
public void urlPath(DslProperty path)
- Parameters:
path- URL to which the request will be sent
-
body
public void body(Map<String,Object> body)
Allows set an HTTP body.- Parameters:
body- body to set
-
body
public void body(List body)
Allows set an HTTP body.- Parameters:
body- body to set
-
body
public void body(MatchingStrategy matchingStrategy)
Allows set an HTTP body.- Parameters:
matchingStrategy- body to set
-
body
public void body(DslProperty dslProperty)
Allows set an HTTP body.- Parameters:
dslProperty- body to set
-
body
public void body(Object bodyAsValue)
Allows set an HTTP body.- Parameters:
bodyAsValue- body to set
-
getBody
public Body getBody()
-
setBody
public void setBody(Body body)
-
multipart
public void multipart(Map<String,Object> body)
Allows to set multipart via the map notation.- Parameters:
body- multipart in a map notation
-
multipart
public void multipart(List multipartAsList)
Allows to set multipart via lists.- Parameters:
multipartAsList- multipart in a list notation
-
multipart
public void multipart(DslProperty dslProperty)
Allows to set multipart value.- Parameters:
dslProperty- multipart
-
multipart
public void multipart(Object multipartAsValue)
Allows to set multipart value.- Parameters:
multipartAsValue- multipart
-
equalTo
public MatchingStrategy equalTo(Object value)
Sets the equality check to the given query parameter.- Parameters:
value- value to check against- Returns:
- matching strategy
-
containing
public MatchingStrategy containing(Object value)
Sets the containing check to the given query parameter.- Parameters:
value- value to check against- Returns:
- matching strategy
-
matching
public MatchingStrategy matching(Object value)
Sets the matching check to the given query parameter.- Parameters:
value- value to check against- Returns:
- matching strategy
-
notMatching
public MatchingStrategy notMatching(Object value)
Sets the not matching check to the given query parameter.- Parameters:
value- value to check against- Returns:
- matching strategy
-
equalToXml
public MatchingStrategy equalToXml(Object value)
Sets the XML equality check to the body.- Parameters:
value- value to check against- Returns:
- matching strategy
-
equalToJson
public MatchingStrategy equalToJson(Object value)
Sets the JSON equality check to the body.- Parameters:
value- value to check against- Returns:
- matching strategy
-
absent
public MatchingStrategy absent()
Sets absence check to the given query parameter.- Returns:
- matching strategy
-
assertThatSidesMatch
public void assertThatSidesMatch(Object stubSide, Object testSide)
- Overrides:
assertThatSidesMatchin classCommon
-
value
public DslProperty value(ClientDslProperty client)
Allows to set a dynamic value for the given element.- Parameters:
client- client value- Returns:
- dsl property
-
$
public DslProperty $(RegexProperty property)
Allows to set a dynamic value for the given regular expression element.- Parameters:
property- property to set- Returns:
- dsl property
-
value
public DslProperty value(RegexProperty property)
Allows to set a dynamic value for the given regular expression element.- Parameters:
property- property to set- Returns:
- dsl property
-
$
public DslProperty $(ClientDslProperty client)
Allows to set a dynamic value for the given element.- Parameters:
client- property to set- Returns:
- dsl property
-
value
public DslProperty value(Pattern client)
Allows to set a dynamic value for the Pattern element.- Parameters:
client- property to set- Returns:
- dsl property
-
$
public DslProperty $(Pattern client)
Allows to set a dynamic value for the given Pattern element.- Parameters:
client- property to set- Returns:
- dsl property
-
regexProperty
public RegexProperty regexProperty(Object object)
- Overrides:
regexPropertyin classCommon
-
value
public DslProperty value(ClientDslProperty client, ServerDslProperty server)
Allows to set a dynamic value for client and server side.
-
value
public DslProperty value(ServerDslProperty server, ClientDslProperty client)
Allows to set a dynamic value for client and server side.
-
getProperty
public org.springframework.cloud.contract.spec.internal.Request.ClientPatternValueDslProperty getProperty()
-
setProperty
public void setProperty(org.springframework.cloud.contract.spec.internal.Request.ClientPatternValueDslProperty property)
-
getMethod
public DslProperty getMethod()
-
setMethod
public void setMethod(DslProperty method)
-
getUrl
public Url getUrl()
-
setUrl
public void setUrl(Url url)
-
getUrlPath
public UrlPath getUrlPath()
-
setUrlPath
public void setUrlPath(UrlPath urlPath)
-
getHeaders
public Headers getHeaders()
-
setHeaders
public void setHeaders(Headers headers)
-
getCookies
public Cookies getCookies()
-
setCookies
public void setCookies(Cookies cookies)
-
getMultipart
public Multipart getMultipart()
-
setMultipart
public void setMultipart(Multipart multipart)
-
getBodyMatchers
public BodyMatchers getBodyMatchers()
-
setBodyMatchers
public void setBodyMatchers(BodyMatchers bodyMatchers)
-
anyAlphaUnicode
public ClientDslProperty anyAlphaUnicode()
-
anyAlphaNumeric
public ClientDslProperty anyAlphaNumeric()
-
anyNumber
public ClientDslProperty anyNumber()
-
anyInteger
public ClientDslProperty anyInteger()
-
anyPositiveInt
public ClientDslProperty anyPositiveInt()
-
anyDouble
public ClientDslProperty anyDouble()
-
anyHex
public ClientDslProperty anyHex()
-
aBoolean
public ClientDslProperty aBoolean()
-
anyIpAddress
public ClientDslProperty anyIpAddress()
-
anyHostname
public ClientDslProperty anyHostname()
-
anyEmail
public ClientDslProperty anyEmail()
-
anyUrl
public ClientDslProperty anyUrl()
-
anyHttpsUrl
public ClientDslProperty anyHttpsUrl()
-
anyUuid
public ClientDslProperty anyUuid()
-
anyDate
public ClientDslProperty anyDate()
-
anyDateTime
public ClientDslProperty anyDateTime()
-
anyTime
public ClientDslProperty anyTime()
-
anyIso8601WithOffset
public ClientDslProperty anyIso8601WithOffset()
-
anyNonBlankString
public ClientDslProperty anyNonBlankString()
-
anyNonEmptyString
public ClientDslProperty anyNonEmptyString()
-
anyOf
public ClientDslProperty anyOf(String... values)
-
GET
public String GET()
-
HEAD
public String HEAD()
-
POST
public String POST()
-
PUT
public String PUT()
-
PATCH
public String PATCH()
-
DELETE
public String DELETE()
-
OPTIONS
public String OPTIONS()
-
TRACE
public String TRACE()
-
url
public void url(Object url, Consumer<Url> consumer)
The URL of the contract.- Parameters:
url- url valueconsumer- function to manipulate the URL
-
url
public void url(DslProperty url, Consumer<Url> consumer)
URL to which the request will be sent. Allows to customize additional query parameters if needed- Parameters:
url- url valueconsumer- function to manipulate the URL
-
urlPath
public void urlPath(String path, Consumer<UrlPath> consumer)
URL to which the request will be sent. Allows to customize additional query. parameters if needed- Parameters:
path- url valueconsumer- function to manipulate the URL
-
urlPath
public void urlPath(DslProperty path, Consumer<UrlPath> consumer)
URL to which the request will be sent. Allows to customize additional query. parameters if needed- Parameters:
path- url valueconsumer- function to manipulate the URL
-
headers
public void headers(Consumer<Headers> consumer)
Allows to configure HTTP headers.- Parameters:
consumer- function to manipulate the headers
-
cookies
public void cookies(Consumer<Cookies> consumer)
Allows to configure HTTP cookies.- Parameters:
consumer- function to manipulate the cookies
-
bodyMatchers
public void bodyMatchers(Consumer<BodyMatchers> consumer)
Allows to set matchers for the body.- Parameters:
consumer- function to manipulate the URL
-
url
public void url(Object url, @DelegatesTo(Url.class) groovy.lang.Closure consumer)
The URL of the contract.- Parameters:
url- url valueconsumer- function to manipulate the URL
-
url
public void url(DslProperty url, @DelegatesTo(Url.class) groovy.lang.Closure consumer)
URL to which the request will be sent. Allows to customize additional query parameters if needed- Parameters:
url- url valueconsumer- function to manipulate the URL
-
urlPath
public void urlPath(String path, @DelegatesTo(UrlPath.class) groovy.lang.Closure consumer)
URL to which the request will be sent. Allows to customize additional query. parameters if needed- Parameters:
path- url valueconsumer- function to manipulate the URL
-
urlPath
public void urlPath(DslProperty path, @DelegatesTo(UrlPath.class) groovy.lang.Closure consumer)
URL to which the request will be sent. Allows to customize additional query. parameters if needed- Parameters:
path- url valueconsumer- function to manipulate the URL
-
headers
public void headers(@DelegatesTo(Headers.class) groovy.lang.Closure consumer)
Allows to configure HTTP headers.- Parameters:
consumer- function to manipulate the headers
-
cookies
public void cookies(@DelegatesTo(Cookies.class) groovy.lang.Closure consumer)
Allows to configure HTTP cookies.- Parameters:
consumer- function to manipulate the cookies
-
bodyMatchers
public void bodyMatchers(@DelegatesTo(BodyMatchers.class) groovy.lang.Closure consumer)
Allows to set matchers for the body.- Parameters:
consumer- function to manipulate the URL
-
-