OrPromise extends AwexPromise<T, P> { @Override public void cancelTask(boolean mayInterrupt) { synchronized (this) { super.cancelTask(mayInterrupt); mMainPromise.cancelTask(mayInterrupt); mSecondChoicePromise.cancelTask(mayInterrupt); } } OrPromise(Awex awex, Promise<T, P> mainPromise, Promise<T, P> secondChoicePromise); @Override void cancelTask(boolean mayInterrupt);  }
@Test public void shouldBeCancelledOnceMainPromiseIsCancelled() throws Exception { setUpAwex(); setUpPromises(); mMainPromise.cancelTask(); assertTrue(mOrPromise.isCancelled()); }
@Test public void shouldBeCancelledOnceMainIsRejectedAndSecondChoicePromiseIsCancelled() throws Exception { setUpAwex(); setUpPromises(); mMainPromise.reject(new Exception()); mSecondChoicePromise.cancelTask(); assertTrue(mOrPromise.isCancelled()); }