Search in sources :

Example 1 with OperationDeclarations

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

Example 2 with OperationDeclarations

use of uk.gov.gchq.gaffer.store.operation.declaration.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 = 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 OperationDeclarations

use of uk.gov.gchq.gaffer.store.operation.declaration.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 : ToStringBuilder(uk.gov.gchq.gaffer.commonutil.ToStringBuilder) HashCodeBuilder(org.apache.commons.lang3.builder.HashCodeBuilder) EqualsBuilder(org.apache.commons.lang3.builder.EqualsBuilder) OperationDeclarations(uk.gov.gchq.gaffer.store.operation.declaration.OperationDeclarations) JsonIgnore(com.fasterxml.jackson.annotation.JsonIgnore)

Example 4 with OperationDeclarations

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

the class GetFromEndpointHandlerTest method shouldLoadOperationDeclarations.

@Test
public void shouldLoadOperationDeclarations() throws IOException {
    // When
    InputStream stream = StreamUtil.openStream(GetFromEndpointHandler.class, "GetFromEndpointOperationDeclarations.json");
    // Given
    OperationDeclarations opDeclarations = JSONSerialiser.deserialise(IOUtils.toByteArray(stream), OperationDeclarations.class);
    // Then
    assertEquals(1, opDeclarations.getOperations().size());
    assertEquals(GetFromEndpoint.class, opDeclarations.getOperations().get(0).getOperation());
    assertEquals(GetFromEndpointHandler.class, opDeclarations.getOperations().get(0).getHandler().getClass());
}
Also used : InputStream(java.io.InputStream) OperationDeclarations(uk.gov.gchq.gaffer.store.operation.declaration.OperationDeclarations) Test(org.junit.jupiter.api.Test)

Example 5 with OperationDeclarations

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

Aggregations

OperationDeclarations (uk.gov.gchq.gaffer.store.operation.declaration.OperationDeclarations)8 Test (org.junit.jupiter.api.Test)7 OperationDeclaration (uk.gov.gchq.gaffer.store.operation.declaration.OperationDeclaration)5 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 EqualsBuilder (org.apache.commons.lang3.builder.EqualsBuilder)1 HashCodeBuilder (org.apache.commons.lang3.builder.HashCodeBuilder)1 ToStringBuilder (uk.gov.gchq.gaffer.commonutil.ToStringBuilder)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 GetAllElements (uk.gov.gchq.gaffer.operation.impl.get.GetAllElements)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