last day (15 days later) » 

8:08 AM
1
A: While statement in web service requests

Mate MršeYou need to use JsonSlurper with the bodyContent: import groovy.json.JsonSlurper JsonSlurper slurper = new JsonSlurper() Map parsedJson = slurper.parseText(bodyContent) and then try getting the statement_id: String statement_id = parsedJson.statement_id

 
everything works now, but for comparison I need to store the old statementId and compare to the new one, if they are different. I've tried some things with jsonslurper but now what I did, every statementId is now the same :D
 
Add this line: def statement_ids = [] before the while loop and statement_ids << statement_id after the line where you get the statement_id. And now you have a list of statement ids that you can compare.
You can then compare for example statement_ids[0] and statement_ids[1]
 
I should compare it in loop, yes ?
 
Well, it depends on what do you want to do. If you want to verify every id is different, you can add this line to the end of the loop (before incrementing accountId): WebUI.verifyNotEqual(statement_ids[GlobalVariable.accountId]‌​, statement_id)
 
will that work correctly ? if(statement_ids[0] == statement_ids[1]) { log.LogWarning('Error: Errrrrrrrrrrrrrrrrrror') } else{ GlobalVariable.accountId++ }
 
8:09 AM
I moved this to chat
This will work for the first iteration but you need to make it more general
 
yes, I checked it and it works for only 2-3 steps
When I added this WS.verifyNotEqual(statement_ids[GlobalVariable.accountId], statement_id) it says in log viewer that : Actual object 'null' and expected object '0bf33ec6-8baf-4995-b072-674725242625' are not equal
 
but does it pass or fail?
 
I think there should not be GlobalVariable.accountId inside statement_ids
it did pass
but everytime it is null
 
Try using something else as a counter
What is the default value of GlobalVariable.accountId?
 
I use accountId in the reqeust and then it gives me statementId for the accountId
1
testapi/v1/statement${accountId}?startDate=2018-12-01&endDate=2018-12-31‌​&inEquivalent=false
This is the request link
{
  "statementId":"25358c95-ecad-4471-be19-cc7c6ccd8efc",
  "accountId":123,
  "accountIban":"123456",
  "ccy":"One",
  "startDate":"2018-12-10",
  "endDate":"2019-01-09",
  "startBalance":100.0,
  "endBalance":1000.0,
  "startPointer":"0094230492304923090Anffjle39440583490434rieklfrlfkjedtu8er9t7548684568t9fkgmndflkgr5908yt546"
}
and this is a response
and I should test if for the 100 Ids ir more the statementIds are not the same
 
8:17 AM
Could you just use something else as the counter?
for example
def i = GlobalVariable.accountId
and then replace "GlobalVariable.accountId" with "i" everywhere int the loop
 
Okay, I made so
Its default value is 1
but it doesnt work WS.verifyNotEqual(statement_ids[i], statement_id)
It doesn't stores the old object for comparing
 
WebUI.verifyNotEqual(statement_ids[i-1], statement_id)
How about this?
Oh
It won't work for the first iteration
because statement_ids[] is empty
so you should skip this part and only do it if (i>0)
you should skip this part and only do it if (i>1)
 
8:57 AM
Yes, it works now ! Thanks a lot !
 

last day (15 days later) »