@@ -20,6 +20,8 @@ import groovy.transform.EqualsAndHashCode
|
||||
import groovy.transform.ToString
|
||||
import groovy.transform.TypeChecked
|
||||
|
||||
import java.util.regex.Pattern
|
||||
|
||||
/**
|
||||
* Represents a set of headers of a request / response or a message
|
||||
*
|
||||
@@ -68,6 +70,10 @@ class Headers {
|
||||
return new DslProperty(value)
|
||||
}
|
||||
|
||||
protected NotToEscapePattern notEscaped(Pattern pattern) {
|
||||
return new NotToEscapePattern(pattern)
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts the headers into their stub side representations and returns as
|
||||
* a map of String key => Object value.
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
package org.springframework.cloud.contract.spec.internal
|
||||
|
||||
import java.util.regex.Pattern
|
||||
|
||||
|
||||
/**
|
||||
* Special case of Patterns that we don't want to escape
|
||||
*
|
||||
* @author Marcin Grzejszczak
|
||||
* @since 1.0.3
|
||||
*/
|
||||
class NotToEscapePattern extends DslProperty<Pattern> {
|
||||
|
||||
NotToEscapePattern(Pattern clientValue, Pattern serverValue) {
|
||||
super(clientValue, serverValue)
|
||||
}
|
||||
|
||||
NotToEscapePattern(Pattern singleValue) {
|
||||
super(singleValue)
|
||||
}
|
||||
}
|
||||
@@ -144,7 +144,7 @@ class Response extends Common {
|
||||
|
||||
@Override
|
||||
DslProperty matching(String value) {
|
||||
return $(p(Pattern.compile("${RegexpUtils.escapeSpecialRegexWithSingleEscape(value)}.*")),
|
||||
return $(p(notEscaped(Pattern.compile("${RegexpUtils.escapeSpecialRegexWithSingleEscape(value)}.*"))),
|
||||
c(value))
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user