Search in sources :

Example 11 with HashMapGraphLibrary

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

the class GraphTest method shouldBuildGraphFromConfigAndSetIdsToGraphsWhenGraphSchemaAndStorePropertiesIdsAreNull.

@Test
public void shouldBuildGraphFromConfigAndSetIdsToGraphsWhenGraphSchemaAndStorePropertiesIdsAreNull() {
    // Given
    final StoreProperties libraryStoreProperties = new StoreProperties();
    libraryStoreProperties.setStoreClass(TestStoreImpl.class.getName());
    final StoreProperties graphStoreProperties = new StoreProperties();
    graphStoreProperties.setStoreClass(TestStoreImpl.class.getName());
    final Schema librarySchema = new Schema.Builder().build();
    final Schema graphSchema = new Schema.Builder().build();
    final String graphId1 = "graphId1";
    final HashMapGraphLibrary library = new HashMapGraphLibrary();
    library.addSchema(SCHEMA_ID_1, librarySchema);
    library.addProperties(STORE_PROPERTIES_ID_1, libraryStoreProperties);
    // When
    final GraphConfig config = new GraphConfig.Builder().graphId(graphId1).library(library).build();
    final Graph graph1 = new Graph.Builder().config(config).addToLibrary(true).parentStorePropertiesId("storePropertiesId1").storeProperties(graphStoreProperties).addParentSchemaIds(SCHEMA_ID_1).addSchemas(graphSchema).build();
    // Then
    assertEquals(graphId1, graph1.getGraphId());
    JsonAssert.assertEquals(library.getSchema(SCHEMA_ID_1).toJson(false), librarySchema.toJson(false));
    // Check that the schemaId = schemaId1 as both the supplied schema id is null
    // Check that the storePropsId = storePropertiesId1 as the supplied storeProps id is null
    assertThat(graphId1).isEqualTo(library.getIds(graphId1).getFirst()).isEqualTo(library.getIds(graphId1).getSecond());
}
Also used : HashMapGraphLibrary(uk.gov.gchq.gaffer.store.library.HashMapGraphLibrary) Schema(uk.gov.gchq.gaffer.store.schema.Schema) StoreProperties(uk.gov.gchq.gaffer.store.StoreProperties) Test(org.junit.jupiter.api.Test)

Example 12 with HashMapGraphLibrary

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

the class SchemaTest method shouldAddMergedSchemaToLibrary.

@Test
public void shouldAddMergedSchemaToLibrary() {
    // Given
    final HashMapGraphLibrary graphLibrary = new HashMapGraphLibrary();
    final Schema schema1ToMerge = new Schema.Builder().build();
    final Schema schema2ToMerge = new Schema.Builder().build();
    final Schema schema = new Schema.Builder().merge(schema1ToMerge).merge(schema2ToMerge).build();
    // When
    graphLibrary.addSchema("TEST_SCHEMA_ID_merged", schema);
// Then - no exceptions
}
Also used : HashMapGraphLibrary(uk.gov.gchq.gaffer.store.library.HashMapGraphLibrary) Test(org.junit.jupiter.api.Test)

Example 13 with HashMapGraphLibrary

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

the class AddStorePropertiesToLibraryHandlerTest method shouldSupportAddToGraphLibrary.

@Test
public void shouldSupportAddToGraphLibrary() throws Exception {
    HashMapGraphLibrary library = new HashMapGraphLibrary();
    store.setGraphLibrary(library);
    store.initialise(TEST_STORE_ID, new Schema(), new StoreProperties());
    assertTrue(store.isSupported(AddSchemaToLibrary.class));
}
Also used : HashMapGraphLibrary(uk.gov.gchq.gaffer.store.library.HashMapGraphLibrary) Schema(uk.gov.gchq.gaffer.store.schema.Schema) AddSchemaToLibrary(uk.gov.gchq.gaffer.store.operation.add.AddSchemaToLibrary) StoreProperties(uk.gov.gchq.gaffer.store.StoreProperties) Test(org.junit.jupiter.api.Test)

Example 14 with HashMapGraphLibrary

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

the class AddSchemaToLibraryHandlerTest method shouldSupportAddToGraphLibrary.

@Test
public void shouldSupportAddToGraphLibrary() throws Exception {
    // given
    HashMapGraphLibrary library = new HashMapGraphLibrary();
    store.setGraphLibrary(library);
    // when
    store.initialise(TEST_STORE_ID, new Schema(), new StoreProperties());
    // then
    assertTrue(store.isSupported(AddSchemaToLibrary.class));
}
Also used : HashMapGraphLibrary(uk.gov.gchq.gaffer.store.library.HashMapGraphLibrary) Schema(uk.gov.gchq.gaffer.store.schema.Schema) AddSchemaToLibrary(uk.gov.gchq.gaffer.store.operation.add.AddSchemaToLibrary) StoreProperties(uk.gov.gchq.gaffer.store.StoreProperties) Test(org.junit.jupiter.api.Test)

Example 15 with HashMapGraphLibrary

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

the class FederatedStoreGraphVisibilityTest method setUp.

@BeforeEach
public void setUp() throws Exception {
    HashMapGraphLibrary.clear();
    CacheServiceLoader.shutdown();
    fedProperties = new FederatedStoreProperties();
    fedProperties.setCacheProperties(CACHE_SERVICE_CLASS_STRING);
    addingUser = testUser();
    nonAddingUser = blankUser();
    authNonAddingUser = authUser();
    library = new HashMapGraphLibrary();
}
Also used : HashMapGraphLibrary(uk.gov.gchq.gaffer.store.library.HashMapGraphLibrary) BeforeEach(org.junit.jupiter.api.BeforeEach)

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