Search in sources :

Example 16 with HashMapGraphLibrary

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

the class FederatedStoreTest method setUp.

@BeforeEach
public void setUp() throws Exception {
    clearCache();
    federatedProperties = new FederatedStoreProperties();
    federatedProperties.set(HashMapCacheService.STATIC_CACHE, String.valueOf(true));
    clearLibrary();
    library = new HashMapGraphLibrary();
    library.addProperties(ID_PROPS_ACC_1, PROPERTIES_1);
    library.addProperties(ID_PROPS_ACC_2, PROPERTIES_2);
    library.addProperties(ID_PROPS_ACC_ALT, PROPERTIES_ALT);
    library.addSchema(ID_SCHEMA_EDGE, getSchemaFromPath(PATH_BASIC_EDGE_SCHEMA_JSON));
    library.addSchema(ID_SCHEMA_ENTITY, getSchemaFromPath(PATH_BASIC_ENTITY_SCHEMA_JSON));
    store = new FederatedStore();
    store.setGraphLibrary(library);
    store.initialise(FEDERATED_STORE_ID, null, federatedProperties);
    userContext = new Context(blankUser());
    blankUser = blankUser();
    ignore = new IgnoreOptions();
}
Also used : Context(uk.gov.gchq.gaffer.store.Context) HashMapGraphLibrary(uk.gov.gchq.gaffer.store.library.HashMapGraphLibrary) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 17 with HashMapGraphLibrary

use of uk.gov.gchq.gaffer.store.library.HashMapGraphLibrary 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

HashMapGraphLibrary (uk.gov.gchq.gaffer.store.library.HashMapGraphLibrary)17 Test (org.junit.jupiter.api.Test)11 Schema (uk.gov.gchq.gaffer.store.schema.Schema)11 StoreProperties (uk.gov.gchq.gaffer.store.StoreProperties)8 Context (uk.gov.gchq.gaffer.store.Context)6 BeforeEach (org.junit.jupiter.api.BeforeEach)4 Graph (uk.gov.gchq.gaffer.graph.Graph)3 GraphLibrary (uk.gov.gchq.gaffer.store.library.GraphLibrary)3 AddGraph (uk.gov.gchq.gaffer.federatedstore.operation.AddGraph)2 AddSchemaToLibrary (uk.gov.gchq.gaffer.store.operation.add.AddSchemaToLibrary)2 HashMapCacheService (uk.gov.gchq.gaffer.cache.impl.HashMapCacheService)1 CloseableIterable (uk.gov.gchq.gaffer.commonutil.iterable.CloseableIterable)1 Element (uk.gov.gchq.gaffer.data.element.Element)1 View (uk.gov.gchq.gaffer.data.elementdefinition.view.View)1 RoadAndRoadUseWithTimesAndCardinalitiesElementGenerator (uk.gov.gchq.gaffer.doc.user.generator.RoadAndRoadUseWithTimesAndCardinalitiesElementGenerator)1 FederatedStoreProperties (uk.gov.gchq.gaffer.federatedstore.FederatedStoreProperties)1 AddGraphWithHooks (uk.gov.gchq.gaffer.federatedstore.operation.AddGraphWithHooks)1 GetAllGraphIds (uk.gov.gchq.gaffer.federatedstore.operation.GetAllGraphIds)1 RemoveGraph (uk.gov.gchq.gaffer.federatedstore.operation.RemoveGraph)1 AddOperationsToChain (uk.gov.gchq.gaffer.graph.hook.AddOperationsToChain)1