use of uk.gov.gchq.gaffer.jsonserialisation.JSONSerialiser in project Gaffer by gchq.
the class ComparableMaxTest method shouldJsonSerialiseAndDeserialise.
@Test
public void shouldJsonSerialiseAndDeserialise() throws SerialisationException {
// Given
final ComparableMax aggregator = getInstance();
// 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.ComparableMax\"%n" + "}"), json);
// When 2
final ComparableMax 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 ComparableMinTest method shouldJsonSerialiseAndDeserialise.
@Test
public void shouldJsonSerialiseAndDeserialise() throws SerialisationException {
// Given
final ComparableMin aggregator = getInstance();
// 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.ComparableMin\"%n" + "}"), json);
// When 2
final ComparableMin 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 FreqMapAggregatorTest method shouldJsonSerialiseAndDeserialise.
@Test
public void shouldJsonSerialiseAndDeserialise() throws SerialisationException {
// Given
final FreqMapAggregator aggregator = new FreqMapAggregator();
// 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.FreqMapAggregator\"%n" + "}"), json);
// When 2
final FreqMapAggregator 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 AgeOffTest method shouldJsonSerialiseAndDeserialise.
@Test
public void shouldJsonSerialiseAndDeserialise() throws SerialisationException {
// Given
final AgeOff filter = new AgeOff(CUSTOM_AGE_OFF);
// When
final String json = new String(new JSONSerialiser().serialise(filter, true));
// Then
JsonUtil.assertEquals(String.format("{%n" + " \"class\" : \"uk.gov.gchq.gaffer.function.filter.AgeOff\",%n" + " \"ageOffTime\" : 100000%n" + "}"), json);
// When 2
final AgeOff deserialisedFilter = new JSONSerialiser().deserialise(json.getBytes(), AgeOff.class);
// Then 2
assertNotNull(deserialisedFilter);
assertEquals(CUSTOM_AGE_OFF, deserialisedFilter.getAgeOffTime());
}
use of uk.gov.gchq.gaffer.jsonserialisation.JSONSerialiser in project Gaffer by gchq.
the class AreEqualTest method shouldJsonSerialiseAndDeserialise.
@Test
public void shouldJsonSerialiseAndDeserialise() throws SerialisationException {
// Given
final AreEqual filter = new AreEqual();
// When
final String json = new String(new JSONSerialiser().serialise(filter, true));
// Then
JsonUtil.assertEquals(String.format("{%n" + " \"class\" : \"uk.gov.gchq.gaffer.function.filter.AreEqual\"%n" + "}"), json);
// When 2
final AreEqual deserialisedFilter = new JSONSerialiser().deserialise(json.getBytes(), AreEqual.class);
// Then 2
assertNotNull(deserialisedFilter);
}
Aggregations