use of org.junit.platform.commons.util.CollectionUtils in project junit5 by junit-team.
the class MethodArgumentsProvider method provideArguments.
@Override
public Stream<Arguments> provideArguments(ExtensionContext context) {
Class<?> testClass = context.getRequiredTestClass();
Object testInstance = context.getTestInstance().orElse(null);
// @formatter:off
return Arrays.stream(this.methodNames).map(methodName -> StringUtils.isNotBlank(methodName) ? methodName : context.getRequiredTestMethod().getName()).map(methodName -> ReflectionUtils.findMethod(testClass, methodName).orElseThrow(() -> new JUnitException(format("Could not find factory method [%s] in class [%s]", methodName, testClass.getName())))).map(method -> ReflectionUtils.invokeMethod(method, testInstance)).flatMap(CollectionUtils::toStream).map(MethodArgumentsProvider::toArguments);
// @formatter:on
}
Aggregations