Cover commented AssertJ tests: array length, Comparable & BigDecimal compareTo#1039
Merged
Conversation
Un-comments the disabled cases in AssertJBestPracticesTest and closes the
coverage gaps they represented:
- Comparable relational operators (>, >=, <, <=) were already handled by
AssertJPrimitiveRules; the cases were only disabled because the test
template emitted an invalid `import int;` for primitive types. Fix the
template to skip imports for primitives and strip array brackets.
- Add a SimplifyChainedAssertJAssertion entry mapping BigDecimal
`compareTo(y).isZero()` to `isEqualByComparingTo(y)`.
- Add SimplifyArrayLengthAssertion to convert `assertThat(array.length)`
size assertions to dedicated array assertions (isEmpty, hasSize,
hasSameSizeAs, hasSize{Less,Greater}Than[OrEqualTo]), for both object
and primitive arrays. Ordered before AssertJNumberRules to avoid the
`isGreaterThanOrEqualTo(1)` -> `isPositive()` collision.
…-tests-coverage # Conflicts: # src/main/resources/META-INF/rewrite/recipes.csv
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Un-comments the disabled cases in
AssertJBestPracticesTestand closes the coverage gaps they represented. The Comparable relational operators (>,>=,<,<=) were already handled byAssertJPrimitiveRulesand were only disabled because the parameterized test template emitted an invalidimport int;for primitive types, which this fixes. A newSimplifyArrayLengthAssertionrecipe convertsassertThat(array.length)size assertions to dedicated array assertions (isEmpty,hasSize,hasSameSizeAs,hasSize{Less,Greater}Than[OrEqualTo]) for both object and primitive arrays, ordered beforeAssertJNumberRulesto avoid theisGreaterThanOrEqualTo(1)→isPositive()collision. A declarativeSimplifyChainedAssertJAssertionentry also maps BigDecimalcompareTo(y).isZero()toisEqualByComparingTo(y).