use of uk.gov.gchq.gaffer.arrayliststore.data.generator.SimpleEntityGenerator in project Gaffer by gchq.
the class ArrayListStoreTest method shouldAddAndGetEntitiesBySeed.
@Test
public void shouldAddAndGetEntitiesBySeed() throws OperationException {
final Graph graph = createGraph();
addElementsToGraph(graph);
//set up the operation to fetch the entities
final OperationChain<CloseableIterable<SimpleEntityDataObject>> opChain = new OperationChain.Builder().first(new GetEntities.Builder().addSeed(new EntitySeed(1)).view(new View.Builder().entity(TestGroups.ENTITY, new ViewElementDefinition.Builder().preAggregationFilter(new ElementFilter.Builder().select(TestPropertyNames.INT).execute(new IsLessThan(2)).build()).build()).build()).build()).then(new GenerateObjects.Builder<Entity, SimpleEntityDataObject>().generator(new SimpleEntityGenerator()).build()).build();
//now do the hop
final CloseableIterable<SimpleEntityDataObject> 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 SimpleEntityDataObject obj : results) {
LOGGER.info(obj.toString());
}
final List<SimpleEntityDataObject> resultList = Lists.newArrayList(results);
int index = 0;
SimpleEntityDataObject obj = resultList.get(index);
assertEquals(1, obj.getId());
assertEquals(1, obj.getVisibility());
assertEquals("Red", obj.getProperties());
}
results.close();
}
use of uk.gov.gchq.gaffer.arrayliststore.data.generator.SimpleEntityGenerator in project Gaffer by gchq.
the class ArrayListStoreTest method shouldAddAndGetRelatedEntities.
@Test
public void shouldAddAndGetRelatedEntities() throws OperationException {
final Graph graph = createGraph();
addElementsToGraph(graph);
//set up the operation to fetch the entities
final OperationChain<CloseableIterable<SimpleEntityDataObject>> opChain = new OperationChain.Builder().first(new GetEntities.Builder<>().addSeed(new EdgeSeed(2, 1, false)).view(new View.Builder().entity(TestGroups.ENTITY, new ViewElementDefinition.Builder().preAggregationFilter(new ElementFilter.Builder().select(TestPropertyNames.INT).execute(new IsLessThan(2)).build()).build()).build()).build()).then(new GenerateObjects.Builder<Entity, SimpleEntityDataObject>().generator(new SimpleEntityGenerator()).build()).build();
//now do the hop
final CloseableIterable<SimpleEntityDataObject> 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 SimpleEntityDataObject obj : results) {
LOGGER.info(obj.toString());
}
final List<SimpleEntityDataObject> resultList = Lists.newArrayList(results);
int index = 0;
SimpleEntityDataObject obj = resultList.get(index++);
assertEquals(1, obj.getId());
assertEquals(1, obj.getVisibility());
assertEquals("Red", obj.getProperties());
obj = resultList.get(index);
assertEquals(2, obj.getId());
assertEquals(1, obj.getVisibility());
assertEquals("Orange", obj.getProperties());
}
results.close();
}
use of uk.gov.gchq.gaffer.arrayliststore.data.generator.SimpleEntityGenerator in project Gaffer by gchq.
the class ArrayListStoreTest method shouldAddAndGetEdgesThenEntities.
@Test
public void shouldAddAndGetEdgesThenEntities() throws OperationException {
final Graph graph = createGraph();
addElementsToGraph(graph);
//set up the operation to fetch the entities
final OperationChain<CloseableIterable<SimpleEntityDataObject>> opChain = new OperationChain.Builder().first(new GetEdges.Builder<>().addSeed(new EntitySeed(1)).build()).then(new GenerateObjects.Builder<Edge, EntitySeed>().generator(new EntitySeedExtractor(IdentifierType.DESTINATION)).build()).then(new GetEntities.Builder().view(new View.Builder().entity(TestGroups.ENTITY, new ViewElementDefinition.Builder().preAggregationFilter(new ElementFilter.Builder().select(TestPropertyNames.INT).execute(new IsLessThan(2)).build()).build()).build()).build()).then(new GenerateObjects.Builder<Entity, SimpleEntityDataObject>().generator(new SimpleEntityGenerator()).build()).build();
//now do the hop
final CloseableIterable<SimpleEntityDataObject> 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 SimpleEntityDataObject obj : results) {
LOGGER.info(obj.toString());
}
final List<SimpleEntityDataObject> resultList = Lists.newArrayList(results);
assertEquals(1, resultList.size());
assertEquals(1, resultList.get(0).getId());
assertEquals(1, resultList.get(0).getVisibility());
assertEquals("Red", resultList.get(0).getProperties());
}
results.close();
}
Aggregations