use of com.yahoo.elide.core.utils.coerce.converters.Serde 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);
}
use of com.yahoo.elide.core.utils.coerce.converters.Serde 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);
}
use of com.yahoo.elide.core.utils.coerce.converters.Serde in project elide by yahoo.
the class SecondSerdeTest method testDeserializeDateInvalidFormat.
@Test
public void testDeserializeDateInvalidFormat() {
String dateInString = "00:18:19 2020-01-01";
Serde serde = new Second.SecondSerde();
assertThrows(DateTimeParseException.class, () -> serde.deserialize(dateInString));
}
use of com.yahoo.elide.core.utils.coerce.converters.Serde in project elide by yahoo.
the class TimeSerdeTest method testTimeDeserializeSecond.
@Test
public void testTimeDeserializeSecond() {
LocalDateTime localDate = LocalDateTime.of(2020, java.time.Month.of(01), 01, 00, 00, 00);
Time expectedDate = new Time(localDate, true, true, true, true, true, true, (unused) -> "");
Serde serde = new Time.TimeSerde();
Object actualDate = serde.deserialize(SECOND);
assertEquals(expectedDate, actualDate);
assertEquals(SECOND, serde.serialize(actualDate));
}
use of com.yahoo.elide.core.utils.coerce.converters.Serde in project elide by yahoo.
the class TimeSerdeTest method testTimeDeserializeHour.
@Test
public void testTimeDeserializeHour() {
LocalDateTime localDate = LocalDateTime.of(2020, java.time.Month.of(01), 01, 00, 00, 00);
Time expectedDate = new Time(localDate, true, true, true, true, true, true, (unused) -> "");
Serde serde = new Time.TimeSerde();
Object actualDate = serde.deserialize(HOUR);
assertEquals(expectedDate, actualDate);
assertEquals(HOUR, serde.serialize(actualDate));
}
Aggregations