Search in sources :

Example 26 with GraphLibrary

use of uk.gov.gchq.gaffer.store.library.GraphLibrary in project Gaffer by gchq.

the class FederatedAddGraphHandlerTest method shouldAddGraphUsingLibrary.

@Test
public void shouldAddGraphUsingLibrary() throws Exception {
    store.initialise(FEDERATEDSTORE_GRAPH_ID, null, federatedStoreProperties);
    Schema expectedSchema = new Schema.Builder().build();
    assertEquals(0, store.getGraphs(testUser, null, ignore).size());
    assertEquals(0, store.getGraphs(testUser, null, ignore).size());
    FederatedAddGraphHandler federatedAddGraphHandler = new FederatedAddGraphHandler();
    federatedAddGraphHandler.doOperation(new AddGraph.Builder().graphId(EXPECTED_GRAPH_ID).schema(expectedSchema).storeProperties(PROPERTIES).build(), new Context(testUser), store);
    Collection<Graph> graphs = store.getGraphs(testUser, null, ignore);
    assertThat(graphs).hasSize(1);
    Graph next = graphs.iterator().next();
    assertEquals(EXPECTED_GRAPH_ID, next.getGraphId());
    assertEquals(expectedSchema, next.getSchema());
    final GraphLibrary library = new HashMapGraphLibrary();
    library.add(EXPECTED_GRAPH_ID_2, expectedSchema, PROPERTIES);
    store.setGraphLibrary(library);
    federatedAddGraphHandler.doOperation(new AddGraph.Builder().graphId(EXPECTED_GRAPH_ID_2).build(), new Context(testUser), store);
    graphs = store.getGraphs(testUser, null, ignore);
    assertThat(graphs).hasSize(2);
    Iterator<Graph> iterator = graphs.iterator();
    final HashSet<String> set = Sets.newHashSet();
    while (iterator.hasNext()) {
        set.add(iterator.next().getGraphId());
    }
    assertThat(set).contains(EXPECTED_GRAPH_ID, EXPECTED_GRAPH_ID_2);
}
Also used : Context(uk.gov.gchq.gaffer.store.Context) HashMapGraphLibrary(uk.gov.gchq.gaffer.store.library.HashMapGraphLibrary) Schema(uk.gov.gchq.gaffer.store.schema.Schema) AddGraph(uk.gov.gchq.gaffer.federatedstore.operation.AddGraph) Graph(uk.gov.gchq.gaffer.graph.Graph) AddGraph(uk.gov.gchq.gaffer.federatedstore.operation.AddGraph) GraphLibrary(uk.gov.gchq.gaffer.store.library.GraphLibrary) HashMapGraphLibrary(uk.gov.gchq.gaffer.store.library.HashMapGraphLibrary) Test(org.junit.jupiter.api.Test)

Aggregations

GraphLibrary (uk.gov.gchq.gaffer.store.library.GraphLibrary)26 Test (org.junit.jupiter.api.Test)17 Schema (uk.gov.gchq.gaffer.store.schema.Schema)14 FileGraphLibrary (uk.gov.gchq.gaffer.store.library.FileGraphLibrary)13 ExportToOtherAuthorisedGraph (uk.gov.gchq.gaffer.operation.export.graph.ExportToOtherAuthorisedGraph)9 Graph (uk.gov.gchq.gaffer.graph.Graph)7 HashMapGraphLibrary (uk.gov.gchq.gaffer.store.library.HashMapGraphLibrary)7 View (uk.gov.gchq.gaffer.data.elementdefinition.view.View)5 StoreProperties (uk.gov.gchq.gaffer.store.StoreProperties)5 AccumuloProperties (uk.gov.gchq.gaffer.accumulostore.AccumuloProperties)3 SchemaException (uk.gov.gchq.gaffer.data.elementdefinition.exception.SchemaException)3 GraphHook (uk.gov.gchq.gaffer.graph.hook.GraphHook)3 StoreException (uk.gov.gchq.gaffer.store.StoreException)3 ArrayList (java.util.ArrayList)2 Element (uk.gov.gchq.gaffer.data.element.Element)2 FederatedGetTraitsHandlerTest (uk.gov.gchq.gaffer.federatedstore.operation.handler.impl.FederatedGetTraitsHandlerTest)2 FunctionAuthoriser (uk.gov.gchq.gaffer.graph.hook.FunctionAuthoriser)2 NamedViewResolver (uk.gov.gchq.gaffer.graph.hook.NamedViewResolver)2 OperationChain (uk.gov.gchq.gaffer.operation.OperationChain)2 OperationException (uk.gov.gchq.gaffer.operation.OperationException)2