SOATEST - How to assert on blank values

I am using SOATest (9.9) and in my JSON response I am asserting on an element (status) which can have a value or null value. I am trying to assert this against my datasource column 'status'.
I added the below assertions in this case and did the below:
1) Added a Value Assertion for the element 'status' and parameterized it to refer to the data source spreadsheet column.
2) Added another Fixed Value Assertion for the element 'status' and added value as blank and saved it.
3)Added a Conditional assertion and added the Assertion #2 to my "If Assertion" section and then Assertion #1 to "Then Assertion" section and saved it.
When I run the test its ignoring this above assertion and passing my test everytime no matter what I give in the status column in my datacolumn spreadsheet.
Am I doing something wrong here ?

Answers

Does an empty element represent a null value or no element in the response? If no element in the response in the response represents a null value, you want to use Occurrence Assertion. If no value in the element represents a null value, you want to use Has Content Assertion. Please let me know if this helps.

In my response the element comes back with no value against it . Something like as below:
{
"clientTypeCode": "ORG",
"status": ""
}
I used 'Has Content Assertion' and parameterized it to refer to the data source spreadsheet column 'status' and after running it gives me an error as below:

Has Content Assertion../status could not be located or did not contain text content.

Hi jakubiak,
My datasource column 'status' has a valid (non null) value for first row/ scenario.
For the second row/scenation the column has blank value. This is where SOATEST is failing with "Has Content Assertion../status could not be located or did not contain text content."

Just to clarify I am getting the error "Has Content Assertion../status could not be located or did not contain text content." whenever the response looks like this:
{
"clientTypeCode": "ORG",
"status": ""
}
Whenever the response has a valid value for 'status' element like as below,then my assertion is not an issue.:
{
"clientTypeCode": "ORG",
"status": "PEND"
}
I want to know which assertion to use to assert for blank/null values in the response .

Hi Ireneusz,
My scenario is I am expecting blank value for 'status' element for one of my scenario and I expect my test not to fail if it returns blank value and how do I handle through assertion? So I am asserting my 'status' element in the response against 'status' column in my datasource sheet and this datasource sheet has 2 rows/scenarios. For the first scenario, 'status' (expected value for 'status element) column has a value 'PEND' and when SOATest runs this scenario then the test passes as the 'status' element comes back with 'PEND" value . For the second scenario,'status' column has no value in the datasource sheet and when SOATest runs this scenario then the test fails saying '"Has Content Assertion../status did not contain text content." because the response had blank value for 'status' element. How can I have an assertion against an element which will work for both null/blank and non blank values ?

Do not parametrize it at the beginning.
Has Content assertion expects to get true or false, so in your data source you have to add column which contains true or false for particular case, and then parametrize it in JSON Assertor.

I tried it so , now it shows the below error for both the scenarios
DataSource: Models (row 1): Has Content Assertion1: Element "../status" was expected to be empty
DataSource: Models (row 2): Has Content Assertion1: Element "../status" was expected to be empty

My response was as below for row 1 and row 2 respectively:
Response for row1:
{"clientTypeCode":"IP","status":"PEND"}
Response for row2:
{"clientTypeCode":"ORG","status":""}

Well this compound assertion will work for my my first scenario where my element has a non blank value but it will fail for the second scenario where my element doesn't have a content/ or comes back blank.

I used Conditional Assertion in the first place. Below are the steps I followed (am copy pasting the steps from my initial question in this thread):
1) Added a Value Assertion for the element 'status' and parameterized it to refer to the data source spreadsheet column.
2) Added another Fixed Value Assertion for the element 'status' and added value as blank and saved it.
3)Added a Conditional assertion and added the Assertion #2 to my "If Assertion" section and then Assertion #1 to "Then Assertion" section and saved it.
When I run the test its ignoring this above assertion and passing my test everytime no matter what I give in the status column in my datacolumn spreadsheet.

But I think you have to check Has Content assertion in IF then check the value.
Has Content should be set with data source as true or false.
The column which you want to use in parametrization in Has Content should contain true/false.Could you please attach your tst in this thread?

Thanks Ireneusz. I had already tried this approach but the problem here is , its not actually asserting for non blank values properly. So in your example, for the value of test column 'My' if response has 'xyz' then also my test is passing , which shouldn't be the case. I agree Conditional assertion is taking care of not failing when its coming across blank values for 'status' in the response but at the same time its not truely asserting on the right value . For ex: if you change value of 'test' column for row#1 to '123444' and then run the test it will still pass. I hope am not confusing you.

It would extremely helpful if you could provide a sample .tst file to demonstrate where your current hurdle lies. Please attach a sample .tst file so that we can reproduce the behavior and give you some additional insight. Save the traffic in the traffic viewer!

The only reason I was hesitant to share the tst file was because I had framed the scenario/question in simplistic way than what actually the real tst file is doing.
Anyways I've attached the sample tst file and the excel sheet which its using in the Data source .
Also in my tst file, I am trying to assert on 'statusCode' element(referred to Status in the earlier contexts) for different values of 'ExpectedIPList' column(maps to 'name' element in the response) .Also I have Status column as suggested by you which has 'true' value.
Just to make it clear In my Data sheet my row#1 has 'ExpectedStatus' column value as '123' and in the response its coming back as 'PEND' as below but still it passes:
Response looks like as below:
{"clientTypeCode":"IP","statusCode":"PEND","statusName":"Pending Approval","id":0,"name":"Auto_OZ_IP"}.
For row#2, 'ExpectedStatus' column value as '' value and in the response 'statusCode' is coming back as '' as below and response looks like as below:
{"clientTypeCode":"IP","statusCode":"","statusName":"","id":241,"name":"Auto_CES_IP","displayName":"Auto_CES_IP","description":"Auto_CES_IP","typeCode":"PRED","typeName":"Predictive"}
Hope this helps to understand my problem better.

Sorry about the multiple posts with the same thing . I was getting approval messages when I was submitting my initial post and submitted multiple times without knowing it did submit multiple times. Please excuse me

Hi Testuser,
I have attached slightly changed tst.
I have changed xpath used to extract values from response.
It works in my environment as I'm using column requestUrl to iterate over your datasource.
I think that we have misunderstanding in this case as I think you expecting to use assertion with parametrization for any request ( let's say without order).
In my example I expecting that when I execute test I will get two requests with response order like this:
1.Response {"clientTypeCode":"IP","statusCode":"PEND","statusName":"Pending Approval","id":0,"name":"Auto_OZ_IP"}
2.Response{"clientTypeCode":"IP","statusCode":"","statusName":"","id":241,"name":"Auto_CES_IP","displayName":"Auto_CES_IP","description":"Auto_CES_IP","typeCode":"PRED","typeName":"Predictive"}

So the only change you did in your attached zip file was to change the xpath query. I followed the same and did that change to remove parameterization from my Xpath (like you did ) and then ran and still it passed instead of failing for ExpectedStatus value as '123'. Also I anyways have to use parameterization to assert for the statusCode for a particular ExpectedIPList column value. I am not sure where am going wrong.

In Traffic Viewer you should have a response from server with JSON for both request.
Compare that responses with Xpath.
I have examples working. If you have valid service contract ask for help on [email protected]