@Test
void retriesAfterTimeout() {

    final LoanApi mock = mock(LoanApi.class);
    final Api<LoanApi> api = new Api<>(mock);
    final String expected = UUID.randomUUID()
        .toString();
    final LongAdder adder = new LongAdder();
    final Function<LoanApi, String> function = (a) -> {
        adder.add(1);
        if (adder.intValue() > 2) {
            return expected;
        } else if (adder.intValue() == 2) {
            throw new ProcessingException(new IOException());
        } else {
            throw new ProcessingException(new SocketTimeoutException());
        }
    };
    final String result = api.call(function);
    assertThat(result).isSameAs(expected);
}