I'm using Spring Cloud Contract framework for REST services integration testing and related client apps contracts. It works for object JSON request / response, but is there a chance to check simple string. Espetially, service which responses Boolean (true or false in response body)?
Part of groovy definition:
response {
status 200
headers {
header('Content-Type', 'application/json;charset=UTF-8')
}
body(
value(client('true'), server(regex("true|false")))
)
}
Related part of generated test:
String responseBody = response.getBody().asString();
null;
Is it a bug, isn't it? Or should I do something better in groovy definition? First row gives a chance generator understands what I want, but second line is completely out. Thanks for any hint.
P.S. I know there are different opinions about only string "true" validity as JSON response (some people says so, other not) Please, don't solve it, but only the real issue :-)
org.springframework.cloud.contract.spec.Contract.make { request { method 'GET' urlPath ('url')
This is worked for me.