Search in sources :

Example 1 with MapStoreProperties

use of uk.gov.gchq.gaffer.mapstore.MapStoreProperties in project gaffer-doc by gchq.

the class AbstractWalkthrough method getMapStoreProperties.

protected StoreProperties getMapStoreProperties() {
    final MapStoreProperties properties = new MapStoreProperties();
    properties.setStoreClass(SingleUseMapStore.class);
    properties.set(CacheProperties.CACHE_SERVICE_CLASS, HashMapCacheService.class.getName());
    return properties;
}
Also used : HashMapCacheService(uk.gov.gchq.gaffer.cache.impl.HashMapCacheService) MapStoreProperties(uk.gov.gchq.gaffer.mapstore.MapStoreProperties)

Example 2 with MapStoreProperties

use of uk.gov.gchq.gaffer.mapstore.MapStoreProperties in project Gaffer by gchq.

the class SimpleMapFactoryTest method shouldCreateNewMapUsingMapClass.

@Test
public void shouldCreateNewMapUsingMapClass() throws StoreException {
    // Given
    final Class<? extends Map> mapClass = LinkedHashMap.class;
    final Schema schema = mock(Schema.class);
    final MapStoreProperties properties = mock(MapStoreProperties.class);
    final SimpleMapFactory factory = new SimpleMapFactory();
    given(properties.get(SimpleMapFactory.MAP_CLASS, SimpleMapFactory.MAP_CLASS_DEFAULT)).willReturn(mapClass.getName());
    factory.initialise(schema, properties);
    // When
    final Map<Object, Object> map1 = factory.getMap("mapName1", Object.class, Object.class);
    final Map<Object, Object> map2 = factory.getMap("mapName2", Object.class, Object.class);
    // Then
    assertThat(map1).isInstanceOf(LinkedHashMap.class).isEmpty();
    assertThat(map2).isInstanceOf(LinkedHashMap.class).isEmpty();
    assertNotSame(map1, map2);
}
Also used : Schema(uk.gov.gchq.gaffer.store.schema.Schema) LinkedHashMap(java.util.LinkedHashMap) MapStoreProperties(uk.gov.gchq.gaffer.mapstore.MapStoreProperties) Test(org.junit.jupiter.api.Test)

Example 3 with MapStoreProperties

use of uk.gov.gchq.gaffer.mapstore.MapStoreProperties in project Gaffer by gchq.

the class SimpleMapFactoryTest method shouldThrowExceptionIfMapClassCannotBeInstantiated.

@Test
public void shouldThrowExceptionIfMapClassCannotBeInstantiated() throws StoreException {
    // Given
    final Class<? extends Map> mapClass = Map.class;
    final Schema schema = mock(Schema.class);
    final MapStoreProperties properties = mock(MapStoreProperties.class);
    final SimpleMapFactory factory = new SimpleMapFactory();
    given(properties.get(SimpleMapFactory.MAP_CLASS, SimpleMapFactory.MAP_CLASS_DEFAULT)).willReturn(mapClass.getName());
    factory.initialise(schema, properties);
    // When / Then
    assertThatIllegalArgumentException().isThrownBy(() -> factory.getMap("mapName1", Object.class, Object.class)).extracting("message").isNotNull();
}
Also used : Schema(uk.gov.gchq.gaffer.store.schema.Schema) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) MapStoreProperties(uk.gov.gchq.gaffer.mapstore.MapStoreProperties) Test(org.junit.jupiter.api.Test)

Example 4 with MapStoreProperties

use of uk.gov.gchq.gaffer.mapstore.MapStoreProperties in project Gaffer by gchq.

the class SimpleMapFactoryTest method shouldExtractMapClassFromPropertiesWhenInitialised.

@Test
public void shouldExtractMapClassFromPropertiesWhenInitialised() throws StoreException {
    // Given
    final Class<? extends Map> mapClass = LinkedHashMap.class;
    final Schema schema = mock(Schema.class);
    final MapStoreProperties properties = mock(MapStoreProperties.class);
    final SimpleMapFactory factory = new SimpleMapFactory();
    given(properties.get(SimpleMapFactory.MAP_CLASS, SimpleMapFactory.MAP_CLASS_DEFAULT)).willReturn(mapClass.getName());
    // When
    factory.initialise(schema, properties);
    // Then
    assertEquals(mapClass, factory.getMapClass());
}
Also used : Schema(uk.gov.gchq.gaffer.store.schema.Schema) LinkedHashMap(java.util.LinkedHashMap) MapStoreProperties(uk.gov.gchq.gaffer.mapstore.MapStoreProperties) Test(org.junit.jupiter.api.Test)

Example 5 with MapStoreProperties

use of uk.gov.gchq.gaffer.mapstore.MapStoreProperties in project Gaffer by gchq.

the class GraphConfigurationControllerIT method shouldReturn500WhenANonExistentClassIsProvidedEndingInClassForGetFilterFunctions.

@Test
public void shouldReturn500WhenANonExistentClassIsProvidedEndingInClassForGetFilterFunctions() {
    // Given
    Graph emptyGraph = new Graph.Builder().config(new GraphConfig.Builder().graphId("id").build()).storeProperties(new MapStoreProperties()).addSchema(new Schema()).build();
    when(graphFactory.getGraph()).thenReturn(emptyGraph);
    // When
    ResponseEntity<Error> response = get("/graph/config/filterFunctions/a.random.class", Error.class);
    // Then
    checkResponse(response, 500);
    assertThat(response.getBody().getSimpleMessage()).isEqualTo("Could not find input class: a.random.class");
}
Also used : Graph(uk.gov.gchq.gaffer.graph.Graph) Schema(uk.gov.gchq.gaffer.store.schema.Schema) Error(uk.gov.gchq.gaffer.core.exception.Error) MapStoreProperties(uk.gov.gchq.gaffer.mapstore.MapStoreProperties) Test(org.junit.Test)

Aggregations

MapStoreProperties (uk.gov.gchq.gaffer.mapstore.MapStoreProperties)39 Schema (uk.gov.gchq.gaffer.store.schema.Schema)31 Graph (uk.gov.gchq.gaffer.graph.Graph)25 Test (org.junit.Test)19 Test (org.junit.jupiter.api.Test)15 GraphConfig (uk.gov.gchq.gaffer.graph.GraphConfig)9 Set (java.util.Set)7 Error (uk.gov.gchq.gaffer.core.exception.Error)7 HashSet (java.util.HashSet)6 LinkedHashMap (java.util.LinkedHashMap)4 AddElements (uk.gov.gchq.gaffer.operation.impl.add.AddElements)4 Map (java.util.Map)3 HashMapCacheService (uk.gov.gchq.gaffer.cache.impl.HashMapCacheService)3 Edge (uk.gov.gchq.gaffer.data.element.Edge)3 Entity (uk.gov.gchq.gaffer.data.element.Entity)3 StoreProperties (uk.gov.gchq.gaffer.store.StoreProperties)3 Before (org.junit.Before)2 Assertions.assertEquals (org.junit.jupiter.api.Assertions.assertEquals)2 HttpEntity (org.springframework.http.HttpEntity)2 Streams (uk.gov.gchq.gaffer.commonutil.stream.Streams)2