use of uk.gov.gchq.gaffer.function.filter.IsLessThan 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();
}
use of uk.gov.gchq.gaffer.function.filter.IsLessThan in project Gaffer by gchq.
the class OrExample method property1IsLessThan2OrProperty2IsMoreThan2.
public void property1IsLessThan2OrProperty2IsMoreThan2() {
// ---------------------------------------------------------
final Or function = new Or(Arrays.asList(new ConsumerFunctionContext.Builder<Integer, FilterFunction>().select(// select first property
0).execute(new IsLessThan(2)).build(), new ConsumerFunctionContext.Builder<Integer, FilterFunction>().select(// select second property
1).execute(new IsMoreThan(2)).build()));
// ---------------------------------------------------------
runExample(function, new Object[] { 1, 3 }, new Object[] { 1, 1 }, new Object[] { 3, 3 }, new Object[] { 3, 1 }, new Object[] { 1L, 3L }, new Object[] { 1 });
}
use of uk.gov.gchq.gaffer.function.filter.IsLessThan in project Gaffer by gchq.
the class OrExample method isLessThan2OrIsMoreThan2.
public void isLessThan2OrIsMoreThan2() {
// ---------------------------------------------------------
final Or function = new Or(Arrays.asList(new ConsumerFunctionContext.Builder<Integer, FilterFunction>().select(// select first property
0).execute(new IsLessThan(2)).build(), new ConsumerFunctionContext.Builder<Integer, FilterFunction>().select(// select first property
0).execute(new IsMoreThan(2)).build()));
// ---------------------------------------------------------
runExample(function, new Object[] { 1 }, new Object[] { 2 }, new Object[] { 3 }, new Object[] { 1L }, new Object[] { 3L });
}
use of uk.gov.gchq.gaffer.function.filter.IsLessThan in project Gaffer by gchq.
the class IsLessThanExample method isLessThanAString.
public void isLessThanAString() {
// ---------------------------------------------------------
final IsLessThan function = new IsLessThan("B");
// ---------------------------------------------------------
runExample(function, 1, "A", "B", "C");
}
use of uk.gov.gchq.gaffer.function.filter.IsLessThan in project Gaffer by gchq.
the class IsLessThanExample method isLessThanOrEqualTo5.
public void isLessThanOrEqualTo5() {
// ---------------------------------------------------------
final IsLessThan function = new IsLessThan(5, true);
// ---------------------------------------------------------
runExample(function, 1, 1L, 5, 5L, 10, 10L, "1");
}
Aggregations