Search in sources :

Example 36 with GetElements

use of uk.gov.gchq.gaffer.operation.impl.get.GetElements in project Gaffer by gchq.

the class IfTest method shouldUpdateOperations.

@Test
public void shouldUpdateOperations() {
    // Given
    final GetElements getElements = new GetElements.Builder().input(new EntitySeed("A")).build();
    final OperationChain opChain = new OperationChain.Builder().first(new GetAllElements()).then(new Limit<>(3)).build();
    final If<Object, Object> ifOp = new If.Builder<>().condition(false).build();
    final Collection<Operation> opList = Lists.newArrayList(new OperationChain<>(), getElements, opChain);
    // When
    ifOp.updateOperations(opList);
    // Then
    assertNotNull(ifOp.getThen());
    assertNotNull(ifOp.getOtherwise());
    assertEquals(getElements, ifOp.getThen());
    assertEquals(opChain, ifOp.getOtherwise());
}
Also used : OperationChain(uk.gov.gchq.gaffer.operation.OperationChain) EntitySeed(uk.gov.gchq.gaffer.operation.data.EntitySeed) GetAllElements(uk.gov.gchq.gaffer.operation.impl.get.GetAllElements) GetElements(uk.gov.gchq.gaffer.operation.impl.get.GetElements) Operation(uk.gov.gchq.gaffer.operation.Operation) OperationTest(uk.gov.gchq.gaffer.operation.OperationTest) Test(org.junit.jupiter.api.Test)

Example 37 with GetElements

use of uk.gov.gchq.gaffer.operation.impl.get.GetElements in project Gaffer by gchq.

the class OperationChainTest method shouldDetermineOperationChainOutputType.

@Test
public void shouldDetermineOperationChainOutputType() {
    // Given
    final Operation operation1 = mock(Operation.class);
    final GetElements operation2 = mock(GetElements.class);
    final TypeReference typeRef = mock(TypeReference.class);
    given(operation2.getOutputTypeReference()).willReturn(typeRef);
    // When
    final OperationChain opChain = new OperationChain.Builder().first(operation1).then(operation2).build();
    // When / Then
    assertSame(typeRef, opChain.getOutputTypeReference());
}
Also used : Builder(uk.gov.gchq.gaffer.operation.OperationChain.Builder) GetElements(uk.gov.gchq.gaffer.operation.impl.get.GetElements) TypeReference(com.fasterxml.jackson.core.type.TypeReference) Test(org.junit.jupiter.api.Test)

Example 38 with GetElements

use of uk.gov.gchq.gaffer.operation.impl.get.GetElements in project Gaffer by gchq.

the class GetWalksTest method builderShouldCreatePopulatedOperation.

@Test
@Override
public void builderShouldCreatePopulatedOperation() {
    // Given
    final GetWalks getWalks = new GetWalks.Builder().input(new EntitySeed("1"), new EntitySeed("2")).operations(new GetElements()).resultsLimit(100).build();
    // Then
    Assertions.<EntityId>assertThat(getWalks.getInput()).hasSize(2).containsOnly(new EntitySeed("1"), new EntitySeed("2"));
    assertThat(getWalks.getResultsLimit()).isEqualTo(100);
    assertThat(getWalks.getOperations()).hasSize(1);
}
Also used : EntityId(uk.gov.gchq.gaffer.data.element.id.EntityId) EntitySeed(uk.gov.gchq.gaffer.operation.data.EntitySeed) GetElements(uk.gov.gchq.gaffer.operation.impl.get.GetElements) OperationTest(uk.gov.gchq.gaffer.operation.OperationTest) Test(org.junit.jupiter.api.Test)

Example 39 with GetElements

use of uk.gov.gchq.gaffer.operation.impl.get.GetElements in project Gaffer by gchq.

the class OperationChainTest method shouldBuildOperationChain_AdjEntitySeedsThenElements.

