Created
November 13, 2018 01:37
-
-
Save xjj59307/b2cf0ea36af52f847f95bcd8519e368a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.stream.Collectors; | |
import java.util.stream.Stream; | |
import org.junit.Test; | |
public class ThrowableLambdaTest { | |
@Test(expected = ClassNotFoundException.class) | |
public void testThrowableConsumer() throws ClassNotFoundException { | |
Stream.of("foo.bar").forEach( | |
uncheckConsumer(Class::forName) | |
); | |
} | |
@Test(expected = ClassNotFoundException.class) | |
public void testThrowableFunction() throws ClassNotFoundException { | |
Stream.of("foo.bar").map( | |
uncheckFunction(Class::forName) | |
).collect(Collectors.toList()); | |
} | |
@Test(expected = Exception.class) | |
public void testThrowableSupplier() throws Exception { | |
uncheckSupplier(() -> { | |
throw new Exception(); | |
}).get(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment