use of com.yahoo.elide.core.utils.coerce.converters.Serde in project elide by yahoo.
the class MinuteSerdeTest method testDeserializeTimestamp.
@Test
public void testDeserializeTimestamp() {
String dateInString = "2020-01-01T01:18";
Minute expectedDate = new Minute(LocalDateTime.from(formatter.parse(dateInString)));
Timestamp timestamp = new Timestamp(expectedDate.getTime());
Serde serde = new Minute.MinuteSerde();
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 MinuteSerdeTest method testDateDeserializeString.
@Test
public void testDateDeserializeString() {
String dateInString = "2020-01-01T01:18";
Minute expectedDate = new Minute(LocalDateTime.from(formatter.parse(dateInString)));
String actual = "2020-01-01T01:18";
Serde serde = new Minute.MinuteSerde();
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 MinuteSerdeTest method testDeserializeOffsetDateTime.
@Test
public void testDeserializeOffsetDateTime() {
String dateInString = "2020-01-01T01:18";
Minute expectedDate = new Minute(LocalDateTime.from(formatter.parse(dateInString)));
OffsetDateTime dateTime = OffsetDateTime.of(2020, 01, 01, 01, 18, 0, 0, ZoneOffset.UTC);
Serde serde = new Minute.MinuteSerde();
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 MonthSerdeTest method testDateDeserialize.
@Test
public void testDateDeserialize() {
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 actualDate = serde.deserialize("2020-01");
assertEquals(expectedDate, actualDate);
}
use of com.yahoo.elide.core.utils.coerce.converters.Serde in project elide by yahoo.
the class QuarterSerdeTest method testDeserializeDateInvalidFormat.
@Test
public void testDeserializeDateInvalidFormat() {
String dateInString = "January-2020";
Serde serde = new Quarter.QuarterSerde();
assertThrows(DateTimeParseException.class, () -> serde.deserialize(dateInString));
}
Aggregations