ReadyAPI: How to remove table name in jdbc response
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ReadyAPI: How to remove table name in jdbc response
Hello,
I need to know how it is possible to remove the table name in the jdbc response.
My situation is:
I have configured 2 environments on my project: one has Postgres database, the other one has Oracle database.
When I run a jdbc step on postgres, an example of response is:
<Results>
<ResultSet fetchSize="0">
<Row rowNumber="1">
<DICTIONARY_CODE.SEQ_DICTIONARY_CODE>107</DICTIONARY_CODE.SEQ_DICTIONARY_CODE>
</Row>
</ResultSet>
</Results>
where DICTIONARY_CODE is the table name and SEQ_DICTIONARY_CODE is the column name.
When I run it on the Oracle database, the response is:
<Results>
<ResultSet fetchSize="0">
<Row rowNumber="1">
<SEQ_DICTIONARY_CODE>107</SEQ_DICTIONARY_CODE>
</Row>
</ResultSet>
</Results>
so, on oracle is not returned the table name.
It is a problem for the assertions and also when I want to use this value as a property in another step.
To do an example:
After the jdbc request, I have a REST Request in which I use the jdbc response value as a property:
"seqAbbreviationGroup" : "${Find abbreviation_group from dictionary_code#ResponseAsXml#//Results[1]/ResultSet[1]/Row[1]/DICTIONARY_CODE.SEQ_DICTIONARY_CODE[1]}"
So, to use it, on postgres I need to define the table name and the column name, on Oracle only the column name.
In this way it is impossible to run the same project on 2 different environments.
A solution could be to have the same jdbc response in both the environments: so, how it is possible to remove the table name in the jdbc response?
Or, there is any particular settings to make "universal" the jdbc response?
I use the 3.20.0 ReadyAPI version.
I hope my request is clear. If you need, I can give you further details.
Thanks in advance.
- Labels:
-
Configuration
-
Function Tests
-
Scripting
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
One of the approach is to apply filter on response and remove the unwanted table name if the environment is postgres.
Regards,
Rao.
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you for the answer but how is it possible to filter the response?
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Regards,
Rao.
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Can you provide me an example of script that can be used in Events please?
I really don't know how to start.
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Moreover, based on the readyapi documentation, a "ResponseFilter" event doesn't exist , but only the RequestFilter exists so please since you know how to do it, can you also show me the type of event to use?
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Any news?
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Add Event Handler, select the "After Run TestStep" event.
And use below script, hope it will help
import com.eviware.soapui.impl.wsdl.teststeps.JdbcRequestTestStep
//Set the tablename to be removed
def tableName = 'DICTIONARY_CODE'
def currentStep = context.currentStep
if (currentStep instanceof JdbcRequestTestStep) {
// Custom logic to be executed for JDBC Request steps only
// Add your script code here
log.info("After Step Run Event - JDBC Request Step")
// Get the response of the JDBC step
def response = currentStep.testRequest.response.contentAsString
// Perform processing to remove table names from the response (you can customize this as per your requirements)
def modifiedResponse = response.replaceAll(/tableName\./, '')
// Set the modified response content
currentStep.testRequest.response.setContent(modifiedResponse)
}
Regards,
Rao.
