Datasink issue
I have scenario where I need to sink different Promotion IDs CategoryType data from Response to datasource.If it is 1 Promotion then I am able to sink but for multiple promotions script is not working properly, reason CategoryType field is same for both Promotion IDs and scripts unable to identify properly.I have attached my response and script detail for reference.I need Help.
EX:-
PromotionID-513 , categoryType-Marketing_Offers
PromotionID-390 , categoryType-Loyalty_Offers
PromotionID-234 , categoryType-Marketing_Offers
script:
//remove properties from DataSink
testRunner.testCase.getTestStepByName("DataSink").propertyList.forEach{
testRunner.testCase.getTestStepByName("DataSink").setPropertyValue(it.name,"")
}
//Transfer and sink properties
def categoryType = context.expand( '${valid Loyalty offers_issued from ODM#Response#$[\'personalizedOffers\'][0][\'validCoupon\'][\'promotion\'][\'categoryType\']}' )
testRunner.testCase.getTestStepByName("DataSink").setPropertyValue("categoryType", categoryType)
//log.info categoryType
def categoryType1 = context.expand( '${valid Loyalty offers_issued from ODM#Response#$[\'personalizedOffers\'][0][\'validCoupon\'][\'promotion\'][\'categoryType\']}' )
testRunner.testCase.getTestStepByName("DataSink").setPropertyValue("categoryType", categoryType1)
//log.info categoryType1
def globalOfferOverride = context.expand( '${valid Loyalty offers_issued from ODM#Response#$[\'customer\'][\'customerAttributes\'][\'offerStrategy\'][\'globalOfferOverride\']}' )
testRunner.testCase.getTestStepByName("DataSink").setPropertyValue("globalOfferOverride", globalOfferOverride)
//log.info globalOfferOverride
def noOfProductCoupons = context.expand( '${valid Loyalty offers_issued from ODM#Response#$[\'configuration\'][\'noOfProductCoupons\']}' )
testRunner.testCase.getTestStepByName("DataSink").setPropertyValue("noOfProductCoupons", noOfProductCoupons)
//log.info noOfProductCoupons
def noOfGlobalCoupons = context.expand( '${valid Loyalty offers_issued from ODM#Response#$[\'configuration\'][\'noOfGlobalCoupons\']}' )
testRunner.testCase.getTestStepByName("DataSink").setPropertyValue("noOfGlobalCoupons", noOfGlobalCoupons)
//log.info noOfGlobalCoupons
//Extract Response
def response = context.expand( '${valid Loyalty offers_issued from ODM#Response}' )
testRunner.testCase.getTestStepByName("DataSink").setPropertyValue("Response", response)
//log.info response