Search in sources :

Example 1 with Minute

use of com.yahoo.elide.datastores.aggregation.timegrains.Minute in project elide by yahoo.

the class MinuteSerdeTest method testDeserializeTimestamp.

@Test
public void testDeserializeTimestamp() {
    String dateInString = "2020-01-01T01:18";
    Minute expectedDate = new Minute(LocalDateTime.from(formatter.parse(dateInString)));
    Timestamp timestamp = new Timestamp(expectedDate.getTime());
    Serde serde = new Minute.MinuteSerde();
    Object actualDate = serde.deserialize(timestamp);
    assertEquals(expectedDate, actualDate);
}
Also used : Serde(com.yahoo.elide.core.utils.coerce.converters.Serde) Minute(com.yahoo.elide.datastores.aggregation.timegrains.Minute) Timestamp(java.sql.Timestamp) Test(org.junit.jupiter.api.Test)

Example 2 with Minute

use of com.yahoo.elide.datastores.aggregation.timegrains.Minute in project elide by yahoo.

the class MinuteSerdeTest method testDateDeserializeString.

@Test
public void testDateDeserializeString() {
    String dateInString = "2020-01-01T01:18";
    Minute expectedDate = new Minute(LocalDateTime.from(formatter.parse(dateInString)));
    String actual = "2020-01-01T01:18";
    Serde serde = new Minute.MinuteSerde();
    Object actualDate = serde.deserialize(actual);
    assertEquals(expectedDate, actualDate);
}
Also used : Serde(com.yahoo.elide.core.utils.coerce.converters.Serde) Minute(com.yahoo.elide.datastores.aggregation.timegrains.Minute) Test(org.junit.jupiter.api.Test)

Example 3 with Minute

use of com.yahoo.elide.datastores.aggregation.timegrains.Minute in project elide by yahoo.

the class MinuteSerdeTest method testDeserializeOffsetDateTime.

@Test
public void testDeserializeOffsetDateTime() {
    String dateInString = "2020-01-01T01:18";
    Minute expectedDate = new Minute(LocalDateTime.from(formatter.parse(dateInString)));
    OffsetDateTime dateTime = OffsetDateTime.of(2020, 01, 01, 01, 18, 0, 0, ZoneOffset.UTC);
    Serde serde = new Minute.MinuteSerde();
    Object actualDate = serde.deserialize(dateTime);
    assertEquals(expectedDate, actualDate);
}
Also used : Serde(com.yahoo.elide.core.utils.coerce.converters.Serde) Minute(com.yahoo.elide.datastores.aggregation.timegrains.Minute) OffsetDateTime(java.time.OffsetDateTime) Test(org.junit.jupiter.api.Test)

Example 4 with Minute

use of com.yahoo.elide.datastores.aggregation.timegrains.Minute in project elide by yahoo.

the class MinuteSerdeTest method testDateSerialize.

@Test
public void testDateSerialize() {
    String expected = "2020-01-01T01:18";
    Minute expectedDate = new Minute(LocalDateTime.from(formatter.parse(expected)));
    Serde serde = new Minute.MinuteSerde();
    Object actual = serde.serialize(expectedDate);
    assertEquals(expected, actual);
}
Also used : Serde(com.yahoo.elide.core.utils.coerce.converters.Serde) Minute(com.yahoo.elide.datastores.aggregation.timegrains.Minute) Test(org.junit.jupiter.api.Test)

Aggregations

Serde (com.yahoo.elide.core.utils.coerce.converters.Serde)4 Minute (com.yahoo.elide.datastores.aggregation.timegrains.Minute)4 Test (org.junit.jupiter.api.Test)4 Timestamp (java.sql.Timestamp)1 OffsetDateTime (java.time.OffsetDateTime)1