Forum Discussion

andrew_net's avatar
andrew_net
Occasional Contributor
9 years ago

BUG? JSONPath Existence Match cannot use condition

This was discovered when I chatted about a different issue in the forum. I am posting it here so the problem is more clear and hope to get some attention. Let's say I have a response like below

 

{"errors": [{
   "code": "100",
   "message": "Message for 100",
  },

  {
   "code": "200",
   "message": "Message for 200",
  }

]}

 

I created "JSONPath Existence Match" asserts as below

 

  Expression: $..errors[?(@.code == 100)]

  Expected result: true

 

  Expression: $..errors[?(@.code == 800)]

  Expected result: false

 

I would think both VALID, i.e. the actaul result of the second expression would be false. However, the actual result was true. The second assertion failed with the error:

 

  -> Comparision failed for path [$..errors[?(@.code == 800)]], expecting [false], and actual was [true]

 

However, if I create "JSONPath Count" asserts instead as shown below:

 

  Expression: $..errors[?(@.code == 100)]

  Expected result: 1

 

  Expression: $..errors[?(@.code == 800)]

  Expected result: 0

 

Both assertion will be VALID, i.e. the actual result of the second expression will be 0 (which is the expected value).

 

This is not consistent! Should this be a BUG?

 

I tried this on both SoapUI OpenSource 5.2.1 and the SoapUI NG Pro 1.5.0 (ReadyAPI 1.5.0). They all behave the same.

  • TanyaYatskovska's avatar
    TanyaYatskovska
    SmartBear Alumni (Retired)

    Hi Andrew_net,

     

    Thanks for reporting this behavior. I’ve reproduced a similar issue and reported it to our R&D Team. Let’s wait for the news from them.

     

      • andrew_net's avatar
        andrew_net
        Occasional Contributor

        Hi Tanya,

         

        Thanks for getting back to me.

         

        This is really good news! Unfortunately, I cannot test it on Ready API since my trial license is expired and I am still waiting for the approval of the real license. I tried to install the maintenance build and it still tells me the trail license is expired.

         

        Do you know if the change went into SoapUI open software version? Is there a maintenance build for the open software version I can test this on?

         

        Thanks.