Search in sources :

Example 96 with Graph

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());
}
Also used : ExportToOtherGraph(uk.gov.gchq.gaffer.operation.export.graph.ExportToOtherGraph) ExportToOtherGraph(uk.gov.gchq.gaffer.operation.export.graph.ExportToOtherGraph) Graph(uk.gov.gchq.gaffer.graph.Graph) Schema(uk.gov.gchq.gaffer.store.schema.Schema) SchemaEntityDefinition(uk.gov.gchq.gaffer.store.schema.SchemaEntityDefinition) Test(org.junit.jupiter.api.Test)

Example 97 with Graph

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());
}
Also used : ExportToOtherGraph(uk.gov.gchq.gaffer.operation.export.graph.ExportToOtherGraph) ExportToOtherGraph(uk.gov.gchq.gaffer.operation.export.graph.ExportToOtherGraph) Graph(uk.gov.gchq.gaffer.graph.Graph) Test(org.junit.jupiter.api.Test)

Example 98 with Graph

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());
}
Also used : ExportToOtherGraph(uk.gov.gchq.gaffer.operation.export.graph.ExportToOtherGraph) ExportToOtherGraph(uk.gov.gchq.gaffer.operation.export.graph.ExportToOtherGraph) Graph(uk.gov.gchq.gaffer.graph.Graph) StoreProperties(uk.gov.gchq.gaffer.store.StoreProperties) Test(org.junit.jupiter.api.Test)

Example 99 with Graph

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"));
}
Also used : Graph(uk.gov.gchq.gaffer.graph.Graph) User(uk.gov.gchq.gaffer.user.User) Configuration(org.apache.hadoop.conf.Configuration) AccumuloConfiguration(org.apache.accumulo.core.conf.AccumuloConfiguration) GetRDDOfAllElements(uk.gov.gchq.gaffer.spark.operation.scalardd.GetRDDOfAllElements) Element(uk.gov.gchq.gaffer.data.element.Element) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 100 with Graph

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;
}
Also used : Graph(uk.gov.gchq.gaffer.graph.Graph)

Aggregations

Graph (uk.gov.gchq.gaffer.graph.Graph)311 Test (org.junit.jupiter.api.Test)172 User (uk.gov.gchq.gaffer.user.User)155 AddElements (uk.gov.gchq.gaffer.operation.impl.add.AddElements)146 Element (uk.gov.gchq.gaffer.data.element.Element)116 Schema (uk.gov.gchq.gaffer.store.schema.Schema)84 View (uk.gov.gchq.gaffer.data.elementdefinition.view.View)83 EntitySeed (uk.gov.gchq.gaffer.operation.data.EntitySeed)76 Edge (uk.gov.gchq.gaffer.data.element.Edge)75 HashSet (java.util.HashSet)71 Entity (uk.gov.gchq.gaffer.data.element.Entity)68 OperationChain (uk.gov.gchq.gaffer.operation.OperationChain)60 GetElements (uk.gov.gchq.gaffer.operation.impl.get.GetElements)58 ArrayList (java.util.ArrayList)56 OperationException (uk.gov.gchq.gaffer.operation.OperationException)55 Test (org.junit.Test)49 ViewElementDefinition (uk.gov.gchq.gaffer.data.elementdefinition.view.ViewElementDefinition)49 CloseableIterable (uk.gov.gchq.gaffer.commonutil.iterable.CloseableIterable)44 ElementFilter (uk.gov.gchq.gaffer.data.element.function.ElementFilter)44 Set (java.util.Set)38