Forum Discussion

macorrales's avatar
macorrales
Visitor
8 years ago

Mapping optional columns to a json array in parameter template

This is a case of using ReadyAPI to import data from a csv file.

In my Test Case I have
1) Data source: loads a file with a structure similar to :

Customer_Nr;Product_A_Description; Product_A_Category ; Product_B_Description; Product_B_Category;
1;Hand blender;Kitchen;Hair Dryer;Bathroom;
2;Mattress;Bedroom;;;

where product B attributes are optional.

2) Post test step has a request parameter template as:

"customer":{
"customerNr": "${CustomersCvsFile#Customer_Nr}",
"products":[{
"description": "${CustomersCvsFile#Product_A_Description}",
"category" : "${CustomersCvsFile#Product_A_Category}"
},
{
"description": "${CustomersCvsFile#Product_B_Description}",
"category" : "${CustomersCvsFile#Product_B_Category}"
}]
}


How can I make Product B section in the template be gone whene columns Product_B_Description; Product_B_Category; are empty ? so actual requests look like :

"customer":{
"customerNr": "1",
"products":[{
"description": "Hand blender",
"category" : "Kitchen"
},
{
"description": "Hair Dryer",
"category" : "Bathroom"
}]
}
"customer":{
"customerNr": "2",
"products":[{
"description": "Mattress",
"category" : "Bedroom"
}]
}

 

As you can guess I'm quite new to SoapUI, any pointer is higly appreciated.

 

thanks

No RepliesBe the first to reply