use of uk.gov.gchq.gaffer.jsonserialisation.JSONSerialiser in project Gaffer by gchq.
the class IsLessThanTest method shouldJsonSerialiseAndDeserialise.
@Test
public void shouldJsonSerialiseAndDeserialise() throws SerialisationException {
// Given
final Integer controlValue = 5;
final IsLessThan filter = new IsLessThan(controlValue);
// When
final String json = new String(new JSONSerialiser().serialise(filter, true));
// Then
JsonUtil.assertEquals(String.format("{%n" + " \"class\" : \"uk.gov.gchq.gaffer.function.filter.IsLessThan\",%n" + " \"orEqualTo\" : false,%n" + " \"value\" : 5%n" + "}"), json);
// When 2
final IsLessThan deserialisedFilter = new JSONSerialiser().deserialise(json.getBytes(), IsLessThan.class);
// Then 2
assertNotNull(deserialisedFilter);
assertEquals(controlValue, deserialisedFilter.getControlValue());
}
use of uk.gov.gchq.gaffer.jsonserialisation.JSONSerialiser in project Gaffer by gchq.
the class IsMoreThanTest method shouldJsonSerialiseAndDeserialise.
@Test
public void shouldJsonSerialiseAndDeserialise() throws SerialisationException {
// Given
final Integer controlValue = 5;
final IsMoreThan filter = new IsMoreThan(controlValue);
// When
final String json = new String(new JSONSerialiser().serialise(filter, true));
// Then
JsonUtil.assertEquals(String.format("{%n" + " \"class\" : \"uk.gov.gchq.gaffer.function.filter.IsMoreThan\",%n" + " \"orEqualTo\" : false,%n" + " \"value\" : 5%n" + "}"), json);
// When 2
final IsMoreThan deserialisedFilter = new JSONSerialiser().deserialise(json.getBytes(), IsMoreThan.class);
// Then 2
assertNotNull(deserialisedFilter);
assertEquals(controlValue, deserialisedFilter.getControlValue());
}
use of uk.gov.gchq.gaffer.jsonserialisation.JSONSerialiser in project Gaffer by gchq.
the class IsShorterThanTest method shouldJsonSerialiseAndDeserialise.
@Test
public void shouldJsonSerialiseAndDeserialise() throws SerialisationException {
// Given
final int max = 5;
final IsShorterThan filter = new IsShorterThan(max);
// When
final String json = new String(new JSONSerialiser().serialise(filter, true));
// Then
JsonUtil.assertEquals(String.format("{%n" + " \"class\" : \"uk.gov.gchq.gaffer.function.filter.IsShorterThan\",%n" + " \"orEqualTo\" : false,%n" + " \"maxLength\" : 5%n" + "}"), json);
// When 2
final IsShorterThan deserialisedFilter = new JSONSerialiser().deserialise(json.getBytes(), IsShorterThan.class);
// Then 2
assertNotNull(deserialisedFilter);
assertEquals(max, deserialisedFilter.getMaxLength());
}
use of uk.gov.gchq.gaffer.jsonserialisation.JSONSerialiser in project Gaffer by gchq.
the class MinTest method shouldJsonSerialiseAndDeserialise.
@Test
public void shouldJsonSerialiseAndDeserialise() throws SerialisationException {
// Given
final Min aggregator = new Min();
// 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.Min\",%n" + " \"mode\" : \"AUTO\"%n" + "}"), json);
// When 2
final Min deserialisedAggregator = new JSONSerialiser().deserialise(json.getBytes(), Min.class);
// Then 2
assertNotNull(deserialisedAggregator);
}
use of uk.gov.gchq.gaffer.jsonserialisation.JSONSerialiser in project Gaffer by gchq.
the class StringConcatTest method shouldJsonSerialiseAndDeserialise.
@Test
public void shouldJsonSerialiseAndDeserialise() throws SerialisationException {
// Given
final StringConcat aggregator = new StringConcat();
// 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.StringConcat\",%n" + " \"separator\" : \",\"%n" + "}"), json);
// When 2
final StringConcat deserialisedAggregator = new JSONSerialiser().deserialise(json.getBytes(), getFunctionClass());
// Then 2
assertNotNull(deserialisedAggregator);
}
Aggregations