Search in sources :

Example 6 with JSONSerialiser

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

the class EdgeSeedTest method shouldSerialiseAndDeserialiseCustomVertexObjects.

@Test
public void shouldSerialiseAndDeserialiseCustomVertexObjects() throws SerialisationException {
    // Given
    final CustomVertex source = new CustomVertex();
    source.setType("sourceType");
    source.setValue("sourceValue");
    final CustomVertex destination = new CustomVertex();
    destination.setType("destinationType");
    destination.setValue("destinationValue");
    final boolean directed = true;
    final EdgeSeed seed = new EdgeSeed(source, destination, directed);
    final JSONSerialiser serialiser = new JSONSerialiser();
    // When
    final byte[] bytes = serialiser.serialise(seed);
    final EdgeSeed seedDeserialised = serialiser.deserialise(bytes, EdgeSeed.class);
    // Then
    assertTrue(seedDeserialised.getSource() instanceof CustomVertex);
    assertTrue(seedDeserialised.getDestination() instanceof CustomVertex);
    assertEquals("sourceType", ((CustomVertex) seedDeserialised.getSource()).getType());
    assertEquals("sourceValue", ((CustomVertex) seedDeserialised.getSource()).getValue());
    assertEquals("destinationType", ((CustomVertex) seedDeserialised.getDestination()).getType());
    assertEquals("destinationValue", ((CustomVertex) seedDeserialised.getDestination()).getValue());
}
Also used : JSONSerialiser(uk.gov.gchq.gaffer.jsonserialisation.JSONSerialiser) Test(org.junit.Test)

Example 7 with JSONSerialiser

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

the class EdgeSeedTest method shouldSerialiseAndDeserialiseIntegersAndLongs.

@Test
public void shouldSerialiseAndDeserialiseIntegersAndLongs() throws SerialisationException {
    // Given
    final Long source = 1L;
    final Integer destination = 2;
    final boolean directed = true;
    final EdgeSeed seed = new EdgeSeed(source, destination, directed);
    final JSONSerialiser serialiser = new JSONSerialiser();
    // When
    final byte[] bytes = serialiser.serialise(seed);
    final EdgeSeed seedDeserialised = serialiser.deserialise(bytes, EdgeSeed.class);
    // Then
    assertEquals(seed, seedDeserialised);
    assertTrue(seedDeserialised.getSource() instanceof Long);
    assertTrue(seedDeserialised.getDestination() instanceof Integer);
}
Also used : JSONSerialiser(uk.gov.gchq.gaffer.jsonserialisation.JSONSerialiser) Test(org.junit.Test)

Example 8 with JSONSerialiser

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

the class EntitySeedTest method shouldSerialiseAndDeserialiseIntegersAndLongs.

@Test
public void shouldSerialiseAndDeserialiseIntegersAndLongs() throws SerialisationException {
    // Given
    final Long vertex1 = 1L;
    final Integer vertex2 = 2;
    final EntitySeed seed1 = new EntitySeed(vertex1);
    final EntitySeed seed2 = new EntitySeed(vertex2);
    final JSONSerialiser serialiser = new JSONSerialiser();
    // When
    final byte[] bytes1 = serialiser.serialise(seed1);
    final byte[] bytes2 = serialiser.serialise(seed2);
    final EntitySeed seed1Deserialised = serialiser.deserialise(bytes1, EntitySeed.class);
    final EntitySeed seed2Deserialised = serialiser.deserialise(bytes2, EntitySeed.class);
    // Then
    assertEquals(seed1, seed1Deserialised);
    assertEquals(seed2, seed2Deserialised);
    assertTrue(seed1Deserialised.getVertex() instanceof Long);
    assertTrue(seed2Deserialised.getVertex() instanceof Integer);
}
Also used : JSONSerialiser(uk.gov.gchq.gaffer.jsonserialisation.JSONSerialiser) Test(org.junit.Test)

Example 9 with JSONSerialiser

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

the class EntitySeedTest method shouldSerialiseAndDeserialiseCustomVertexObjects.

@Test
public void shouldSerialiseAndDeserialiseCustomVertexObjects() throws SerialisationException {
    // Given
    final CustomVertex vertex = new CustomVertex();
    vertex.setType("type");
    vertex.setValue("value");
    final EntitySeed seed = new EntitySeed(vertex);
    final JSONSerialiser serialiser = new JSONSerialiser();
    // When
    final byte[] bytes = serialiser.serialise(seed);
    final EntitySeed seedDeserialised = serialiser.deserialise(bytes, EntitySeed.class);
    // Then
    assertTrue(seedDeserialised.getVertex() instanceof CustomVertex);
    assertEquals("type", ((CustomVertex) seedDeserialised.getVertex()).getType());
    assertEquals("value", ((CustomVertex) seedDeserialised.getVertex()).getValue());
}
Also used : JSONSerialiser(uk.gov.gchq.gaffer.jsonserialisation.JSONSerialiser) Test(org.junit.Test)

Example 10 with JSONSerialiser

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

the class SparkOperationDeclarationsTest method shouldContainAllSparkOperationsAndHandlers.

