Search in sources :

Example 1 with OperationDeclarations

use of uk.gov.gchq.gaffer.store.operationdeclaration.OperationDeclarations in project Gaffer by gchq.

the class OperationDeclarationsTest method testDeserialiseFile.

@Test
public void testDeserialiseFile() throws SerialisationException {
    // Given
    final String paths = "operationDeclarations1.json,operationDeclarations2.json";
    // When
    final OperationDeclarations deserialised = OperationDeclarations.fromPaths(paths);
    // Then
    assertEquals(2, deserialised.getOperations().size());
    final OperationDeclaration od0 = deserialised.getOperations().get(0);
    final OperationDeclaration od1 = deserialised.getOperations().get(1);
    assertEquals(GenerateElements.class, od0.getOperation());
    assertTrue(od0.getHandler() instanceof GenerateElementsHandler);
    assertEquals(GenerateObjects.class, od1.getOperation());
    assertTrue(od1.getHandler() instanceof GenerateObjectsHandler);
}
Also used : GenerateElementsHandler(uk.gov.gchq.gaffer.store.operation.handler.generate.GenerateElementsHandler) GenerateObjectsHandler(uk.gov.gchq.gaffer.store.operation.handler.generate.GenerateObjectsHandler) OperationDeclarations(uk.gov.gchq.gaffer.store.operationdeclaration.OperationDeclarations) OperationDeclaration(uk.gov.gchq.gaffer.store.operationdeclaration.OperationDeclaration) Test(org.junit.Test)

Example 2 with OperationDeclarations

use of uk.gov.gchq.gaffer.store.operationdeclaration.OperationDeclarations in project Gaffer by gchq.

the class OperationDeclarationsTest method testSerialiseDeserialise.

@Test
public void testSerialiseDeserialise() throws SerialisationException {
    // Given
    final OperationDeclarations declarations = new OperationDeclarations.Builder().declaration(new OperationDeclaration.Builder().handler(new GenerateElementsHandler()).operation(GenerateElements.class).build()).build();
    // When
    final byte[] definitionJson = json.serialise(declarations);
    final OperationDeclarations deserialised = OperationDeclarations.fromJson(definitionJson);
    assertEquals(1, deserialised.getOperations().size());
    final OperationDeclaration deserialisedDeclaration = deserialised.getOperations().get(0);
    assertEquals(GenerateElements.class, deserialisedDeclaration.getOperation());
    assertTrue(deserialisedDeclaration.getHandler() instanceof GenerateElementsHandler);
}
Also used : GenerateElements(uk.gov.gchq.gaffer.operation.impl.generate.GenerateElements) GenerateElementsHandler(uk.gov.gchq.gaffer.store.operation.handler.generate.GenerateElementsHandler) OperationDeclarations(uk.gov.gchq.gaffer.store.operationdeclaration.OperationDeclarations) OperationDeclaration(uk.gov.gchq.gaffer.store.operationdeclaration.OperationDeclaration) Test(org.junit.Test)

Example 3 with OperationDeclarations

use of uk.gov.gchq.gaffer.store.operationdeclaration.OperationDeclarations 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)

Example 4 with OperationDeclarations

use of uk.gov.gchq.gaffer.store.operationdeclaration.OperationDeclarations in project Gaffer by gchq.

the class NamedOperationHandlerTest method shouldLoadFromNamedOperationDeclarationsFile.

@Test
public void shouldLoadFromNamedOperationDeclarationsFile() throws SerialisationException {
    final InputStream s = StreamUtil.openStream(getClass(), "NamedOperationDeclarations.json");
    final OperationDeclarations deserialised = json.deserialise(s, OperationDeclarations.class);
    assertEquals(4, deserialised.getOperations().size());
    assert (deserialised.getOperations().get(0).getHandler() instanceof AddNamedOperationHandler);
    assert (deserialised.getOperations().get(1).getHandler() instanceof NamedOperationHandler);
    assert (deserialised.getOperations().get(2).getHandler() instanceof DeleteNamedOperationHandler);
    assert (deserialised.getOperations().get(3).getHandler() instanceof GetAllNamedOperationsHandler);
}
Also used : InputStream(java.io.InputStream) OperationDeclarations(uk.gov.gchq.gaffer.store.operationdeclaration.OperationDeclarations) Test(org.junit.Test)

Example 5 with OperationDeclarations

use of uk.gov.gchq.gaffer.store.operationdeclaration.OperationDeclarations in project Gaffer by gchq.

the class StoreProperties method getOperationDeclarations.

/**
     * Returns the operation definitions from the file specified in the properties.
     * This is an optional feature, so if the property does not exist then this function
     * will return an empty object.
     *
     * @return The Operation Definitions to load dynamically
     */
@JsonIgnore
public OperationDeclarations getOperationDeclarations() {
    OperationDeclarations declarations = null;
    final String declarationsPaths = get(StoreProperties.OPERATION_DECLARATIONS);
    if (null != declarationsPaths) {
        declarations = OperationDeclarations.fromPaths(declarationsPaths);
    }
    if (null == declarations) {
        declarations = new OperationDeclarations.Builder().build();
    }
    return declarations;
}
Also used : OperationDeclarations(uk.gov.gchq.gaffer.store.operationdeclaration.OperationDeclarations) JsonIgnore(com.fasterxml.jackson.annotation.JsonIgnore)

Aggregations

OperationDeclarations (uk.gov.gchq.gaffer.store.operationdeclaration.OperationDeclarations)7 Test (org.junit.Test)6 OperationDeclaration (uk.gov.gchq.gaffer.store.operationdeclaration.OperationDeclaration)4 GenerateElementsHandler (uk.gov.gchq.gaffer.store.operation.handler.generate.GenerateElementsHandler)3 InputStream (java.io.InputStream)2 GenerateObjectsHandler (uk.gov.gchq.gaffer.store.operation.handler.generate.GenerateObjectsHandler)2 JsonIgnore (com.fasterxml.jackson.annotation.JsonIgnore)1 JSONSerialiser (uk.gov.gchq.gaffer.jsonserialisation.JSONSerialiser)1 INamedOperationCache (uk.gov.gchq.gaffer.named.operation.cache.INamedOperationCache)1 MockNamedOperationCache (uk.gov.gchq.gaffer.named.operation.cache.MockNamedOperationCache)1 Validate (uk.gov.gchq.gaffer.operation.impl.Validate)1 AddElements (uk.gov.gchq.gaffer.operation.impl.add.AddElements)1 GenerateElements (uk.gov.gchq.gaffer.operation.impl.generate.GenerateElements)1 GetAllEdges (uk.gov.gchq.gaffer.operation.impl.get.GetAllEdges)1 GetAllElements (uk.gov.gchq.gaffer.operation.impl.get.GetAllElements)1 GetAllEntities (uk.gov.gchq.gaffer.operation.impl.get.GetAllEntities)1 GetDataFrameOfElementsHandler (uk.gov.gchq.gaffer.sparkaccumulo.operation.handler.dataframe.GetDataFrameOfElementsHandler)1 GetJavaRDDOfAllElementsHandler (uk.gov.gchq.gaffer.sparkaccumulo.operation.handler.javardd.GetJavaRDDOfAllElementsHandler)1 GetJavaRDDOfElementsHandler (uk.gov.gchq.gaffer.sparkaccumulo.operation.handler.javardd.GetJavaRDDOfElementsHandler)1 ImportJavaRDDOfElementsHandler (uk.gov.gchq.gaffer.sparkaccumulo.operation.handler.javardd.ImportJavaRDDOfElementsHandler)1