Search in sources :

Example 1 with GenerateObjectsHandler

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

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

the class StoreTest method shouldCreateStoreWithValidSchemasAndRegisterOperations.

@Test
public void shouldCreateStoreWithValidSchemasAndRegisterOperations() throws StoreException {
    // Given
    final StoreProperties properties = mock(StoreProperties.class);
    final StoreImpl store = new StoreImpl();
    final OperationHandler<AddElements, Void> 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);
    // When
    store.initialise(schema, properties);
    // Then
    assertNotNull(store.getOperationHandlerExposed(Validate.class));
    assertSame(addElementsHandlerOverridden, store.getOperationHandlerExposed(AddElements.class));
    assertSame(getAllElementsHandler, store.getOperationHandlerExposed(GetAllElements.class));
    assertSame(getAllElementsHandler, store.getOperationHandlerExposed(GetAllEntities.class));
    assertSame(getAllElementsHandler, store.getOperationHandlerExposed(GetAllEdges.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(Deduplicate.class) instanceof DeduplicateHandler);
    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(schema, true);
}
Also used : AddElements(uk.gov.gchq.gaffer.operation.impl.add.AddElements) GetAllEntities(uk.gov.gchq.gaffer.operation.impl.get.GetAllEntities) CountGroupsHandler(uk.gov.gchq.gaffer.store.operation.handler.CountGroupsHandler) GenerateObjectsHandler(uk.gov.gchq.gaffer.store.operation.handler.generate.GenerateObjectsHandler) OperationDeclaration(uk.gov.gchq.gaffer.store.operationdeclaration.OperationDeclaration) ExportToSetHandler(uk.gov.gchq.gaffer.store.operation.handler.export.set.ExportToSetHandler) GetSetExportHandler(uk.gov.gchq.gaffer.store.operation.handler.export.set.GetSetExportHandler) DeduplicateHandler(uk.gov.gchq.gaffer.store.operation.handler.DeduplicateHandler) Validate(uk.gov.gchq.gaffer.operation.impl.Validate) GetAllEdges(uk.gov.gchq.gaffer.operation.impl.get.GetAllEdges) 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.operationdeclaration.OperationDeclarations) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)2 GenerateElementsHandler (uk.gov.gchq.gaffer.store.operation.handler.generate.GenerateElementsHandler)2 GenerateObjectsHandler (uk.gov.gchq.gaffer.store.operation.handler.generate.GenerateObjectsHandler)2 OperationDeclaration (uk.gov.gchq.gaffer.store.operationdeclaration.OperationDeclaration)2 OperationDeclarations (uk.gov.gchq.gaffer.store.operationdeclaration.OperationDeclarations)2 Validate (uk.gov.gchq.gaffer.operation.impl.Validate)1 AddElements (uk.gov.gchq.gaffer.operation.impl.add.AddElements)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 CountGroupsHandler (uk.gov.gchq.gaffer.store.operation.handler.CountGroupsHandler)1 DeduplicateHandler (uk.gov.gchq.gaffer.store.operation.handler.DeduplicateHandler)1 ExportToSetHandler (uk.gov.gchq.gaffer.store.operation.handler.export.set.ExportToSetHandler)1 GetSetExportHandler (uk.gov.gchq.gaffer.store.operation.handler.export.set.GetSetExportHandler)1