Class BodyMatchers
- java.lang.Object
-
- org.springframework.cloud.contract.spec.internal.BodyMatchers
-
- Direct Known Subclasses:
ResponseBodyMatchers
public class BodyMatchers extends Object
Matching strategy of dynamic parts of the body.- Since:
- 1.0.3
- Author:
- Marcin Grzejszczak, Olga Maciaszek-Sharma, Tim Ysewyn
-
-
Field Summary
Fields Modifier and Type Field Description protected List<BodyMatcher>matchers
-
Constructor Summary
Constructors Constructor Description BodyMatchers()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description MatchingTypeValuebyDate()MatchingTypeValuebyEquality()RegexMatchingTypeValuebyRegex(String regex)RegexMatchingTypeValuebyRegex(Pattern regex)RegexMatchingTypeValuebyRegex(RegexProperty regex)MatchingTypeValuebyTime()MatchingTypeValuebyTimestamp()MatchingTypeValuebyType(groovy.lang.Closure consumer)The output part of the contract.MatchingTypeValuebyType(Consumer<MatchingTypeValueHolder> consumer)The output part of the contract.booleanequals(Object o)inthashCode()booleanhasMatchers()voidjsonPath(String path, MatchingTypeValue matchingType)List<BodyMatcher>matchers()StringtoString()voidxPath(String xPath, MatchingTypeValue matchingTypeValue)Adds xPath matcher; even though same implementation as injsonPath(java.lang.String, org.springframework.cloud.contract.spec.internal.MatchingTypeValue), added for logical coherence in xml.
-
-
-
Field Detail
-
matchers
protected final List<BodyMatcher> matchers
-
-
Method Detail
-
jsonPath
public void jsonPath(String path, MatchingTypeValue matchingType)
-
xPath
public void xPath(String xPath, MatchingTypeValue matchingTypeValue)
Adds xPath matcher; even though same implementation as injsonPath(java.lang.String, org.springframework.cloud.contract.spec.internal.MatchingTypeValue), added for logical coherence in xml.- Parameters:
xPath- the xPath used to find the element to matchmatchingTypeValue- to match the element found by the xPath against
-
hasMatchers
public boolean hasMatchers()
-
matchers
public List<BodyMatcher> matchers()
-
byDate
public MatchingTypeValue byDate()
-
byTime
public MatchingTypeValue byTime()
-
byTimestamp
public MatchingTypeValue byTimestamp()
-
byRegex
public RegexMatchingTypeValue byRegex(String regex)
-
byRegex
public RegexMatchingTypeValue byRegex(RegexProperty regex)
-
byRegex
public RegexMatchingTypeValue byRegex(Pattern regex)
-
byEquality
public MatchingTypeValue byEquality()
-
byType
public MatchingTypeValue byType(Consumer<MatchingTypeValueHolder> consumer)
The output part of the contract.- Parameters:
consumer- function to manipulate the output message- Returns:
- matching type
-
byType
public MatchingTypeValue byType(@DelegatesTo(MatchingTypeValueHolder.class) groovy.lang.Closure consumer)
The output part of the contract.- Parameters:
consumer- function to manipulate the output message- Returns:
- matching type
-
-