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;
}
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);
}
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();
}
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());
}
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");
}
Aggregations