You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Output:
Exception in thread "main" java.lang.AssertionError: Expecting:
<model.Person@7dc5e7b4>
to be equal to:
<model.Person@1ee0005>
when recursively comparing field by field, but found the following difference(s):
Path to difference: <dateOfBirth>
- expected: <1970-01-01 05:30:00.003>
- actual : <null>
at api.ProblemReproduce.main(ProblemReproduce.java:16)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:147)
The text was updated successfully, but these errors were encountered:
Yeah, field by field comparison is too strict about how it selects the comparator to use, if one of the field is null it wrongly bypasses any registered comparators.
It also expects both fields to have the same type which is also too strict.
Summary
While using AbstractObjectAssert's usingComparatorForFields(comparator,"field") when one of the field is null then the comparator isn't used.
Example
The text was updated successfully, but these errors were encountered: