use of uk.gov.gchq.koryphe.impl.predicate.IsMoreThan 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.IsMoreThan 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.IsMoreThan in project Gaffer by gchq.
the class RoadTrafficTestQueries method checkRoadJunctionsInSouthWestHeavilyUsedByBusesIn2000.
@Test
public void checkRoadJunctionsInSouthWestHeavilyUsedByBusesIn2000() throws OperationException, ParseException {
assumeTrue(this.graph.hasTrait(StoreTrait.QUERY_AGGREGATION), "Skipping test as the store does not implement required trait.");
assumeTrue(this.graph.hasTrait(StoreTrait.TRANSFORMATION), "Skipping test as the store does not implement required trait.");
assumeTrue(this.graph.hasTrait(StoreTrait.PRE_AGGREGATION_FILTERING), "Skipping test as the store does not implement required trait.");
assumeTrue(this.graph.hasTrait(StoreTrait.POST_AGGREGATION_FILTERING), "Skipping test as the store does not implement required trait.");
assertNotNull(this.graph, "graph is null");
final Date JAN_01_2000 = new SimpleDateFormat("yyyy-MM-dd").parse("2000-01-01");
final Date JAN_01_2001 = new SimpleDateFormat("yyyy-MM-dd").parse("2001-01-01");
final OperationChain<Iterable<? extends String>> opChain = new OperationChain.Builder().first(new GetAdjacentIds.Builder().input(new EntitySeed("South West")).view(new View.Builder().edge("RegionContainsLocation").build()).build()).then(new GetAdjacentIds.Builder().view(new View.Builder().edge("LocationContainsRoad").build()).build()).then(new ToSet<>()).then(new GetAdjacentIds.Builder().view(new View.Builder().edge("RoadHasJunction").build()).build()).then(new GetElements.Builder().view(new View.Builder().globalElements(new GlobalViewElementDefinition.Builder().groupBy().build()).entity("JunctionUse", new ViewElementDefinition.Builder().preAggregationFilter(new ElementFilter.Builder().select("startDate").execute(new IsMoreThan(JAN_01_2000, true)).select("endDate").execute(new IsLessThan(JAN_01_2001, false)).build()).postAggregationFilter(new ElementFilter.Builder().select("countByVehicleType").execute(new PredicateMap<>("BUS", new IsMoreThan(1000L))).build()).transientProperty("busCount", Long.class).transformer(new ElementTransformer.Builder().select("countByVehicleType").execute(new FreqMapExtractor("BUS")).project("busCount").build()).build()).build()).inOutType(SeededGraphFilters.IncludeIncomingOutgoingType.OUTGOING).build()).then(new ToCsv.Builder().generator(new CsvGenerator.Builder().vertex("Junction").property("busCount", "Bus Count").build()).build()).build();
Set<String> resultSet = new HashSet<>();
final Iterable<? extends String> results = this.graph.execute(opChain, this.user);
for (final String r : results) {
resultSet.add(r);
}
assertEquals(SW_ROAD_JUNCTIONS_WITH_HEAVY_BUS_USAGE_IN_2000, resultSet);
}
use of uk.gov.gchq.koryphe.impl.predicate.IsMoreThan in project Gaffer by gchq.
the class GetWalksIT method shouldGetPartialPaths.
@Test
@TraitRequirement(StoreTrait.POST_AGGREGATION_FILTERING)
public void shouldGetPartialPaths() 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 OperationChain operationChain = new OperationChain.Builder().first(new GetElements.Builder().view(new View.Builder().entity(TestGroups.ENTITY, new ViewElementDefinition.Builder().postAggregationFilter(new ElementFilter.Builder().select(TestPropertyNames.PROP_1).execute(new IsMoreThan(3)).build()).build()).build()).build()).then(operation).build();
final GetWalks op = new GetWalks.Builder().input(seedA).operations(operation, operationChain).includePartial().build();
// When
final Iterable<Walk> results = graph.execute(op, getUser());
// Then
assertThat(getPaths(results)).isEqualTo("AED,AB");
}
use of uk.gov.gchq.koryphe.impl.predicate.IsMoreThan in project Gaffer by gchq.
the class GetWalksIT method shouldReturnNoResultsWhenNoEntityResults.
@Test
public void shouldReturnNoResultsWhenNoEntityResults() throws Exception {
// Given
final GetWalks op = new GetWalks.Builder().input(seedA).operations(new GetElements.Builder().view(new View.Builder().edge(TestGroups.EDGE).build()).build(), new OperationChain.Builder().first(new GetElements.Builder().view(new View.Builder().entity(TestGroups.ENTITY, new ViewElementDefinition.Builder().preAggregationFilter(new ElementFilter.Builder().select(TestPropertyNames.INT).execute(new IsMoreThan(10000)).build()).build()).build()).build()).then(new GetElements()).build()).build();
// When
final Iterable<Walk> results = graph.execute(op, getUser());
// Then
assertThat(Lists.newArrayList(results)).isEmpty();
}
Aggregations