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());
}
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());
}
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);
}
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));
}
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);
}
Aggregations