Forum Discussion

ili's avatar
ili
Occasional Contributor
3 years ago

Smart Assertion - assert logical/relationship contracts in response

Hi,
I have soap response with format similar to the following dummy example,

...

<person>
     <firstName>xxxxxxxxxx</firstName>
     <lastName>yyyyyyyyyy</lastName>
     <phoneNumber>zzzzzzzzzz</phoneNumber>

</person>

...

Important to note is that node person has relation contract one to one.

I have added Smart Assertion and I am asserting if node exists or attribute equals to value and etc.

HOWEVER, we had a bug where this part of the response <person> node was doubled (one to many) and it bugged our system afterwards... and my Smart Assertion was not smart enough to detect that person is one to many instead of one to one.

Is there a way to assert this in ReadyAPI using the provided assertions, let's say the Smart Assertion?

Or perhaps this requirement is strong potential feature for ReadyAPI? Say there is an additional column in Smart Assertion where beside the 'Condition' you can define (optionally) the relation contract for the specific node or attirbute(such as the example above <person> must be one to one). 

  • ili,

    your API definition (WSDL in the case of SOAP services) should say there's just one occurrence of the person in the answer in the schema definition (XSD).

     

    Afterward, you can use Schema Compliance assertion.

     

    With this approach, you can validate any issues relating to message structure.

     

    Best regards,

    Karel

     

  • KarelHusa's avatar
    KarelHusa
    Champion Level 2

    ili,

    your API definition (WSDL in the case of SOAP services) should say there's just one occurrence of the person in the answer in the schema definition (XSD).

     

    Afterward, you can use Schema Compliance assertion.

     

    With this approach, you can validate any issues relating to message structure.

     

    Best regards,

    Karel

     

  • TNeuschwanger's avatar
    TNeuschwanger
    Champion Level 1

    Hello ili 

     

    Probably not possible for any provided assertions.  Probably not possible for a company (smartbear) to enable too much customization for relation contract.  That is just too big of net to cast to be helpful to anyone.  It would have to be super customizable as to appeal to a broad customer base and I don't think they would go for that when there exists an alternative that everyone can already use. 

     

    The alternative is groovy script test step that allows you to code just a little bit to overcome any restriction you encounter for the assertion you need.  There would be more code in your relation contract than there is in the code to accommodate the groovy scripting assertion in your example.

     

    Just a thought.

     

    Regards,

    Todd