From 52a8daf003f730259fab52c6d9dcc97333818a3b Mon Sep 17 00:00:00 2001 From: Kazuki Shimizu Date: Sat, 21 Apr 2018 11:43:32 +0900 Subject: [PATCH] DATAJDBC-209 - Improve assertion on The QueryAnnotationHsqlIntegrationTests#executeCustomQueryWithReturnTypeIsDate Since Timestamp extends Date the repository returns the Timestamp as it comes from the database. Trying to compare that to an actual Date results in non determistic results, so we have to use an actual Timestamp. Original pull request: #66. --- .../repository/query/QueryAnnotationHsqlIntegrationTests.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/test/java/org/springframework/data/jdbc/repository/query/QueryAnnotationHsqlIntegrationTests.java b/src/test/java/org/springframework/data/jdbc/repository/query/QueryAnnotationHsqlIntegrationTests.java index 5dfd51cad..dc297cb89 100644 --- a/src/test/java/org/springframework/data/jdbc/repository/query/QueryAnnotationHsqlIntegrationTests.java +++ b/src/test/java/org/springframework/data/jdbc/repository/query/QueryAnnotationHsqlIntegrationTests.java @@ -17,6 +17,7 @@ package org.springframework.data.jdbc.repository.query; import static org.assertj.core.api.Assertions.*; +import java.sql.Timestamp; import java.time.LocalDateTime; import java.util.Date; import java.util.List; @@ -195,7 +196,7 @@ public class QueryAnnotationHsqlIntegrationTests { @Test // DATAJDBC-175 public void executeCustomQueryWithReturnTypeIsDate() { - Date now = new Date(); + Date now = new Timestamp(System.currentTimeMillis()); assertThat(repository.nowWithDate()).isAfterOrEqualsTo(now); }