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