Java Code Examples for io.reactivex.rxjava3.observers.TestObserver#awaitDone()

The following examples show how to use io.reactivex.rxjava3.observers.TestObserver#awaitDone() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RxMobiusLoopTest.java    From mobius with Apache License 2.0 5 votes vote down vote up
@Test
public void shouldPropagateIncomingErrorsAsUnrecoverable() throws Exception {
  final RxMobiusLoop<Integer, String, Boolean> loop =
      new RxMobiusLoop<>(builder, "", Collections.emptySet());

  PublishSubject<Integer> input = PublishSubject.create();
  TestObserver<String> subscriber = input.compose(loop).test();
  Exception expected = new RuntimeException("expected");
  input.onError(expected);

  subscriber.awaitDone(1, TimeUnit.SECONDS);
  subscriber.assertError(new UnrecoverableIncomingException(expected));
  assertEquals(0, connection.valueCount());
}
 
Example 2
Source File: RxConnectablesTest.java    From mobius with Apache License 2.0 5 votes vote down vote up
@Test
public void shouldPropagateCompletion() throws Exception {
  TestObserver<Integer> observer =
      input.compose(RxConnectables.toTransformer(connectable)).test();

  input.onNext("hi");
  input.onComplete();

  observer.awaitDone(1, TimeUnit.SECONDS);
  observer.assertComplete();
}
 
Example 3
Source File: RxConnectablesTest.java    From mobius with Apache License 2.0 5 votes vote down vote up
@Test
public void shouldPropagateErrorsFromConnectable() throws Exception {
  TestObserver<Integer> observer =
      input.compose(RxConnectables.toTransformer(connectable)).test();

  input.onNext("crash");

  observer.awaitDone(1, TimeUnit.SECONDS);
  observer.assertError(throwable -> throwable.getMessage().equals("crashing!"));
}
 
Example 4
Source File: RxConnectablesTest.java    From mobius with Apache License 2.0 5 votes vote down vote up
@Test
public void shouldPropagateErrorsFromUpstream() throws Exception {
  final Throwable expected = new RuntimeException("expected");

  TestObserver<Integer> observer =
      input.compose(RxConnectables.toTransformer(connectable)).test();

  input.onError(expected);

  observer.awaitDone(1, TimeUnit.SECONDS);
  observer.assertError(expected);
}