use of uk.gov.gchq.gaffer.jsonserialisation.JSONSerialiser in project Gaffer by gchq.
the class AreInTest method shouldJsonSerialiseAndDeserialise.
@Test
public void shouldJsonSerialiseAndDeserialise() throws SerialisationException {
// Given
final AreIn filter = new AreIn(VALUE1);
// When
final String json = new String(new JSONSerialiser().serialise(filter, true));
// Then
JsonUtil.assertEquals(String.format("{%n" + " \"class\" : \"uk.gov.gchq.gaffer.function.filter.AreIn\",%n" + " \"values\" : [\"value1\"]%n" + "}"), json);
// When 2
final AreIn deserialisedFilter = new JSONSerialiser().deserialise(json.getBytes(), AreIn.class);
// Then 2
assertNotNull(deserialisedFilter);
assertArrayEquals(Collections.singleton(VALUE1).toArray(), deserialisedFilter.getValues().toArray());
}
use of uk.gov.gchq.gaffer.jsonserialisation.JSONSerialiser in project Gaffer by gchq.
the class ExistsTest method shouldJsonSerialiseAndDeserialise.
@Test
public void shouldJsonSerialiseAndDeserialise() throws SerialisationException {
// Given
final Exists filter = new Exists();
// When
final String json = new String(new JSONSerialiser().serialise(filter, true));
// Then
JsonUtil.assertEquals(String.format("{%n" + " \"class\" : \"uk.gov.gchq.gaffer.function.filter.Exists\"%n" + "}"), json);
// When 2
final Exists deserialisedFilter = new JSONSerialiser().deserialise(json.getBytes(), Exists.class);
// Then 2
assertNotNull(deserialisedFilter);
}
use of uk.gov.gchq.gaffer.jsonserialisation.JSONSerialiser in project Gaffer by gchq.
the class ConcatTest method shouldJsonSerialiseAndDeserialise.
@Override
public void shouldJsonSerialiseAndDeserialise() throws IOException {
// Given
final String separator = "-";
final Concat concat = new Concat();
concat.setSeparator(separator);
// When
final String json = new String(new JSONSerialiser().serialise(concat, true));
// Then
JsonUtil.assertEquals(String.format("{%n" + " \"class\" : \"uk.gov.gchq.gaffer.function.transform.Concat\",%n" + " \"separator\" : \"-\"%n" + "}"), json);
// When 2
final Concat deserialisedConcat = new JSONSerialiser().deserialise(json.getBytes(), Concat.class);
// Then 2
assertNotNull(deserialisedConcat);
assertEquals(separator, deserialisedConcat.getSeparator());
}
use of uk.gov.gchq.gaffer.jsonserialisation.JSONSerialiser in project Gaffer by gchq.
the class IsFalseTest method shouldJsonSerialiseAndDeserialise.
@Test
public void shouldJsonSerialiseAndDeserialise() throws SerialisationException {
// Given
final IsFalse filter = new IsFalse();
// When
final String json = new String(new JSONSerialiser().serialise(filter, true));
// Then
JsonUtil.assertEquals(String.format("{%n" + " \"class\" : \"uk.gov.gchq.gaffer.function.filter.IsFalse\"%n" + "}"), json);
// When 2
final IsFalse deserialisedFilter = new JSONSerialiser().deserialise(json.getBytes(), IsFalse.class);
// Then 2
assertNotNull(deserialisedFilter);
}
use of uk.gov.gchq.gaffer.jsonserialisation.JSONSerialiser in project Gaffer by gchq.
the class IsInTest method shouldJsonSerialiseAndDeserialise.
@Test
public void shouldJsonSerialiseAndDeserialise() throws SerialisationException {
// Given
final Object[] controlData = { 1, 2, 3 };
final IsIn filter = new IsIn(Arrays.asList(controlData));
// When
final String json = new String(new JSONSerialiser().serialise(filter, true));
// Then
JsonUtil.assertEquals(String.format("{%n" + " \"class\" : \"uk.gov.gchq.gaffer.function.filter.IsIn\",%n" + " \"values\" : [ 1, 2, 3 ]%n" + "}"), json);
// When 2
final IsIn deserialisedFilter = new JSONSerialiser().deserialise(json.getBytes(), IsIn.class);
// Then 2
assertNotNull(deserialisedFilter);
assertArrayEquals(controlData, deserialisedFilter.getAllowedValuesArray());
}
Aggregations