use of uk.gov.gchq.gaffer.store.StoreProperties in project Gaffer by gchq.
the class ScoreOperationChainHandlerTest method shouldReturnZeroForANullOperationChain.
@Test
public void shouldReturnZeroForANullOperationChain() throws OperationException {
// Given
final ScoreOperationChainHandler handler = new ScoreOperationChainHandler();
final Context context = mock(Context.class);
final Store store = mock(Store.class);
final User user = mock(User.class);
final ScoreOperationChain scoreOperationChain = mock(ScoreOperationChain.class);
final StoreProperties properties = mock(StoreProperties.class);
final OperationChain opChain = null;
given(scoreOperationChain.getOperationChain()).willReturn(opChain);
given(context.getUser()).willReturn(user);
Set<String> opAuths = new HashSet<>();
opAuths.add("TEST_USER");
given(user.getOpAuths()).willReturn(opAuths);
given(store.getProperties()).willReturn(properties);
// When
final Object result = handler.doOperation(new ScoreOperationChain.Builder().operationChain(opChain).build(), context, store);
// Then
assertEquals(0, result);
}
use of uk.gov.gchq.gaffer.store.StoreProperties in project Gaffer by gchq.
the class GetAllNamedOperationsHandlerTest method before.
@BeforeEach
public void before() {
given(store.getProperties()).willReturn(new StoreProperties());
StoreProperties properties = new StoreProperties();
properties.set("gaffer.cache.service.class", "uk.gov.gchq.gaffer.cache.impl.HashMapCacheService");
CacheServiceLoader.initialise(properties.getProperties());
}
use of uk.gov.gchq.gaffer.store.StoreProperties in project Gaffer by gchq.
the class GetTraitsHandlerTest method getStoreTraits.
private Set<StoreTrait> getStoreTraits(final Schema schema) throws StoreException, uk.gov.gchq.gaffer.operation.OperationException {
store.initialise(STORE_ID, schema, new StoreProperties());
Set<StoreTrait> execute = store.execute(new GetTraits.Builder().currentTraits(true).build(), new Context(testUser()));
final Set<StoreTrait> actual = Sets.newHashSet(execute);
assertFalse(actual.isEmpty());
return actual;
}
use of uk.gov.gchq.gaffer.store.StoreProperties in project Gaffer by gchq.
the class AddNamedViewHandlerTest method before.
@BeforeEach
public void before() {
testParameters.put("testParam", TEST_PARAM_VALUE);
view = new View.Builder().edge(TestGroups.EDGE).build();
addNamedView = new AddNamedView.Builder().name(testNamedViewName).view(view).overwrite(false).writeAccessRoles(writeAccessRoles).build();
StoreProperties properties = new StoreProperties();
properties.set("gaffer.cache.service.class", "uk.gov.gchq.gaffer.cache.impl.HashMapCacheService");
CacheServiceLoader.initialise(properties.getProperties());
given(store.getProperties()).willReturn(new StoreProperties());
}
use of uk.gov.gchq.gaffer.store.StoreProperties in project Gaffer by gchq.
the class GraphTest method shouldCallAllGraphHooksAfterOperationChainExecuted.
@Test
public void shouldCallAllGraphHooksAfterOperationChainExecuted() throws OperationException {
// Given
final GraphHook hook1 = mock(GraphHook.class);
final GraphHook hook2 = mock(GraphHook.class);
final Store store = mock(Store.class);
final Schema schema = new Schema();
final Object result1 = mock(Object.class);
final Object result2 = mock(Object.class);
final Object result3 = mock(Object.class);
given(store.getSchema()).willReturn(schema);
given(store.getProperties()).willReturn(new StoreProperties());
given(hook1.postExecute(result1, clonedOpChain, clonedContext)).willReturn(result2);
given(hook2.postExecute(result2, clonedOpChain, clonedContext)).willReturn(result3);
final Graph graph = new Graph.Builder().config(new GraphConfig.Builder().graphId(GRAPH_ID).addHook(hook1).addHook(hook2).build()).storeProperties(StreamUtil.storeProps(getClass())).store(store).addSchema(schema).build();
given(store.execute(clonedOpChain, clonedContext)).willReturn(result1);
// When
final Object actualResult = graph.execute(opChain, context);
// Then
final InOrder inOrder = inOrder(hook1, hook2);
inOrder.verify(hook1).postExecute(result1, clonedOpChain, clonedContext);
inOrder.verify(hook2).postExecute(result2, clonedOpChain, clonedContext);
assertSame(actualResult, result3);
verify(context).setOriginalOpChain(opChain);
}
Aggregations