Related to How to compare recursively ignoring given fields using assertJ?
As a work around the problem, I tried to rig the comparator for the field which I don't want the comparator to compare and made it return 0.
assertThat(service.postComment(12,234,comment)).usingComparatorForFields((a,b)->0,"startDate").isEqualToComparingFieldByFieldRecursively(commentReturned);
But, still I get this exception.
Path to difference: <startDate>
- expected: <null>
- actual : <2017-04-12 18:28:06.766>
As a sidenote - I don't want to compare startDate because it retrieves current date using legacy java.util.Date
which compares milli seconds too.
How does it usingComparatorForFields
work. I even tried it using isEqualToComparingFieldByField
instead of isEqualToComparingFieldByFieldRecursively
and the error persists (in the same case. This one fails for cases where recursive comparison is required.)