Search in sources :

Example 36 with MapStoreProperties

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

the class GraphConfigurationControllerTest method shouldReturnDescription.

@Test
public void shouldReturnDescription() {
    // Given
    when(graphFactory.getGraph()).thenReturn(new Graph.Builder().config(new GraphConfig("id")).addSchema(new Schema()).storeProperties(new MapStoreProperties()).description("test graph").build());
    // When
    GraphConfigurationController controller = new GraphConfigurationController(graphFactory);
    final String description = controller.getDescription();
    // Then
    assertEquals("test graph", description);
}
Also used : GraphConfig(uk.gov.gchq.gaffer.graph.GraphConfig) Schema(uk.gov.gchq.gaffer.store.schema.Schema) MapStoreProperties(uk.gov.gchq.gaffer.mapstore.MapStoreProperties) Test(org.junit.jupiter.api.Test)

Example 37 with MapStoreProperties

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

the class StatusControllerTest method shouldReturnOkayStatusIfGraphFactoryReturnsGraph.

@Test
public void shouldReturnOkayStatusIfGraphFactoryReturnsGraph() {
    // Given
    Graph graph = new Graph.Builder().config(new GraphConfig.Builder().graphId("id").build()).storeProperties(new MapStoreProperties()).addSchema(new Schema()).build();
    Mockito.when(graphFactory.getGraph()).thenReturn(graph);
    // When
    StatusController statusController = new StatusController(graphFactory);
    // Then
    assertEquals(SystemStatus.UP, statusController.getStatus());
}
Also used : Graph(uk.gov.gchq.gaffer.graph.Graph) Schema(uk.gov.gchq.gaffer.store.schema.Schema) MapStoreProperties(uk.gov.gchq.gaffer.mapstore.MapStoreProperties) Test(org.junit.jupiter.api.Test)

Example 38 with MapStoreProperties

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

the class MapImplTest method shouldCreateMapsUsingMapFactory.

@Test
public void shouldCreateMapsUsingMapFactory() throws StoreException {
    // Given
    final Schema schema = mock(Schema.class);
    final MapStoreProperties properties = mock(MapStoreProperties.class);
    final Map aggElements = mock(Map.class);
    final Map nonAggElements = mock(Map.class);
    final MultiMap entityIdToElements = mock(MultiMap.class);
    final MultiMap edgeIdToElements = mock(MultiMap.class);
    given(schema.getGroups()).willReturn(Sets.newHashSet(TestGroups.EDGE));
    given(properties.getMapFactory()).willReturn(TestMapFactory.class.getName());
    given(properties.getCreateIndex()).willReturn(true);
    given(mockMapFactory.getMap(TestGroups.EDGE + "|" + MapImpl.AGG_ELEMENTS, Element.class, GroupedProperties.class)).willReturn(aggElements);
    given(mockMapFactory.getMap(TestGroups.EDGE + "|" + MapImpl.NON_AGG_ELEMENTS, Element.class, Integer.class)).willReturn(nonAggElements);
    given(mockMapFactory.getMultiMap(MapImpl.ENTITY_ID_TO_ELEMENTS, EntityId.class, Element.class)).willReturn(entityIdToElements);
    given(mockMapFactory.getMultiMap(MapImpl.EDGE_ID_TO_ELEMENTS, EdgeId.class, Element.class)).willReturn(edgeIdToElements);
    // When
    new MapImpl(schema, properties);
    // Then
    verify(mockMapFactory).getMap(TestGroups.EDGE + "|" + MapImpl.AGG_ELEMENTS, Element.class, GroupedProperties.class);
    verify(mockMapFactory).getMap(TestGroups.EDGE + "|" + MapImpl.NON_AGG_ELEMENTS, Element.class, Long.class);
    verify(mockMapFactory).getMultiMap(MapImpl.ENTITY_ID_TO_ELEMENTS, EntityId.class, Element.class);
    verify(mockMapFactory).getMultiMap(MapImpl.EDGE_ID_TO_ELEMENTS, EdgeId.class, Element.class);
}
Also used : MultiMap(uk.gov.gchq.gaffer.mapstore.multimap.MultiMap) Schema(uk.gov.gchq.gaffer.store.schema.Schema) MultiMap(uk.gov.gchq.gaffer.mapstore.multimap.MultiMap) Map(java.util.Map) MapStoreProperties(uk.gov.gchq.gaffer.mapstore.MapStoreProperties) Test(org.junit.jupiter.api.Test)

Example 39 with MapStoreProperties

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

the class OperationChainTest method testOperationChain.

