I'm writing integration test for my DAO services. I perform that by using dao insert methods and then reading objects from database and asserting all fields with orginal objects.
I want to use assertj-core to make assertions. Especially isEqualToComparingFieldByField .
But there is problem with java.util.Date fields. They return identical getTime() value but aren't equal.
Currently I ignore these fields in isEqualToComparingFieldByField assertion and then comapre with hasSameTimeAs method.
assertThat(object).isEqualToIgnoringGivenFields(other, "time");
assertThat(object.getTime()).hasSameTimeAs(other.getTime());
Is any way to provide custom comparator to isEqualToComparingFieldByField method for given type(in this case java.util.Date) or any other solution to assert two objects field by field avoiding this issue?
Aucun commentaire:
Enregistrer un commentaire