Search in sources :

Example 6 with Walk

use of uk.gov.gchq.gaffer.data.graph.Walk in project Gaffer by gchq.

the class GetWalksIT method shouldGetPathsWithMultipleSeeds.

@Test
public void shouldGetPathsWithMultipleSeeds() 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, seedE).operations(operation, operation).build();
    // When
    final Iterable<Walk> results = graph.execute(op, getUser());
    // Then
    assertThat(getPaths(results)).isEqualTo("AED,ABC,EDA");
}
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 7 with Walk

use of uk.gov.gchq.gaffer.data.graph.Walk in project Gaffer by gchq.

the class GetWalksIT method shouldGetPathsWithModifiedViews.

@Test
public void shouldGetPathsWithModifiedViews() throws OperationException {
    // Given
    final GetElements operation = new GetElements.Builder().directedType(DirectedType.DIRECTED).inOutType(SeededGraphFilters.IncludeIncomingOutgoingType.OUTGOING).view(new View.Builder().edge(TestGroups.EDGE, new ViewElementDefinition.Builder().preAggregationFilter(new ElementFilter.Builder().select(TestPropertyNames.COUNT).execute(new IsMoreThan(0L)).build()).build()).build()).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) ElementFilter(uk.gov.gchq.gaffer.data.element.function.ElementFilter) Builder(uk.gov.gchq.gaffer.operation.impl.GetWalks.Builder) GetElements(uk.gov.gchq.gaffer.operation.impl.get.GetElements) IsMoreThan(uk.gov.gchq.koryphe.impl.predicate.IsMoreThan) Test(org.junit.Test)

Example 8 with Walk

use of uk.gov.gchq.gaffer.data.graph.Walk in project Gaffer by gchq.

the class GetWalksIT method shouldFilterAllWalksWhenNoneContainProperty.

@Test
public void shouldFilterAllWalksWhenNoneContainProperty() throws Exception {
    final Iterable<Walk> walks = getWalksThatPassPredicateTest(new CollectionContains(6));
    assertThat(getPaths(walks)).isEmpty();
}
Also used : Walk(uk.gov.gchq.gaffer.data.graph.Walk) CollectionContains(uk.gov.gchq.koryphe.impl.predicate.CollectionContains) Test(org.junit.Test)

Example 9 with Walk

use of uk.gov.gchq.gaffer.data.graph.Walk in project Gaffer by gchq.

the class GetWalksIT method shouldReturnAllWalksWhenConditionalIsUnconfigured.

@Test
public void shouldReturnAllWalksWhenConditionalIsUnconfigured() throws Exception {
    final Iterable<Walk> walks = executeGetWalksApplyingConditional(new Conditional());
    assertThat(getPaths(walks)).isEqualTo("AED,ABC");
}
Also used : Walk(uk.gov.gchq.gaffer.data.graph.Walk) Conditional(uk.gov.gchq.gaffer.operation.util.Conditional) Test(org.junit.Test)

Example 10 with Walk

use of uk.gov.gchq.gaffer.data.graph.Walk in project Gaffer by gchq.

the class GetWalksIT method shouldGetPathsWithWhile.

@Test
public void shouldGetPathsWithWhile() 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 Builder().input(seedA).operations(new While.Builder<>().conditional(new Conditional(// This will always be true
    new Exists(), new Map.Builder<>().first(new AssertEntityIdsUnwrapped()).build())).operation(operation).maxRepeats(2).build()).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) GetElements(uk.gov.gchq.gaffer.operation.impl.get.GetElements) ViewElementDefinition(uk.gov.gchq.gaffer.data.elementdefinition.view.ViewElementDefinition) Conditional(uk.gov.gchq.gaffer.operation.util.Conditional) View(uk.gov.gchq.gaffer.data.elementdefinition.view.View) Exists(uk.gov.gchq.koryphe.impl.predicate.Exists) HashMap(java.util.HashMap) Map(uk.gov.gchq.gaffer.operation.impl.Map) Test(org.junit.Test)

Aggregations

Walk (uk.gov.gchq.gaffer.data.graph.Walk)36 Test (org.junit.Test)25 GetWalks (uk.gov.gchq.gaffer.operation.impl.GetWalks)19 Builder (uk.gov.gchq.gaffer.operation.impl.GetWalks.Builder)19 GetElements (uk.gov.gchq.gaffer.operation.impl.get.GetElements)19 ViewElementDefinition (uk.gov.gchq.gaffer.data.elementdefinition.view.ViewElementDefinition)17 View (uk.gov.gchq.gaffer.data.elementdefinition.view.View)13 Test (org.junit.jupiter.api.Test)7 Set (java.util.Set)6 Conditional (uk.gov.gchq.gaffer.operation.util.Conditional)5 CollectionContains (uk.gov.gchq.koryphe.impl.predicate.CollectionContains)5 IsMoreThan (uk.gov.gchq.koryphe.impl.predicate.IsMoreThan)5 HashMap (java.util.HashMap)4 OperationChain (uk.gov.gchq.gaffer.operation.OperationChain)4 Map (uk.gov.gchq.gaffer.operation.impl.Map)4 Edge (uk.gov.gchq.gaffer.data.element.Edge)3 Entity (uk.gov.gchq.gaffer.data.element.Entity)3 TraitRequirement (uk.gov.gchq.gaffer.integration.TraitRequirement)3 OperationException (uk.gov.gchq.gaffer.operation.OperationException)3 List (java.util.List)2