cancel
Showing results for 
Search instead for 
Did you mean: 

Assertion for delete responses.

ilovechiku
Contributor

Assertion for delete responses.

I have a delete request which doesnt return anything in reponse. Sucessful deletion gives me a 204 status code and deletes the row from the table. 

 I would like to assert from the response that on successfully deletion i dont see the row in the table.

 

my request looks like this:

{
"CompanyId":"1",
"RoleName":"CopyofHr",
"ActionTakenBy":3144
}

 

In a groovy step i get these  3 values from the Database.which i have parameterized to get  top 1 values from DB.  All these three fields are coming from table called roles. On deletion a row is deleted from role.

How can i do a assertion that the row is actually deleted.

 

 

 

please help.

 

12 REPLIES 12
nmrao
Community Hero

Re: Assertion for delete responses.

Not sure I completely understand the question.

1. Do you want to assert on the delete request i.e., based on response code?
2. Do you want to assert using jdbc result?
3. Like to do both?

Please clarify.


Regards,
Rao.
ilovechiku
Contributor

Re: Assertion for delete responses.

 

Yes I would like to -. Do you want to assert on the delete request i.e., based on response code? 

 

 

Also would like to know  if this is possible in PRO version

Can you use property transfer for assertions as well? I want to assert on a delete testcase. the delete reponse is empty. However,on successful deletion the row is deleted from the table. I have captured the primary key of the deleted row in a scripted Groovy step (star step )above the testcase. How can i transfer this property (primary key of row that was deleted) to reponse?

 

nmrao
Community Hero

Re: Assertion for delete responses.

May be you can go one by one.
Let us deal with first question, can you post the raw response?
Do you have license for PRO or just evaluating?



Regards,
Rao.
ilovechiku
Contributor

Re: Assertion for delete responses.

raw response looks like this are you sure you asked for reponse or raw request. Becuase the reponse is empty.

I have a trial version of readyAPI 1.6.0

 

 

 

HTTP/1.1 204 No Content
Content-Length: 0
Server: Microsoft-IIS/8.5
X-Powered-By: ASP.NET
Date: Tue, 08 Mar 2016 18:07:05 GMT

nmrao
Community Hero

Re: Assertion for delete responses.

I have requested you for raw response.


Regards,
Rao.
nmrao
Community Hero

Re: Assertion for delete responses.

And 204 the expected code?


Regards,
Rao.
ilovechiku
Contributor

Re: Assertion for delete responses.

Yes 204 is reponse with no content which satisfies buisness case. 

in a groovy step before the testcase i have captured the primarykeyid of the row that got deleted by the teststep like below

 

testRunner.testCase.setPropertyValue("RrdId",getDeleteResourceRoleDefinitionIdFromDB(db)) . However this is in a Groovy Step(star step). I need this property become available in the assertion of the testcase. 

nmrao
Community Hero

Re: Assertion for delete responses.

Here is the script assertion for the Delete request step.

 

/**
 * let us assume that there is a custom level test case property defined
 * EXPECTED_HTTP_STATUS_CODE, with value "HTTP/1.1 204 No Content"
 */
def actualHttpStatusCode = messageExchange.responseHeaders['#status#'][0]
def expectedHttpStatusCode = context.testCase.getPropertyValue('EXPECTED_HTTP_STATUS_CODE')
assert expectedHttpStatusCode == actualHttpStatusCode, "HTTP status code is not matching"


Regards,
Rao.
ilovechiku
Contributor

Re: Assertion for delete responses.

I want to assert that row is deleted in DB. Not based on Status. Status is good 

New Here?
Join us and watch the welcome video:
Announcements
Top Kudoed Authors