I have the following consumer test (excerpt of):
new PactDslJsonArray()
.object()
.stringType("createdBy")
.booleanType("isLastVersion")
.integerType("orderNumber")
.closeObject()
.object()
.stringType("createdBy")
.booleanType("isLastVersion")
.integerType("orderNumber")
.closeObject()
.object()
.stringType("createdBy")
.booleanType("isLastVersion")
.integerType("orderNumber")
.closeObject();
that generates this interaction:
{
"consumer": {
"name": "bm"
},
"interactions": [
{
"description": "Get budgets for specific project",
"providerStates": [
{
"name": "PMM module is running"
}
],
"request": {
"headers": {
"Content-Type": "application/json"
},
"method": "GET",
"path": "/budgets/project/002e3ac0-1b4e-4450-a44e-a90532acfa33"
},
"response": {
"body": [
{
"createdBy": "string",
"isLastVersion": true,
"orderNumber": 100
},
{
"createdBy": "string",
"isLastVersion": true,
"orderNumber": 100
},
{
"createdBy": "string",
"isLastVersion": true,
"orderNumber": 100
}
],
"generators": {
"body": {
"$[0].createdBy": {
"size": 20,
"type": "RandomString"
},
"$[0].orderNumber": {
"max": 2147483647,
"min": 0,
"type": "RandomInt"
},
"$[1].createdBy": {
"size": 20,
"type": "RandomString"
},
"$[1].orderNumber": {
"max": 2147483647,
"min": 0,
"type": "RandomInt"
},
"$[2].createdBy": {
"size": 20,
"type": "RandomString"
},
"$[2].orderNumber": {
"max": 2147483647,
"min": 0,
"type": "RandomInt"
}
}
},
"headers": {
"Content-Type": "application/json"
},
"matchingRules": {
"body": {
"$[0].createdBy": {
"combine": "AND",
"matchers": [
{
"match": "type"
}
]
},
"$[0].isLastVersion": {
"combine": "AND",
"matchers": [
{
"match": "type"
}
]
},
"$[0].orderNumber": {
"combine": "AND",
"matchers": [
{
"match": "integer"
}
]
},
"$[1].createdBy": {
"combine": "AND",
"matchers": [
{
"match": "type"
}
]
},
"$[1].isLastVersion": {
"combine": "AND",
"matchers": [
{
"match": "type"
}
]
},
"$[1].orderNumber": {
"combine": "AND",
"matchers": [
{
"match": "integer"
}
]
},
"$[2].createdBy": {
"combine": "AND",
"matchers": [
{
"match": "type"
}
]
},
"$[2].isLastVersion": {
"combine": "AND",
"matchers": [
{
"match": "type"
}
]
},
"$[2].orderNumber": {
"combine": "AND",
"matchers": [
{
"match": "integer"
}
]
}
}
},
"status": 200
}
}
],
"metadata": {
"pact-jvm": {
"version": "4.6.7"
},
"pactSpecification": {
"version": "3.0.0"
}
},
"provider": {
"name": "pmm"
}
}
When I verify this with the broker, though, I get the following errors:
"differences": [
{
"description": "Expected a String (like \"string\") but got nil at $[0].createdBy"
},
{
"description": "Expected 100 but got 1 at $[0].orderNumber"
},
{
"description": "Expected a String (like \"string\") but got nil at $[1].createdBy"
},
{
"description": "Expected 100 but got 2 at $[1].orderNumber"
},
{
"description": "Expected a String (like \"string\") but got nil at $[2].createdBy"
},
{
"description": "Expected 100 but got 3 at $[2].orderNumber"
}
]
which lead me to believe the consumer test generates interactions that bind actual values rather than the structure -- which is what I would like to verify.
Am I doing anything wrong here? In that case, how do I verify the structure of objects rather than the values for their fields?
Thankyou in advance!