Search in sources :

Example 51 with JSONSerialiser

use of uk.gov.gchq.gaffer.jsonserialisation.JSONSerialiser in project Gaffer by gchq.

the class IntegerFreqMapAggregatorTest method shouldJsonSerialiseAndDeserialise.

@Test
public void shouldJsonSerialiseAndDeserialise() throws SerialisationException {
    // Given
    final IntegerFreqMapAggregator aggregator = new IntegerFreqMapAggregator();
    // 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.IntegerFreqMapAggregator\"%n" + "}"), json);
    // When 2
    final IntegerFreqMapAggregator deserialisedAggregator = new JSONSerialiser().deserialise(json.getBytes(), getFunctionClass());
    // Then 2
    assertNotNull(deserialisedAggregator);
}
Also used : JSONSerialiser(uk.gov.gchq.gaffer.jsonserialisation.JSONSerialiser) Test(org.junit.Test) AggregateFunctionTest(uk.gov.gchq.gaffer.function.AggregateFunctionTest)

Example 52 with JSONSerialiser

use of uk.gov.gchq.gaffer.jsonserialisation.JSONSerialiser in project Gaffer by gchq.

the class MaxTest method shouldJsonSerialiseAndDeserialise.

@Test
public void shouldJsonSerialiseAndDeserialise() throws SerialisationException {
    // Given
    final Max aggregator = new Max();
    // 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.Max\",%n" + "  \"mode\" : \"AUTO\"%n" + "}"), json);
    // When 2
    final Max deserialisedAggregator = new JSONSerialiser().deserialise(json.getBytes(), Max.class);
    // Then 2
    assertNotNull(deserialisedAggregator);
}
Also used : JSONSerialiser(uk.gov.gchq.gaffer.jsonserialisation.JSONSerialiser) Test(org.junit.Test) AggregateFunctionTest(uk.gov.gchq.gaffer.function.AggregateFunctionTest)

Example 53 with JSONSerialiser

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);
}
Also used : JSONSerialiser(uk.gov.gchq.gaffer.jsonserialisation.JSONSerialiser) Test(org.junit.Test) AggregateFunctionTest(uk.gov.gchq.gaffer.function.AggregateFunctionTest)

Example 54 with JSONSerialiser

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);
}
Also used : JSONSerialiser(uk.gov.gchq.gaffer.jsonserialisation.JSONSerialiser) Test(org.junit.Test) AggregateFunctionTest(uk.gov.gchq.gaffer.function.AggregateFunctionTest)

Example 55 with JSONSerialiser

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);
}
Also used : JSONSerialiser(uk.gov.gchq.gaffer.jsonserialisation.JSONSerialiser) FilterFunctionTest(uk.gov.gchq.gaffer.function.FilterFunctionTest) Test(org.junit.Test)

Aggregations

JSONSerialiser (uk.gov.gchq.gaffer.jsonserialisation.JSONSerialiser)57 Test (org.junit.Test)56 FilterFunctionTest (uk.gov.gchq.gaffer.function.FilterFunctionTest)23 AggregateFunctionTest (uk.gov.gchq.gaffer.function.AggregateFunctionTest)19 Graph (uk.gov.gchq.gaffer.graph.Graph)11 User (uk.gov.gchq.gaffer.user.User)11 Edge (uk.gov.gchq.gaffer.data.element.Edge)8 AddElements (uk.gov.gchq.gaffer.operation.impl.add.AddElements)6 CloseableIterable (uk.gov.gchq.gaffer.commonutil.iterable.CloseableIterable)2 Entity (uk.gov.gchq.gaffer.data.element.Entity)2 ConsumerFunctionContext (uk.gov.gchq.gaffer.function.context.ConsumerFunctionContext)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 Map (java.util.Map)1 Pattern (java.util.regex.Pattern)1 IsA (uk.gov.gchq.gaffer.function.IsA)1 MapFilter (uk.gov.gchq.gaffer.function.MapFilter)1 GetAllEdges (uk.gov.gchq.gaffer.operation.impl.get.GetAllEdges)1 GetAllEntities (uk.gov.gchq.gaffer.operation.impl.get.GetAllEntities)1