Search in sources :

Example 26 with FederatedStore

use of uk.gov.gchq.gaffer.federatedstore.FederatedStore in project Gaffer by gchq.

the class FederatedRemoveGraphHandlerTest method shouldNotRemoveGraphConfiguredWithNoAccessWritePredicate.

@Test
public void shouldNotRemoveGraphConfiguredWithNoAccessWritePredicate() throws Exception {
    FederatedStore store = new FederatedStore();
    final FederatedStoreProperties federatedStoreProperties = new FederatedStoreProperties();
    federatedStoreProperties.setCacheProperties(CACHE_SERVICE_CLASS_STRING);
    store.initialise(FEDERATEDSTORE_GRAPH_ID, null, federatedStoreProperties);
    final AccessPredicate noAccessPredicate = new NoAccessPredicate();
    store.addGraphs(testUser.getOpAuths(), "other", false, false, null, noAccessPredicate, new GraphSerialisable.Builder().config(new GraphConfig(EXPECTED_GRAPH_ID)).schema(new Schema.Builder().build()).properties(PROPERTIES).build());
    assertEquals(1, store.getGraphs(testUser, null, ignore).size());
    new FederatedRemoveGraphHandler().doOperation(new RemoveGraph.Builder().graphId(EXPECTED_GRAPH_ID).build(), new Context(testUser), store);
    Collection<Graph> graphs = store.getGraphs(testUser, null, ignore);
    assertThat(graphs).hasSize(1);
}
Also used : Context(uk.gov.gchq.gaffer.store.Context) NoAccessPredicate(uk.gov.gchq.gaffer.access.predicate.NoAccessPredicate) FederatedStoreProperties(uk.gov.gchq.gaffer.federatedstore.FederatedStoreProperties) Schema(uk.gov.gchq.gaffer.store.schema.Schema) GraphConfig(uk.gov.gchq.gaffer.graph.GraphConfig) Graph(uk.gov.gchq.gaffer.graph.Graph) RemoveGraph(uk.gov.gchq.gaffer.federatedstore.operation.RemoveGraph) GraphSerialisable(uk.gov.gchq.gaffer.graph.GraphSerialisable) NoAccessPredicate(uk.gov.gchq.gaffer.access.predicate.NoAccessPredicate) AccessPredicate(uk.gov.gchq.gaffer.access.predicate.AccessPredicate) RemoveGraph(uk.gov.gchq.gaffer.federatedstore.operation.RemoveGraph) FederatedStore(uk.gov.gchq.gaffer.federatedstore.FederatedStore) Test(org.junit.jupiter.api.Test)

Example 27 with FederatedStore

use of uk.gov.gchq.gaffer.federatedstore.FederatedStore in project Gaffer by gchq.

the class FederatedOperationChainHandlerTest method shouldHandleChainWithExtraLimit.

@Test
public void shouldHandleChainWithExtraLimit() throws OperationException {
    // Given
    final FederatedStore store = createStore();
    final Context context = new Context();
    final OperationChain<Iterable<? extends Element>> opChain = new OperationChain.Builder().first(new FederatedOperationChain.Builder<Void, Element>().operationChain(new OperationChain.Builder().first(new GetAllElements()).then(new Limit<>(1)).build()).option(KEY_OPERATION_OPTIONS_GRAPH_IDS, GRAPH_IDS).build()).then(new Limit<>(1)).build();
    // When
    final Iterable result = store.execute(opChain, context);
    // Then - the result will contain 1 element from the first graph
    ElementUtil.assertElementEquals(Collections.singletonList(elements[0]), result);
}
Also used : Context(uk.gov.gchq.gaffer.store.Context) CloseableIterable(uk.gov.gchq.gaffer.commonutil.iterable.CloseableIterable) Element(uk.gov.gchq.gaffer.data.element.Element) FederatedOperationChain(uk.gov.gchq.gaffer.federatedstore.operation.FederatedOperationChain) OperationChain(uk.gov.gchq.gaffer.operation.OperationChain) GetAllElements(uk.gov.gchq.gaffer.operation.impl.get.GetAllElements) Limit(uk.gov.gchq.gaffer.operation.impl.Limit) FederatedStore(uk.gov.gchq.gaffer.federatedstore.FederatedStore) PredefinedFederatedStore(uk.gov.gchq.gaffer.federatedstore.PredefinedFederatedStore) Test(org.junit.jupiter.api.Test)

