use of uk.gov.gchq.gaffer.operation.impl.GetWalks in project Gaffer by gchq.
the class GetWalksIT method shouldGetPathsWithSimpleGraphHook_2.
@Test
public void shouldGetPathsWithSimpleGraphHook_2() throws Exception {
// Given
final AddOperationsToChain graphHook = new AddOperationsToChain();
final java.util.Map<String, List<Operation>> graphHookConfig = new HashMap<>();
graphHookConfig.put(GetElements.class.getName(), Lists.newArrayList(new Limit.Builder<>().resultLimit(1).build()));
graphHook.setAfter(graphHookConfig);
final GraphConfig config = new GraphConfig.Builder().addHook(graphHook).graphId("integrationTest").build();
createGraph(config);
addDefaultElements();
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(operation, operation).build();
// When
final Iterable<Walk> results = graph.execute(op, getUser());
// Then
assertThat(getPaths(results)).isEqualTo("ABC");
}
use of uk.gov.gchq.gaffer.operation.impl.GetWalks in project Gaffer by gchq.
the class GetWalksIT method shouldThrowExceptionIfGetPathsWithHopContainingNoEdges.
@Test
public void shouldThrowExceptionIfGetPathsWithHopContainingNoEdges() throws Exception {
// Given
final GetElements getEntities = new GetElements.Builder().directedType(DirectedType.DIRECTED).view(new View.Builder().entity(TestGroups.ENTITY).build()).build();
final GetElements getElements = new GetElements.Builder().directedType(DirectedType.DIRECTED).inOutType(SeededGraphFilters.IncludeIncomingOutgoingType.OUTGOING).view(new View.Builder().entity(TestGroups.ENTITY).edge(TestGroups.EDGE).build()).build();
final GetWalks op = new GetWalks.Builder().input(seedA).operations(getElements, getEntities, getElements).build();
// When / Then
try {
Lists.newArrayList(graph.execute(op, getUser()));
} catch (final Exception e) {
assertThat(e.getMessage()).as(e.getMessage()).contains("must contain a single hop");
}
}
use of uk.gov.gchq.gaffer.operation.impl.GetWalks in project Gaffer by gchq.
the class GetWalksIT method shouldGetPathsWithPruning.
@Test
public void shouldGetPathsWithPruning() throws Exception {
// Given
final StoreProperties properties = getStoreProperties();
properties.setOperationDeclarationPaths("getWalksWithPruningDeclaration.json");
createGraph(properties);
addDefaultElements();
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(operation, operation).build();
// When
final Iterable<Walk> results = graph.execute(op, getUser());
// Then
assertThat(getPaths(results)).isEqualTo("AED,ABC");
}
use of uk.gov.gchq.gaffer.operation.impl.GetWalks in project Gaffer by gchq.
the class GetWalksIT method shouldGetPathsWithPreFiltering_1.
@Test
@TraitRequirement(StoreTrait.POST_AGGREGATION_FILTERING)
public void shouldGetPathsWithPreFiltering_1() 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).build();
// When
final Iterable<Walk> results = graph.execute(op, getUser());
// Then
assertThat(getPaths(results)).isEqualTo("AED");
}
use of uk.gov.gchq.gaffer.operation.impl.GetWalks in project Gaffer by gchq.
the class GetWalksIT method shouldGetPathsWithPreFiltering_2.
@Test
@TraitRequirement(StoreTrait.POST_AGGREGATION_FILTERING)
public void shouldGetPathsWithPreFiltering_2() 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 IsLessThan(3)).build()).build()).build()).build()).then(operation).build();
final GetWalks op = new GetWalks.Builder().input(seedA).operations(operationChain, operationChain).build();
// When
final Iterable<Walk> results = graph.execute(op, getUser());
// Then
assertThat(getPaths(results)).isEqualTo("ABC");
}
Aggregations