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