Skip to content

Instantly share code, notes, and snippets.

@xjj59307
Created November 13, 2018 01:37
Show Gist options
  • Save xjj59307/b2cf0ea36af52f847f95bcd8519e368a to your computer and use it in GitHub Desktop.
Save xjj59307/b2cf0ea36af52f847f95bcd8519e368a to your computer and use it in GitHub Desktop.
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