Added one more test

This commit is contained in:
Marcin Grzejszczak
2017-04-18 09:53:08 +02:00
parent 3ace049241
commit 4414ffb333

View File

@@ -1153,4 +1153,37 @@ DATA
methodBuilderName | methodBuilder
"JaxRsClientJUnitMethodBodyBuilder" | { org.springframework.cloud.contract.spec.Contract dsl -> new JaxRsClientJUnitMethodBodyBuilder(dsl, properties) }
}
@Issue('#261')
@Unroll
def "should not produce any additional quotes for json body [#methodBuilderName]"() {
given:
Contract contractDsl = Contract.make {
request {
method "POST"
url "/foo"
headers {
header 'Content-Type': "application/json"
}
body $('''{ "foo": "bar"}''')
}
response {
status 400
body "File name is required"
}
}
MethodBodyBuilder builder = methodBuilder(contractDsl)
BlockBuilder blockBuilder = new BlockBuilder(" ")
when:
builder.appendTo(blockBuilder)
def test = blockBuilder.toString()
then:
!test.contains('entity("\\"\\n')
test.contains('''.method("POST", entity("{\\"foo\\":\\"bar\\"}", "application/json"))''')
and:
SyntaxChecker.tryToCompile(methodBuilderName, blockBuilder.toString())
where:
methodBuilderName | methodBuilder
"JaxRsClientJUnitMethodBodyBuilder" | { org.springframework.cloud.contract.spec.Contract dsl -> new JaxRsClientJUnitMethodBodyBuilder(dsl, properties) }
}
}