use of uk.gov.gchq.gaffer.arrayliststore.data.generator.SimpleEdgeGenerator in project Gaffer by gchq.
the class ArrayListStoreTest method shouldAddAndGetRelatedEdges.
@Test
public void shouldAddAndGetRelatedEdges() throws OperationException {
final Graph graph = createGraph();
addElementsToGraph(graph);
//set up the operation to fetch the edges
final OperationChain<CloseableIterable<SimpleEdgeDataObject>> opChain = new OperationChain.Builder().first(new GetEdges.Builder<>().addSeed(new EntitySeed(1)).addSeed(new EntitySeed(2)).view(new View.Builder().edge(TestGroups.EDGE, new ViewElementDefinition.Builder().preAggregationFilter(new ElementFilter.Builder().select(TestPropertyNames.INT).execute(new IsLessThan(2)).build()).build()).build()).build()).then(new GenerateObjects.Builder<Edge, SimpleEdgeDataObject>().generator(new SimpleEdgeGenerator()).build()).build();
//now do the hop
final CloseableIterable<SimpleEdgeDataObject> results = graph.execute(opChain, new User());
//check the results by converting our edges back into SimpleDataObjects
if (!results.iterator().hasNext()) {
fail("No results returned");
} else {
for (final SimpleEdgeDataObject obj : results) {
LOGGER.info(obj.toString());
}
final List<SimpleEdgeDataObject> resultList = Lists.newArrayList(results);
assertEquals(3, resultList.size());
int index = 0;
SimpleEdgeDataObject obj = resultList.get(index++);
assertEquals(1, obj.getLeft());
assertEquals(2, obj.getRight());
assertEquals(1, obj.getVisibility());
assertEquals("121", obj.getProperties());
obj = resultList.get(index++);
assertEquals(2, obj.getLeft());
assertEquals(3, obj.getRight());
assertEquals(1, obj.getVisibility());
assertEquals("231", obj.getProperties());
obj = resultList.get(index);
assertEquals(4, obj.getLeft());
assertEquals(1, obj.getRight());
assertEquals(1, obj.getVisibility());
assertEquals("142", obj.getProperties());
}
results.close();
}
use of uk.gov.gchq.gaffer.arrayliststore.data.generator.SimpleEdgeGenerator in project Gaffer by gchq.
the class ArrayListStoreTest method shouldAddAndGetEdgesBySeed.
@Test
public void shouldAddAndGetEdgesBySeed() throws OperationException {
final Graph graph = createGraph();
addElementsToGraph(graph);
//set up the operation to fetch the edges
final OperationChain<CloseableIterable<SimpleEdgeDataObject>> opChain = new OperationChain.Builder().first(new GetEdges.Builder().addSeed(new EdgeSeed(2, 1, false)).view(new View.Builder().edge(TestGroups.EDGE, new ViewElementDefinition.Builder().preAggregationFilter(new ElementFilter.Builder().select(TestPropertyNames.INT).execute(new IsLessThan(2)).build()).build()).build()).build()).then(new GenerateObjects.Builder<Edge, SimpleEdgeDataObject>().generator(new SimpleEdgeGenerator()).build()).build();
//now do the hop
final CloseableIterable<SimpleEdgeDataObject> results = graph.execute(opChain, new User());
//check the results by converting our edges back into SimpleDataObjects
if (!results.iterator().hasNext()) {
fail("No results returned");
} else {
for (final SimpleEdgeDataObject obj : results) {
LOGGER.info(obj.toString());
}
final List<SimpleEdgeDataObject> resultList = Lists.newArrayList(results);
assertEquals(1, resultList.size());
int index = 0;
SimpleEdgeDataObject obj = resultList.get(index);
assertEquals(1, obj.getLeft());
assertEquals(2, obj.getRight());
assertEquals(1, obj.getVisibility());
assertEquals("121", obj.getProperties());
}
results.close();
}
Aggregations