This is an automated email from the ASF dual-hosted git repository.
ipavlukhin pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ignite.git
The following commit(s) were added to refs/heads/master by this push:
new dd6abfa IGNITE-12004 Check nanos precision in all tests, test UPDATE
with millis precision, ignore UPDATE test with nanos precision - Fixes #6719.
dd6abfa is described below
commit dd6abfade3c51d50acdbb7f5dcb94c217f87d1a4
Author: ipavlukhin <[email protected]>
AuthorDate: Fri Jul 26 17:42:44 2019 +0300
IGNITE-12004 Check nanos precision in all tests, test UPDATE with millis
precision, ignore UPDATE test with nanos precision - Fixes #6719.
Signed-off-by: ipavlukhin <[email protected]>
---
.../CacheQueryEntityWithDateTimeApiFieldsTest.java | 56 +++++++++++++++++++++-
1 file changed, 54 insertions(+), 2 deletions(-)
diff --git
a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/CacheQueryEntityWithDateTimeApiFieldsTest.java
b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/CacheQueryEntityWithDateTimeApiFieldsTest.java
index f1281bf..3aeef87 100644
---
a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/CacheQueryEntityWithDateTimeApiFieldsTest.java
+++
b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/CacheQueryEntityWithDateTimeApiFieldsTest.java
@@ -35,8 +35,11 @@ import org.apache.ignite.cache.query.SqlFieldsQuery;
import org.apache.ignite.cache.query.annotations.QuerySqlField;
import org.apache.ignite.configuration.CacheConfiguration;
import
org.apache.ignite.internal.processors.cache.index.AbstractIndexingCommonTest;
+import org.junit.Ignore;
import org.junit.Test;
+import static java.time.temporal.ChronoUnit.MILLIS;
+
/**
* Tests queries against entities with Java 8 Date and Time API fields.
*/
@@ -49,13 +52,13 @@ public class CacheQueryEntityWithDateTimeApiFieldsTest
extends AbstractIndexingC
private static final long DAYS_BEFORE_NOW = 10;
/** {@link LocalTime} instance. */
- private static final LocalTime SAMPLE_TIME =
LocalTime.now().minusHours(10);
+ private static final LocalTime SAMPLE_TIME =
LocalTime.now().minusHours(10).withNano(1);
/** {@link LocalDate} instance. */
private static final LocalDate SAMPLE_DATE =
LocalDate.now().minusDays(DAYS_BEFORE_NOW);
/** {@link LocalDateTime} instance. */
- private static final LocalDateTime SAMPLE_DATE_TIME =
LocalDateTime.of(SAMPLE_DATE, LocalTime.MIDNIGHT);
+ private static final LocalDateTime SAMPLE_DATE_TIME =
LocalDateTime.of(SAMPLE_DATE, LocalTime.MIDNIGHT.withNano(1));
/** Cache. */
private IgniteCache<Long, EntityWithDateTimeFields> cache;
@@ -132,6 +135,29 @@ public class CacheQueryEntityWithDateTimeApiFieldsTest
extends AbstractIndexingC
}
/**
+ * Tests MERGE statement.
+ *
+ * @throws Exception If failed.
+ */
+ @Test
+ public void testMergeEntityFields() throws Exception {
+ assertEquals(1, cache.size());
+
+ SqlFieldsQuery qry = new SqlFieldsQuery(
+ "merge into EntityWithDateTimeFields(_key, id, locTime, locDate,
locDateTime) values(?, ?, ?, ?, ?)"
+ ).setArgs(
+ entity.getId(), entity.getId(), entity.getLocalTime(),
entity.getLocalDate(), entity.getLocalDateTime()
+ );
+
+ List<List<?>> qryResults = cache.query(qry).getAll();
+
+ assertEquals(1, qryResults.size());
+ assertEquals(1L, qryResults.get(0).get(0));
+ assertEquals(1, cache.size());
+ assertEquals(entity, cache.get(entity.getId()));
+ }
+
+ /**
* Tests that DATEDIFF SQL function works for {@link LocalDateTime}
* fields with the time part set to midnight.
*
@@ -212,6 +238,7 @@ public class CacheQueryEntityWithDateTimeApiFieldsTest
extends AbstractIndexingC
* Tests updating of all Date and Time fields.
*/
@Test
+ @Ignore("https://issues.apache.org/jira/browse/IGNITE-12009")
public void testUpdateAllFields() {
EntityWithDateTimeFields expEntity = new
EntityWithDateTimeFields(entity);
@@ -231,6 +258,31 @@ public class CacheQueryEntityWithDateTimeApiFieldsTest
extends AbstractIndexingC
}
/**
+ * Tests updating of all Date and Time fields.
+ * <p>
+ * Trim precision of {@link LocalDateTime} to milliseconds.
+ * Nanosecond precision test -- {@link #testUpdateAllFields}.
+ */
+ @Test
+ public void testUpdateAllFieldsMillisTimePrecision() {
+ EntityWithDateTimeFields expEntity = new
EntityWithDateTimeFields(entity);
+
+
expEntity.setLocalTime(expEntity.getLocalTime().plusHours(1).withNano(0).plus(123,
MILLIS));
+ expEntity.setLocalDate(expEntity.getLocalDate().plusDays(1));
+ expEntity.setLocalDateTime(LocalDateTime.of(expEntity.getLocalDate(),
expEntity.getLocalTime()));
+
+ SqlFieldsQuery qry = new SqlFieldsQuery(
+ "update EntityWithDateTimeFields set locTime = ?, locDate = ?,
locDateTime = ? where id = ?"
+ ).setArgs(expEntity.getLocalTime(), expEntity.getLocalDate(),
expEntity.getLocalDateTime(), entity.getId());
+
+ List<List<?>> qryResults = cache.query(qry).getAll();
+
+ assertEquals(1, qryResults.size());
+ assertEquals(1L, qryResults.get(0).get(0));
+ assertEquals(expEntity, cache.get(expEntity.getId()));
+ }
+
+ /**
* Tests deleting by all Date and Time fields.
*/
@Test