@Test
public void testOperationChain() throws StoreException, OperationException {
    // Given
    final Graph graph = new Graph.Builder().config(new GraphConfig.Builder().graphId("graph1").build()).addSchemas(StreamUtil.openStreams(getClass(), "example-schema")).storeProperties(new MapStoreProperties()).build();
    final AddElements addElements = new AddElements.Builder().input(getElements()).build();
    graph.execute(addElements, new User());
    // When
    final CloseableIterable<? extends Element> results = graph.execute(new OperationChain.Builder().first(new GetAdjacentIds.Builder().input(new EntitySeed("vertex1")).build()).then(new GetElements.Builder().view(new View.Builder().edge("edge").build()).build()).build(), new User());
    // Then
    final Set<Element> resultsSet = new HashSet<>();
    Streams.toStream(results).forEach(resultsSet::add);
    final Set<Element> expectedResults = new HashSet<>();
    getElements().stream().filter(e -> e instanceof Edge).filter(e -> {
        final Edge edge = (Edge) e;
        return edge.getSource().equals("vertex1") || edge.getDestination().equals("vertex2");
    }).forEach(expectedResults::add);
    assertEquals(expectedResults, resultsSet);
}
Also used : AddElements(uk.gov.gchq.gaffer.operation.impl.add.AddElements) StoreException(uk.gov.gchq.gaffer.store.StoreException) User(uk.gov.gchq.gaffer.user.User) MapStoreProperties(uk.gov.gchq.gaffer.mapstore.MapStoreProperties) GetElements(uk.gov.gchq.gaffer.operation.impl.get.GetElements) Set(java.util.Set) Entity(uk.gov.gchq.gaffer.data.element.Entity) GraphConfig(uk.gov.gchq.gaffer.graph.GraphConfig) Element(uk.gov.gchq.gaffer.data.element.Element) ArrayList(java.util.ArrayList) Test(org.junit.jupiter.api.Test) HashSet(java.util.HashSet) EntitySeed(uk.gov.gchq.gaffer.operation.data.EntitySeed) List(java.util.List) Graph(uk.gov.gchq.gaffer.graph.Graph) CloseableIterable(uk.gov.gchq.gaffer.commonutil.iterable.CloseableIterable) View(uk.gov.gchq.gaffer.data.elementdefinition.view.View) GetAdjacentIds(uk.gov.gchq.gaffer.operation.impl.get.GetAdjacentIds) AddElements(uk.gov.gchq.gaffer.operation.impl.add.AddElements) OperationChain(uk.gov.gchq.gaffer.operation.OperationChain) Edge(uk.gov.gchq.gaffer.data.element.Edge) OperationException(uk.gov.gchq.gaffer.operation.OperationException) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) Streams(uk.gov.gchq.gaffer.commonutil.stream.Streams) StreamUtil(uk.gov.gchq.gaffer.commonutil.StreamUtil) User(uk.gov.gchq.gaffer.user.User) Element(uk.gov.gchq.gaffer.data.element.Element) GetElements(uk.gov.gchq.gaffer.operation.impl.get.GetElements) View(uk.gov.gchq.gaffer.data.elementdefinition.view.View) MapStoreProperties(uk.gov.gchq.gaffer.mapstore.MapStoreProperties) Graph(uk.gov.gchq.gaffer.graph.Graph) EntitySeed(uk.gov.gchq.gaffer.operation.data.EntitySeed) Edge(uk.gov.gchq.gaffer.data.element.Edge) HashSet(java.util.HashSet) Test(org.junit.jupiter.api.Test)

Example 40 with MapStoreProperties

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

the class VisibilityTest method executeOperation.

public static <OUTPUT, OPERATION extends Operation & Output<OUTPUT>> void executeOperation(final OPERATION operation, final BiConsumer<OUTPUT, String[]> resultConsumer) throws OperationException {
    final MapStoreProperties storeProperties = new MapStoreProperties();
    final Graph graph = new Graph.Builder().config(new GraphConfig.Builder().graphId("graph1").build()).addSchema(SCHEMA).storeProperties(storeProperties).build();
    final AddElements addElements = new AddElements.Builder().input(createElements()).build();
    graph.execute(addElements, getUserWithDataAuths(PUBLIC, PRIVATE));
    for (final String[] dataAuths : DATA_AUTH_COMBINATIONS) {
        resultConsumer.accept(graph.execute(operation, getUserWithDataAuths(dataAuths)), dataAuths);
    }
}
Also used : AddElements(uk.gov.gchq.gaffer.operation.impl.add.AddElements) Graph(uk.gov.gchq.gaffer.graph.Graph) MapStoreProperties(uk.gov.gchq.gaffer.mapstore.MapStoreProperties)

Aggregations

MapStoreProperties (uk.gov.gchq.gaffer.mapstore.MapStoreProperties)42 Schema (uk.gov.gchq.gaffer.store.schema.Schema)34 Graph (uk.gov.gchq.gaffer.graph.Graph)28 Test (org.junit.Test)19 Test (org.junit.jupiter.api.Test)15 GraphConfig (uk.gov.gchq.gaffer.graph.GraphConfig)10 Set (java.util.Set)7 Error (uk.gov.gchq.gaffer.core.exception.Error)7 HashSet (java.util.HashSet)6 AddElements (uk.gov.gchq.gaffer.operation.impl.add.AddElements)5 LinkedHashMap (java.util.LinkedHashMap)4 Element (uk.gov.gchq.gaffer.data.element.Element)4 TypeDefinition (uk.gov.gchq.gaffer.store.schema.TypeDefinition)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 View (uk.gov.gchq.gaffer.data.elementdefinition.view.View)3 OperationChain (uk.gov.gchq.gaffer.operation.OperationChain)3 GetAllElements (uk.gov.gchq.gaffer.operation.impl.get.GetAllElements)3