/** * Create a new scheduler that will post actions to the specified queue. * @param queueName name of the queue to use for scheduling actions * @return scheduler instance */ public Scheduler scheduler(String queueName) { return new GoroScheduler(goro, queueName); }
/** * @see Goro#schedule(Callable) */ public <T> Observable<T> schedule(final Callable<T> task) { return schedule(Goro.DEFAULT_QUEUE, task); }
@Override public GoroAsync<T> replicate() { return new GoroAsync<>(queue, task); }
/** * @see {@link Goro#schedule(Callable)} */ public <T> Async<T> schedule(final Callable<T> task) { return schedule(Goro.DEFAULT_QUEUE, task); }
@Before public void init() { goro = mock(Goro.class); doReturn(mock(ObservableFuture.class)).when(goro).schedule(anyString(), any(Callable.class)); asyncGoro = new AsyncGoro(goro); }
public void testResult() throws InterruptedException { TestActivity activity = getActivity(); assertThat(activity.resultSync.await(5, TimeUnit.SECONDS)).isTrue(); assertThat(activity.result).isEqualTo("ok"); }
@Override public Worker createWorker() { return new GoroWorker(); }
@Override public Void call() { if (!isUnsubscribed()) { action.call(); } return null; } });
@Before public void init() { rxGoro = new RxGoro(createGoroWith(queues)); }
@Test public void schedule() { TestSubscriber<String> subscriber = new TestSubscriber<>(); Observable.just("ok") .subscribeOn(rxGoro.scheduler("test")) .subscribe(subscriber); subscriber.assertNoValues(); subscriber.assertNotCompleted(); queues.executeAll(); subscriber.assertNoErrors(); subscriber.assertCompleted(); subscriber.assertValue("ok"); }
/** * @see Goro#schedule(Callable) */ public <T> Async<T> schedule(final Callable<T> task) { return schedule(Goro.DEFAULT_QUEUE, task); }
/** * @see {@link Goro#schedule(String, Callable)} */ public <T> Async<T> schedule(final String queue, final Callable<T> task) { return new GoroAsync<>(queue, task); }
/** * @see {@link Goro#schedule(Callable)} */ public <T> Observable<T> schedule(final Callable<T> task) { return schedule(Goro.DEFAULT_QUEUE, task); }
/** * Create a new scheduler that will post actions to the default queue. * @return scheduler instance using {@link Goro#DEFAULT_QUEUE} */ public Scheduler scheduler() { return new GoroScheduler(goro, Goro.DEFAULT_QUEUE); }
public void testError() throws InterruptedException { TestActivity activity = getActivity(); assertThat(activity.errorSync.await(5, TimeUnit.SECONDS)).isTrue(); assertThat(activity.error).hasMessage("test error"); }
@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)); }
/** * @see Goro#schedule(String, Callable) */ public <T> Async<T> schedule(final String queue, final Callable<T> task) { return new GoroAsync<>(queue, 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 /* not 2 */)).schedule(anyString(), any(Callable.class)); }
@Override public GoroAsync<T> replicate() { return new GoroAsync<>(queue, task); }