Search in sources :

Example 1 with Log4jLogger

use of uk.gov.gchq.gaffer.graph.hook.Log4jLogger in project Gaffer by gchq.

the class FederatedAddGraphWithHooksHandlerTest method shouldAddGraphWithHooks.

@Test
public void shouldAddGraphWithHooks() throws Exception {
    store.initialise(FEDERATEDSTORE_GRAPH_ID, null, federatedStoreProperties);
    Schema expectedSchema = new Schema.Builder().build();
    assertEquals(0, store.getGraphs(testUser, null, ignore).size());
    FederatedAddGraphWithHooksHandler federatedAddGraphHandler = new FederatedAddGraphWithHooksHandler();
    federatedAddGraphHandler.doOperation(new AddGraphWithHooks.Builder().graphId(EXPECTED_GRAPH_ID).schema(expectedSchema).storeProperties(PROPERTIES).hooks(new Log4jLogger()).build(), new Context(testUser), store);
    Collection<Graph> graphs = store.getGraphs(testUser, null, ignore);
    List<Class<? extends GraphHook>> graphHooks = graphs.iterator().next().getGraphHooks();
    assertThat(graphHooks).contains(Log4jLogger.class);
}
Also used : Context(uk.gov.gchq.gaffer.store.Context) Graph(uk.gov.gchq.gaffer.graph.Graph) GraphHook(uk.gov.gchq.gaffer.graph.hook.GraphHook) Schema(uk.gov.gchq.gaffer.store.schema.Schema) Log4jLogger(uk.gov.gchq.gaffer.graph.hook.Log4jLogger) Test(org.junit.jupiter.api.Test)

Example 2 with Log4jLogger

use of uk.gov.gchq.gaffer.graph.hook.Log4jLogger in project Gaffer by gchq.

the class AddGraphWithHooksTest method builderShouldCreatePopulatedOperation.

@Test
@Override
public void builderShouldCreatePopulatedOperation() {
    Schema expectedSchema = new Schema.Builder().build();
    StoreProperties storeProperties = new AccumuloProperties();
    Log4jLogger log4jLogger = new Log4jLogger();
    AddGraphWithHooks op = new Builder().graphId(EXPECTED_GRAPH_ID).schema(expectedSchema).storeProperties(storeProperties).hooks(log4jLogger).readAccessPredicate(READ_ACCESS_PREDICATE).writeAccessPredicate(WRITE_ACCESS_PREDICATE).build();
    assertEquals(EXPECTED_GRAPH_ID, op.getGraphId());
    assertEquals(expectedSchema, op.getSchema());
    assertNotNull(op.getStoreProperties().getStorePropertiesClassName());
    assertEquals(AccumuloProperties.class, op.getStoreProperties().getStorePropertiesClass());
    assertThat(op.getHooks()).hasSize(1);
    assertEquals(log4jLogger, op.getHooks()[0]);
    assertEquals(READ_ACCESS_PREDICATE, op.getReadAccessPredicate());
    assertEquals(WRITE_ACCESS_PREDICATE, op.getWriteAccessPredicate());
}
Also used : AccumuloProperties(uk.gov.gchq.gaffer.accumulostore.AccumuloProperties) Schema(uk.gov.gchq.gaffer.store.schema.Schema) Builder(uk.gov.gchq.gaffer.federatedstore.operation.AddGraphWithHooks.Builder) StoreProperties(uk.gov.gchq.gaffer.store.StoreProperties) Log4jLogger(uk.gov.gchq.gaffer.graph.hook.Log4jLogger) OperationTest(uk.gov.gchq.gaffer.operation.OperationTest) Test(org.junit.jupiter.api.Test)

Example 3 with Log4jLogger

use of uk.gov.gchq.gaffer.graph.hook.Log4jLogger in project Gaffer by gchq.

the class GraphTest method shouldAddHooksVarArgsAndGetGraphHooks.

@Test
public void shouldAddHooksVarArgsAndGetGraphHooks() throws Exception {
    // Given
    final StoreProperties storeProperties = new StoreProperties();
    storeProperties.setStoreClass(TestStoreImpl.class.getName());
    final GraphHook graphHook1 = mock(GraphHook.class);
    final Log4jLogger graphHook2 = mock(Log4jLogger.class);
    // When
    final Graph graph = new Graph.Builder().config(new GraphConfig.Builder().graphId("graphId").addHooks(graphHook1, graphHook2).build()).storeProperties(storeProperties).addSchemas(StreamUtil.schemas(getClass())).build();
    // Then
    assertEquals(Arrays.asList(NamedViewResolver.class, graphHook1.getClass(), graphHook2.getClass(), FunctionAuthoriser.class), graph.getGraphHooks());
}
Also used : GraphHook(uk.gov.gchq.gaffer.graph.hook.GraphHook) StoreProperties(uk.gov.gchq.gaffer.store.StoreProperties) NamedViewResolver(uk.gov.gchq.gaffer.graph.hook.NamedViewResolver) Log4jLogger(uk.gov.gchq.gaffer.graph.hook.Log4jLogger) FunctionAuthoriser(uk.gov.gchq.gaffer.graph.hook.FunctionAuthoriser) Test(org.junit.jupiter.api.Test)

Example 4 with Log4jLogger

use of uk.gov.gchq.gaffer.graph.hook.Log4jLogger in project Gaffer by gchq.

