Search in sources :

Example 1 with Week

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

the class WeekSerdeTest method testDeserializeTimestamp.

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

Example 2 with Week

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

the class WeekSerdeTest method testDateSerialize.

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

Example 3 with Week

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

the class WeekSerdeTest method testDateDeserializeString.

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

Example 4 with Week

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

the class WeekSerdeTest method testDeserializeTimestampNotSunday.

@Test
public void testDeserializeTimestampNotSunday() {
    LocalDateTime localDate = LocalDateTime.of(2020, java.time.Month.of(01), 06, 00, 00, 00);
    Week expectedDate = new Week(localDate);
    Serde serde = new Week.WeekSerde();
    assertThrows(IllegalArgumentException.class, () -> serde.deserialize(expectedDate));
}
Also used : LocalDateTime(java.time.LocalDateTime) Serde(com.yahoo.elide.core.utils.coerce.converters.Serde) Week(com.yahoo.elide.datastores.aggregation.timegrains.Week) Test(org.junit.jupiter.api.Test)

Example 5 with Week

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

the class WeekSerdeTest method testDeserializeOffsetDateTime.

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

Aggregations

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