var requestData = JSON.parse(request.data);
var responseData = JSON.parse(responseBody);
var IsFruit=requestData.IsFruit;// IsFruit can be either 0,1 or empty
pm.test("Status code is 200", function () {
pm.response.to.have.status(200);
pm.test("Check if Fruits found with this search criteria", function() {
pm.expect(responseData.Message).to.not.eql("No Fruits found with this search criteria");
var list = (responseData.Fruits).length;
//console.log(list);
var a = [];
for (var i = 0; i < list; i++) {
var counter = responseData.Fruits[i];
FruitsYN = counter.FruitsYN
//console.log(FruitsYN);
a.push(FruitsYN)
pm.test("Check whether Fruit values in the Fruits returned is accurate based on fruit filter in the request", function() {
if (IsFruit == 0) {
pm.expect(FruitsYN).to.eql("N")
if (IsFruit == 1) {
pm.expect(FruitsYN).to.eql("Y")
if (IsFruit =="") {
pm.expect(FruitsYN).to.be.oneOf(["Y", "N"]);