Search in sources :

Example 1 with ToSingletonList

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());
}
Also used : GetElements(uk.gov.gchq.gaffer.operation.impl.get.GetElements) CsvGenerator(uk.gov.gchq.gaffer.data.generator.CsvGenerator) ForEach(uk.gov.gchq.gaffer.operation.impl.ForEach) EdgeSeed(uk.gov.gchq.gaffer.operation.data.EdgeSeed) ToCsv(uk.gov.gchq.gaffer.operation.impl.output.ToCsv) ElementSeed(uk.gov.gchq.gaffer.operation.data.ElementSeed) ToSingletonList(uk.gov.gchq.gaffer.operation.impl.output.ToSingletonList) Test(org.junit.Test)

Example 2 with ToSingletonList

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));
}
Also used : ToEntitySeeds(uk.gov.gchq.gaffer.operation.impl.output.ToEntitySeeds) Element(uk.gov.gchq.gaffer.data.element.Element) GetElements(uk.gov.gchq.gaffer.operation.impl.get.GetElements) CsvGenerator(uk.gov.gchq.gaffer.data.generator.CsvGenerator) ForEach(uk.gov.gchq.gaffer.operation.impl.ForEach) ToCsv(uk.gov.gchq.gaffer.operation.impl.output.ToCsv) ToSingletonList(uk.gov.gchq.gaffer.operation.impl.output.ToSingletonList) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)2 CsvGenerator (uk.gov.gchq.gaffer.data.generator.CsvGenerator)2 ForEach (uk.gov.gchq.gaffer.operation.impl.ForEach)2 GetElements (uk.gov.gchq.gaffer.operation.impl.get.GetElements)2 ToCsv (uk.gov.gchq.gaffer.operation.impl.output.ToCsv)2 ToSingletonList (uk.gov.gchq.gaffer.operation.impl.output.ToSingletonList)2 Element (uk.gov.gchq.gaffer.data.element.Element)1 EdgeSeed (uk.gov.gchq.gaffer.operation.data.EdgeSeed)1 ElementSeed (uk.gov.gchq.gaffer.operation.data.ElementSeed)1 ToEntitySeeds (uk.gov.gchq.gaffer.operation.impl.output.ToEntitySeeds)1