Class Contract


  • public class Contract
    extends Object
    The definition of a Contract. Contains helper methods in Groovy left for backward compatibility reasons.
    Since:
    1.0.0
    • Constructor Detail

      • Contract

        public Contract()
    • Method Detail

      • priority

        public void priority​(int priority)
        You can set the level of priority of this contract. If there are two contracts mapped for example to the same endpoint, then the one with greater priority should take precedence. A priority of 1 is highest and takes precedence over a priority of 2.
        Parameters:
        priority - the higher the value the lower the priority
      • name

        public void name​(String name)
        Name of the generated test / stub. If not provided then the file name will be used. If you have multiple contracts in a single file and you don't provide this value then a prefix will be added to the file with the index number while iterating over the collection of contracts. Remember to have a unique name for every single contract. Otherwise you might generate tests that have two identical methods or you will override the stubs.
        Parameters:
        name - name of the contract
      • label

        public void label​(String label)
        Label used by the messaging contracts to trigger a message on the consumer side.
        Parameters:
        label - - name of the label of a messaging contract to trigger
      • description

        public void description​(String description)
        Description text. Might be used to describe the usage scenario.
        Parameters:
        description - - value of the description
      • assertContract

        public static void assertContract​(Contract dsl)
      • make

        public static Contract make​(Consumer<Contract> consumer)
        Point of entry to build a contract.
        Parameters:
        consumer - function to manipulate the contract
        Returns:
        manipulated contract
      • make

        public static Contract make​(@DelegatesTo(Contract.class)
                                    groovy.lang.Closure closure)
        Groovy point of entry to build a contract. Left for backward compatibility reasons.
        Parameters:
        closure - function to manipulate the contract
        Returns:
        manipulated contract
      • request

        public void request​(Consumer<Request> consumer)
        The HTTP request part of the contract.
        Parameters:
        consumer - function to manipulate the request
      • response

        public void response​(Consumer<Response> consumer)
        The HTTP response part of the contract.
        Parameters:
        consumer - function to manipulate the response
      • input

        public void input​(Consumer<Input> consumer)
        The input part of the contract.
        Parameters:
        consumer - function to manipulate the input
      • outputMessage

        public void outputMessage​(Consumer<OutputMessage> consumer)
        The output part of the contract.
        Parameters:
        consumer - function to manipulate the output message
      • request

        public void request​(@DelegatesTo(Request.class)
                            groovy.lang.Closure consumer)
        The HTTP request part of the contract.
        Parameters:
        consumer - function to manipulate the request
      • response

        public void response​(@DelegatesTo(Response.class)
                             groovy.lang.Closure consumer)
        The HTTP response part of the contract.
        Parameters:
        consumer - function to manipulate the response
      • input

        public void input​(@DelegatesTo(Input.class)
                          groovy.lang.Closure consumer)
        The input part of the contract.
        Parameters:
        consumer - function to manipulate the input
      • outputMessage

        public void outputMessage​(@DelegatesTo(OutputMessage.class)
                                  groovy.lang.Closure consumer)
        The output part of the contract.
        Parameters:
        consumer - function to manipulate the output message
      • metadata

        public void metadata​(Map<String,​Object> map)
        Appends all entries to the existing metadata mapping.
        Parameters:
        map - metadata to set
      • ignored

        public void ignored()
        Whether the contract should be ignored or not.
      • inProgress

        public void inProgress()
        Whether the contract is in progress or not.
      • isInProgress

        public boolean isInProgress()
      • getPriority

        public Integer getPriority()
      • setPriority

        public void setPriority​(Integer priority)
      • getRequest

        public Request getRequest()
      • setRequest

        public void setRequest​(Request request)
      • getResponse

        public Response getResponse()
      • setResponse

        public void setResponse​(Response response)
      • getLabel

        public String getLabel()
      • setLabel

        public void setLabel​(String label)
      • getDescription

        public String getDescription()
      • setDescription

        public void setDescription​(String description)
      • getName

        public String getName()
      • setName

        public void setName​(String name)
      • getInput

        public Input getInput()
      • setInput

        public void setInput​(Input input)
      • setOutputMessage

        public void setOutputMessage​(OutputMessage outputMessage)
      • getIgnored

        public boolean getIgnored()
      • isIgnored

        public boolean isIgnored()
      • setIgnored

        public void setIgnored​(boolean ignored)
      • getInProgress

        public boolean getInProgress()
      • setInProgress

        public void setInProgress​(boolean inProgress)
      • setMetadata

        public void setMetadata​(Map<String,​Object> metadata)
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object