I am going to work on an api testing framework where I need to create payload and assert dynamically based on a template, which I need to create both positive and negative payloads on the fly and test. Let me explain it further. I have an endpoint that gives rules for another endpoint. Lets call it /api/v1/rules/india
{
"name": "india",
"attributes": [
{
"fieldName": "name",
"isRequired": true,
"minLength":3,
"maxLength":10,
"type":"string",
"regex":"emailRegEx"
},
{
"fieldName": "pinCode",
"isRequired": false,
"minLength":3,
"maxLength":10,
"type":"string",
"regex":"emailRegEx"
}
]
}
Lets call it /api/v1/rules/USA
{
"name": "india",
"attributes": [
{
"fieldName": "name",
"isRequired": true,
"minLength":3,
"maxLength":10,
"type":"string",
"regex":"emailRegEx"
},
{
"fieldName": "zipCode",
"isRequired": false,
"minLength":3,
"maxLength":10,
"type":"string",
"regex":"emailRegEx"
}
]
}
if you look at the parameter, fields are differnt for the same webservice like when you pass india then one of the field in payload is pincode andwhen you pass USA it changes to Zipcode ( this is just for eferenc ein my case payloads will change significantly for same endpoint) These are the rules for creating a payload for another endpoint. Values for these fields can be changed by the business team say whatever is required True can be changed to Required False tomorrow. So basically I cannot hardcode my payload/test data and also I cannot hardcode my expected condition as it should be derived from that rulebook.
Can you guy suggest to me some approach to solve this problem using Java Restassued or karate or just plain java?