Search in sources :

Example 6 with EntitySeedExtractor

use of uk.gov.gchq.gaffer.operation.data.generator.EntitySeedExtractor 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();
}
Also used : SimpleEntityGenerator(uk.gov.gchq.gaffer.arrayliststore.data.generator.SimpleEntityGenerator) User(uk.gov.gchq.gaffer.user.User) CloseableIterable(uk.gov.gchq.gaffer.commonutil.iterable.CloseableIterable) ViewElementDefinition(uk.gov.gchq.gaffer.data.elementdefinition.view.ViewElementDefinition) View(uk.gov.gchq.gaffer.data.elementdefinition.view.View) GetEntities(uk.gov.gchq.gaffer.operation.impl.get.GetEntities) Graph(uk.gov.gchq.gaffer.graph.Graph) IsLessThan(uk.gov.gchq.gaffer.function.filter.IsLessThan) EntitySeedExtractor(uk.gov.gchq.gaffer.operation.data.generator.EntitySeedExtractor) GetEdges(uk.gov.gchq.gaffer.operation.impl.get.GetEdges) OperationChain(uk.gov.gchq.gaffer.operation.OperationChain) EntitySeed(uk.gov.gchq.gaffer.operation.data.EntitySeed) SimpleEntityDataObject(uk.gov.gchq.gaffer.arrayliststore.data.SimpleEntityDataObject) Test(org.junit.Test)

Aggregations

EntitySeedExtractor (uk.gov.gchq.gaffer.operation.data.generator.EntitySeedExtractor)6 Test (org.junit.Test)5 EntitySeed (uk.gov.gchq.gaffer.operation.data.EntitySeed)5 Edge (uk.gov.gchq.gaffer.data.element.Edge)4 View (uk.gov.gchq.gaffer.data.elementdefinition.view.View)2 Graph (uk.gov.gchq.gaffer.graph.Graph)2 OperationChain (uk.gov.gchq.gaffer.operation.OperationChain)2 GetEdges (uk.gov.gchq.gaffer.operation.impl.get.GetEdges)2 User (uk.gov.gchq.gaffer.user.User)2 SimpleEntityDataObject (uk.gov.gchq.gaffer.arrayliststore.data.SimpleEntityDataObject)1 SimpleEntityGenerator (uk.gov.gchq.gaffer.arrayliststore.data.generator.SimpleEntityGenerator)1 CloseableIterable (uk.gov.gchq.gaffer.commonutil.iterable.CloseableIterable)1 IsEdgeValidator (uk.gov.gchq.gaffer.data.IsEdgeValidator)1 Entity (uk.gov.gchq.gaffer.data.element.Entity)1 ElementFilter (uk.gov.gchq.gaffer.data.element.function.ElementFilter)1 ViewElementDefinition (uk.gov.gchq.gaffer.data.elementdefinition.view.ViewElementDefinition)1 DataGenerator7 (uk.gov.gchq.gaffer.example.gettingstarted.generator.DataGenerator7)1 IsLessThan (uk.gov.gchq.gaffer.function.filter.IsLessThan)1 IsMoreThan (uk.gov.gchq.gaffer.function.filter.IsMoreThan)1 AddElements (uk.gov.gchq.gaffer.operation.impl.add.AddElements)1