Added equality check to matchers

This commit is contained in:
Marcin Grzejszczak
2017-01-11 14:16:53 +01:00
parent 9ccc5bc0fd
commit 76966a985c
12 changed files with 172 additions and 60 deletions

View File

@@ -25,7 +25,7 @@ interface BodyMatcher {
* by type, the defined response body contained an integer but the actual one
* contained a string then the assertion should fail
*/
String value()
Object value()
/**
* Min no of occurrence when matching by type. In all other cases it will be ignored

View File

@@ -46,6 +46,11 @@ class BodyMatchers {
return new MatchingTypeValue(MatchingType.REGEX, regex)
}
MatchingTypeValue byValue(Object value) {
assert value
return new MatchingTypeValue(MatchingType.EQUALITY, value)
}
boolean equals(o) {
if (this.is(o)) return true
if (this.getClass() != o.class) return false
@@ -81,7 +86,7 @@ class JsonPathBodyMatcher implements BodyMatcher {
}
@Override
String value() {
Object value() {
return this.matchingTypeValue.value
}
@@ -106,9 +111,9 @@ class MatchingTypeValue {
MatchingType type
/**
* Value of regular expression
* Value to check
*/
String value
Object value
/**
* Min occurrence when matching by type