0

I have a expected List of Strings:

List<String> expected = Arrays.asList("a", "b");

I want these assertions be evaluated with these results:

{"a", "a", "b", "b"} -> true
{"a", "b", "c"} -> false

Essentially, I want assertJ to ignore/remove any duplicates that is being evaluated. How can I do this with the Assertions API?

George
  • 2,820
  • 4
  • 29
  • 56

1 Answers1

1

Try containsOnly, to quote the javadoc:

Verifies that the actual group contains only the given values and nothing else, in any order and ignoring duplicates (i.e. once a value is found, its duplicates are also considered found).

Joel Costigliola
  • 6,308
  • 27
  • 35
  • 1
    According to the doc, the iterable version of this method is what I need: `containsOnlyElementsOf`. – George Mar 30 '19 at 03:02