As I'm only interested in checking some of the values from the response for my Contract Test, I want to leave out those fields that are not important to me. Thing is that when I run the test, generated test file checks if body defined in the test.groovy file is identical to the one generated from controller. So, my question is if there's a way to just assert those values that I'm interested in.
test.groovy
Contract.make {
request {
method 'GET'
urlPath('/api/node') {
queryParameters {
parameter('number', '123')
parameter('size', '1')
parameter('status', 'ACTIVE')
}
}
headers {
header("key", "someKey")
}
}
response {
status 200
headers {
contentType applicationJson()
}
body("""
"content":[
{
"id": "123456",
"status":"ACTIVE",
"details":[
{
"object":{
"id":"ccId",
"codeOne":"1",
"codeTwo":"2",
"codeThree":"3",
"_links":{
"self":{
"href":"https://url.com"
},
"style":{
"href":"https://universal-url.com"
},
"universalStyle":{
"href":"https://universal-style-v1-url.com"
}
}
}
"code":null
}
]
This is the error I'm getting
org.junit.ComparisonFailure: expected:<"[content]"> but was:
<"[{"links":[
{"rel":"first","href":"http://localhost/api/node?number=123&status=ACTIVE&page=0&size=1"},
{"rel":"prev","href":"http://localhost/api/node?number=123&status=ACTIVE&page=0&size=1"},
{"rel":"self","href":"http://localhost/api/node?number=123&size=1&status=ACTIVE"},
{"rel":"last","href":"http://localhost/api/node?number=123&status=ACTIVE&page=1&size=1"}],
"content":[{"id":"123456",...
In this case, I don't want to verify any related to "links" array. Is there any configuration I can use in order to bypass it?
Just don't put them in the response and they won't get generated.