I am using AssertJ extracting()
method with Java8 lambdas and mapping some fields to BigDecimal, then asserting the resulting array. But I need to compare BigDecimal using compareTo()
and not with equals()
(because of this). How can I do that?
Example:
Actual actual = performTest();
Assertions.assertThat(actual)
.extracting(
Actual::getName, // returns String
Actual::getValue // returns BigDecimal
)
.containsExactly(
"abc", // ok, String equals comparison
new BigDecimal("1.1") // NOT OK, equals comparison, but I need compareTo comparison
);
Edit: I am looking for a fluent way to do this, because of course I can split this into multiple different Asserts and compare it that way, or put everything in one giant Condition
.