@Test
public void shouldContainAllSparkOperationsAndHandlers() throws SerialisationException {
    // Given
    final JSONSerialiser jsonSerialiser = new JSONSerialiser();
    // When
    final OperationDeclarations deserialised = jsonSerialiser.deserialise(StreamUtil.openStream(getClass(), ACCUMULO_OP_DECLARATIONS_JSON_PATH), OperationDeclarations.class);
    // Then
    assertEquals(9, deserialised.getOperations().size());
    final OperationDeclaration od0 = deserialised.getOperations().get(0);
    assertEquals(GetJavaRDDOfElements.class, od0.getOperation());
    assertTrue(od0.getHandler() instanceof GetJavaRDDOfElementsHandler);
    final OperationDeclaration od1 = deserialised.getOperations().get(1);
    assertEquals(GetRDDOfElements.class, od1.getOperation());
    assertTrue(od1.getHandler() instanceof GetRDDOfElementsHandler);
    final OperationDeclaration od2 = deserialised.getOperations().get(2);
    assertEquals(GetRDDOfAllElements.class, od2.getOperation());
    assertTrue(od2.getHandler() instanceof GetRDDOfAllElementsHandler);
    final OperationDeclaration od3 = deserialised.getOperations().get(3);
    assertEquals(GetJavaRDDOfAllElements.class, od3.getOperation());
    assertTrue(od3.getHandler() instanceof GetJavaRDDOfAllElementsHandler);
    final OperationDeclaration od4 = deserialised.getOperations().get(4);
    assertEquals(GetDataFrameOfElements.class, od4.getOperation());
    assertTrue(od4.getHandler() instanceof GetDataFrameOfElementsHandler);
    final OperationDeclaration od5 = deserialised.getOperations().get(5);
    assertEquals(ImportKeyValueJavaPairRDDToAccumulo.class, od5.getOperation());
    assertTrue(od5.getHandler() instanceof ImportKeyValueJavaPairRDDToAccumuloHandler);
    final OperationDeclaration od6 = deserialised.getOperations().get(6);
    assertEquals(ImportJavaRDDOfElements.class, od6.getOperation());
    assertTrue(od6.getHandler() instanceof ImportJavaRDDOfElementsHandler);
    final OperationDeclaration od7 = deserialised.getOperations().get(7);
    assertEquals(ImportKeyValuePairRDDToAccumulo.class, od7.getOperation());
    assertTrue(od7.getHandler() instanceof ImportKeyValuePairRDDToAccumuloHandler);
    final OperationDeclaration od8 = deserialised.getOperations().get(8);
    assertEquals(ImportRDDOfElements.class, od8.getOperation());
    assertTrue(od8.getHandler() instanceof ImportRDDOfElementsHandler);
}
Also used : GetRDDOfAllElementsHandler(uk.gov.gchq.gaffer.sparkaccumulo.operation.handler.scalardd.GetRDDOfAllElementsHandler) GetJavaRDDOfElementsHandler(uk.gov.gchq.gaffer.sparkaccumulo.operation.handler.javardd.GetJavaRDDOfElementsHandler) JSONSerialiser(uk.gov.gchq.gaffer.jsonserialisation.JSONSerialiser) GetRDDOfElementsHandler(uk.gov.gchq.gaffer.sparkaccumulo.operation.handler.scalardd.GetRDDOfElementsHandler) ImportRDDOfElementsHandler(uk.gov.gchq.gaffer.sparkaccumulo.operation.handler.scalardd.ImportRDDOfElementsHandler) GetDataFrameOfElementsHandler(uk.gov.gchq.gaffer.sparkaccumulo.operation.handler.dataframe.GetDataFrameOfElementsHandler) ImportKeyValueJavaPairRDDToAccumuloHandler(uk.gov.gchq.gaffer.sparkaccumulo.operation.handler.javardd.ImportKeyValueJavaPairRDDToAccumuloHandler) ImportKeyValuePairRDDToAccumuloHandler(uk.gov.gchq.gaffer.sparkaccumulo.operation.handler.scalardd.ImportKeyValuePairRDDToAccumuloHandler) OperationDeclarations(uk.gov.gchq.gaffer.store.operationdeclaration.OperationDeclarations) OperationDeclaration(uk.gov.gchq.gaffer.store.operationdeclaration.OperationDeclaration) GetJavaRDDOfAllElementsHandler(uk.gov.gchq.gaffer.sparkaccumulo.operation.handler.javardd.GetJavaRDDOfAllElementsHandler) ImportJavaRDDOfElementsHandler(uk.gov.gchq.gaffer.sparkaccumulo.operation.handler.javardd.ImportJavaRDDOfElementsHandler) Test(org.junit.Test)

Aggregations

JSONSerialiser (uk.gov.gchq.gaffer.jsonserialisation.JSONSerialiser)68 Test (org.junit.Test)67 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)7 CloseableIterable (uk.gov.gchq.gaffer.commonutil.iterable.CloseableIterable)4 TestStore (uk.gov.gchq.gaffer.integration.store.TestStore)4 GafferResultCacheExporter (uk.gov.gchq.gaffer.operation.export.resultcache.GafferResultCacheExporter)4 Context (uk.gov.gchq.gaffer.store.Context)4 Store (uk.gov.gchq.gaffer.store.Store)4 Date (java.util.Date)2 WrappedCloseableIterable (uk.gov.gchq.gaffer.commonutil.iterable.WrappedCloseableIterable)2 Entity (uk.gov.gchq.gaffer.data.element.Entity)2 ConsumerFunctionContext (uk.gov.gchq.gaffer.function.context.ConsumerFunctionContext)2 OperationChain (uk.gov.gchq.gaffer.operation.OperationChain)2 ExportToGafferResultCache (uk.gov.gchq.gaffer.operation.impl.export.resultcache.ExportToGafferResultCache)2 GetGafferResultCacheExport (uk.gov.gchq.gaffer.operation.impl.export.resultcache.GetGafferResultCacheExport)2