With Assertj, I can use anyMatch
to test if a collection has at least one element matching a predicate, e.g.
var list = List.of("abc", "xyz")
assertThat(list).anyMatch(element -> element.endsWith("xyz"));
But how do I test if a collection has exactly one element that matches a predicate?