I am having multiple API tests which have different sets of multipart input values which vary dynamically, I want to create 1 common function which can accept these varying multiple multipart into a single multipart line so that I don't have to create multiple response functions to accept these varying values.
public test1(){
| KEY| VALUE |
|key1 | value1|
|key2 | value2|
|key3 | value3|
}
public test2(){
| KEY| VALUE |
|key1 | value1|
|key2 | value2|
}
public test3(){
| KEY| VALUE |
|key1 | value1|
|key2 | value2|
|key3 | value3|
|key4 | value4|
|key5 | value5|
}
Actual:
public void common() {
Response response = given().urlEncodingEnabled(true).config(RestAssured.config()
.encoderConfig(encoderConfig().encodeContentTypeAs("multipart/form-data", ContentType.TEXT)))
.multiPart("key1","value1")
.multiPart("key2","value2")
.multiPart("key3","value3")
.multiPart("key4","value4")
.multiPart("key5","value5")
.config(RestAssured.config()
.contentType(ContentType.JSON)
.headers(request.getHeaders())
.post(path);
}
Expected logic something like which combines all multipart values into a single function:
public void common() {
given().urlEncodingEnabled(true).config(RestAssured.config()
.encoderConfig(encoderConfig().encodeContentTypeAs("multipart/form-data", ContentType.TEXT)))
.multiPart("key1","value1";"key2","value2";"key3","value3";"key4","value4";"key5","value5")
.config(RestAssured.config()
.contentType(ContentType.JSON)
.headers(request.getHeaders())
.post(path);
}
Any pointers will be appreciated.