Forum Discussion
It looks like your JSON has an object called entity, not entities.
Plus, it looks like there is only one (?). So...
jsonAdd.entity.id
Below is my Json
{
"entity": {
"createDate": 1525870547786,
"modifyDate": 1525870547786,
"id": 547725,
"companyTransactionId": "N/A",
"transactionType": "IP",
"transactionStatus": "SALE_PENDING",
"item": {
"id": 38678000,
"company": {
"id": 10801,
"name": "AutomationCompany",
"enableTradeIn": true,
"logoUrl": null,
"bannerUrl": null,
"paymentInstructions": "Payment Instruction entered for company. Payment needs to be done with agreed period.",
"paymentGatewayAccount": null,
"externalId": "AutomationCompanyExtId",
"thirdPartySellerId": null,
"hideFromIsys": false,
"hideFromDirectory": false,
"hideFromPartner": false,
"url": "",
"logoFileName": null,
"bannerFileName": null,
"companyTokenSet": false,
"escapedName": "AutomationCompany",
"searchFilterTag": "AutomationCompany|8979878789"
},
"companyItemId": "AUTO9055",
"companyItemUrl": "https://test1www.proxibid.com",
"title": "AUTO9055 Title",
"description": "this is for testing only. description key",
"minimumPrice": 60000,
"listPrice": 80000,
"terms": "these are some terms. terms key",
"currency": {
"id": 1,
"code": "USD",
"name": "United States Dollars",
"description": "",
"htmlCode": "$",
"conversionFactor": 1,
"displayOrder": 1,
"active": true
},
"active": true,
"companyMobileItemUrl": null,
"quantity": 1,
"available": true,
"upsellInfo": "testing the upsell info",
"itemTax": null,
"buyersPremium": null,
"images": [{
"id": 30565039,
"url": "https://test1www.proxibid.com/itemImages/100/122/31420327/1.jpg",
"path": "/15167/10801/38671953/",
"name": "1.jpg",
"altText": "Alt image",
"type": "PRIMARY",
"status": "OK",
"source": "EXTERNAL",
"mediaType": "PHOTO",
"displayOrder": 1,
"caption": null,
"defaultUrl": "https://test1www.proxibid.com/itemImages/100/122/31420327/1.jpg",
"plainUrl": "https://test1www.proxibid.com/itemImages/100/122/31420327/1.jpg"
}],
"enableVeritread": false,
"itemCategorizationType": "LISTING_ITEM_API",
"hasLegacyLot": false,
"escapedTitle": "AUTO9055-Title",
"defaultImageUrl": "https://test1www.proxibid.com/itemImages/100/122/31420327/1.jpg",
"sortedPriceRanges": [{
"id": 144029,
"itemPriceRangeType": "DAYS",
"value": 1,
"price": 250.5,
"active": true
}, {
"id": 144030,
"itemPriceRangeType": "DAYS",
"value": 7,
"price": 200.5,
"active": true
}, {
"id": 144031,
"itemPriceRangeType": "DAYS",
"value": 14,
"price": 175,
"active": true
}, {
"id": 144032,
"itemPriceRangeType": "DAYS",
"value": 33,
"price": 150,
"active": true
}],
"lotStatus": "",
"originPartner": "Proxibid"
},
"buyer": {
"id": 440516,
"username": "automationbuyer",
"firstName": "aBuyerFirst",
"lastName": "aBuyerLast",
"email": "schaudhary+abuyer@mailcatch.proxibid.com",
"phoneHome": "(988) 156-5692",
"phoneWork": null,
"phoneMobile": null,
"faxNumber": null,
"emailNotification": true,
"smsNotification": null,
"locale": "en_US",
"restrictions": [],
"leadTimeSeconds": null,
"carrierType": null,
"buyerId": 54234,
"verificationNeeded": false,
"riskAssessment": null,
"phoneVerified": null,
"userId": 440516,
"thirdPartyTokenSet": false,
"phone": "(988) 156-5692"
},
"amount": 80000,
"fundsHeld": null,
"paymentSummaryAmount": null,
"currency": {
"id": 1,
"code": "USD",
"name": "United States Dollars",
"description": "",
"htmlCode": "$",
"conversionFactor": 1,
"displayOrder": 1,
"active": true
},
"active": true,
"thirdPartyTransactionId": null,
"thirdPartyLineItemId": null,
"tradeInText": null,
"originPartner": "Proxibid",
"priceRangeType": null,
"priceRangeValue": null,
"priceRangePrice": null,
"rentalStartDate": null,
"rentalEndDate": null,
"notes": null,
"rentalEndDateString": null,
"restrictions": [],
"topRestrictionTypes": null,
"rentalStartDateString": null,
"transactionReportTransactionStatus": null,
"buyerId": 440516
}
}
//=============xox======================
My code is:
import com.eviware.soapui.support.XmlHolder
import groovy.json.JsonSlurper
//from response get value transaction id
def getResponse = testRunner.testCase.testSteps["ClickBuyNow"].getPropertyValue("Response")
//def jsons1 = new JsonSlurper(confirmReq) // created obj for jsonslurper class to pulled json res
// with this obj we can place data in req
//def jsons1 = new JsonSlurper().parseText(getResponse)
def getJsonRes = new JsonSlurper().parseText(getResponse)
def getTransID = getJsonRes.entities[0].id
log.info getTransID
def getcompanyItemId = getJsonRes.entities.item.companyItemId
log.info getcompanyItemId
def gettitle = getJsonRes.entities.item.title
//def gettitle = getJsonRes.getNodeValue(".entities[0].item.title") === showing error
//log.info testRunner.testCase.testSuite.testCases["TC01-BuyNowRequestFlow"].setPropertyValue("TransactionID", getTransID)
testRunner.testCase.testSuite.testCases["TC01-BuyNowRequestFlow"].setPropertyValue("TransactionID", getTransID.toString())
//context.getTestCase().setPropertyValue("TransactionID", getTransID)
testRunner.testCase.testSuite.testCases["TC01-BuyNowRequestFlow"].setPropertyValue("CompanyItemID", getcompanyItemId.toString())
testRunner.testCase.testSuite.testCases["TC01-BuyNowRequestFlow"].setPropertyValue("title", gettitle.toString())
//==============xox===============xox=================xox===================xox===================xox========
def ItemID = testRunner.testCase.testSuite.testCases["TC01-BuyNowRequestFlow"].getPropertyValue("ItemID")
def TransactionID = testRunner.testCase.testSuite.testCases["TC01-BuyNowRequestFlow"].getPropertyValue("TransactionID")
def CompanyItemID = testRunner.testCase.testSuite.testCases["TC01-BuyNowRequestFlow"].getPropertyValue("CompanyItemID")
def title = testRunner.testCase.testSuite.testCases["TC01-BuyNowRequestFlow"].getPropertyValue("title")
log.info title
//
def JsonRequest = testRunner.testCase.testSteps["ConfirmBuyNow_ForScript"].getPropertyValue("Request")
log.info JsonRequest
def jsonAdd = new JsonSlurper().parseText(JsonRequest)
testRunner.testCase.testSteps["ConfirmBuyNow_ForScript"].setPropertyValue("jsonAdd.entity.id","TransactionID")
//jsonAdd.setNodeValue(".entity.item.id",ItemID)
//jsonAdd.setNodeValue(".entity.item.companyItemId",CompanyItemID)
//jsonAdd.setNodeValue(".entity.item.title",title)
def newAddJson = jsonAdd.getJson();
testRunner.testCase.testSteps["ConfirmBuyNow_ForScript"].getPropertyValue("Request",newAddJson)
//========xox===================
still getting an error. plz refer attached screenshots for line no 40 &42
Related Content
- 3 years ago
- 2 years ago
- 7 years ago
Recent Discussions
- 4 days ago