@SuppressWarnings("unchecked") @Test public void ambIterable2Error() { PerhapsProcessor<Integer> sp1 = PerhapsProcessor.create(); PerhapsProcessor<Integer> sp2 = PerhapsProcessor.create(); TestSubscriber<Integer> ts = Perhaps.amb(Arrays.asList(sp1, sp2)) .test(); assertTrue(sp1.hasSubscribers()); assertTrue(sp2.hasSubscribers()); ts.assertEmpty(); sp2.onError(new IOException()); ts.assertFailure(IOException.class); assertFalse(sp1.hasSubscribers()); assertFalse(sp2.hasSubscribers()); }
@SuppressWarnings("unchecked") @Test public void ambIterable1Error() { PerhapsProcessor<Integer> sp1 = PerhapsProcessor.create(); PerhapsProcessor<Integer> sp2 = PerhapsProcessor.create(); TestSubscriber<Integer> ts = Perhaps.amb(Arrays.asList(sp1, sp2)) .test(); assertTrue(sp1.hasSubscribers()); assertTrue(sp2.hasSubscribers()); ts.assertEmpty(); sp1.onError(new IOException()); ts.assertFailure(IOException.class); assertFalse(sp1.hasSubscribers()); assertFalse(sp2.hasSubscribers()); }
@Test public void ambWith2Error() { PerhapsProcessor<Integer> sp1 = PerhapsProcessor.create(); PerhapsProcessor<Integer> sp2 = PerhapsProcessor.create(); TestSubscriber<Integer> ts = sp1.ambWith(sp2) .test(); assertTrue(sp1.hasSubscribers()); assertTrue(sp2.hasSubscribers()); ts.assertEmpty(); sp2.onError(new IOException()); ts.assertFailure(IOException.class); assertFalse(sp1.hasSubscribers()); assertFalse(sp2.hasSubscribers()); }
@SuppressWarnings("unchecked") @Test public void ambArray1Error() { PerhapsProcessor<Integer> sp1 = PerhapsProcessor.create(); PerhapsProcessor<Integer> sp2 = PerhapsProcessor.create(); TestSubscriber<Integer> ts = Perhaps.ambArray(sp1, sp2) .test(); assertTrue(sp1.hasSubscribers()); assertTrue(sp2.hasSubscribers()); ts.assertEmpty(); sp1.onError(new IOException()); ts.assertFailure(IOException.class); assertFalse(sp1.hasSubscribers()); assertFalse(sp2.hasSubscribers()); }
@Test public void ambWith1Error() { PerhapsProcessor<Integer> sp1 = PerhapsProcessor.create(); PerhapsProcessor<Integer> sp2 = PerhapsProcessor.create(); TestSubscriber<Integer> ts = sp1.ambWith(sp2) .test(); assertTrue(sp1.hasSubscribers()); assertTrue(sp2.hasSubscribers()); ts.assertEmpty(); sp1.onError(new IOException()); ts.assertFailure(IOException.class); assertFalse(sp1.hasSubscribers()); assertFalse(sp2.hasSubscribers()); }
@SuppressWarnings("unchecked") @Test public void ambArray2Error() { PerhapsProcessor<Integer> sp1 = PerhapsProcessor.create(); PerhapsProcessor<Integer> sp2 = PerhapsProcessor.create(); TestSubscriber<Integer> ts = Perhaps.ambArray(sp1, sp2) .test(); assertTrue(sp1.hasSubscribers()); assertTrue(sp2.hasSubscribers()); ts.assertEmpty(); sp2.onError(new IOException()); ts.assertFailure(IOException.class); assertFalse(sp1.hasSubscribers()); assertFalse(sp2.hasSubscribers()); }