@@ -0,0 +1,3177 @@
+package throwing.stream;%0A%0Aimport static org.junit.Assert.assertSame;%0Aimport static org.junit.Assert.fail;%0Aimport static org.mockito.Mockito.inOrder;%0Aimport static org.mockito.Mockito.mock;%0Aimport static org.mockito.Mockito.never;%0Aimport static org.mockito.Mockito.verify;%0A%0Aimport java.io.IOException;%0Aimport java.util.function.Supplier;%0A%0Aimport org.junit.Test;%0Aimport org.mockito.InOrder;%0A%0Aimport throwing.Nothing;%0Aimport throwing.function.ThrowingSupplier;%0A%0Apublic class ThrowingLambdasTest %7B%0A    private %3CX extends Throwable%3E ThrowingSupplier%3CObject, X%3E failure(Runnable callback, X x) %7B%0A        return () -%3E %7B%0A            if (callback != null) %7B%0A                callback.run();%0A            %7D%0A            throw x;%0A        %7D;%0A    %7D%0A%0A    private %3CX extends Throwable%3E ThrowingSupplier%3CObject, X%3E success() %7B%0A        Object o = new Object();%0A        return () -%3E o;%0A    %7D%0A%0A    @Test%0A    public void fallbackFailureTest() %7B%0A        IOException e = new IOException(%22foo%22);%0A        Runnable mock = mock(Runnable.class);%0A        ThrowingSupplier%3CObject, IOException%3E s = failure(mock, e);%0A%0A        Supplier%3CObject%3E fallback = this.%3CNothing%3E success()::get;%0A        Object o = fallback.get();%0A%0A        assertSame(%22fallback was called%22, o, s.fallbackTo(fallback).get());%0A        verify(mock).run();%0A    %7D%0A%0A    @Test%0A    public void fallbackSuccessTest() throws IOException %7B%0A        ThrowingSupplier%3CObject, IOException%3E s = success();%0A        Object o = s.get();%0A%0A        Runnable mock = mock(Runnable.class);%0A        Supplier%3CObject%3E s2 = failure(mock, (Nothing) null)::get;%0A%0A        assertSame(%22fallback was not called%22, o, s.fallbackTo(s2).get());%0A        verify(mock, never()).run();%0A    %7D%0A%0A    @Test%0A    public void orTrySingleFailureTest() throws IOException %7B%0A        IOException e = new IOException();%0A        Runnable mock = mock(Runnable.class);%0A        ThrowingSupplier%3CObject, IOException%3E s = failure(mock, e);%0A%0A        ThrowingSupplier%3CObject, IOException%3E s2 = success();%0A        Object o = s2.get();%0A%0A        assertSame(%22s2 was called%22, o, s.orTry(s2).get());%0A        verify(mock).run();%0A    %7D%0A%0A    @Test%0A    public void orTryDoubleFailureTest() %7B%0A        IOException e = new IOException();%0A        IOException e2 = new IOException();%0A        Runnable m = mock(Runnable.class);%0A        Runnable m2 = mock(Runnable.class);%0A%0A        ThrowingSupplier%3CObject, IOException%3E s = failure(m, e);%0A        ThrowingSupplier%3CObject, IOException%3E s2 = failure(m2, e2);%0A%0A        try %7B%0A            s.orTry(s2).get();%0A            fail(%22exception was not thrown%22);%0A        %7D catch (IOException x) %7B%0A            assertSame(x, e2);%0A            assertSame(e, e2.getSuppressed()%5B0%5D);%0A        %7D%0A%0A        InOrder i = inOrder(m, m2);%0A        i.verify(m).run();%0A        i.verify(m2).run();%0A    %7D%0A%0A    @Test%0A    public void orTrySuccessTest() throws IOException %7B%0A        ThrowingSupplier%3CObject, IOException%3E s = success();%0A        Object o = s.get();%0A%0A        Runnable mock = mock(Runnable.class);%0A        ThrowingSupplier%3CObject, Nothing%3E s2 = failure(mock, (Nothing) null);%0A%0A        assertSame(%22fallback was not called%22, o, s.orTry(s2).get());%0A        verify(mock, never()).run();%0A    %7D%0A%7D%0A

test cases