I have an actual list of strings generated in my integration test and an expected list of substrings. It is trivial to assert that the collections are equal, e.g.:
assertThat(actual).containsExactly(expected);
In my case it is a bit more difficult though, because I would effectively like to have a containsExactlySubstring()
function -- that is I would like to assert that there is a one-to-one correspondence between the actual strings and expected substrings. Is there a neat (descriptive) way to implement it out of the box?
EXAMPLES:
expected = {"abc", "def", "ghi"}
actualPass = {"#abc", "#ghi", "#def"}
actualFail1 = {"abc", "def"}
actualFail2 = {"#abc", "#ghi", "#abc"}
actualFail3 = {"#abc", "#ghi", "#xyz"}