Search in sources :

Example 1 with Quarter

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

the class QuarterSerdeTest method testDeserializeTimestampNotQuarterMonth.

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

Example 2 with Quarter

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

the class QuarterSerdeTest method testDateDeserialize.

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

Example 3 with Quarter

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

the class QuarterSerdeTest method testDeserializeOffsetDateTime.

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

Example 4 with Quarter

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

the class QuarterSerdeTest method testDeserializeTimestamp.

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

Example 5 with Quarter

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

the class QuarterSerdeTest method testDateSerialize.

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

Aggregations

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