AssertJ contains many assertions methods specific to common types. Both versions will test the same things, but the dedicated one will provide a better error message, simplifying the debugging process.
This rule reports an issue when an assertion can be simplified to a dedicated one.
The array below gives a non-exhaustive list of assertion reported by the rule. Code behaving similarly, or with a negation will also be reported.
| Original | Dedicated |
|---|---|
|
Related to Object |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Related to |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Related to |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Related to |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Related to |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Related to |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Related to |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Related to |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Related to |
|
|
|
|
|
|
|
|
|
|
assertThat(getObject()).isEqualTo(null); // Noncompliant assertThat(getObject()).isNotEqualTo(null); // Noncompliant - not listed above but also supported assertThat(getString().trim()).isEmpty(); assertThat(getFile().canRead()).isTrue(); assertThat(getPath().getParent()).isNull();
assertThat(getObject()).isNull(); assertThat(getObject()).isNotNull(); assertThat(getString()).isBlank(); assertThat(getFile()).canRead(); assertThat(getPath()).hasNoParentRaw();