use of rx.exceptions.OnErrorNotImplementedException in project storio by pushtorefresh.
the class AbstractEmissionCheckerTest method shouldThrowExcepionBecauseObservableEmittedUnexpectedItemAfterExpectedSequence.
@Test
public void shouldThrowExcepionBecauseObservableEmittedUnexpectedItemAfterExpectedSequence() {
final Queue<String> expectedValues = new LinkedList<String>();
expectedValues.add("1");
expectedValues.add("2");
expectedValues.add("3");
final PublishSubject<String> publishSubject = PublishSubject.create();
final AbstractEmissionChecker<String> emissionChecker = new AbstractEmissionChecker<String>(expectedValues) {
@NonNull
@Override
public Subscription subscribe() {
return publishSubject.subscribe(new Action1<String>() {
@Override
public void call(String s) {
onNextObtained(s);
}
});
}
};
final Subscription subscription = emissionChecker.subscribe();
publishSubject.onNext("1");
publishSubject.onNext("2");
publishSubject.onNext("3");
emissionChecker.awaitNextExpectedValue();
emissionChecker.awaitNextExpectedValue();
emissionChecker.awaitNextExpectedValue();
emissionChecker.assertThatNoExpectedValuesLeft();
try {
publishSubject.onNext("4");
failBecauseExceptionWasNotThrown(OnErrorNotImplementedException.class);
} catch (OnErrorNotImplementedException expected) {
assertThat(expected.getCause()).hasMessage("Received emission, but no more emissions were expected: obtained 4, expectedValues = [], obtainedValues = []");
} finally {
subscription.unsubscribe();
}
}
use of rx.exceptions.OnErrorNotImplementedException in project retrofit by square.
the class CallArbiter method deliverResponse.
private void deliverResponse(Response<T> response) {
try {
if (!isUnsubscribed()) {
subscriber.onNext(response);
}
} catch (OnCompletedFailedException | OnErrorFailedException | OnErrorNotImplementedException e) {
RxJavaPlugins.getInstance().getErrorHandler().handleError(e);
return;
} catch (Throwable t) {
Exceptions.throwIfFatal(t);
try {
subscriber.onError(t);
} catch (OnCompletedFailedException | OnErrorFailedException | OnErrorNotImplementedException e) {
RxJavaPlugins.getInstance().getErrorHandler().handleError(e);
} catch (Throwable inner) {
Exceptions.throwIfFatal(inner);
CompositeException composite = new CompositeException(t, inner);
RxJavaPlugins.getInstance().getErrorHandler().handleError(composite);
}
return;
}
try {
if (!isUnsubscribed()) {
subscriber.onCompleted();
}
} catch (OnCompletedFailedException | OnErrorFailedException | OnErrorNotImplementedException e) {
RxJavaPlugins.getInstance().getErrorHandler().handleError(e);
} catch (Throwable t) {
Exceptions.throwIfFatal(t);
RxJavaPlugins.getInstance().getErrorHandler().handleError(t);
}
}
Aggregations