Skip to content

Commit

Permalink
gh-2421: Changed GetElementsIT to test both seed and element input
Browse files Browse the repository at this point in the history
  • Loading branch information
t92549 committed Sep 17, 2021
1 parent 014885c commit 67d608a
Showing 1 changed file with 18 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.StreamSupport;

import static org.assertj.core.api.Assertions.assertThat;
import static uk.gov.gchq.gaffer.operation.SeedMatching.SeedMatchingType;
Expand Down Expand Up @@ -546,19 +548,32 @@ private void shouldGetElements(final Collection<Element> expectedElements,
viewBuilder.edge(TestGroups.EDGE);
}

final GetElements op = new GetElements.Builder()
final GetElements opSeed = new GetElements.Builder()
.input(seeds)
.directedType(directedType)
.inOutType(inOutType)
.view(viewBuilder.build())
.seedMatching(seedMatching)
.build();

Collection<ElementId> seedCollection = StreamSupport.stream(seeds.spliterator(), false)
.collect(Collectors.toList());

final GetElements opElement = new GetElements.Builder()
.input(getElements(seedCollection, null))
.directedType(directedType)
.inOutType(inOutType)
.view(viewBuilder.build())
.seedMatching(seedMatching)
.build();

// When
final CloseableIterable<? extends Element> results = graph.execute(op, user);
final CloseableIterable<? extends Element> resultsSeed = graph.execute(opSeed, user);
final CloseableIterable<? extends Element> resultsElement = graph.execute(opElement, user);

// Then
ElementUtil.assertElementEquals(expectedElements, results, true);
ElementUtil.assertElementEquals(expectedElements, resultsSeed, true);
ElementUtil.assertElementEquals(expectedElements, resultsElement, true);
}

private static Collection<Element> getElements(final Collection<ElementId> seeds, final Boolean direction) {
Expand Down

0 comments on commit 67d608a

Please sign in to comment.