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);
}
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());
}
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());
}
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());
}
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());
}
Aggregations