error-prone-support icon indicating copy to clipboard operation
error-prone-support copied to clipboard

AssertJ Refaster rules for `Iterator#hasNext()`

Open knutwannheden opened this issue 3 months ago • 2 comments

Running the JUnitToAssertJRules across some code I noticed that AssertThatIsTrue and AssertThatIsFalse transformed some JUnit assertTrue() and assertFalse() calls:

image

It seems like it would be a nice addition to have specific rules calling AbstractIteratorAssert#hasNext() and AbstractIteratorAssert#isExhausted() instead.

The example was found in hibernate/hibernate-tools: https://github.com/hibernate/hibernate-tools/blob/10431fc27866d295be9d2062ffdc9b1cd9099c16/jbt/src/test/java/org/hibernate/tool/orm/jbt/util/NativeConfigurationTest.java#L242-L247

knutwannheden avatar Mar 14 '24 09:03 knutwannheden

I suppose there would be a lot more interesting rules of this type that could be added. String#contains(CharSequence) comes to mind.

knutwannheden avatar Mar 14 '24 15:03 knutwannheden

Adding these type of rules to AssertJRules probably makes more sense.

knutwannheden avatar Mar 14 '24 15:03 knutwannheden