Example 28 with FederatedStore

use of uk.gov.gchq.gaffer.federatedstore.FederatedStore in project Gaffer by gchq.

the class FederatedOperationChainHandlerTest method shouldHandleChainWithNoOutput.

@Test
public void shouldHandleChainWithNoOutput() throws OperationException {
    // Given
    final FederatedStore store = createStore();
    final Context context = new Context();
    final FederatedOperationChain<Object, Void> opChain = new FederatedOperationChain.Builder<Object, Void>().operationChain(new OperationChain.Builder().first(new AddElements.Builder().input(elements2).build()).build()).option(KEY_OPERATION_OPTIONS_GRAPH_IDS, GRAPH_IDS).build();
    // When
    final Iterable result = store.execute(opChain, context);
    // Then
    assertNull(result);
    final CloseableIterable<? extends Element> allElements = store.execute(new GetAllElements(), context);
    ElementUtil.assertElementEquals(Arrays.asList(elements[0], elements[1], elements2[0], elements2[1]), allElements);
}
Also used : Context(uk.gov.gchq.gaffer.store.Context) AddElements(uk.gov.gchq.gaffer.operation.impl.add.AddElements) FederatedOperationChain(uk.gov.gchq.gaffer.federatedstore.operation.FederatedOperationChain) CloseableIterable(uk.gov.gchq.gaffer.commonutil.iterable.CloseableIterable) FederatedOperationChain(uk.gov.gchq.gaffer.federatedstore.operation.FederatedOperationChain) OperationChain(uk.gov.gchq.gaffer.operation.OperationChain) GetAllElements(uk.gov.gchq.gaffer.operation.impl.get.GetAllElements) FederatedStore(uk.gov.gchq.gaffer.federatedstore.FederatedStore) PredefinedFederatedStore(uk.gov.gchq.gaffer.federatedstore.PredefinedFederatedStore) Test(org.junit.jupiter.api.Test)

Example 29 with FederatedStore

use of uk.gov.gchq.gaffer.federatedstore.FederatedStore in project Gaffer by gchq.

the class FederatedOperationChainHandlerTest method createStore.

private FederatedStore createStore() throws OperationException {
    final Schema schema = new Schema.Builder().entity(TestGroups.ENTITY, new SchemaEntityDefinition.Builder().vertex(TestTypes.ID_STRING).aggregate(false).build()).edge(TestGroups.EDGE, new SchemaEdgeDefinition.Builder().source(TestTypes.ID_STRING).destination(TestTypes.ID_STRING).directed(TestTypes.DIRECTED_TRUE).aggregate(false).build()).type(TestTypes.ID_STRING, new TypeDefinition.Builder().clazz(String.class).build()).type(TestTypes.DIRECTED_TRUE, new TypeDefinition.Builder().clazz(Boolean.class).validateFunctions(new IsTrue()).build()).build();
    final FederatedStore store = (FederatedStore) Store.createStore("federatedGraph", schema, StoreProperties.loadStoreProperties(StreamUtil.openStream(FederatedStoreITs.class, "predefinedFederatedStore.properties")));
    final Context context = new Context();
    store.execute(new AddElements.Builder().input(elements).build(), context);
    return store;
}
Also used : Context(uk.gov.gchq.gaffer.store.Context) AddElements(uk.gov.gchq.gaffer.operation.impl.add.AddElements) Schema(uk.gov.gchq.gaffer.store.schema.Schema) FederatedStoreITs(uk.gov.gchq.gaffer.federatedstore.integration.FederatedStoreITs) TypeDefinition(uk.gov.gchq.gaffer.store.schema.TypeDefinition) IsTrue(uk.gov.gchq.koryphe.impl.predicate.IsTrue) SchemaEdgeDefinition(uk.gov.gchq.gaffer.store.schema.SchemaEdgeDefinition) FederatedStore(uk.gov.gchq.gaffer.federatedstore.FederatedStore) PredefinedFederatedStore(uk.gov.gchq.gaffer.federatedstore.PredefinedFederatedStore)

