use of uk.gov.gchq.gaffer.operation.impl.GetWalks in project Gaffer by gchq.
the class GetWalksIT method shouldGetPaths.
@Test
public void shouldGetPaths() 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(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 shouldGetPathsWithLoops_3.
@Test
public void shouldGetPathsWithLoops_3() throws Exception {
// Given
final GetElements operation = new GetElements.Builder().directedType(DirectedType.DIRECTED).view(new View.Builder().edge(TestGroups.EDGE_3, new ViewElementDefinition.Builder().properties(TestPropertyNames.COUNT).build()).build()).inOutType(SeededGraphFilters.IncludeIncomingOutgoingType.OUTGOING).build();
final GetWalks op = new GetWalks.Builder().input(seedA).operations(operation, operation, operation, operation).build();
// When
final Iterable<Walk> results = graph.execute(op, getUser());
// Then
assertThat(getPaths(results)).isEqualTo("AAAAA");
}
use of uk.gov.gchq.gaffer.operation.impl.GetWalks in project Gaffer by gchq.
the class AbstractExamplesFactory method getWalks.
public GetWalks getWalks() {
final List<String> edges = new ArrayList<>(getSchema().getEdgeGroups());
if (edges.isEmpty()) {
return new GetWalks();
}
final EntityId entityId = getEntityId(1);
if (null == entityId.getVertex()) {
entityId.setVertex("vertex1");
}
return new GetWalks.Builder().input(entityId).operations(new GetElements.Builder().view(new View.Builder().edge(edges.size() > 1 ? edges.get(1) : edges.get(0)).build()).build()).resultsLimit(10000).build();
}
use of uk.gov.gchq.gaffer.operation.impl.GetWalks in project Gaffer by gchq.
the class AbstractExamplesFactoryTest method shouldProvideEmptyGetWalksIfSchemaContainsNoEdges.
@Test
public void shouldProvideEmptyGetWalksIfSchemaContainsNoEdges() throws InstantiationException, IllegalAccessException {
// Given
TestExamplesFactory examplesFactory = new TestExamplesFactory(new Schema());
// When
GetWalks operation = (GetWalks) examplesFactory.generateExample(GetWalks.class);
// Then
assertNull(operation.getInput());
assertEquals(0, operation.getOperations().size());
}
use of uk.gov.gchq.gaffer.operation.impl.GetWalks in project Gaffer by gchq.
the class IfHandlerTest method shouldExecuteThenOperationWhenConditionMet.
@Test
public void shouldExecuteThenOperationWhenConditionMet() throws OperationException {
// Given
final Object input = Arrays.asList(new EntitySeed("1"), new EntitySeed("2"));
final Conditional conditional = mock(Conditional.class);
final Predicate<Object> predicate = mock(Predicate.class);
final GetWalks then = mock(GetWalks.class);
final GetElements otherwise = mock(GetElements.class);
final If filter = new If.Builder<>().input(input).conditional(conditional).then(then).otherwise(otherwise).build();
final IfHandler handler = new IfHandler();
given(conditional.getPredicate()).willReturn(predicate);
given(predicate.test(input)).willReturn(true);
// When
handler.doOperation(filter, context, store);
// Then
verify(predicate).test(input);
verify(store).execute(then, context);
verify(store, never()).execute(otherwise, context);
}
Aggregations