NoRetryJaxRsStrategy implements JaxRsStrategy<T> { @Override public <R> R apply(final Function<T, R> function) throws IOException { final T jaxRsClient = jaxRsClientFactory.createClient(apiClass, hostName, port, pathPrefix, scheme); try { return function.apply(jaxRsClient); } catch (ProcessingException e) { throw new IOException("Communication with REST server failed", e); } } NoRetryJaxRsStrategy(
            final HostName hostName,
            final int port,
            final JaxRsClientFactory jaxRsClientFactory,
            final Class<T> apiClass,
            final String pathPrefix,
            String scheme); @Override R apply(final Function<T, R> function);  }
@Test public void noRetryIfNoFailure() throws Exception { jaxRsStrategy.apply(TestJaxRsApi::doSomething); verify(mockApi, times(1)).doSomething(); verify(jaxRsClientFactory, times(1)) .createClient(eq(TestJaxRsApi.class), eq(SERVER_HOST), eq(REST_PORT), eq(API_PATH), eq("http")); }
@Test public void testNoRetryAfterFailure() throws Exception { when(mockApi.doSomething()) .thenThrow(new ProcessingException("Fake timeout induced by test")) .thenReturn("a response"); try { jaxRsStrategy.apply(TestJaxRsApi::doSomething); fail("The above statement should throw"); } catch (IOException e) { } verify(mockApi, times(1)).doSomething(); }