Search in sources :

Example 6 with OperationDeclarations

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

the class NamedOperationHandlerTest method shouldLoadCacheFromOperationsDeclarationsFile.

@Test
public void shouldLoadCacheFromOperationsDeclarationsFile() throws SerialisationException {
    final InputStream s = StreamUtil.openStream(getClass(), "NamedOperationDeclarations.json");
    final OperationDeclarations deserialised = json.deserialise(s, OperationDeclarations.class);
    INamedOperationCache cache = ((AddNamedOperationHandler) deserialised.getOperations().get(0).getHandler()).getCache();
    assert (cache instanceof MockNamedOperationCache);
}
Also used : InputStream(java.io.InputStream) MockNamedOperationCache(uk.gov.gchq.gaffer.named.operation.cache.MockNamedOperationCache) INamedOperationCache(uk.gov.gchq.gaffer.named.operation.cache.INamedOperationCache) OperationDeclarations(uk.gov.gchq.gaffer.store.operationdeclaration.OperationDeclarations) Test(org.junit.Test)

Example 7 with OperationDeclarations

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

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