use of uk.gov.gchq.gaffer.data.graph.Walk in project Gaffer by gchq.
the class ExtractWalkEdgesTest method shouldReturnEdgesFromWalkObject.
@Test
public void shouldReturnEdgesFromWalkObject() {
// Given
final Function<Walk, Iterable<Set<Edge>>> function = new ExtractWalkEdges();
final Walk walk = new Walk.Builder().edge(EDGE_AB).entity(ENTITY_B).edge(EDGE_BC).entity(ENTITY_C).edge(EDGE_CA).build();
// When
final Iterable<Set<Edge>> results = function.apply(walk);
// Then
assertThat(results).containsOnly(Sets.newHashSet(EDGE_AB), Sets.newHashSet(EDGE_BC), Sets.newHashSet(EDGE_CA));
}
use of uk.gov.gchq.gaffer.data.graph.Walk in project Gaffer by gchq.
the class GetWalksIT method shouldGetPathsWithWhileRepeat.
@Test
public void shouldGetPathsWithWhileRepeat() 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 GetWalks.Builder().input(seedA).operations(new While.Builder<>().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.gaffer.data.graph.Walk in project Gaffer by gchq.
the class GetWalksIT method shouldFilterWalksUsingWalkPredicateWithoutTransform.
@Test
public void shouldFilterWalksUsingWalkPredicateWithoutTransform() throws Exception {
final Conditional conditional = new Conditional();
conditional.setPredicate(new WalkPredicate());
final Iterable<Walk> walks = executeGetWalksApplyingConditional(conditional);
assertThat(getPaths(walks)).isEqualTo("AED");
}
use of uk.gov.gchq.gaffer.data.graph.Walk 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.gaffer.data.graph.Walk in project Gaffer by gchq.
the class GetWalksIT method getPaths.
private String getPaths(final Iterable<Walk> walks) {
final StringBuilder sb = new StringBuilder();
for (final Walk walk : walks) {
sb.append(walk.getVerticesOrdered().stream().map(Object::toString).collect(Collectors.joining("")));
sb.append(',');
}
if (sb.length() > 0) {
sb.setLength(sb.length() - 1);
}
return sb.toString();
}
Aggregations