the class GraphTest method shouldAddHookAndGetGraphHooks.

@Test
public void shouldAddHookAndGetGraphHooks() throws Exception {
    // Given
    final StoreProperties storeProperties = new StoreProperties();
    storeProperties.setStoreClass(TestStore.class.getName());
    TestStore.mockStore = mock(Store.class);
    given(TestStore.mockStore.isSupported(NamedOperation.class)).willReturn(true);
    final GraphHook graphHook1 = mock(GraphHook.class);
    final NamedOperationResolver graphHook2 = new NamedOperationResolver();
    final Log4jLogger graphHook3 = mock(Log4jLogger.class);
    // When
    final Graph graph = new Graph.Builder().graphId("graphId").storeProperties(storeProperties).addSchemas(StreamUtil.schemas(getClass())).addHook(graphHook1).addHook(graphHook2).addHook(graphHook3).build();
    // Then
    assertEquals(Arrays.asList(NamedViewResolver.class, graphHook1.getClass(), graphHook2.getClass(), graphHook3.getClass(), FunctionAuthoriser.class), graph.getGraphHooks());
}
Also used : NamedOperationResolver(uk.gov.gchq.gaffer.graph.hook.NamedOperationResolver) GraphHook(uk.gov.gchq.gaffer.graph.hook.GraphHook) Store(uk.gov.gchq.gaffer.store.Store) TestStore(uk.gov.gchq.gaffer.integration.store.TestStore) StoreProperties(uk.gov.gchq.gaffer.store.StoreProperties) NamedViewResolver(uk.gov.gchq.gaffer.graph.hook.NamedViewResolver) TestStore(uk.gov.gchq.gaffer.integration.store.TestStore) Log4jLogger(uk.gov.gchq.gaffer.graph.hook.Log4jLogger) FunctionAuthoriser(uk.gov.gchq.gaffer.graph.hook.FunctionAuthoriser) Test(org.junit.jupiter.api.Test)

Example 5 with Log4jLogger

use of uk.gov.gchq.gaffer.graph.hook.Log4jLogger in project Gaffer by gchq.

the class GraphTest method shouldAddNamedViewResolverHookAfterNamedOperationResolver.

@Test
public void shouldAddNamedViewResolverHookAfterNamedOperationResolver() throws Exception {
    // Given
    final StoreProperties storeProperties = new StoreProperties();
    storeProperties.setStoreClass(TestStore.class.getName());
    TestStore.mockStore = mock(Store.class);
    given(TestStore.mockStore.isSupported(NamedOperation.class)).willReturn(true);
    final GraphHook graphHook1 = mock(GraphHook.class);
    final Log4jLogger graphHook2 = mock(Log4jLogger.class);
    // When
    final Graph graph = new Graph.Builder().config(new GraphConfig.Builder().graphId("graphId").addHook(graphHook1).addHook(graphHook2).build()).storeProperties(storeProperties).addSchemas(StreamUtil.schemas(getClass())).build();
    // Then
    assertEquals(Arrays.asList(NamedOperationResolver.class, NamedViewResolver.class, graphHook1.getClass(), graphHook2.getClass(), FunctionAuthoriser.class), graph.getGraphHooks());
}
Also used : NamedOperationResolver(uk.gov.gchq.gaffer.graph.hook.NamedOperationResolver) GraphHook(uk.gov.gchq.gaffer.graph.hook.GraphHook) Store(uk.gov.gchq.gaffer.store.Store) TestStore(uk.gov.gchq.gaffer.integration.store.TestStore) StoreProperties(uk.gov.gchq.gaffer.store.StoreProperties) NamedViewResolver(uk.gov.gchq.gaffer.graph.hook.NamedViewResolver) TestStore(uk.gov.gchq.gaffer.integration.store.TestStore) Log4jLogger(uk.gov.gchq.gaffer.graph.hook.Log4jLogger) FunctionAuthoriser(uk.gov.gchq.gaffer.graph.hook.FunctionAuthoriser) Test(org.junit.jupiter.api.Test)

Aggregations

Test (org.junit.jupiter.api.Test)6 Log4jLogger (uk.gov.gchq.gaffer.graph.hook.Log4jLogger)6 StoreProperties (uk.gov.gchq.gaffer.store.StoreProperties)5 GraphHook (uk.gov.gchq.gaffer.graph.hook.GraphHook)4 FunctionAuthoriser (uk.gov.gchq.gaffer.graph.hook.FunctionAuthoriser)3 NamedViewResolver (uk.gov.gchq.gaffer.graph.hook.NamedViewResolver)3 Schema (uk.gov.gchq.gaffer.store.schema.Schema)3 Builder (uk.gov.gchq.gaffer.federatedstore.operation.AddGraphWithHooks.Builder)2 NamedOperationResolver (uk.gov.gchq.gaffer.graph.hook.NamedOperationResolver)2 TestStore (uk.gov.gchq.gaffer.integration.store.TestStore)2 OperationTest (uk.gov.gchq.gaffer.operation.OperationTest)2 Store (uk.gov.gchq.gaffer.store.Store)2 AccumuloProperties (uk.gov.gchq.gaffer.accumulostore.AccumuloProperties)1 Graph (uk.gov.gchq.gaffer.graph.Graph)1 Context (uk.gov.gchq.gaffer.store.Context)1