use of com.yahoo.elide.core.utils.coerce.converters.Serde 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));
}
use of com.yahoo.elide.core.utils.coerce.converters.Serde 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);
}
use of com.yahoo.elide.core.utils.coerce.converters.Serde 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);
}
use of com.yahoo.elide.core.utils.coerce.converters.Serde in project elide by yahoo.
the class SecondSerdeTest method testDateSerialize.
@Test
public void testDateSerialize() {
String expected = "2020-01-01T01:18:19";
Second expectedDate = new Second(LocalDateTime.from(formatter.parse(expected)));
Serde serde = new Second.SecondSerde();
Object actual = serde.serialize(expectedDate);
assertEquals(expected, actual);
}
use of com.yahoo.elide.core.utils.coerce.converters.Serde in project elide by yahoo.
the class HashMapStoreTransaction method loadObject.
@Override
public Object loadObject(EntityProjection projection, Serializable id, RequestScope scope) {
EntityDictionary dictionary = scope.getDictionary();
synchronized (dataStore) {
Map<String, Object> data = dataStore.get(projection.getType());
if (data == null) {
return null;
}
Serde serde = dictionary.getSerdeLookup().apply(id.getClass());
String idString = (serde == null) ? id.toString() : (String) serde.serialize(id);
return data.get(idString);
}
}
Aggregations