@Test
public void shouldBuildOperationChain_AdjEntitySeedsThenElements() {
    // Given
    final GetAdjacentIds getAdjacentIds = mock(GetAdjacentIds.class);
    final GetElements getEdges = mock(GetElements.class);
    // When
    final OperationChain opChain = new OperationChain.Builder().first(getAdjacentIds).then(getEdges).build();
    // Then
    assertEquals(2, opChain.getOperations().size());
    assertSame(getAdjacentIds, opChain.getOperations().get(0));
    assertSame(getEdges, opChain.getOperations().get(1));
}
Also used : GetAdjacentIds(uk.gov.gchq.gaffer.operation.impl.get.GetAdjacentIds) Builder(uk.gov.gchq.gaffer.operation.OperationChain.Builder) GetElements(uk.gov.gchq.gaffer.operation.impl.get.GetElements) Test(org.junit.jupiter.api.Test)

Example 40 with GetElements

use of uk.gov.gchq.gaffer.operation.impl.get.GetElements in project Gaffer by gchq.

the class AbstractLoaderIT method shouldGetElementsWithMatchedVertex.

@TraitRequirement({ StoreTrait.MATCHED_VERTEX, StoreTrait.QUERY_AGGREGATION })
@Test
public void shouldGetElementsWithMatchedVertex() throws Exception {
    // Then
    final View view = new Builder().edge(TestGroups.EDGE).build();
    final GetElements op = new GetElements.Builder().input(new EntitySeed(SOURCE_DIR_1), new EntitySeed(DEST_DIR_2), new EntitySeed(SOURCE_DIR_3)).view(view).build();
    final CloseableIterable<? extends Element> results = graph.execute(op, getUser());
    assertElementEquals(getQuerySummarisedEdges(view).stream().filter(Edge::isDirected).filter(edge -> {
        final List<String> vertices = Lists.newArrayList(SOURCE_DIR_1, SOURCE_DIR_2, SOURCE_DIR_3);
        return vertices.contains(edge.getMatchedVertexValue());
    }).collect(toList()), results);
}
Also used : Builder(uk.gov.gchq.gaffer.data.elementdefinition.view.View.Builder) EntitySeed(uk.gov.gchq.gaffer.operation.data.EntitySeed) GetElements(uk.gov.gchq.gaffer.operation.impl.get.GetElements) View(uk.gov.gchq.gaffer.data.elementdefinition.view.View) Test(org.junit.Test) TraitRequirement(uk.gov.gchq.gaffer.integration.TraitRequirement)

Aggregations

GetElements (uk.gov.gchq.gaffer.operation.impl.get.GetElements)256 Test (org.junit.jupiter.api.Test)153 EntitySeed (uk.gov.gchq.gaffer.operation.data.EntitySeed)112 User (uk.gov.gchq.gaffer.user.User)102 Element (uk.gov.gchq.gaffer.data.element.Element)91 View (uk.gov.gchq.gaffer.data.elementdefinition.view.View)84 OperationChain (uk.gov.gchq.gaffer.operation.OperationChain)83 AddElements (uk.gov.gchq.gaffer.operation.impl.add.AddElements)67 Context (uk.gov.gchq.gaffer.store.Context)60 Test (org.junit.Test)56 HashSet (java.util.HashSet)52 Graph (uk.gov.gchq.gaffer.graph.Graph)49 ViewElementDefinition (uk.gov.gchq.gaffer.data.elementdefinition.view.ViewElementDefinition)46 Entity (uk.gov.gchq.gaffer.data.element.Entity)42 ElementFilter (uk.gov.gchq.gaffer.data.element.function.ElementFilter)38 Operation (uk.gov.gchq.gaffer.operation.Operation)35 EdgeSeed (uk.gov.gchq.gaffer.operation.data.EdgeSeed)35 GetAdjacentIds (uk.gov.gchq.gaffer.operation.impl.get.GetAdjacentIds)34 Edge (uk.gov.gchq.gaffer.data.element.Edge)32 ArrayList (java.util.ArrayList)31