ContributionsMost RecentMost LikesSolutionsRe: JSON (REST) to JDBC resultset comparison Thanks a lot Alex. Able to get some matches for the key elements. Would try to play around with the iterate() see if I could exactly match values and pass assertions. Re: JSON (REST) to JDBC resultset comparison Thanks Alex, that was pretty detailed. :smileyhappy: for some reason I'm getting no matches. Getting the below Logs: INFO:all matches: [] WARN:left over JDBC values: [ACCOUNTNUMBER:[657015, 657015, 657015, 657015, 657015, 657015, 657015, 657015, 657015, 657015......].......[.....] - //This pulls all keynote values WARN:left over JSON values: [:] // This doesn't pull ?? INFO:end Have attached my two response files Re: JSON (REST) to JDBC resultset comparison Thanks Alex99 i'm getting this error (attached screenshot) Not sure if I'm doing it right since I didn't understand the (<JDBC_TEXT>) AND <JSON_TEXT> do we have to pass just the keyword or the entire JDBC response in "JDBC_TEXT" and similarly for "JSON_TEXT" currently I've done this new XmlSlurper().parseText(SKU).ResultSet.Row.children().each { it-> def key = it.name().toLowerCase().replace("_", "") def value = it.text() def foundElements = [] for(s in sku.findAll( /"[\w]+" : "?[\w.-]{0,}"?/ )) { jsonkey = s.replace("\"", "").split(":")[0].trim() jsonvalue = s.replace("\"", "").split(":")[1].trim() if(key.equalsIgnoreCase(jsonkey)) { foundElements.add(s) } } if(foundElements.size > 0) { log.info "for [key=${key}] ${foundElements.size} elements were found ${foundElements}" } else { log.error "for [key=${key}] no elements were found" } } log.info "done" How to compare a JDBC response returned in XML against Rest API result which is in JSON Hi I'm using SoapUI open source tool. I got a response from JDBC DB query which is in XML like below. I need to compare this results against rest service API results which is returned in JSON. The issue is I have more elements in API response, so I'm only keen in checking specific elements present in a specific order. How to achieve this using Groovy script ? The DB respnse result is like below <row1> <plantcode>2343</plantcode> <plantname>John Plant</plantname> <category>CT</category> <sku>23432</sku> <model>OC59SK11PX1</model> <productName>Built-in, 7 Function</productName> <availableStock>7</availableStock> <availabledate>112890</availaledate> </row1> ..... <row2>..... <row3>....... The JSON respnose from API is like below {"records": [{ "firstRecordSKU": "81572", "firstRecordRowNum": "1", "lastRecordSKU": "81497", "lastRecordRowNum": "4", "totalRecords": "4", "accountList": [ { "accountNumber": "657015", "accountName": "ABC Account", "wareHouses": [ { "wareHouseCode": "5912", "wareHouseName": "Zenith Plant", "categories": [ { "categoryDesc": "", "categoryCode": [ { "subCategoryCode": "BA", "subCategoryDesc": "Baring", "products": [ { "sku": "24246", "modelNumber": "OC59SK11PX1", "productName": "Built-in 50,Pyrolytic", "availableStock": "10", "stockInTransit": "5", "availableFrom": "2018-08-30" }, { "sku": "24330", "modelNumber": "OBE0HL7DEW1", "productName": "Built-in, 7 Function", "availableStock": "0", "stockInTransit": "", "availableFrom": "" } ] }, { "subCategoryCode": "CT", "subCategoryDesc": "ClasTolls", "products": [ { "sku": "24246", "modelNumber": "OB60SD11PX1", "productName": "Class Tool 85L, 11 Function", "availableStock": "10", "stockInTransit": "5", "availableFrom": "2018-08-30" }, { "sku": "24330", "modelNumber": "OB60SL7DEW1", "productName": "Class Tool 90L, 7 Function", "availableStock": "0", "stockInTransit": "", "availableFrom": "" } ] }, { "subCategoryCode": "OW", "subCategoryDesc": "Owls", "products": [ { "sku": "24246", "modelNumber": "OB60SD11PX1", "productName": "Generic Owls 85L, 11 Function", "availableStock": "10", "stockInTransit": "5", "availableFrom": "2018-08-30" }, { "sku": "24330", "modelNumber": "OB60SL7DEW1", "productName": "Greater Space Owls, 7 Function", "availableStock": "0", "stockInTransit": "", "availableFrom": "" } ] } ] }] }] }] }]} I need to check all elements in a specific row returned in DB query is matching against API result, how could I achieve this using groovy script ? Any help is highly appreciated.. Thank you Re: Data Driven using SoapUI Open Source Have cracked this Groovy Script for writing back response value to external file. Works well :smileyhappy: If your response xml looks like below: <ns2:About> <ns2:make>Samsung</ns2:make> <ns2:model>S5</ns2:model> <ns2:cost>589.62</ns2:cost> </ns2:About> The below groovy script does the following actions 1. Captures the xml response for test case 2. Captures the xml node values with 'Cost' element 3. Writes into a file and prints each results in next line (useful for looping) where we want to capture each results in next line def retrieve = groovyUtils.getXmlHolder("TestCaseName#Response" ) def cost = retrieve.getNodeValues("//ns2:Cost").toString() new File( "C:/Projects/results.txt" ).append( cost + "\n") // You could view the value in log output if you want to log.info cost Re: Data Driven using SoapUI Open Source I was able to successfully create inputs via external file and using counter check this link https://learnsoapui.wordpress.com/2012/05/19/groovy-datasource-teststep-dataloop-teststep-using-groovy-in-soapui/ Haven't got my luck to get groovy script to record specific value of respnonse xml to an external file. Challenge is to record in looper. As I want to store each response in next line of xls file or .txt file. eg. want to record the below value of xml to external file with each response in new line <ns2:cost>1953.44</ns2:cost> Thanks Re: Data Driven using SoapUI Open Source I want a specific response xml value from the payload to be stored back in excel sheet for each of the input values supplied through looping. The response values need not write on same excel sheet in which Input values are supplied, but could be different one. Would be easier if it's on same excel sheet. looking to print in any column of excel sheet Thanks Data Driven using SoapUI Open Source Hi Guys, I am using SoapUI free version tool. I want to use a data driven testing having the below scenario: 1. Load the parameter from an excel sheet to Test Case 2. Write back the response parameter to the respective excel sheet I have seen some posts using groovy script, but didn't find how to write back the response values to excel sheet. Thanks Re: I am getting "groovy.lang.MissingPropertyException: No such property:" for my groovy script. Thanks all for your help. The below worked. testRunner.testCase.setPropertyValue("EffectiveDate", effectiveDate) I was thinking we have to literally replace the test case name with the actual test case name, which isn't the case. All good now :) Re: I am getting "groovy.lang.MissingPropertyException: No such property:" for my groovy script. Thanks, I tried running it on a complete test case, still same result testRunner.DEC.testSteps['Dec_Quote'].setPropertyValue("EffectiveDate", effectiveDate) DEC is the Test Case