Skip to content

Commit

Permalink
make test-template provide return a Stream
Browse files Browse the repository at this point in the history
  • Loading branch information
LiamClark committed Mar 11, 2017
1 parent 551b897 commit e8ade4b
Showing 1 changed file with 4 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Optional;
Expand Down Expand Up @@ -61,10 +59,10 @@ public boolean supports(ContainerExtensionContext context) {
}

@Override
public Iterator<TestTemplateInvocationContext> provide(ContainerExtensionContext context) {
public Stream<TestTemplateInvocationContext> provide(ContainerExtensionContext context) {
// grabbing the parent ensures the paremeters are stored in the same store.
return context.getParent().flatMap(ParameterizedExtension::parameters).map(
ParameterizedExtension::testTemplateContextsFromParameters).orElse(Collections.emptyIterator());
ParameterizedExtension::testTemplateContextsFromParameters).orElse(Stream.empty());
}

/**
Expand Down Expand Up @@ -204,8 +202,8 @@ private static Optional<Method> ensureSingleParametersMethod(Class<?> testClass)
m -> m.isAnnotationPresent(Parameterized.Parameters.class)).stream().findFirst();
}

private static Iterator<TestTemplateInvocationContext> testTemplateContextsFromParameters(Collection<Object[]> o) {
return o.stream().map(ParameterizedExtension::contextFactory).iterator();
private static Stream<TestTemplateInvocationContext> testTemplateContextsFromParameters(Collection<Object[]> o) {
return o.stream().map(ParameterizedExtension::contextFactory);
}

private static TestTemplateInvocationContext contextFactory(Object[] parameters) {
Expand Down

0 comments on commit e8ade4b

Please sign in to comment.