I have a List<List<String>>
with sample data like:
("T1#R1", "T1#R1", "T1#R3", "T1#R4")
("T1#R1", "T1#R1", "T1#R3", "T1#R5")
("T1#R1", "T1#R1", "T1#R6", "T1#R4")
("T1#R1", "T1#R1", "T1#R6", "T1#R5")
And I need to assert, that a List<String>
is present in the above sample, but without taking order into consideration.
For example, the following list ("T1#R1", "T1#R1", "T1#R4", "T1#R3")
should be considered as present in the List<List<String>>
, as it would contain the same items as the 1st list, but in different order.
On the other hand, ("T1#R1", "T1#R3", "T1#R4", "T1#R3")
shouldn't be considered as present in the list, as it has the same items, but with a different count.
I know I could do this programmatically, but was wandering if there could be a Matcher
for example that could help.
I've seen assertions like:
assertThat(myList, containsInAnyOrder(anotherList.toArray())
But that would just compare one list with another, and not a list inside a List of Lists.
PS: I'm using Java6, hamcrest-core-1.3, testng-5.14.1