Search in sources :

Example 91 with StoreProperties

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);
}
Also used : Context(uk.gov.gchq.gaffer.store.Context) User(uk.gov.gchq.gaffer.user.User) OperationChain(uk.gov.gchq.gaffer.operation.OperationChain) ScoreOperationChain(uk.gov.gchq.gaffer.operation.impl.ScoreOperationChain) Store(uk.gov.gchq.gaffer.store.Store) StoreProperties(uk.gov.gchq.gaffer.store.StoreProperties) ScoreOperationChain(uk.gov.gchq.gaffer.operation.impl.ScoreOperationChain) HashSet(java.util.HashSet) Test(org.junit.jupiter.api.Test)

Example 92 with StoreProperties

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());
}
Also used : StoreProperties(uk.gov.gchq.gaffer.store.StoreProperties) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 93 with StoreProperties

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;
}
Also used : Context(uk.gov.gchq.gaffer.store.Context) StoreTrait(uk.gov.gchq.gaffer.store.StoreTrait) GetTraits(uk.gov.gchq.gaffer.store.operation.GetTraits) StoreProperties(uk.gov.gchq.gaffer.store.StoreProperties)

Example 94 with StoreProperties

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());
}
Also used : StoreProperties(uk.gov.gchq.gaffer.store.StoreProperties) NamedView(uk.gov.gchq.gaffer.data.elementdefinition.view.NamedView) View(uk.gov.gchq.gaffer.data.elementdefinition.view.View) AddNamedView(uk.gov.gchq.gaffer.named.view.AddNamedView) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 95 with 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);
}
Also used : InOrder(org.mockito.InOrder) GraphHook(uk.gov.gchq.gaffer.graph.hook.GraphHook) Schema(uk.gov.gchq.gaffer.store.schema.Schema) Store(uk.gov.gchq.gaffer.store.Store) TestStore(uk.gov.gchq.gaffer.integration.store.TestStore) CreateObject(uk.gov.gchq.koryphe.impl.function.CreateObject) StoreProperties(uk.gov.gchq.gaffer.store.StoreProperties) Test(org.junit.jupiter.api.Test)

Aggregations

StoreProperties (uk.gov.gchq.gaffer.store.StoreProperties)170 Test (org.junit.jupiter.api.Test)136 Schema (uk.gov.gchq.gaffer.store.schema.Schema)102 Store (uk.gov.gchq.gaffer.store.Store)74 Context (uk.gov.gchq.gaffer.store.Context)47 TestStore (uk.gov.gchq.gaffer.integration.store.TestStore)42 OperationChain (uk.gov.gchq.gaffer.operation.OperationChain)39 View (uk.gov.gchq.gaffer.data.elementdefinition.view.View)26 Graph (uk.gov.gchq.gaffer.graph.Graph)26 Operation (uk.gov.gchq.gaffer.operation.Operation)24 GetElements (uk.gov.gchq.gaffer.operation.impl.get.GetElements)21 OperationView (uk.gov.gchq.gaffer.operation.graph.OperationView)20 User (uk.gov.gchq.gaffer.user.User)18 NamedOperation (uk.gov.gchq.gaffer.named.operation.NamedOperation)17 BeforeEach (org.junit.jupiter.api.BeforeEach)16 GraphHook (uk.gov.gchq.gaffer.graph.hook.GraphHook)16 SchemaEdgeDefinition (uk.gov.gchq.gaffer.store.schema.SchemaEdgeDefinition)16 ExportToOtherGraph (uk.gov.gchq.gaffer.operation.export.graph.ExportToOtherGraph)14 HashSet (java.util.HashSet)13 FunctionAuthoriser (uk.gov.gchq.gaffer.graph.hook.FunctionAuthoriser)13