Service Virtualization

Expand all | Collapse all

When particular JSON tag is not found (as the tag is option tags in service response) the value in the created property is captured as e.g. The specified JSON path is not found. JSON path = '$[0].names[0].middleName' and assertion is failing although the

Jump to Best Answer
  • 1.  When particular JSON tag is not found (as the tag is option tags in service response) the value in the created property is captured as e.g. The specified JSON path is not found. JSON path = '$[0].names[0].middleName' and assertion is failing although the

    Posted 06-18-2018 03:34 AM

    I am using scripted assertion for validating JSON response tag values with JDBC SQL result column values but when particular JSON tag is not found (as the tag is option tags in service response) the value in the created property e.g. The specified JSON path is not found. JSON path = '$[0].names[0].middleName' and assertion is failing although the SQL result is empty. can anyone suggest a way to fix this issue?

     

    I am using JSON filter to extract tag value and below beanshell code snippet to assert.

    var result=false;
    String result1;

    //DOB validation
    if(testExec.getStateValue("Res_DOB").equals("") && testExec.getStateValue("DB_DOB").equals(""))
    {
    result=true;
    testExec.setStateValue("result1", result);
    }

    else if
    (testExec.getStateValue("Res_DOB").equals(testExec.getStateValue("DB_DOB")))
    {
    result=true;
    testExec.setStateValue("result1", result);
    }
    else
    {
    testExec.setStateValue("result1", "False");
    }

     

    I tried to use contains, includes functions to compare partial string, but beanshell does not support this it seems.

    Suggest me the solutions ASAP.

     

    Thanks,

    Saumya Pandey



  • 2.  Re: When particular JSON tag is not found (as the tag is option tags in service response) the value in the created property is captured as e.g. The specified JSON path is not found. JSON path = '$[0].names[0].middleName' and assertion is failing although

    Posted 06-18-2018 07:59 AM

    Just a thought - if the error is indicated by an empty SQL result, why not check that before attempting to validate your DOB information?



  • 3.  Re: When particular JSON tag is not found (as the tag is option tags in service response) the value in the created property is captured as e.g. The specified JSON path is not found. JSON path = '$[0].names[0].middleName' and assertion is failing although

    Posted 06-18-2018 12:01 PM

    Thanks for the idea Dave, but it's not just DOB, there are around 40 tags. Like for name - fullName, first, second, last, prefix and suffix likewise for address 17 tags, for phone, email, etc. I created one DB connection for validating each block.



  • 4.  Re: When particular JSON tag is not found (as the tag is option tags in service response) the value in the created property is captured as e.g. The specified JSON path is not found. JSON path = '$[0].names[0].middleName' and assertion is failing although
    Best Answer

    Posted 06-18-2018 12:25 PM

    Can you open a support case and share the details?



  • 5.  Re: When particular JSON tag is not found (as the tag is option tags in service response) the value in the created property is captured as e.g. The specified JSON path is not found. JSON path = '$[0].names[0].middleName' and assertion is failing although

    Posted 06-20-2018 02:18 AM

    I dont have to log the support case neither the agent was able to as they could not find the customer ID.



  • 6.  Re: When particular JSON tag is not found (as the tag is option tags in service response) the value in the created property is captured as e.g. The specified JSON path is not found. JSON path = '$[0].names[0].middleName' and assertion is failing although

    Posted 07-10-2018 03:09 AM

    {{property}}.contains(he specified JSON path is not found. JSON path = '$) turned out to be the solution.