Search in sources :

Example 1 with OperationDeclaration

use of uk.gov.gchq.gaffer.store.operation.declaration.OperationDeclaration 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.operation.declaration.OperationDeclarations) OperationDeclaration(uk.gov.gchq.gaffer.store.operation.declaration.OperationDeclaration) Test(org.junit.jupiter.api.Test)

Example 2 with OperationDeclaration

use of uk.gov.gchq.gaffer.store.operation.declaration.OperationDeclaration 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 = JSONSerialiser.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.operation.declaration.OperationDeclarations) OperationDeclaration(uk.gov.gchq.gaffer.store.operation.declaration.OperationDeclaration) Test(org.junit.jupiter.api.Test)

Example 3 with OperationDeclaration

use of uk.gov.gchq.gaffer.store.operation.declaration.OperationDeclaration in project Gaffer by gchq.

the class SparkOperationDeclarationsTest method shouldContainAllSparkOperationsAndHandlers.

@Test
public void shouldContainAllSparkOperationsAndHandlers() throws SerialisationException {
    // When
    final OperationDeclarations deserialised = JSONSerialiser.deserialise(StreamUtil.openStream(getClass(), ACCUMULO_OP_DECLARATIONS_JSON_PATH), OperationDeclarations.class);
    // Then
    final List<OperationDeclaration> deserialisedOps = deserialised.getOperations();
    final List<OperationDeclaration> expectedOps = Arrays.asList(new Builder().operation(GetJavaRDDOfElements.class).handler(new GetJavaRDDOfElementsHandler()).build(), new Builder().operation(GetRDDOfElements.class).handler(new GetRDDOfElementsHandler()).build(), new Builder().operation(GetRDDOfAllElements.class).handler(new GetRDDOfAllElementsHandler()).build(), new Builder().operation(GetJavaRDDOfAllElements.class).handler(new GetJavaRDDOfAllElementsHandler()).build(), new Builder().operation(GetDataFrameOfElements.class).handler(new GetDataFrameOfElementsHandler()).build(), new Builder().operation(ImportKeyValueJavaPairRDDToAccumulo.class).handler(new ImportKeyValueJavaPairRDDToAccumuloHandler()).build(), new Builder().operation(ImportJavaRDDOfElements.class).handler(new ImportJavaRDDOfElementsHandler()).build(), new Builder().operation(ImportKeyValuePairRDDToAccumulo.class).handler(new ImportKeyValuePairRDDToAccumuloHandler()).build(), new Builder().operation(ImportRDDOfElements.class).handler(new ImportRDDOfElementsHandler()).build(), new Builder().operation(GetGraphFrameOfElements.class).handler(new GetGraphFrameOfElementsHandler()).build(), new Builder().operation(GetJavaRDDOfElementsInRanges.class).handler(new GetJavaRDDOfElementsInRangesHandler()).build(), new Builder().operation(GetRDDOfElementsInRanges.class).handler(new GetRDDOfElementsInRangesHandler()).build(), new Builder().operation(SplitStoreFromJavaRDDOfElements.class).handler(new SplitStoreFromJavaRDDOfElementsHandler()).build(), new Builder().operation(SplitStoreFromRDDOfElements.class).handler(new SplitStoreFromRDDOfElementsHandler()).build());
    assertEquals(expectedOps.size(), deserialisedOps.size());
    for (int i = 0; i < expectedOps.size(); i++) {
        assertEquals(expectedOps.get(i).getOperation(), deserialisedOps.get(i).getOperation());
        assertEquals(expectedOps.get(i).getHandler().getClass(), deserialisedOps.get(i).getHandler().getClass());
    }
}
Also used : GetRDDOfAllElementsHandler(uk.gov.gchq.gaffer.sparkaccumulo.operation.handler.scalardd.GetRDDOfAllElementsHandler) SplitStoreFromJavaRDDOfElements(uk.gov.gchq.gaffer.spark.operation.javardd.SplitStoreFromJavaRDDOfElements) GetDataFrameOfElements(uk.gov.gchq.gaffer.spark.operation.dataframe.GetDataFrameOfElements) SplitStoreFromRDDOfElementsHandler(uk.gov.gchq.gaffer.sparkaccumulo.operation.handler.scalardd.SplitStoreFromRDDOfElementsHandler) SplitStoreFromJavaRDDOfElementsHandler(uk.gov.gchq.gaffer.sparkaccumulo.operation.handler.javardd.SplitStoreFromJavaRDDOfElementsHandler) Builder(uk.gov.gchq.gaffer.store.operation.declaration.OperationDeclaration.Builder) GetJavaRDDOfAllElements(uk.gov.gchq.gaffer.spark.operation.javardd.GetJavaRDDOfAllElements) ImportKeyValueJavaPairRDDToAccumuloHandler(uk.gov.gchq.gaffer.sparkaccumulo.operation.handler.javardd.ImportKeyValueJavaPairRDDToAccumuloHandler) OperationDeclaration(uk.gov.gchq.gaffer.store.operation.declaration.OperationDeclaration) GetGraphFrameOfElementsHandler(uk.gov.gchq.gaffer.spark.operation.handler.graphframe.GetGraphFrameOfElementsHandler) ImportRDDOfElements(uk.gov.gchq.gaffer.spark.operation.scalardd.ImportRDDOfElements) GetJavaRDDOfElementsHandler(uk.gov.gchq.gaffer.sparkaccumulo.operation.handler.javardd.GetJavaRDDOfElementsHandler) GetRDDOfAllElements(uk.gov.gchq.gaffer.spark.operation.scalardd.GetRDDOfAllElements) GetRDDOfElementsInRanges(uk.gov.gchq.gaffer.sparkaccumulo.operation.scalardd.GetRDDOfElementsInRanges) GetRDDOfElementsInRangesHandler(uk.gov.gchq.gaffer.sparkaccumulo.operation.handler.scalardd.GetRDDOfElementsInRangesHandler) ImportKeyValuePairRDDToAccumulo(uk.gov.gchq.gaffer.sparkaccumulo.operation.scalardd.ImportKeyValuePairRDDToAccumulo) GetJavaRDDOfElements(uk.gov.gchq.gaffer.spark.operation.javardd.GetJavaRDDOfElements) ImportJavaRDDOfElements(uk.gov.gchq.gaffer.spark.operation.javardd.ImportJavaRDDOfElements) GetGraphFrameOfElements(uk.gov.gchq.gaffer.spark.operation.graphframe.GetGraphFrameOfElements) GetJavaRDDOfElementsInRangesHandler(uk.gov.gchq.gaffer.sparkaccumulo.operation.handler.javardd.GetJavaRDDOfElementsInRangesHandler) OperationDeclarations(uk.gov.gchq.gaffer.store.operation.declaration.OperationDeclarations) GetRDDOfElements(uk.gov.gchq.gaffer.spark.operation.scalardd.GetRDDOfElements) SplitStoreFromRDDOfElements(uk.gov.gchq.gaffer.spark.operation.scalardd.SplitStoreFromRDDOfElements) GetDataFrameOfElementsHandler(uk.gov.gchq.gaffer.sparkaccumulo.operation.handler.dataframe.GetDataFrameOfElementsHandler) ImportKeyValuePairRDDToAccumuloHandler(uk.gov.gchq.gaffer.sparkaccumulo.operation.handler.scalardd.ImportKeyValuePairRDDToAccumuloHandler) ImportJavaRDDOfElementsHandler(uk.gov.gchq.gaffer.sparkaccumulo.operation.handler.javardd.ImportJavaRDDOfElementsHandler) ImportKeyValueJavaPairRDDToAccumulo(uk.gov.gchq.gaffer.sparkaccumulo.operation.javardd.ImportKeyValueJavaPairRDDToAccumulo) GetRDDOfElementsHandler(uk.gov.gchq.gaffer.sparkaccumulo.operation.handler.scalardd.GetRDDOfElementsHandler) ImportRDDOfElementsHandler(uk.gov.gchq.gaffer.sparkaccumulo.operation.handler.scalardd.ImportRDDOfElementsHandler) GetJavaRDDOfAllElementsHandler(uk.gov.gchq.gaffer.sparkaccumulo.operation.handler.javardd.GetJavaRDDOfAllElementsHandler) GetJavaRDDOfElementsInRanges(uk.gov.gchq.gaffer.sparkaccumulo.operation.javardd.GetJavaRDDOfElementsInRanges) Test(org.junit.jupiter.api.Test)

