use of uk.gov.gchq.gaffer.graph.Graph.Builder in project Gaffer by gchq.
the class FederatedStoreGraphVisibilityTest method shouldNotShowHiddenGraphIdWithIDs.
@Test
public void shouldNotShowHiddenGraphIdWithIDs() throws Exception {
final Schema aSchema = new Schema.Builder().entity("e1", new SchemaEntityDefinition.Builder().vertex("string").build()).type("string", String.class).build();
library.add(TEST_GRAPH_ID, TEST_SCHEMA_ID, aSchema, TEST_STORE_PROPS_ID, PROPERTIES);
fedGraph = new Builder().config(new GraphConfig.Builder().graphId(TEST_FED_GRAPH_ID).library(library).build()).addStoreProperties(fedProperties).build();
fedGraph.execute(new AddGraph.Builder().graphId("g1").parentPropertiesId(// <- with ID
TEST_STORE_PROPS_ID).parentSchemaIds(// <- with ID
Arrays.asList(TEST_SCHEMA_ID)).build(), addingUser);
fedGraph.execute(new AddGraph.Builder().graphId("g2").parentPropertiesId(// <- with ID
TEST_STORE_PROPS_ID).parentSchemaIds(// <- with ID
Arrays.asList(TEST_SCHEMA_ID)).graphAuths("auth1").build(), addingUser);
commonAssertions();
}
use of uk.gov.gchq.gaffer.graph.Graph.Builder in project Gaffer by gchq.
the class SchemaHidingIT method shouldCreateStoreWithFullSchemaAndThenBeAbleUseASubsetOfTheSchema.
@SuppressWarnings("unchecked")
@Test
public void shouldCreateStoreWithFullSchemaAndThenBeAbleUseASubsetOfTheSchema() throws Exception {
// Add some data to the full graph
final Store fullStore = createStore(createFullSchema());
final Graph fullGraph = new Builder().store(fullStore).build();
final Edge edge1a = new Edge.Builder().source("source1a").dest("dest1a").directed(true).group(TestGroups.EDGE).property(TestPropertyNames.COUNT, 1).property(TestPropertyNames.PROP_1, "1a").property(TestPropertyNames.VISIBILITY, "public").property(TestPropertyNames.TIMESTAMP, 1L).build();
final Edge edge1b = new Edge.Builder().source("source1b").dest("dest1b").directed(true).group(TestGroups.EDGE).property(TestPropertyNames.COUNT, 1).property(TestPropertyNames.PROP_1, "1b").property(TestPropertyNames.VISIBILITY, "public").property(TestPropertyNames.TIMESTAMP, 1L).build();
final Edge edge2 = new Edge.Builder().source("source2").dest("dest2").directed(true).group(TestGroups.EDGE_2).property(TestPropertyNames.COUNT, 1).property(TestPropertyNames.PROP_1, "2").property(TestPropertyNames.VISIBILITY, "public").property(TestPropertyNames.TIMESTAMP, 1L).build();
fullGraph.execute(new AddElements.Builder().input(edge1a, edge1b, edge2).build(), USER);
// Create a graph with a hidden group backed by the same store
final Store filteredStore = createStore(createFilteredSchema());
final Graph filteredGraph = new Builder().store(filteredStore).build();
final List<Edge> fullExpectedResults = Arrays.asList(edge1a, edge1b, edge2);
final List<Edge> filteredExpectedResults = Arrays.asList(edge1a, edge1b);
// Run operations and check the hidden group is hidden when the operation is run on the filtered graph
testOperations(fullGraph, filteredGraph, fullExpectedResults, filteredExpectedResults);
}
use of uk.gov.gchq.gaffer.graph.Graph.Builder in project Gaffer by gchq.
the class Queries method createGraph.
private Graph createGraph(final User user) throws IOException, OperationException {
final Graph graph = new Builder().config(new GraphConfig.Builder().graphId("roadTraffic").build()).addSchemas(StreamUtil.openStreams(ElementGroup.class, "schema")).storeProperties(StreamUtil.openStream(getClass(), "accumulo/store.properties")).build();
final OperationChain<Void> populateChain = new OperationChain.Builder().first(new GenerateElements.Builder<String>().input(IOUtils.readLines(StreamUtil.openStream(getClass(), "roadTrafficSampleData.csv"))).generator(new RoadTrafficStringElementGenerator()).build()).then(new AddElements.Builder().skipInvalidElements(false).build()).build();
graph.execute(populateChain, user);
return graph;
}
use of uk.gov.gchq.gaffer.graph.Graph.Builder in project Gaffer by gchq.
the class FederatedStoreGraphVisibilityTest method shouldNotShowHiddenGraphIdWithoutIDs.
/*
* Adhoc test to make sure that the naming of props and schemas without ID's
* is still retrievable via the name of the graph that is was added to the LIBRARY.
*/
@Test
public void shouldNotShowHiddenGraphIdWithoutIDs() throws Exception {
final Schema aSchema = // <- without ID
new Schema.Builder().entity("e1", new SchemaEntityDefinition.Builder().vertex("string").build()).type("string", String.class).build();
library.add(TEST_GRAPH_ID, aSchema, PROPERTIES);
fedGraph = new Builder().config(new GraphConfig.Builder().graphId(TEST_FED_GRAPH_ID).library(library).build()).addStoreProperties(fedProperties).build();
fedGraph.execute(new AddGraph.Builder().graphId("g1").parentPropertiesId(// <- without ID
TEST_GRAPH_ID).parentSchemaIds(// <- without ID
Arrays.asList(TEST_GRAPH_ID)).build(), addingUser);
fedGraph.execute(new AddGraph.Builder().graphId("g2").parentPropertiesId(// <- without ID
TEST_GRAPH_ID).parentSchemaIds(// <- without ID
Arrays.asList(TEST_GRAPH_ID)).graphAuths("auth1").build(), addingUser);
commonAssertions();
}
Aggregations