use of uk.gov.gchq.gaffer.graph.Graph in project Gaffer by gchq.
the class ExportToOtherGraphHandlerTest method shouldCreateNewGraphWithMergedParentSchemaIdAndProvidedSchema.
@Test
public void shouldCreateNewGraphWithMergedParentSchemaIdAndProvidedSchema() {
// Given
Schema schema1 = new Schema.Builder().entity("entity", new SchemaEntityDefinition.Builder().vertex("vertex").build()).type("vertex", String.class).build();
Schema schema2 = new Schema.Builder().edge("edge", new SchemaEdgeDefinition.Builder().source("vertex").destination("vertex").directed(DIRECTED_EITHER).build()).type("vertex", String.class).type(DIRECTED_EITHER, Boolean.class).build();
graphLibrary.addOrUpdate(GRAPH_ID + 1, schema, storeProperties);
graphLibrary.addSchema(SCHEMA_ID_1, schema1);
graphLibrary.addSchema(SCHEMA_ID_2, schema2);
final ExportToOtherGraph export = new ExportToOtherGraph.Builder().graphId(GRAPH_ID + 2).parentSchemaIds(SCHEMA_ID_1, SCHEMA_ID_2).schema(schema).storeProperties(storeProperties).build();
// When
Graph graph = createGraph(export);
// Then
assertEquals(GRAPH_ID + 2, graph.getGraphId());
JsonAssert.assertEquals(new Schema.Builder().entity("entity", new SchemaEntityDefinition.Builder().vertex("vertex").build()).edge("edge", new SchemaEdgeDefinition.Builder().source("vertex").destination("vertex").directed(DIRECTED_EITHER).build()).type("vertex", String.class).type(DIRECTED_EITHER, Boolean.class).build().toJson(false), graph.getSchema().toJson(false));
assertEquals(storeProperties, graph.getStoreProperties());
}
use of uk.gov.gchq.gaffer.graph.Graph in project Gaffer by gchq.
the class ExportToOtherGraphHandlerTest method shouldCreateNewGraphWithStoreGraphLibrary.
@Test
public void shouldCreateNewGraphWithStoreGraphLibrary() {
// Given
graphLibrary.add(GRAPH_ID + 1, schema, storeProperties);
final ExportToOtherGraph export = new ExportToOtherGraph.Builder().graphId(GRAPH_ID + 1).build();
// When
Graph graph = createGraph(export);
// Then
assertEquals(GRAPH_ID + 1, graph.getGraphId());
assertEquals(schema, graph.getSchema());
assertEquals(storeProperties, graph.getStoreProperties());
}
use of uk.gov.gchq.gaffer.graph.Graph in project Gaffer by gchq.
the class ExportToOtherGraphHandlerTest method shouldCreateNewGraphWithStoresSchema.
@Test
public void shouldCreateNewGraphWithStoresSchema() {
// Given
given(store.getSchema()).willReturn(schema);
given(store.getGraphLibrary()).willReturn(null);
final StoreProperties storeProperties1 = StoreProperties.loadStoreProperties(StreamUtil.storeProps(getClass()));
final ExportToOtherGraph export = new ExportToOtherGraph.Builder().graphId(GRAPH_ID + 1).storeProperties(storeProperties1).build();
// When
Graph graph = createGraph(export);
// Then
assertEquals(GRAPH_ID + 1, graph.getGraphId());
assertEquals(schema, graph.getSchema());
assertEquals(storeProperties1, graph.getStoreProperties());
}
use of uk.gov.gchq.gaffer.graph.Graph in project Gaffer by gchq.
the class GetRDDOfAllElementsHandlerIT method checkHadoopConfIsPassedThrough.
@Test
public void checkHadoopConfIsPassedThrough() throws OperationException, IOException {
final Graph graph1 = new Graph.Builder().config(new GraphConfig.Builder().graphId("graphId").build()).addSchema(getClass().getResourceAsStream("/schema/elements.json")).addSchema(getClass().getResourceAsStream("/schema/types.json")).addSchema(getClass().getResourceAsStream("/schema/serialisation.json")).storeProperties(PROPERTIES_A).build();
final Configuration conf = new Configuration();
conf.set("AN_OPTION", "A_VALUE");
final String encodedConf = AbstractGetRDDHandler.convertConfigurationToString(conf);
final GetRDDOfAllElements rddQuery = new GetRDDOfAllElements.Builder().option(AbstractGetRDDHandler.HADOOP_CONFIGURATION_KEY, encodedConf).build();
final RDD<Element> rdd = graph1.execute(rddQuery, new User());
assertEquals(encodedConf, rddQuery.getOption(AbstractGetRDDHandler.HADOOP_CONFIGURATION_KEY));
assertEquals("A_VALUE", rdd.sparkContext().hadoopConfiguration().get("AN_OPTION"));
}
use of uk.gov.gchq.gaffer.graph.Graph in project Gaffer by gchq.
the class GetRDDOfAllElementsHandlerIT method _getGraphForAccumulo.
private Graph _getGraphForAccumulo(final Schema schema, final List<Element> elements, final KeyPackage keyPackage) throws OperationException {
final Graph graph = new Graph.Builder().config(new GraphConfig.Builder().graphId(GRAPH_ID).build()).addSchema(schema).storeProperties(getAccumuloProperties(keyPackage)).build();
graph.execute(new AddElements.Builder().input(elements).validate(false).build(), USER);
return graph;
}
Aggregations