0
votes

I am trying to find variable value in Array list but error popup displayed.

Groovy code :-

def testCase = messageExchange.modelItem.testCase;
def Created_BookingID = testCase.testSuite.project.getPropertyValue("Created_BookingID");
log.info Created_BookingID


import groovy.json.JsonSlurper
JsonSlurper jsonSlurper = new JsonSlurper()
String jsonString = context.expand('${ListAllRoomBookings#Response}')
Map convertedJSONMap  = jsonSlurper.parseText(jsonString)
def RoomID
//If you have the nodes then fetch the first one only
if(convertedJSONMap."RoomBookings"){

     RoomID = convertedJSONMap."RoomBookings"."BookingData"."BookingID"
     log.info RoomID
}

//Find the created booking in list.
assert Created_BookingID.containsAll(RoomID)

Error :- No signature of method: java.lang.String.containsAll() is applicable for argument types: (java.util.ArrayList) values: [[148281, 148282, 148277]] Possible solutions: contains(java.lang.CharSequence), contains(java.lang.CharSequence), contains(java.lang.String), notifyAll()

Print Values in window :-

Wed Aug 02 17:17:22 IST 2017:INFO:148277
Wed Aug 02 17:17:22 IST 2017:INFO:[148281, 148282, 148277]
1

1 Answers

1
votes
assert Created_BookingID.containsAll(RoomID)

No signature of method: java.lang.String.containsAll()
is applicable for argument types: (java.util.ArrayList) values: [[148281, 148282, 148277]]

you try to call containsAll() method on String object. this means that Created_BookingID vaiable at this point is String.

if you want to check that string Created_BookingID is in array RoomID code will be like this:

assert Created_BookingID in RoomID