use of uk.gov.gchq.koryphe.impl.predicate.Exists in project Gaffer by gchq.
the class ViewTest method shouldConcatGlobalPreAggFiltersWhenSpecificGroupPreAggFiltersSet.
@Test
public void shouldConcatGlobalPreAggFiltersWhenSpecificGroupPreAggFiltersSet() {
// Given
final ElementFilter globalFilter = new ElementFilter.Builder().select(TestPropertyNames.PROP_1).execute(new Exists()).build();
final ElementFilter groupFilter = new ElementFilter.Builder().select(TestPropertyNames.PROP_1).execute(new ExampleFilterFunction()).build();
final View view = new View.Builder().globalEntities(new GlobalViewElementDefinition.Builder().groups(TestGroups.ENTITY).preAggregationFilter(globalFilter).build()).entity(TestGroups.ENTITY, new ViewElementDefinition.Builder().preAggregationFilter(groupFilter).build()).build();
// When
view.expandGlobalDefinitions();
// Then
assertTrue(view.hasPreAggregationFilters());
assertEquals(Exists.class.getSimpleName(), view.getEntity(TestGroups.ENTITY).getPreAggregationFilter().getComponents().get(0).getPredicate().getClass().getSimpleName());
assertEquals(ExampleFilterFunction.class.getSimpleName(), view.getEntity(TestGroups.ENTITY).getPreAggregationFilter().getComponents().get(1).getPredicate().getClass().getSimpleName());
}
use of uk.gov.gchq.koryphe.impl.predicate.Exists in project Gaffer by gchq.
the class ViewUtilTest method shouldReturnTrueWhenViewHasPreAggEdgeFilters.
@Test
public void shouldReturnTrueWhenViewHasPreAggEdgeFilters() {
final View view = new View.Builder().entity(TestGroups.ENTITY).edge(TestGroups.EDGE, new ViewElementDefinition.Builder().preAggregationFilter(new ElementFilter.Builder().select(TestPropertyNames.PROP_1).execute(new Exists()).build()).build()).edge(TestGroups.EDGE_2, null).build();
final boolean result = view.hasPreAggregationFilters();
assertTrue(result);
}
use of uk.gov.gchq.koryphe.impl.predicate.Exists in project Gaffer by gchq.
the class GetWalksIT method shouldGetPathsWithWhile.
@Test
public void shouldGetPathsWithWhile() throws Exception {
// Given
final GetElements operation = new GetElements.Builder().directedType(DirectedType.DIRECTED).view(new View.Builder().edge(TestGroups.EDGE, new ViewElementDefinition.Builder().properties(TestPropertyNames.COUNT).build()).build()).inOutType(SeededGraphFilters.IncludeIncomingOutgoingType.OUTGOING).build();
final GetWalks op = new Builder().input(seedA).operations(new While.Builder<>().conditional(new Conditional(// This will always be true
new Exists(), new Map.Builder<>().first(new AssertEntityIdsUnwrapped()).build())).operation(operation).maxRepeats(2).build()).build();
// When
final Iterable<Walk> results = graph.execute(op, getUser());
// Then
assertThat(getPaths(results)).isEqualTo("AED,ABC");
}
use of uk.gov.gchq.koryphe.impl.predicate.Exists in project gaffer-doc by gchq.
the class NotExample method doesNotExist.
public void doesNotExist() {
// ---------------------------------------------------------
final Not function = new Not<>(new Exists());
// ---------------------------------------------------------
runExample(function, null, 1, null, "", "abc");
}
use of uk.gov.gchq.koryphe.impl.predicate.Exists in project Gaffer by gchq.
the class AddOperationsToChainTest method shouldAddIfOperation.
@Test
public void shouldAddIfOperation() throws SerialisationException {
// Given
final GetWalks getWalks = new GetWalks();
final uk.gov.gchq.gaffer.operation.impl.Map map = new uk.gov.gchq.gaffer.operation.impl.Map();
final ToVertices toVertices = new ToVertices();
final ToSet toSet = new ToSet();
final Exists exists = new Exists();
final Limit limit = new Limit();
final GetAllElements getAllElements = new GetAllElements();
final GetElements getElements = new GetElements();
final Conditional conditional = new Conditional();
conditional.setPredicate(exists);
final If ifOp = new If.Builder<>().conditional(conditional).then(getElements).otherwise(getAllElements).build();
final AddOperationsToChain hook = new AddOperationsToChain();
final Map<String, List<Operation>> after = new HashMap<>();
final List<Operation> afterOps = new LinkedList<>();
afterOps.add(ifOp);
afterOps.add(limit);
after.put("uk.gov.gchq.gaffer.operation.impl.output.ToSet", afterOps);
hook.setAfter(after);
final OperationChain opChain = new OperationChain.Builder().first(getWalks).then(map).then(toVertices).then(toSet).build();
// When
hook.preExecute(opChain, new Context());
// Then
final OperationChain expectedOpChain = new OperationChain.Builder().first(getWalks).then(map).then(toVertices).then(toSet).then(ifOp).then(limit).build();
JsonAssert.assertEquals(JSONSerialiser.serialise(expectedOpChain), JSONSerialiser.serialise(opChain));
}
Aggregations