Adding an option to validate children nodes in an array (#219)

without this change it's impossible to assert with response matchers all elements of an array
with this change we're using AssertJs conditions in case the pattern contains [*]

fixes #217
This commit is contained in:
Marcin Grzejszczak
2017-02-08 11:41:59 +01:00
committed by GitHub
parent 8449382110
commit ab7fe13aac
7 changed files with 154 additions and 10 deletions

View File

@@ -39,4 +39,11 @@ enum MatchingType {
* provided regex
*/
REGEX
static boolean regexRelated(MatchingType type) {
if (type == EQUALITY || type == TYPE ) {
return false
}
return true
}
}

View File

@@ -0,0 +1,22 @@
package org.springframework.cloud.contract.spec.internal
import spock.lang.Specification
/**
* @author Marcin Grzejszczak
*/
class MatchingTypeSpec extends Specification {
def "should return [#expected] for type [#type]"() {
expect:
MatchingType.regexRelated(type) == expected
where:
type | expected
MatchingType.EQUALITY | false
MatchingType.TYPE | false
MatchingType.REGEX | true
MatchingType.DATE | true
MatchingType.TIME | true
MatchingType.TIMESTAMP | true
}
}