Search in sources :

Example 1 with Year

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

the class YearSerdeTest method testDateDeserialize.

@Test
public void testDateDeserialize() {
    LocalDateTime localDate = LocalDateTime.of(2020, java.time.Month.of(01), 01, 00, 00, 00);
    Year expectedDate = new Year(localDate);
    Serde serde = new Year.YearSerde();
    Object actualDate = serde.deserialize("2020");
    assertEquals(expectedDate, actualDate);
}
Also used : LocalDateTime(java.time.LocalDateTime) Serde(com.yahoo.elide.core.utils.coerce.converters.Serde) Year(com.yahoo.elide.datastores.aggregation.timegrains.Year) Test(org.junit.jupiter.api.Test)

Example 2 with Year

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

the class YearSerdeTest method testDeserializeTimestamp.

@Test
public void testDeserializeTimestamp() {
    LocalDateTime localDate = LocalDateTime.of(2020, java.time.Month.of(01), 01, 00, 00, 00);
    Year expectedDate = new Year(localDate);
    Timestamp timestamp = new Timestamp(expectedDate.getTime());
    Serde serde = new Year.YearSerde();
    Object actualDate = serde.deserialize(timestamp);
    assertEquals(expectedDate, actualDate);
}
Also used : LocalDateTime(java.time.LocalDateTime) Serde(com.yahoo.elide.core.utils.coerce.converters.Serde) Year(com.yahoo.elide.datastores.aggregation.timegrains.Year) Timestamp(java.sql.Timestamp) Test(org.junit.jupiter.api.Test)

Example 3 with Year

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

the class YearSerdeTest method testDateSerialize.

@Test
public void testDateSerialize() {
    LocalDateTime localDate = LocalDateTime.of(2020, java.time.Month.of(01), 01, 00, 00, 00);
    Year expectedDate = new Year(localDate);
    Serde serde = new Year.YearSerde();
    Object actual = serde.serialize(expectedDate);
    assertEquals("2020", actual);
}
Also used : LocalDateTime(java.time.LocalDateTime) Serde(com.yahoo.elide.core.utils.coerce.converters.Serde) Year(com.yahoo.elide.datastores.aggregation.timegrains.Year) Test(org.junit.jupiter.api.Test)

Example 4 with Year

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

the class YearSerdeTest method testDeserializeOffsetDateTime.

@Test
public void testDeserializeOffsetDateTime() {
    LocalDateTime localDate = LocalDateTime.of(2020, java.time.Month.of(01), 01, 00, 00, 00);
    Year expectedDate = new Year(localDate);
    OffsetDateTime dateTime = OffsetDateTime.of(2020, 1, 1, 0, 0, 0, 0, ZoneOffset.UTC);
    Serde serde = new Year.YearSerde();
    Object actualDate = serde.deserialize(dateTime);
    assertEquals(expectedDate, actualDate);
}
Also used : LocalDateTime(java.time.LocalDateTime) Serde(com.yahoo.elide.core.utils.coerce.converters.Serde) Year(com.yahoo.elide.datastores.aggregation.timegrains.Year) OffsetDateTime(java.time.OffsetDateTime) Test(org.junit.jupiter.api.Test)

Aggregations

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