use of uk.gov.gchq.gaffer.jsonserialisation.JSONSerialiser in project Gaffer by gchq.
the class HyperLogLogPlusIsLessThanTest method shouldJsonSerialiseAndDeserialise.
@Test
public void shouldJsonSerialiseAndDeserialise() throws SerialisationException {
// Given
final long controlValue = 15;
final HyperLogLogPlusIsLessThan filter = new HyperLogLogPlusIsLessThan(controlValue);
// When 1
final String json = new String(new JSONSerialiser().serialise(filter, true));
// Then 1
JsonUtil.assertEquals(String.format("{%n" + " \"class\" : \"uk.gov.gchq.gaffer.sketches.function.filter.HyperLogLogPlusIsLessThan\",%n" + " \"orEqualTo\" : false,%n" + " \"value\" : 15%n" + "}"), json);
// When 2
final HyperLogLogPlusIsLessThan deserialisedProperty = new JSONSerialiser().deserialise(json.getBytes(), HyperLogLogPlusIsLessThan.class);
// Then 2
assertNotNull(deserialisedProperty);
assertEquals(controlValue, deserialisedProperty.getControlValue());
}
use of uk.gov.gchq.gaffer.jsonserialisation.JSONSerialiser in project Gaffer by gchq.
the class StringsSketchAggregatorTest method shouldJsonSerialiseAndDeserialise.
@Test
public void shouldJsonSerialiseAndDeserialise() throws SerialisationException {
// Given
final StringsSketchAggregator aggregator = new StringsSketchAggregator();
// When 1
final String json = new String(new JSONSerialiser().serialise(aggregator, true));
// Then 1
JsonUtil.assertEquals(String.format("{%n" + " \"class\" : \"uk.gov.gchq.gaffer.sketches.datasketches.frequencies.function.aggregate.StringsSketchAggregator\"%n" + "}"), json);
// When 2
final StringsSketchAggregator deserialisedAggregator = new JSONSerialiser().deserialise(json.getBytes(), StringsSketchAggregator.class);
// Then 2
assertNotNull(deserialisedAggregator);
}
use of uk.gov.gchq.gaffer.jsonserialisation.JSONSerialiser in project Gaffer by gchq.
the class StringsUnionAggregatorTest method shouldJsonSerialiseAndDeserialise.
@Test
public void shouldJsonSerialiseAndDeserialise() throws SerialisationException {
// Given
final StringsUnionAggregator aggregator = new StringsUnionAggregator();
// When 1
final String json = new String(new JSONSerialiser().serialise(aggregator, true));
// Then 1
JsonUtil.assertEquals(String.format("{%n" + " \"class\" : \"uk.gov.gchq.gaffer.sketches.datasketches.quantiles.function.aggregate.StringsUnionAggregator\"%n" + "}"), json);
// When 2
final StringsUnionAggregator deserialisedAggregator = new JSONSerialiser().deserialise(json.getBytes(), StringsUnionAggregator.class);
// Then 2
assertNotNull(deserialisedAggregator);
}
use of uk.gov.gchq.gaffer.jsonserialisation.JSONSerialiser in project Gaffer by gchq.
the class UnionAggregatorTest method shouldJsonSerialiseAndDeserialise.
@Test
public void shouldJsonSerialiseAndDeserialise() throws SerialisationException {
// Given
final UnionAggregator aggregator = new UnionAggregator();
// When 1
final String json = new String(new JSONSerialiser().serialise(aggregator, true));
// Then 1
JsonUtil.assertEquals(String.format("{%n" + " \"class\" : \"uk.gov.gchq.gaffer.sketches.datasketches.theta.function.aggregate.UnionAggregator\"%n" + "}"), json);
// When 2
final UnionAggregator deserialisedAggregator = new JSONSerialiser().deserialise(json.getBytes(), UnionAggregator.class);
// Then 2
assertNotNull(deserialisedAggregator);
}
use of uk.gov.gchq.gaffer.jsonserialisation.JSONSerialiser in project Gaffer by gchq.
the class HyperLogLogPlusAggregatorTest method shouldJsonSerialiseAndDeserialise.
@Test
public void shouldJsonSerialiseAndDeserialise() throws SerialisationException {
// Given
final HyperLogLogPlusAggregator aggregator = new HyperLogLogPlusAggregator();
// When 1
final String json = new String(new JSONSerialiser().serialise(aggregator, true));
// Then 1
JsonUtil.assertEquals(String.format("{%n" + " \"class\" : \"uk.gov.gchq.gaffer.sketches.function.aggregate.HyperLogLogPlusAggregator\"%n" + "}"), json);
// When 2
final HyperLogLogPlusAggregator deserialisedAggregator = new JSONSerialiser().deserialise(json.getBytes(), HyperLogLogPlusAggregator.class);
// Then 2
assertNotNull(deserialisedAggregator);
}
Aggregations