Hello Team ,
can someone please help me here
I have 2 Json Reponses , I need to verify that first objects value are present in Second objects values
first object name and second object name are different
in first response I have 977 objects same name below is example
{
"name": "i_vestmark_tpi_household_allocations",
"elements": [
{
"household_name": "Test Household DEF"
},
{
"household_name": "test"
},
{
"household_name": "Test Household 3"
},
{
"household_name": "Test WM"
},
{
"household_name": "Test HH Sandeep"
},
{
"household_name": "Test Co-Relationship Household"
},
{
"household_name": "Test Sandy 1"
},
In 2 nd Response I have 4000 objects
{
"name": "i_source_data_salesforce_tpi_target_allo_v2",
"elements": [
{
"householdname": "Test Household DEF",
"organization": "TPI"
},
{
"householdname": "test",
"organization": "TPI"
},
{
"householdname": "Test Household 3",
"organization": "TPI"
},
{
"householdname": "Test WM",
"organization": "TPI"
},
{
"householdname": "Test HH Sandeep",
"organization": "TPI"
},
{
"householdname": "Test Co-Relationship Household",
"organization": "TPI"
},
{
"householdname": "Test Sandy 1",
"organization": "TPI"
},
{
"householdname": "Test HHs",
"organization": "TPI"
},
{
"householdname": "Lee, Jeffrey Household",
"organization": "TPI"
},
{
"householdname": "D'Alessandro, Gail Household",
"organization": "TPI"
},
{
"householdname": "Lee, Michelle Household",
"organization": "TPI"
},
{
"householdname": "Lee, Andrew Household",
"organization": "TPI"
},
{
"householdname": "ZZX-Lee, Christopher Household",
"organization": "TPI"
},
{
"householdname": "Lee, Christopher Household",
"organization": "TPI"
},
{
"householdname": "McCarthy, Kate & Bryan Household",
"organization": "TPI"
},
{
"householdname": "Richards, Rob Household",
"organization": "TPI"
},
{
"householdname": "DiOrio, Chris & Veronica Household",
"organization": "TPI"
},
{
"householdname": "ZZX-Sagalyn, Rita",
"organization": "TPI"
},
{
"householdname": "Sawhney-Martin, Shilpa & James Household",
"organization": "TPI"
},
{
"householdname": "Dvorstov, Mikhail & Elena Household",
"organization": "TPI"
},
{
"householdname": "Percy, Jane Household",
"organization": "TPI"
},
{
"householdname": "Joel, Michael Household",
"organization": "TPI"
},
{
"householdname": "ZZ-TEST",
"organization": "TPI"
},
Here I need to verify that household_name values from first response are present in Second householdname values .
I have tried it with for loop , can we do other way simple with assertions?
I have written below like in in my First Request Test TAB
let jsonData = pm.response.json().elements
pm.test(āsuccess household_name column stored as variableā, function () {
jsonData.forEach((item, index) => {
pm.collectionVariables.set(one-${index}
, item[āhousehold_nameā])
})
});
let DataSize = pm.response.json().elements.length
pm.environment.set(āSizeā,DataSize);
I have written below like in my Second Request Test TAB
et jsonData = pm.response.json().elements
var secondValue = ;
jsonData.forEach((item, index) => {
secondValue.push(item["householdname"]);
});
pm.test("Succes compared vestmark view household_name values are present in salesforce view householdname organization = TPI ", function () {
for (var i = 0, len =pm.environment.get(āSizeā); i < len; i++){
if(pm.expect(secondValue).to.include(pm.collectionVariables.get(`one-${i}`)));
}
});
can we do it any other simple way ?