Class Request


  • public class Request
    extends Common
    Represents the request side of the HTTP communication.
    Since:
    1.0.0
    Author:
    Marcin Grzejszczak, Tim Ysewyn
    • 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
      • 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
      • getProperty

        public org.springframework.cloud.contract.spec.internal.Request.ClientPatternValueDslProperty getProperty()
      • setProperty

        public void setProperty​(org.springframework.cloud.contract.spec.internal.Request.ClientPatternValueDslProperty property)
      • 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)
      • setBodyMatchers

        public void setBodyMatchers​(BodyMatchers bodyMatchers)
      • PATCH

        public String PATCH()
      • DELETE

        public String DELETE()
      • OPTIONS

        public String OPTIONS()
      • TRACE

        public String TRACE()
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object
      • url

        public void url​(Object url,
                        Consumer<Url> consumer)
        The URL of the contract.
        Parameters:
        url - url value
        consumer - 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 value
        consumer - 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 value
        consumer - 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 value
        consumer - 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 value
        consumer - 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 value
        consumer - 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 value
        consumer - 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 value
        consumer - 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