How to iterate over Collection of LinkedHashMap

Viewed 46

I have something like

Collection<LinkedHashMap<String,Object>> responseObjects = (Collection<LinkedHashMap<String, Object>>) response.getResponseObjects();

I am writing some unit tests where I am getting 2 elements in this collection and want to put assertions on each element Collection having a map of <String,Object>. Both elements have different sets of values in LinkedHashMap.

I tried using For-Each

for(Map<String,Object> response : responseObjects) {
     assertEquals("Test", responseObj.get("stringField"));
}

But how do I control the index from this, since I need to put assertion on different data coming in.

0 Answers
Related