Skip to content

Commit

Permalink
Fix Timestamp areEqual with LocalDate
Browse files Browse the repository at this point in the history
  • Loading branch information
VanRoy committed Jul 8, 2020
1 parent e918c11 commit 31752ec
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/main/java/org/assertj/db/util/Values.java
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,8 @@ else if (valueType == ValueType.DATE_TIME) {
return areEqual(value, DateTimeValue.from((Timestamp) expected));
} else if (expected instanceof LocalDateTime) {
return areEqual(value, DateTimeValue.from((LocalDateTime) expected));
} else if (expected instanceof LocalDate) {
return areEqual(value, DateValue.from((LocalDate) expected));
}
}
else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -268,8 +268,12 @@ public void test_are_equal_for_dates() throws Exception {
public void test_are_equal_for_timestamp_and_dates() throws Exception {
assertThat(Values.areEqual(getValue(null, Timestamp.valueOf("2007-12-23 00:00:00.000000000")), (Object) DateValue.of(2007, 12, 23)))
.isTrue();
assertThat(Values.areEqual(getValue(null, Timestamp.valueOf("2007-12-23 00:00:00.000000000")), LocalDate.of(2007, 12, 23)))
.isTrue();
assertThat(Values.areEqual(getValue(null, Timestamp.valueOf("2007-12-23 00:00:00.000000000")), (Object) DateValue.of(2007, 1, 2)))
.isFalse();
assertThat(Values.areEqual(getValue(null, Timestamp.valueOf("2007-12-23 00:00:00.000000000")), LocalDate.of(2007, 1, 2)))
.isFalse();
assertThat(Values.areEqual(getValue(null, ""), (Object) DateValue.of(2007, 12, 23))).isFalse();
assertThat(Values.areEqual(getValue(null, Timestamp.valueOf("2007-12-23 00:00:00.000000000")), (Object) null)).isFalse();

Expand Down

0 comments on commit 31752ec

Please sign in to comment.