use of uk.gov.gchq.koryphe.impl.predicate.IsIn in project gaffer-doc by gchq.
the class IsInExample method isInSet.
public void isInSet() {
// ---------------------------------------------------------
final IsIn function = new IsIn(5, 5L, "5", '5');
// ---------------------------------------------------------
runExample(function, null, 5, 5L, "5", '5', 1, 1L, "1", '1');
}
use of uk.gov.gchq.koryphe.impl.predicate.IsIn in project Gaffer by gchq.
the class FilterHandlerTest method shouldFilterBasedOnMatchedVertex.
@Test
public void shouldFilterBasedOnMatchedVertex() throws OperationException {
// Given
final Schema schema = new Schema.Builder().edge(TestGroups.EDGE, new SchemaEdgeDefinition.Builder().source("vertex").destination("vertex").property(TestPropertyNames.COUNT, "count.long").build()).type("vertex", new TypeDefinition(String.class)).type("count.long", new TypeDefinition(Long.class)).build();
given(store.getSchema()).willReturn(schema);
final Filter filter = new Filter.Builder().input(new Edge.Builder().group(TestGroups.EDGE).source("srcVal1").dest("destVal1").matchedVertex(EdgeId.MatchedVertex.SOURCE).build(), new Edge.Builder().group(TestGroups.EDGE).source("srcVal2").dest("destVal2").matchedVertex(EdgeId.MatchedVertex.SOURCE).build(), new Edge.Builder().group(TestGroups.EDGE).source("srcVal3").dest("destVal3").matchedVertex(EdgeId.MatchedVertex.DESTINATION).build(), new Edge.Builder().group(TestGroups.EDGE).source("srcVal4").dest("destVal4").matchedVertex(EdgeId.MatchedVertex.DESTINATION).build()).edge(TestGroups.EDGE, new ElementFilter.Builder().select(IdentifierType.MATCHED_VERTEX.name()).execute(new IsIn("srcVal1", "destVal3")).build()).build();
// When
final Iterable<? extends Element> results = handler.doOperation(filter, context, store);
// Then
ElementUtil.assertElementEquals(Arrays.asList(new Edge.Builder().group(TestGroups.EDGE).source("srcVal1").dest("destVal1").matchedVertex(EdgeId.MatchedVertex.SOURCE).build(), new Edge.Builder().group(TestGroups.EDGE).source("srcVal3").dest("destVal3").matchedVertex(EdgeId.MatchedVertex.SOURCE).build()), results);
}
use of uk.gov.gchq.koryphe.impl.predicate.IsIn in project Gaffer by gchq.
the class UpdateViewHookTest method shouldMergeAndApplyWhiteList.
@Test
public void shouldMergeAndApplyWhiteList() throws Exception {
updateViewHook.setViewToMerge(viewToMerge);
updateViewHook.setWithOpAuth(Sets.newHashSet("opA"));
updateViewHook.setWhiteListElementGroups(Sets.newHashSet("white2", "white1", "testGroup"));
opChain = new OperationChain.Builder().first(new GetAllElements.Builder().view(new View.Builder().entity("wrong1").entity("white1").entity("white2").edge("testGroup", new ViewElementDefinition.Builder().preAggregationFilter(new ElementFilter.Builder().select("prop1").execute(new Exists()).build()).build()).build()).build()).build();
updateViewHook.preExecute(opChain, new Context(new User.Builder().opAuth("opA").build()));
GetAllElements op = (GetAllElements) opChain.getOperations().get(0);
JsonAssert.assertEquals(new View.Builder().entity("white1", new ViewElementDefinition.Builder().preAggregationFilter(new ElementFilter.Builder().select("prop1").execute(new IsIn("value1", "value2")).build()).build()).entity("white2").edge("testGroup", new ViewElementDefinition.Builder().preAggregationFilter(new ElementFilter.Builder().select("prop1").execute(new Exists()).select("count").execute(new IsMoreThan(10)).build()).build()).build().toJson(true), op.getView().toJson(true));
assertTrue(op.getView().getGroups().contains("testGroup"));
}
use of uk.gov.gchq.koryphe.impl.predicate.IsIn in project Gaffer by gchq.
the class UpdateViewHookTest method setUp.
@BeforeEach
public void setUp() throws Exception {
userAuths.clear();
validAuths.clear();
updateViewHook = new UpdateViewHook();
viewToMerge = new View.Builder().entity("white1", new ViewElementDefinition.Builder().preAggregationFilter(new ElementFilter.Builder().select("prop1").execute(new IsIn("value1", "value2")).build()).build()).edge("testGroup", new ViewElementDefinition.Builder().preAggregationFilter(new ElementFilter.Builder().select("count").execute(new IsMoreThan(10)).build()).build()).build();
userOpAuths.clear();
userDataAuths.clear();
opAuths.clear();
dataAuths.clear();
userBuilder = new Builder();
}
use of uk.gov.gchq.koryphe.impl.predicate.IsIn in project Gaffer by gchq.
the class AggregationIT method shouldGetAllElementsWithFilterSummarisation.
@Test
@TraitRequirement({ StoreTrait.PRE_AGGREGATION_FILTERING, StoreTrait.QUERY_AGGREGATION })
public void shouldGetAllElementsWithFilterSummarisation() throws Exception {
final Edge edge1 = getEdges().get(new EdgeSeed(SOURCE_1, DEST_1, false)).emptyClone();
edge1.putProperty(TestPropertyNames.INT, 100);
edge1.putProperty(TestPropertyNames.COUNT, 1L);
final Edge edge2 = edge1.emptyClone();
edge2.putProperty(TestPropertyNames.INT, 101);
edge2.putProperty(TestPropertyNames.COUNT, 1L);
graph.execute(new AddElements.Builder().input(edge1, edge2).build(), getUser());
final GetAllElements op = new GetAllElements.Builder().view(new View.Builder().edge(TestGroups.EDGE, new ViewElementDefinition.Builder().preAggregationFilter(new ElementFilter.Builder().select(TestPropertyNames.INT).execute(new IsIn(Arrays.asList(100, 101))).build()).groupBy().aggregator(new ElementAggregator.Builder().select(TestPropertyNames.INT).execute(new Product()).build()).build()).build()).build();
// When
final CloseableIterable<? extends Element> results = graph.execute(op, getUser());
// Then
final List<Element> resultList = Lists.newArrayList(results);
assertThat(resultList).hasSize(1);
// aggregation is has been replaced with Product
assertThat(resultList.get(0).getProperty(TestPropertyNames.INT)).isEqualTo(10100);
}
Aggregations