Add a way to use Comparator for certain type fields for AbstractObjectAssert.isEqualToComparingOnlyGivenFields();
See original GitHub issueCurrently when calling:
assertThat(actual).isEqualToComparingFieldByField(expected)
There’s no way of using certain Comparators for certain datatype fields. For example, for BigDecimal fields, I’d like set the precision and scale.
Issue Analytics
- State:
- Created 8 years ago
- Comments:17 (12 by maintainers)
Top Results From Across the Web
Add a way to use Comparator for certain type fields ... - GitHub
There's no way of using certain Comparators for certain datatype fields. For example, for BigDecimal fields, I'd like set the precision and ...
Read more >org.assertj.core.api.AbstractObjectAssert ... - Tabnine
Asserts that the actual object is equal to the given one using a property/field by property/field comparison on the given properties/fields only (fields...
Read more >AbstractObjectAssert (AssertJ fluent assertions 3.18.1 API)
Allows to set a specific comparator to compare properties or fields with the given type. RecursiveComparisonAssert<?> usingRecursiveComparison().
Read more >AssertJ - fluent assertions java library - GitHub Pages
AllowComparingPrivateFields. Globally sets whether the use of private fields is allowed for field/property by field/property comparison. Defaults to true.
Read more >How to compare recursively ignoring given fields using assertJ?
With latest 'Recursive comparison api improvements' from AssertJ release 3.12.0 it's possible now to do a recursive comparison and ignore ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@DevDik You can use
isEqualToIgnoringGivenFields
orisEqualToComparingOnlyGivenFields
see: http://joel-costigliola.github.io/assertj/core/api/org/assertj/core/api/AbstractObjectAssert.html#isEqualToIgnoringGivenFields(java.lang.Object, java.lang.String...) http://joel-costigliola.github.io/assertj/core/api/org/assertj/core/api/AbstractObjectAssert.html#isEqualToIgnoringGivenFields(java.lang.Object, java.lang.String...)@DevDik if you would like to compare different objects I would suggest to have a look at https://github.com/mapstruct/mapstruct which can help you map one object to another and then use the same object for assertions with AssertJ