0

I'm looking for an alternative of the deprecated method containsOnlyElementsOf.

It has to check whether the given iterable (a list of Integers in my case) contains only Integers in-between given bounds.

I've tried looking at the docs but didn't find any...

IDK
  • 359
  • 1
  • 16

1 Answers1

2

I think this is what you are looking for. The name of the method is indeed confusing. The substitute depends on what you want - you either should use isSubsetOf, or containsOnly. Check out the documentation of both, and pick the one you need)

Mikhail2048
  • 1,715
  • 1
  • 9
  • 26
  • In the end I opted for iterating over my list of integer and using ```isIn``` on each of the elements. – IDK Oct 03 '22 at 17:39
  • https://www.javadoc.io/doc/org.assertj/assertj-core/latest/org/assertj/core/api/AbstractIterableAssert.html#containsOnlyElementsOf(java.lang.Iterable) suggests alternatives: use ObjectEnumerableAssert.isSubsetOf(Iterable) to check that actual is a subset of given iterable, or if you need to same assertion semantics use ObjectEnumerableAssert.hasSameElementsAs(Iterable). – Joel Costigliola Oct 04 '22 at 09:37