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