package com.github.kaaveland.tryagain;

import org.junit.Test;

import java.io.IOException;

public class BypassExceptionCheckingTest {

    private class ThrowIOException implements RetriableWithoutResult {
        @Override
        public void execute(final int attempt) throws Exception {
            throw new IOException();
        }
    }

    private Retrier retrier = Retrier.retryOn(new ExceptionMatcher() {
        @Override
        public boolean matches(final Exception exception) {
            return true;
        }
    });

    @Test(expected = IOException.class)
    public void that_bypass_exception_checking_allows_us_to_throw_checked_exceptions_unchecked() {
        BypassExceptionChecking bypassExceptionChecking = new BypassExceptionChecking(retrier);
        bypassExceptionChecking.execute(new ThrowIOException());
    }

}

@@ -339,16 +339,232 @@
 %0A    %7D%0A%0A
+    private class ThrowIOExceptionWithResult implements Retriable%3CString%3E %7B%0A        @Override%0A        public String execute(final int attempt) throws Exception %7B%0A            throw new IOException();%0A        %7D%0A    %7D%0A%0A
     priv
@@ -1055,10 +1055,338 @@
 %0A    %7D%0A%0A
+    @Test(expected = IOException.class)%0A    public void that_bypass_exception_checking_allows_us_to_throw_checked_exceptions_unchecked_with_result() %7B%0A        BypassExceptionChecking bypassExceptionChecking = new BypassExceptionChecking(retrier);%0A        bypassExceptionChecking.execute(new ThrowIOExceptionWithResult());%0A    %7D%0A
 %7D%0A

Test BypassExceptionChecking for Retriable.