Search in sources :

Example 1 with Functions2

use of org.eclipse.collections.impl.block.factory.Functions2 in project eclipse-collections by eclipse.

the class Functions2Test method throwingWithUserSpecifiedException.

@Test
public void throwingWithUserSpecifiedException() {
    Verify.assertThrowsWithCause(RuntimeException.class, IOException.class, () -> {
        Functions2.throwing((one, two) -> {
            throw new IOException();
        }, (one, two, ce) -> new RuntimeException(ce)).value(null, null);
    });
    Verify.assertThrowsWithCause(MyRuntimeException.class, IOException.class, () -> {
        Functions2.throwing((one, two) -> {
            throw new IOException();
        }, this::throwMyException).value(null, null);
    });
    Verify.assertThrows(NullPointerException.class, () -> {
        Functions2.throwing((one, two) -> {
            throw new NullPointerException();
        }, this::throwMyException).value(null, null);
    });
}
Also used : Function2(org.eclipse.collections.api.block.function.Function2) IOException(java.io.IOException) Test(org.junit.Test) Verify(org.eclipse.collections.impl.test.Verify) Assert(org.junit.Assert) Functions2(org.eclipse.collections.impl.block.factory.Functions2) IOException(java.io.IOException) Test(org.junit.Test)

Aggregations

IOException (java.io.IOException)1 Function2 (org.eclipse.collections.api.block.function.Function2)1 Functions2 (org.eclipse.collections.impl.block.factory.Functions2)1 Verify (org.eclipse.collections.impl.test.Verify)1 Assert (org.junit.Assert)1 Test (org.junit.Test)1