Made test stable against rounding errors.
@@ -210,9 +210,11 @@ public class QueryAnnotationHsqlIntegrationTests {
@Test // DATAJDBC-175
public void executeCustomQueryWithReturnTypeIsLocalDateTimeList() {
- LocalDateTime now = LocalDateTime.now();
+ LocalDateTime preciseNow = LocalDateTime.now();
+ LocalDateTime truncatedNow = truncateSubmillis(preciseNow);
+
repository.nowWithLocalDateTimeList() //
- .forEach(d -> assertThat(d).isAfterOrEqualTo(now));
+ .forEach(d -> assertThat(d).isAfterOrEqualTo(truncatedNow));
}
@@ -259,6 +261,12 @@ public class QueryAnnotationHsqlIntegrationTests {
assertThat(repository.immutableTuple()).isEqualTo(new DummyEntityRepository.ImmutableTuple("one", "two", 3));
}
+ private static LocalDateTime truncateSubmillis(LocalDateTime now) {
+
+ int NANOS_IN_MILLIS = 1_000_000;
+ return now.withNano((now.getNano() / NANOS_IN_MILLIS) * 1_000_000);
+ }
+
private DummyEntity dummyEntity(String name) {
DummyEntity entity = new DummyEntity();
