I want to compare if a list is a sublist of another list
Assume I have the following lists
List<String> checkList = Arrays.asList("a", "d");
List<String> actualList = Arrays.asList("a", "b", "c", "d");
I want to check if actualList contains checkList . I can iterate each value and compare. But is there any hamcrest matcher that will do the job
For ex.
a,d should pass
a,b,c should pass
But a,e should fail
the hasItems supports the strings to be passed individually, and contains is checking for all the values, in supports an item to be present in a list. But I wanted
assertThat(actualList,containsList(checkList))
Is there any inbuilt matcher available or do I need to write custom matcher?