use of uk.gov.gchq.gaffer.jsonserialisation.JSONSerialiser in project Gaffer by gchq.
the class ProductTest method shouldJsonSerialiseAndDeserialise.
@Test
public void shouldJsonSerialiseAndDeserialise() throws SerialisationException {
// Given
final Product aggregator = new Product();
// 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.Product\",%n" + " \"mode\" : \"AUTO\"%n" + "}"), json);
// When 2
final Product deserialisedAggregator = new JSONSerialiser().deserialise(json.getBytes(), Product.class);
// Then 2
assertNotNull(deserialisedAggregator);
}
use of uk.gov.gchq.gaffer.jsonserialisation.JSONSerialiser in project Gaffer by gchq.
the class SetAggregatorTest method shouldJsonSerialiseAndDeserialise.
@Test
public void shouldJsonSerialiseAndDeserialise() throws SerialisationException {
// Given
SetAggregator<String> aggregator = new SetAggregator<>();
// 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.SetAggregator\"%n" + "}"), json);
// When 2
SetAggregator<String> deserialisedAggregator = new JSONSerialiser().deserialise(json.getBytes(), getFunctionClass());
// Then 2
assertNotNull(deserialisedAggregator);
}
use of uk.gov.gchq.gaffer.jsonserialisation.JSONSerialiser in project Gaffer by gchq.
the class IsEqualTest method shouldJsonSerialiseAndDeserialise.
@Test
public void shouldJsonSerialiseAndDeserialise() throws SerialisationException {
// Given
final IsEqual filter = new IsEqual("test");
// When
final String json = new String(new JSONSerialiser().serialise(filter, true));
// Then
JsonUtil.assertEquals(String.format("{%n" + " \"class\" : \"uk.gov.gchq.gaffer.function.filter.IsEqual\",%n" + " \"value\" : \"test\"%n" + "}"), json);
// When 2
final IsEqual deserialisedFilter = new JSONSerialiser().deserialise(json.getBytes(), IsEqual.class);
// Then 2
assertNotNull(deserialisedFilter);
}
Aggregations