Forum Discussion

HughMungus's avatar
HughMungus
New Contributor
5 years ago

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

  • nmrao's avatar
    nmrao
    Champion Level 3
    Instead, please to try JSONPath count assertion.
    • HughMungus's avatar
      HughMungus
      New Contributor

      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.

      • nmrao's avatar
        nmrao
        Champion Level 3
        Hmm.
        And want non scripting solution.
        Not good at JSONPath. May be you can show sample response along what data needs to be asserted.