use of uk.gov.gchq.gaffer.operation.impl.output.ToSingletonList in project Gaffer by gchq.
the class ForEachIT method shouldExecuteForEachOperationOnGetElementsWithEmptyIterable.
@Test
public void shouldExecuteForEachOperationOnGetElementsWithEmptyIterable() throws OperationException {
// Given
final ForEach<ElementSeed, Iterable<String>> op = new ForEach.Builder<ElementSeed, Iterable<String>>().input(Collections.singletonList(new EdgeSeed("doesNotExist", "doesNotExist", true))).operation(new OperationChain.Builder().first(new ToSingletonList<EntitySeed>()).then(new GetElements()).then(new ToCsv.Builder().includeHeader(false).generator(new CsvGenerator.Builder().vertex("vertex").destination("dest").build()).build()).build()).build();
// When
final List<Iterable<String>> results = Lists.newArrayList(graph.execute(op, getUser()));
// Then
assertThat(results).hasSize(1);
assertThat(Lists.newArrayList(results.get(0))).isEqualTo(Collections.emptyList());
}
use of uk.gov.gchq.gaffer.operation.impl.output.ToSingletonList in project Gaffer by gchq.
the class ForEachIT method shouldExecuteForEachOperationOnGetElementsWithValidResults.
@Test
public void shouldExecuteForEachOperationOnGetElementsWithValidResults() throws OperationException {
// Given
final ForEach<String, Iterable<String>> op = new ForEach.Builder<String, Iterable<String>>().input(Collections.singletonList(SOURCE_DIR_1)).operation(new OperationChain.Builder().first(new ToSingletonList<>()).then(new ToEntitySeeds()).then(new GetElements()).then(new ToList<Element>()).then(new ToCsv.Builder().includeHeader(false).generator(new CsvGenerator.Builder().vertex("vertex").destination("dest").build()).build()).build()).build();
// When
final List<Iterable<String>> results = Lists.newArrayList(graph.execute(op, getUser()));
// Then
assertThat(results).hasSize(1);
assertThat(Sets.newHashSet(results.get(0))).isEqualTo(Sets.newHashSet(SOURCE_DIR_1 + ",", "," + DEST_DIR_1));
}
Aggregations