[#49] Surrounded with different quotes
This commit is contained in:
@@ -36,8 +36,8 @@ class WiremockToDslConverter {
|
||||
}
|
||||
""" : ""
|
||||
}
|
||||
${bodyPatterns?.equalTo?.every { it } ? "body('''${bodyPatterns.equalTo[0]}''')" : ''}
|
||||
${bodyPatterns?.equalToJson?.every { it } ? "body('''${bodyPatterns.equalToJson[0]}''')" : ''}
|
||||
${bodyPatterns?.equalTo?.every { it } ? "body(\"\"\"${bodyPatterns.equalTo[0]}\"\"\")" : ''}
|
||||
${bodyPatterns?.equalToJson?.every { it } ? "body(\"\"\"${bodyPatterns.equalToJson[0]}\"\"\")" : ''}
|
||||
${bodyPatterns?.matches?.every { it } ? "body \$(client(regex('${escapeJava(bodyPatterns.matches[0])}')), server(''))" : ""}
|
||||
}
|
||||
response {
|
||||
|
||||
@@ -42,6 +42,18 @@ class Body extends DslProperty {
|
||||
super(bodyAsValue.clientValue, bodyAsValue.serverValue)
|
||||
}
|
||||
|
||||
/**
|
||||
* Due to the fact that we allow users to have a body with GString and different values inside
|
||||
* we need to be prepared that they pass regexps around both on client and server side.
|
||||
*
|
||||
* In order to preserve the original JSON structure we need to convert the passed Regex patterns
|
||||
* to a temporary string, then convert all to a legitimate JSON structure and then finally
|
||||
* convert it back from string to a pattern.
|
||||
*
|
||||
* @param bodyAsValue - GString with passed values
|
||||
* @param valueProvider - provider of values either for server or client side
|
||||
* @return JSON structure with replaced client / server side parts
|
||||
*/
|
||||
private static Object extractValue(GString bodyAsValue, Closure valueProvider) {
|
||||
GString gString = new GStringImpl(bodyAsValue.values.clone(), bodyAsValue.strings.clone())
|
||||
Object[] values = bodyAsValue.values.collect { it instanceof DslProperty ? valueProvider(it) : it } as Object[]
|
||||
|
||||
Reference in New Issue
Block a user