AsyncGoro { public <T> Async<T> schedule(final String queue, final Callable<T> task) { return new GoroAsync<>(queue, task); } AsyncGoro(final Goro goro); Goro wrappedGoro(); Async<T> schedule(final String queue, final Callable<T> task); Async<T> schedule(final Callable<T> task);  }
@SuppressWarnings("unchecked") @Test public void firstSubscribeShouldCallSchedule() { Callable<?> task = mock(Callable.class); Async<?> async = asyncGoro.schedule("1", task); verify(goro, never()).schedule(anyString(), any(Callable.class)); async.subscribe(mock(AsyncObserver.class)); verify(goro).schedule("1", task); async.subscribe(mock(AsyncObserver.class)); verify(goro, times(1 )).schedule(anyString(), any(Callable.class)); }
@SuppressWarnings("unchecked") @Test public void cancelShouldMakeSubscribeNoOp() { Async<?> async = asyncGoro.schedule("1", mock(Callable.class)); async.cancel(); async.subscribe(mock(AsyncObserver.class)); verify(goro, never()).schedule(anyString(), any(Callable.class)); }