cancel
Showing results for 
Search instead for 
Did you mean: 

Asserting NULL values

Highlighted
New Contributor

Asserting NULL values

I'm doing comparison of values in Oracle database on one end and the service at the other. There are attributes which return NULL value and those same attributes are not found in the service response when this is the case.

 

I need an assertion in the REST request that will pass this scenario, but the regular assertions do not work. When I try to assert these, I get the following error:

 

Comparison failed. Path:

[$['list'][0]['firstLevelNode'][0]['attributeName']];

Expected value: [];

Actual value: [].

 

Expected value is the attribute from the JDBC Request and the Actual value is the corresponding attribute from the REST request. As you can see, the responses are the same, but the assertion does not pass. Is there a way to bypass this? Thanks.

 

EDIT: I know this can be done with a Groovy script, but I would really prefer a solution with assertions inside the REST request.

5 REPLIES 5
Highlighted
Community Hero

Re: Asserting NULL values

Instead, please to try JSONPath count assertion.


Regards,
Rao.
Highlighted
New Contributor

Re: Asserting NULL values

Thing is, I cannot be certain that the response will be returned NULL and when it's a non-NULL value, I need the assertion, so I need one that would cover both cases.

Highlighted
Community Hero

Re: Asserting NULL values

Hmm.
And want non scripting solution.
Not good at JSONPath. May be you can show sample response along what data needs to be asserted.



Regards,
Rao.
Highlighted
New Contributor

Re: Asserting NULL values

Unfortunately, I cannot share the response cause of the NDA, but here's an example of what it might look like:

 

{

   "list":{

      "attribute" : someValue

   }

}

 

And the SQL query 'select attribute from table' returns the value 'someValue'.

 

Now let's say that the attribute from the SQL query returns '(null)', in that case the 'list' node would not contain the 'attribute' element.

 

Funny thing is that when you reference a non-existing element in the REST request, it returns an empty string, which should be perfect and it's the same when you reference a NULL value in the JDBC request, but they just won't match for some reason.

Highlighted
Community Hero

Re: Asserting NULL values

You can show with dummy values with same structure to avoid confusion later to relate to actual case.

By the way, list representation is incorrect.

Any specific reason you don't want do in Script?


Regards,
Rao.
New Here?
Join us and watch the welcome video:
Top Kudoed Authors