Java 类org.junit.jupiter.api.function.ThrowingConsumer 实例源码

项目:mastering-junit5    文件:StreamExampleTest.java   
@TestFactory
Stream<DynamicTest> streamTest() {
    // Input data
    Integer array[] = { 1, 2, 3 };
    Iterator<Integer> inputGenerator = Arrays.asList(array).iterator();

    // Display names
    Function<Integer, String> displayNameGenerator = (
            input) -> "Data input:" + input;

    // Test executor
    ThrowingConsumer<Integer> testExecutor = (input) -> {
        System.out.println(input);
        assertTrue(input % 2 == 0);
    };

    // Returns a stream of dynamic tests
    return stream(inputGenerator, displayNameGenerator, testExecutor);
}
项目:Mastering-Software-Testing-with-JUnit-5    文件:StreamExampleTest.java   
@TestFactory
Stream<DynamicTest> streamTest() {
    // Input data
    Integer array[] = { 1, 2, 3 };
    Iterator<Integer> inputGenerator = Arrays.asList(array).iterator();

    // Display names
    Function<Integer, String> displayNameGenerator = (
            input) -> "Data input:" + input;

    // Test executor
    ThrowingConsumer<Integer> testExecutor = (input) -> {
        System.out.println(input);
        assertTrue(input % 2 == 0);
    };

    // Returns a stream of dynamic tests
    return stream(inputGenerator, displayNameGenerator, testExecutor);
}
项目:roboslack    文件:SlackMarkdownTests.java   
private static ThrowingConsumer<ValueDecorator<String>> stringDecoratorConsumer(String input) {
    return decorator -> {
        String expectedDecorated = decorator.prefix().orElse("")
                + input
                + decorator.suffix().orElse("");
        assertThat(decorator.decorate(input), is(equalTo(expectedDecorated)));
        assertThat(decorator.decorate(expectedDecorated), is(equalTo(expectedDecorated)));
    };
}
项目:roboslack    文件:SlackMarkdownTests.java   
private static ThrowingConsumer<TupleDecorator<URL, String>> tupleUrlStringDecoratorConsumer(URL inputUrl,
        String inputText) {
    return decorator -> {
        String expectedDecorated = decorator.prefix().orElse("")
                + inputUrl.toString()
                + decorator.separator()
                + inputText
                + decorator.suffix().orElse("");
        assertThat(decorator.decorate(inputUrl, inputText), is(equalTo(expectedDecorated)));
    };
}
项目:roboslack    文件:MoreReflection.java   
@SuppressWarnings("unchecked")
public static <T> ThrowingConsumer<Method> noArgStaticFactoryConsumer(Consumer<T> delegateConsumer) {
    return staticFactoryMethod -> delegateConsumer.accept((T) staticFactoryMethod.invoke(null));
}