Example 30 with FederatedStore

use of uk.gov.gchq.gaffer.federatedstore.FederatedStore in project Gaffer by gchq.

the class FederatedOperationChainHandlerTest method shouldHandleChainWithoutSpecialFederation.

@Test
public void shouldHandleChainWithoutSpecialFederation() throws OperationException {
    // Given
    final FederatedStore store = createStore();
    final Context context = new Context();
    final OperationChain<Iterable<? extends Element>> opChain = new OperationChain.Builder().first(new GetAllElements.Builder().option(KEY_OPERATION_OPTIONS_GRAPH_IDS, GRAPH_IDS).build()).then(new Limit<>(1)).build();
    // When
    final Iterable result = store.execute(opChain, context);
    // Then - the result will contain just 1 element from the first graph
    ElementUtil.assertElementEquals(Collections.singletonList(elements[0]), result);
}
Also used : Context(uk.gov.gchq.gaffer.store.Context) CloseableIterable(uk.gov.gchq.gaffer.commonutil.iterable.CloseableIterable) Element(uk.gov.gchq.gaffer.data.element.Element) FederatedOperationChain(uk.gov.gchq.gaffer.federatedstore.operation.FederatedOperationChain) OperationChain(uk.gov.gchq.gaffer.operation.OperationChain) GetAllElements(uk.gov.gchq.gaffer.operation.impl.get.GetAllElements) Limit(uk.gov.gchq.gaffer.operation.impl.Limit) FederatedStore(uk.gov.gchq.gaffer.federatedstore.FederatedStore) PredefinedFederatedStore(uk.gov.gchq.gaffer.federatedstore.PredefinedFederatedStore) Test(org.junit.jupiter.api.Test)

Aggregations

FederatedStore (uk.gov.gchq.gaffer.federatedstore.FederatedStore)38 Test (org.junit.jupiter.api.Test)25 Context (uk.gov.gchq.gaffer.store.Context)25 Schema (uk.gov.gchq.gaffer.store.schema.Schema)19 Graph (uk.gov.gchq.gaffer.graph.Graph)16 OperationChain (uk.gov.gchq.gaffer.operation.OperationChain)12 OperationException (uk.gov.gchq.gaffer.operation.OperationException)12 StoreProperties (uk.gov.gchq.gaffer.store.StoreProperties)11 Store (uk.gov.gchq.gaffer.store.Store)10 FederatedOperationChain (uk.gov.gchq.gaffer.federatedstore.operation.FederatedOperationChain)8 CloseableIterable (uk.gov.gchq.gaffer.commonutil.iterable.CloseableIterable)7 FederatedStoreProperties (uk.gov.gchq.gaffer.federatedstore.FederatedStoreProperties)7 PredefinedFederatedStore (uk.gov.gchq.gaffer.federatedstore.PredefinedFederatedStore)7 Operation (uk.gov.gchq.gaffer.operation.Operation)7 GetAllElements (uk.gov.gchq.gaffer.operation.impl.get.GetAllElements)6 User (uk.gov.gchq.gaffer.user.User)6 BeforeEach (org.junit.jupiter.api.BeforeEach)5 Element (uk.gov.gchq.gaffer.data.element.Element)4 GraphConfig (uk.gov.gchq.gaffer.graph.GraphConfig)4 GraphSerialisable (uk.gov.gchq.gaffer.graph.GraphSerialisable)4