Search in sources :

Example 11 with GetWalks

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");
}
Also used : Walk(uk.gov.gchq.gaffer.data.graph.Walk) GetWalks(uk.gov.gchq.gaffer.operation.impl.GetWalks) Builder(uk.gov.gchq.gaffer.operation.impl.GetWalks.Builder) Builder(uk.gov.gchq.gaffer.operation.impl.GetWalks.Builder) GetElements(uk.gov.gchq.gaffer.operation.impl.get.GetElements) ViewElementDefinition(uk.gov.gchq.gaffer.data.elementdefinition.view.ViewElementDefinition) View(uk.gov.gchq.gaffer.data.elementdefinition.view.View) Test(org.junit.Test)

Example 12 with GetWalks

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");
}
Also used : Walk(uk.gov.gchq.gaffer.data.graph.Walk) GetWalks(uk.gov.gchq.gaffer.operation.impl.GetWalks) Builder(uk.gov.gchq.gaffer.operation.impl.GetWalks.Builder) Builder(uk.gov.gchq.gaffer.operation.impl.GetWalks.Builder) GetElements(uk.gov.gchq.gaffer.operation.impl.get.GetElements) ViewElementDefinition(uk.gov.gchq.gaffer.data.elementdefinition.view.ViewElementDefinition) View(uk.gov.gchq.gaffer.data.elementdefinition.view.View) Test(org.junit.Test)

Example 13 with GetWalks

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();
}
Also used : EntityId(uk.gov.gchq.gaffer.data.element.id.EntityId) GetWalks(uk.gov.gchq.gaffer.operation.impl.GetWalks) ArrayList(java.util.ArrayList) GetElements(uk.gov.gchq.gaffer.operation.impl.get.GetElements) View(uk.gov.gchq.gaffer.data.elementdefinition.view.View) AddNamedView(uk.gov.gchq.gaffer.named.view.AddNamedView)

Example 14 with GetWalks

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());
}
Also used : GetWalks(uk.gov.gchq.gaffer.operation.impl.GetWalks) Schema(uk.gov.gchq.gaffer.store.schema.Schema) Test(org.junit.jupiter.api.Test)

Example 15 with GetWalks

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);
}
Also used : GetWalks(uk.gov.gchq.gaffer.operation.impl.GetWalks) EntitySeed(uk.gov.gchq.gaffer.operation.data.EntitySeed) GetElements(uk.gov.gchq.gaffer.operation.impl.get.GetElements) Conditional(uk.gov.gchq.gaffer.operation.util.Conditional) If(uk.gov.gchq.gaffer.operation.impl.If) Test(org.junit.jupiter.api.Test)

Aggregations

GetWalks (uk.gov.gchq.gaffer.operation.impl.GetWalks)31 GetElements (uk.gov.gchq.gaffer.operation.impl.get.GetElements)27 Test (org.junit.Test)19 Walk (uk.gov.gchq.gaffer.data.graph.Walk)19 Builder (uk.gov.gchq.gaffer.operation.impl.GetWalks.Builder)19 ViewElementDefinition (uk.gov.gchq.gaffer.data.elementdefinition.view.ViewElementDefinition)17 View (uk.gov.gchq.gaffer.data.elementdefinition.view.View)15 Test (org.junit.jupiter.api.Test)11 OperationChain (uk.gov.gchq.gaffer.operation.OperationChain)9 Conditional (uk.gov.gchq.gaffer.operation.util.Conditional)8 HashMap (java.util.HashMap)5 Operation (uk.gov.gchq.gaffer.operation.Operation)5 If (uk.gov.gchq.gaffer.operation.impl.If)5 IsMoreThan (uk.gov.gchq.koryphe.impl.predicate.IsMoreThan)5 List (java.util.List)4 EntitySeed (uk.gov.gchq.gaffer.operation.data.EntitySeed)4 Limit (uk.gov.gchq.gaffer.operation.impl.Limit)4 LinkedHashMap (java.util.LinkedHashMap)3 GraphConfig (uk.gov.gchq.gaffer.graph.GraphConfig)3 AddOperationsToChain (uk.gov.gchq.gaffer.graph.hook.AddOperationsToChain)3