Why is this an issue?
AssertJ assertions taking
Consumer objects as arguments are expected to contain "requirements", which should themselves be expressed
as assertions. This concerns the following methods: allSatisfy,
hasOnlyOneElementSatisfying, isInstanceOfSatisfying, noneSatisfy,
These methods are assuming the
Consumer will do the assertions itself. If you do not do any assertion in the
Consumer, it probably means that you are inadvertently only partially testing your object.
This rule raises an issue when a
Consumer argument of any of the above methods does not contain any assertion.
Noncompliant code example
assertThat(myObject).isInstanceOfSatisfying(String.class, s -> "Hello".equals(s)); // Noncompliant - not testing the string value
assertThat(myObject).satisfies("Hello"::equals); // Noncompliant - not testing the string value
assertThat(myObject).isInstanceOfSatisfying(String.class, s -> assertThat(s).isEqualTo("Hello"));
assertThat(myObject).satisfies(obj -> assertThat(obj).isEqualTo("Hello"));