Search in sources :

Example 6 with FederatedStore

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

the class FederatedRemoveGraphHandlerTest method shouldRemoveGraphForAddingUser.

@Test
public void shouldRemoveGraphForAddingUser() throws Exception {
    FederatedStore store = new FederatedStore();
    final FederatedStoreProperties federatedStoreProperties = new FederatedStoreProperties();
    federatedStoreProperties.setCacheProperties(CACHE_SERVICE_CLASS_STRING);
    store.initialise(FEDERATEDSTORE_GRAPH_ID, null, federatedStoreProperties);
    store.addGraphs(testUser.getOpAuths(), testUser.getUserId(), false, 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).isEmpty();
}
Also used : Context(uk.gov.gchq.gaffer.store.Context) 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) RemoveGraph(uk.gov.gchq.gaffer.federatedstore.operation.RemoveGraph) FederatedStore(uk.gov.gchq.gaffer.federatedstore.FederatedStore) Test(org.junit.jupiter.api.Test)

Example 7 with FederatedStore

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

the class FederatedRemoveGraphHandlerTest method shouldNotRemoveGraphForNonAddingUser.

@Test
public void shouldNotRemoveGraphForNonAddingUser() throws Exception {
    FederatedStore store = new FederatedStore();
    final FederatedStoreProperties federatedStoreProperties = new FederatedStoreProperties();
    federatedStoreProperties.setCacheProperties(CACHE_SERVICE_CLASS_STRING);
    store.initialise(FEDERATEDSTORE_GRAPH_ID, null, federatedStoreProperties);
    store.addGraphs(testUser.getOpAuths(), "other", false, 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) 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) RemoveGraph(uk.gov.gchq.gaffer.federatedstore.operation.RemoveGraph) FederatedStore(uk.gov.gchq.gaffer.federatedstore.FederatedStore) Test(org.junit.jupiter.api.Test)

Example 8 with FederatedStore

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

the class FederatedOperationChainHandlerTest method shouldHandleChainWithIterableOutput.

@Test
public void shouldHandleChainWithIterableOutput() throws OperationException {
    // Given
    final FederatedStore store = createStore();
    final Context context = new Context();
    final FederatedOperationChain<Void, Element> opChain = 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();
    // When
    final Iterable result = store.execute(opChain, context);
    // Then - the result will contain 2 elements - 1 from each graph
    ElementUtil.assertElementEquals(Arrays.asList(elements[0], elements[1]), result);
}
Also used : Context(uk.gov.gchq.gaffer.store.Context) FederatedOperationChain(uk.gov.gchq.gaffer.federatedstore.operation.FederatedOperationChain) CloseableIterable(uk.gov.gchq.gaffer.commonutil.iterable.CloseableIterable) Element(uk.gov.gchq.gaffer.data.element.Element) 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 9 with FederatedStore

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

the class FederatedOperationChainHandlerTest method shouldHandleChainWithLongOutput.

@Test
public void shouldHandleChainWithLongOutput() throws OperationException {
    // Given
    final FederatedStore store = createStore();
    final Context context = new Context();
    final FederatedOperationChain<Void, Long> opChain = new FederatedOperationChain.Builder<Void, Long>().operationChain(new OperationChain.Builder().first(new GetAllElements()).then(new Count<>()).build()).option(KEY_OPERATION_OPTIONS_GRAPH_IDS, GRAPH_IDS).build();
    // When
    final Iterable result = store.execute(opChain, context);
    // Then
    assertEquals(Lists.newArrayList(1L, 1L), Lists.newArrayList(result));
}
Also used : Context(uk.gov.gchq.gaffer.store.Context) FederatedOperationChain(uk.gov.gchq.gaffer.federatedstore.operation.FederatedOperationChain) CloseableIterable(uk.gov.gchq.gaffer.commonutil.iterable.CloseableIterable) 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 10 with FederatedStore

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

the class FederatedOperationChainHandlerTest method shouldHandleChainNestedInsideAnOperationChain.

@Test
public void shouldHandleChainNestedInsideAnOperationChain() throws OperationException {
    // Given
    final FederatedStore store = createStore();
    final Context context = new Context();
    final OperationChain<CloseableIterable<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()).build();
    // When
    final Iterable result = store.execute(opChain, context);
    // Then - the result will contain 2 elements - 1 from each graph
    ElementUtil.assertElementEquals(Arrays.asList(elements[0], elements[1]), result);
}
Also used : Context(uk.gov.gchq.gaffer.store.Context) FederatedOperationChain(uk.gov.gchq.gaffer.federatedstore.operation.FederatedOperationChain) CloseableIterable(uk.gov.gchq.gaffer.commonutil.iterable.CloseableIterable) CloseableIterable(uk.gov.gchq.gaffer.commonutil.iterable.CloseableIterable) Element(uk.gov.gchq.gaffer.data.element.Element) 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)

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