Search in sources :

Example 1 with GenerateElementsHandler

use of uk.gov.gchq.gaffer.store.operation.handler.generate.GenerateElementsHandler 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 GenerateElementsHandler

use of uk.gov.gchq.gaffer.store.operation.handler.generate.GenerateElementsHandler 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 GenerateElementsHandler

use of uk.gov.gchq.gaffer.store.operation.handler.generate.GenerateElementsHandler in project Gaffer by gchq.

the class AccumuloStoreTest method testStoreReturnsHandlersForRegisteredOperations.

public void testStoreReturnsHandlersForRegisteredOperations(final AccumuloStore store) {
    OperationHandler op;
    // Then
    assertNotNull(store.getOperationHandler(Validate.class));
    op = store.getOperationHandler(AddElementsFromHdfs.class);
    assertTrue(op instanceof AddElementsFromHdfsHandler);
    op = store.getOperationHandler(GetElementsBetweenSets.class);
    assertTrue(op instanceof GetElementsBetweenSetsHandler);
    op = store.getOperationHandler(GetElementsInRanges.class);
    assertTrue(op instanceof GetElementsInRangesHandler);
    op = store.getOperationHandler(GetElementsWithinSet.class);
    assertTrue(op instanceof GetElementsWithinSetHandler);
    op = store.getOperationHandler(SplitStore.class);
    assertTrue(op instanceof SplitStoreHandler);
    op = store.getOperationHandler(SampleDataForSplitPoints.class);
    assertTrue(op instanceof SampleDataForSplitPointsHandler);
    op = store.getOperationHandler(ImportAccumuloKeyValueFiles.class);
    assertTrue(op instanceof ImportAccumuloKeyValueFilesHandler);
    op = store.getOperationHandler(GenerateElements.class);
    assertTrue(op instanceof GenerateElementsHandler);
    op = store.getOperationHandler(GenerateObjects.class);
    assertTrue(op instanceof GenerateObjectsHandler);
}
Also used : SplitStore(uk.gov.gchq.gaffer.operation.impl.SplitStore) AddElementsFromHdfs(uk.gov.gchq.gaffer.hdfs.operation.AddElementsFromHdfs) ImportAccumuloKeyValueFiles(uk.gov.gchq.gaffer.accumulostore.operation.hdfs.operation.ImportAccumuloKeyValueFiles) GetElementsBetweenSets(uk.gov.gchq.gaffer.accumulostore.operation.impl.GetElementsBetweenSets) GenerateElements(uk.gov.gchq.gaffer.operation.impl.generate.GenerateElements) SampleDataForSplitPointsHandler(uk.gov.gchq.gaffer.accumulostore.operation.hdfs.handler.SampleDataForSplitPointsHandler) GetElementsInRanges(uk.gov.gchq.gaffer.accumulostore.operation.impl.GetElementsInRanges) GetElementsBetweenSetsHandler(uk.gov.gchq.gaffer.accumulostore.operation.handler.GetElementsBetweenSetsHandler) GenerateObjectsHandler(uk.gov.gchq.gaffer.store.operation.handler.generate.GenerateObjectsHandler) GenerateObjects(uk.gov.gchq.gaffer.operation.impl.generate.GenerateObjects) SplitStoreHandler(uk.gov.gchq.gaffer.accumulostore.operation.hdfs.handler.SplitStoreHandler) Validate(uk.gov.gchq.gaffer.operation.impl.Validate) ImportAccumuloKeyValueFilesHandler(uk.gov.gchq.gaffer.accumulostore.operation.hdfs.handler.ImportAccumuloKeyValueFilesHandler) GetElementsWithinSetHandler(uk.gov.gchq.gaffer.accumulostore.operation.handler.GetElementsWithinSetHandler) GetElementsWithinSet(uk.gov.gchq.gaffer.accumulostore.operation.impl.GetElementsWithinSet) GenerateElementsHandler(uk.gov.gchq.gaffer.store.operation.handler.generate.GenerateElementsHandler) AddElementsFromHdfsHandler(uk.gov.gchq.gaffer.accumulostore.operation.hdfs.handler.AddElementsFromHdfsHandler) GetElementsInRangesHandler(uk.gov.gchq.gaffer.accumulostore.operation.handler.GetElementsInRangesHandler) SampleDataForSplitPoints(uk.gov.gchq.gaffer.hdfs.operation.SampleDataForSplitPoints) OperationHandler(uk.gov.gchq.gaffer.store.operation.handler.OperationHandler)

Example 4 with GenerateElementsHandler

use of uk.gov.gchq.gaffer.store.operation.handler.generate.GenerateElementsHandler in project Gaffer by gchq.

the class StoreTest method shouldCreateStoreWithValidSchemasAndRegisterOperations.

