@Test(expectedExceptions = GoodDataException.class, expectedExceptionsMessageRegExp = ".*timeout.*") public void pollShouldThrowExceptionWhenOverTimeout() throws Exception { PollHandler<?, ?> handler = mock(PollHandler.class); service.poll(handler, 5, TimeUnit.SECONDS); }
final <R> R poll(final PollHandler<?,R> handler, long timeout, final TimeUnit unit) { notNull(handler, "handler"); final long start = System.currentTimeMillis(); while (true) { if (pollOnce(handler)) { return handler.getResult(); } if (unit != null && start + unit.toMillis(timeout) < System.currentTimeMillis()) { throw new GoodDataException("timeout"); } try { Thread.sleep(settings.getPollSleep()); } catch (InterruptedException e) { throw new GoodDataException("interrupted"); } } }
AbstractService { final <R> R poll(final PollHandler<?,R> handler, long timeout, final TimeUnit unit) { notNull(handler, "handler"); final long start = System.currentTimeMillis(); while (true) { if (pollOnce(handler)) { return handler.getResult(); } if (unit != null && start + unit.toMillis(timeout) < System.currentTimeMillis()) { throw new GoodDataException("timeout"); } try { Thread.sleep(settings.getPollSleep()); } catch (InterruptedException e) { throw new GoodDataException("interrupted"); } } } }
AbstractService { final <R> R poll(final PollHandler<?,R> handler, long timeout, final TimeUnit unit) { notNull(handler, "handler"); final long start = System.currentTimeMillis(); while (true) { if (pollOnce(handler)) { return handler.getResult(); } if (unit != null && start + unit.toMillis(timeout) < System.currentTimeMillis()) { throw new GoodDataException("timeout"); } try { Thread.sleep(settings.getPollSleep()); } catch (InterruptedException e) { throw new GoodDataException("interrupted"); } } } AbstractService(final RestTemplate restTemplate, final GoodDataSettings settings); }
AbstractService { final <R> R poll(final PollHandler<?,R> handler, long timeout, final TimeUnit unit) { notNull(handler, "handler"); final long start = System.currentTimeMillis(); while (true) { if (pollOnce(handler)) { return handler.getResult(); } if (unit != null && start + unit.toMillis(timeout) < System.currentTimeMillis()) { throw new GoodDataException("timeout"); } try { Thread.sleep(settings.getPollSleep()); } catch (InterruptedException e) { throw new GoodDataException("interrupted"); } } } AbstractService(final RestTemplate restTemplate, final GoodDataSettings settings);  }
AbstractService { final <R> R poll(final PollHandler<?,R> handler, long timeout, final TimeUnit unit) { notNull(handler, "handler"); final long start = System.currentTimeMillis(); while (true) { if (pollOnce(handler)) { return handler.getResult(); } if (unit != null && start + unit.toMillis(timeout) < System.currentTimeMillis()) { throw new GoodDataException("timeout"); } try { Thread.sleep(settings.getPollSleep()); } catch (InterruptedException e) { throw new GoodDataException("interrupted"); } } } AbstractService(final RestTemplate restTemplate, final GoodDataSettings settings);   }