use of uk.gov.gchq.gaffer.jsonserialisation.JSONSerialiser in project Gaffer by gchq.
the class MapFilterTest method shouldJsonSerialiseAndDeserialise.
@Test
public void shouldJsonSerialiseAndDeserialise() throws SerialisationException {
// Given
final MapFilter mapFilter = new MapFilter(DATE_KEY, new IsA(Map.class));
// When
final String json = new String(new JSONSerialiser().serialise(mapFilter, true));
// Then
JsonUtil.assertEquals(String.format("{\n" + " \"class\" : \"uk.gov.gchq.gaffer.function.MapFilter\",\n" + " \"function\" : {\n" + " \"class\" : \"uk.gov.gchq.gaffer.function.IsA\",\n" + " \"type\" : \"java.util.Map\"\n" + " },\n" + " \"key\" : {\n" + " \"java.util.Date\" : " + DATE_KEY.getTime() + "%n" + " }\n" + "}"), json);
// When 2
final MapFilter deserialisedFilter = new JSONSerialiser().deserialise(json.getBytes(), MapFilter.class);
// Then 2
assertNotNull(deserialisedFilter);
assertEquals(DATE_KEY, deserialisedFilter.getKey());
}
use of uk.gov.gchq.gaffer.jsonserialisation.JSONSerialiser in project Gaffer by gchq.
the class ArrayListConcatTest method shouldJsonSerialiseAndDeserialise.
@Test
public void shouldJsonSerialiseAndDeserialise() throws SerialisationException {
// Given
final ArrayListConcat aggregator = new ArrayListConcat();
// When 1
final String json = new String(new JSONSerialiser().serialise(aggregator, true));
// Then 1
JsonUtil.assertEquals(String.format("{%n" + " \"class\" : \"uk.gov.gchq.gaffer.function.aggregate.ArrayListConcat\"%n" + "}"), json);
// When 2
final ArrayListConcat deserialisedAggregator = new JSONSerialiser().deserialise(json.getBytes(), getFunctionClass());
// Then 2
assertNotNull(deserialisedAggregator);
}
Aggregations