@Test
public void shouldCreateStoreWithValidSchemasAndRegisterOperations() throws StoreException {
    // Given
    final StoreProperties properties = mock(StoreProperties.class);
    final OperationHandler<AddElements> addElementsHandlerOverridden = mock(OperationHandler.class);
    final OperationDeclarations opDeclarations = new OperationDeclarations.Builder().declaration(new OperationDeclaration.Builder().operation(AddElements.class).handler(addElementsHandlerOverridden).build()).build();
    given(properties.getOperationDeclarations()).willReturn(opDeclarations);
    given(properties.getJobExecutorThreadCount()).willReturn(1);
    // When
    store.initialise("graphId", schema, properties);
    // Then
    assertNotNull(store.getOperationHandlerExposed(Validate.class));
    assertSame(addElementsHandlerOverridden, store.getOperationHandlerExposed(AddElements.class));
    assertSame(getAllElementsHandler, store.getOperationHandlerExposed(GetAllElements.class));
    assertTrue(store.getOperationHandlerExposed(GenerateElements.class) instanceof GenerateElementsHandler);
    assertTrue(store.getOperationHandlerExposed(GenerateObjects.class) instanceof GenerateObjectsHandler);
    assertTrue(store.getOperationHandlerExposed(CountGroups.class) instanceof CountGroupsHandler);
    assertTrue(store.getOperationHandlerExposed(ToSet.class) instanceof ToSetHandler);
    assertTrue(store.getOperationHandlerExposed(ExportToSet.class) instanceof ExportToSetHandler);
    assertTrue(store.getOperationHandlerExposed(GetSetExport.class) instanceof GetSetExportHandler);
    assertEquals(1, store.getCreateOperationHandlersCallCount());
    assertSame(schema, store.getSchema());
    assertSame(properties, store.getProperties());
    verify(schemaOptimiser).optimise(store.getSchema(), true);
}
Also used : AddElements(uk.gov.gchq.gaffer.operation.impl.add.AddElements) CountGroupsHandler(uk.gov.gchq.gaffer.store.operation.handler.CountGroupsHandler) ToSetHandler(uk.gov.gchq.gaffer.store.operation.handler.output.ToSetHandler) ExportToSetHandler(uk.gov.gchq.gaffer.store.operation.handler.export.set.ExportToSetHandler) GenerateObjectsHandler(uk.gov.gchq.gaffer.store.operation.handler.generate.GenerateObjectsHandler) OperationDeclaration(uk.gov.gchq.gaffer.store.operation.declaration.OperationDeclaration) ExportToSetHandler(uk.gov.gchq.gaffer.store.operation.handler.export.set.ExportToSetHandler) GetSetExportHandler(uk.gov.gchq.gaffer.store.operation.handler.export.set.GetSetExportHandler) Validate(uk.gov.gchq.gaffer.operation.impl.Validate) GetAllElements(uk.gov.gchq.gaffer.operation.impl.get.GetAllElements) GenerateElementsHandler(uk.gov.gchq.gaffer.store.operation.handler.generate.GenerateElementsHandler) OperationDeclarations(uk.gov.gchq.gaffer.store.operation.declaration.OperationDeclarations) Test(org.junit.jupiter.api.Test)

Aggregations

GenerateElementsHandler (uk.gov.gchq.gaffer.store.operation.handler.generate.GenerateElementsHandler)4 Test (org.junit.jupiter.api.Test)3 OperationDeclaration (uk.gov.gchq.gaffer.store.operation.declaration.OperationDeclaration)3 OperationDeclarations (uk.gov.gchq.gaffer.store.operation.declaration.OperationDeclarations)3 GenerateObjectsHandler (uk.gov.gchq.gaffer.store.operation.handler.generate.GenerateObjectsHandler)3 Validate (uk.gov.gchq.gaffer.operation.impl.Validate)2 GenerateElements (uk.gov.gchq.gaffer.operation.impl.generate.GenerateElements)2 GetElementsBetweenSetsHandler (uk.gov.gchq.gaffer.accumulostore.operation.handler.GetElementsBetweenSetsHandler)1 GetElementsInRangesHandler (uk.gov.gchq.gaffer.accumulostore.operation.handler.GetElementsInRangesHandler)1 GetElementsWithinSetHandler (uk.gov.gchq.gaffer.accumulostore.operation.handler.GetElementsWithinSetHandler)1 AddElementsFromHdfsHandler (uk.gov.gchq.gaffer.accumulostore.operation.hdfs.handler.AddElementsFromHdfsHandler)1 ImportAccumuloKeyValueFilesHandler (uk.gov.gchq.gaffer.accumulostore.operation.hdfs.handler.ImportAccumuloKeyValueFilesHandler)1 SampleDataForSplitPointsHandler (uk.gov.gchq.gaffer.accumulostore.operation.hdfs.handler.SampleDataForSplitPointsHandler)1 SplitStoreHandler (uk.gov.gchq.gaffer.accumulostore.operation.hdfs.handler.SplitStoreHandler)1 ImportAccumuloKeyValueFiles (uk.gov.gchq.gaffer.accumulostore.operation.hdfs.operation.ImportAccumuloKeyValueFiles)1 GetElementsBetweenSets (uk.gov.gchq.gaffer.accumulostore.operation.impl.GetElementsBetweenSets)1 GetElementsInRanges (uk.gov.gchq.gaffer.accumulostore.operation.impl.GetElementsInRanges)1 GetElementsWithinSet (uk.gov.gchq.gaffer.accumulostore.operation.impl.GetElementsWithinSet)1 AddElementsFromHdfs (uk.gov.gchq.gaffer.hdfs.operation.AddElementsFromHdfs)1 SampleDataForSplitPoints (uk.gov.gchq.gaffer.hdfs.operation.SampleDataForSplitPoints)1