Search in sources :

Example 1 with Second

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

the class SecondSerdeTest method testDeserializeTimestamp.

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

Example 2 with Second

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

the class SecondSerdeTest method testDateSerialize.

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

Example 3 with Second

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

the class SecondSerdeTest method testDateDeserializeString.

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

Example 4 with Second

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

the class SecondSerdeTest method testDeserializeOffsetDateTime.

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

Aggregations

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