use of com.yahoo.elide.core.utils.coerce.converters.Serde in project elide by yahoo.
the class MonthSerdeTest method testDeserializeDateInvalidFormat.
@Test
public void testDeserializeDateInvalidFormat() {
String dateInString = "January-2020";
Serde serde = new Month.MonthSerde();
assertThrows(DateTimeParseException.class, () -> serde.deserialize(dateInString));
}
use of com.yahoo.elide.core.utils.coerce.converters.Serde in project elide by yahoo.
the class MonthSerdeTest method testDateSerialize.
@Test
public void testDateSerialize() {
LocalDateTime localDate = LocalDateTime.of(2020, java.time.Month.of(01), 01, 00, 00, 00);
Month expectedDate = new Month(localDate);
Serde serde = new Month.MonthSerde();
Object actual = serde.serialize(expectedDate);
assertEquals("2020-01", actual);
}
use of com.yahoo.elide.core.utils.coerce.converters.Serde 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);
}
use of com.yahoo.elide.core.utils.coerce.converters.Serde 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);
}
use of com.yahoo.elide.core.utils.coerce.converters.Serde in project elide by yahoo.
the class QuarterSerdeTest method testDeserializeOffsetDateTimeNotQuarterMonth.
@Test
public void testDeserializeOffsetDateTimeNotQuarterMonth() {
OffsetDateTime dateTime = OffsetDateTime.of(2020, 2, 1, 0, 0, 0, 0, ZoneOffset.UTC);
Serde serde = new Quarter.QuarterSerde();
assertThrows(IllegalArgumentException.class, () -> serde.deserialize(dateTime));
}
Aggregations