Example 4 with OperationDeclaration

use of uk.gov.gchq.gaffer.store.operation.declaration.OperationDeclaration in project Gaffer by gchq.

the class ExportToOtherAuthorisedGraphHandlerTest method shouldGetHandlerFromJson.

@Test
public void shouldGetHandlerFromJson() throws OperationException {
    // Given
    OperationDeclarations opDeclarations = OperationDeclarations.fromPaths("src/test/resources/ExportToOtherAuthorisedGraphOperationDeclarations.json");
    OperationDeclaration opDeclaration = opDeclarations.getOperations().get(0);
    OperationHandler handler = opDeclaration.getHandler();
    // When / Then
    assertThat(handler.getClass().getName()).contains("AuthorisedGraph");
}
Also used : OperationDeclarations(uk.gov.gchq.gaffer.store.operation.declaration.OperationDeclarations) OperationDeclaration(uk.gov.gchq.gaffer.store.operation.declaration.OperationDeclaration) OperationHandler(uk.gov.gchq.gaffer.store.operation.handler.OperationHandler) Test(org.junit.jupiter.api.Test)

Aggregations

Test (org.junit.jupiter.api.Test)4 OperationDeclaration (uk.gov.gchq.gaffer.store.operation.declaration.OperationDeclaration)4 OperationDeclarations (uk.gov.gchq.gaffer.store.operation.declaration.OperationDeclarations)4 GenerateElementsHandler (uk.gov.gchq.gaffer.store.operation.handler.generate.GenerateElementsHandler)2 GenerateElements (uk.gov.gchq.gaffer.operation.impl.generate.GenerateElements)1 GetDataFrameOfElements (uk.gov.gchq.gaffer.spark.operation.dataframe.GetDataFrameOfElements)1 GetGraphFrameOfElements (uk.gov.gchq.gaffer.spark.operation.graphframe.GetGraphFrameOfElements)1 GetGraphFrameOfElementsHandler (uk.gov.gchq.gaffer.spark.operation.handler.graphframe.GetGraphFrameOfElementsHandler)1 GetJavaRDDOfAllElements (uk.gov.gchq.gaffer.spark.operation.javardd.GetJavaRDDOfAllElements)1 GetJavaRDDOfElements (uk.gov.gchq.gaffer.spark.operation.javardd.GetJavaRDDOfElements)1 ImportJavaRDDOfElements (uk.gov.gchq.gaffer.spark.operation.javardd.ImportJavaRDDOfElements)1 SplitStoreFromJavaRDDOfElements (uk.gov.gchq.gaffer.spark.operation.javardd.SplitStoreFromJavaRDDOfElements)1 GetRDDOfAllElements (uk.gov.gchq.gaffer.spark.operation.scalardd.GetRDDOfAllElements)1 GetRDDOfElements (uk.gov.gchq.gaffer.spark.operation.scalardd.GetRDDOfElements)1 ImportRDDOfElements (uk.gov.gchq.gaffer.spark.operation.scalardd.ImportRDDOfElements)1 SplitStoreFromRDDOfElements (uk.gov.gchq.gaffer.spark.operation.scalardd.SplitStoreFromRDDOfElements)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 GetJavaRDDOfElementsInRangesHandler (uk.gov.gchq.gaffer.sparkaccumulo.operation.handler.javardd.GetJavaRDDOfElementsInRangesHandler)1