Class Contract
java.lang.Object
org.springframework.cloud.contract.spec.Contract
The definition of a Contract. Contains helper methods in Groovy left for backward
compatibility reasons.
- Since:
- 1.0.0
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidassertContract(Contract dsl) voiddescription(String description) Description text.booleanbooleanbooleangetInput()getLabel()getName()inthashCode()voidignored()Whether the contract should be ignored or not.voidWhether the contract is in progress or not.voidinput(groovy.lang.Closure consumer) The input part of the contract.voidThe input part of the contract.booleanbooleanvoidLabel used by the messaging contracts to trigger a message on the consumer side.static Contractmake(groovy.lang.Closure closure) Groovy point of entry to build a contract.static ContractPoint of entry to build a contract.voidAppends all entries to the existing metadata mapping.voidName of the generated test / stub.voidoutputMessage(groovy.lang.Closure consumer) The output part of the contract.voidoutputMessage(Consumer<OutputMessage> consumer) The output part of the contract.voidpriority(int priority) You can set the level of priority of this contract.voidrequest(groovy.lang.Closure consumer) The HTTP request part of the contract.voidThe HTTP request part of the contract.voidresponse(groovy.lang.Closure consumer) The HTTP response part of the contract.voidThe HTTP response part of the contract.voidsetDescription(String description) voidsetIgnored(boolean ignored) voidsetInProgress(boolean inProgress) voidvoidvoidsetMetadata(Map<String, Object> metadata) voidvoidsetOutputMessage(OutputMessage outputMessage) voidsetPriority(Integer priority) voidsetRequest(Request request) voidsetResponse(Response response) toString()
-
Constructor Details
-
Contract
public Contract()
-
-
Method Details
-
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
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
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
Description text. Might be used to describe the usage scenario.- Parameters:
description- - value of the description
-
assertContract
-
make
Point of entry to build a contract.- Parameters:
consumer- function to manipulate the contract- Returns:
- manipulated contract
-
make
Groovy point of entry to build a contract. Left for backward compatibility reasons.- Parameters:
closure- function to manipulate the contract- Returns:
- manipulated contract
-
request
The HTTP request part of the contract.- Parameters:
consumer- function to manipulate the request
-
response
The HTTP response part of the contract.- Parameters:
consumer- function to manipulate the response
-
input
The input part of the contract.- Parameters:
consumer- function to manipulate the input
-
outputMessage
The output part of the contract.- Parameters:
consumer- function to manipulate the output message
-
request
The HTTP request part of the contract.- Parameters:
consumer- function to manipulate the request
-
response
The HTTP response part of the contract.- Parameters:
consumer- function to manipulate the response
-
input
The input part of the contract.- Parameters:
consumer- function to manipulate the input
-
outputMessage
The output part of the contract.- Parameters:
consumer- function to manipulate the output message
-
metadata
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
-
setPriority
-
getRequest
-
setRequest
-
getResponse
-
setResponse
-
getLabel
-
setLabel
-
getDescription
-
setDescription
-
getName
-
setName
-
getInput
-
setInput
-
getOutputMessage
-
setOutputMessage
-
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
-
getMetadata
-
equals
-
hashCode
public int hashCode() -
toString
-