cancel
Showing results for 
Search instead for 
Did you mean: 

Modifying JDBC response to compare with JSON input

Highlighted
New Contributor

Modifying JDBC response to compare with JSON input

Hello,

 

I have a JDBC step, where it returns empty tags if no data is present on the table. Then am comparing this repsosne to excel (datasource) using assertions where my REST input value is NULL.

 

How do i compare an empty tag to a  NULL input ? Also the fields are dynamic where they may have data or jus returns empty tags.

 

Can anyone help me with this.?Thanks in advance for your time.. 

 

Empty vs NULL.png

 Grrovy that i came up with . Not sure if am on right path or not .. 

 

def ActualSourceCode = context.expand( '${CTL_RAD#ResponseAsXml#//Results[1]/ResultSet[1]/Row[1]/SOURCE_CODE[1]}' )
log.info "JDBCSourceCode= $ActualSourceCode"


def ExpectedSourceCode = context.expand( '${DataSource#SourceCode1}' )
log.info "EXCELSourceCode= $ExpectedSourceCode"


if(ActualSourceCode == 'NOVALUE')
{

ExpectedSourceCode = 'NOVALUE'
assert ExpectedSourceCode == ActualSourceCode
log.info "SourceCodeNotEntered = $ActualSourceCode"
}
else
{
assert ExpectedSourceCode == ActualSourceCode
log.info "SourceCodeEntered = $ActualSourceCode"
}

3 REPLIES 3
Highlighted
Moderator

Re: Modifying JDBC response to compare with JSON input

Hi @Aplis, thanks for reaching out!

 

Community, can anyone look into the above code please? Any suggestions on how to implement the task?

 

 


Olga Terentieva
SmartBear Assistant Community Manager

Highlighted
Moderator

Re: Modifying JDBC response to compare with JSON input

Please check this article which may help you: https://smartbear-cc.force.com/portal/KbArticleViewer?name=How-Do-I-Compare-Two-Dynamic-JSON-Respons...


Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
Highlighted
Community Hero

Re: Modifying JDBC response to compare with JSON input

Hi,

 

You may also consider custom formatting options of JsonSlurper to adjust json contents: http://groovy-lang.org/json.html

 

Regards,
  /Alex [Community Hero]
____
[Community Heroes] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Heroes]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Hero] signature is used with permission by SmartBear Software.
https://community.smartbear.com/t5/custom/page/page-id/hall-of-fame
================================
New Here?
Join us and watch the welcome video:
Announcements
Script Wanted
Let's start July with new challenges!

Create a script to change request body before sending it to the server for the TechCorner tag!


Scripts created in June:
- A script to generate a request body based on data from Datasource
- A script to go through all response nodes and check the value of the required field
- A Dispatching script to get responses based on the values in Request Body
- A script to add a new tag and assign it to all TestCases in a TestSuite
Top Kudoed Authors