Search in sources :

Example 6 with ConnectableFlowable

use of io.reactivex.flowables.ConnectableFlowable in project brave by openzipkin.

the class CurrentTraceContextAssemblyTrackingMatrixTest method connectableFlowable_assembleInScope_subscribeNoScope.

@Test
public void connectableFlowable_assembleInScope_subscribeNoScope() {
    ConnectableFlowable<Integer> source, errorSource;
    try (Scope scope = currentTraceContext.newScope(assemblyContext)) {
        source = Flowable.range(1, 3).doOnNext(e -> assertInAssemblyContext()).doOnComplete(this::assertInAssemblyContext).publish();
        errorSource = Flowable.<Integer>error(new IllegalStateException()).doOnError(t -> assertInAssemblyContext()).doOnComplete(this::assertInAssemblyContext).publish();
    }
    subscribeInNoContext(source.autoConnect().toObservable(), errorSource.autoConnect().toObservable()).assertResult(1, 2, 3);
}
Also used : MaybeObserver(io.reactivex.MaybeObserver) ScalarCallable(io.reactivex.internal.fuseable.ScalarCallable) ObservableRange(io.reactivex.internal.operators.observable.ObservableRange) ParallelFilter(io.reactivex.internal.operators.parallel.ParallelFilter) FlowableFromCallable(io.reactivex.internal.operators.flowable.FlowableFromCallable) Completable(io.reactivex.Completable) FlowableFilter(io.reactivex.internal.operators.flowable.FlowableFilter) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) Maybe(io.reactivex.Maybe) ConnectableFlowable(io.reactivex.flowables.ConnectableFlowable) StrictCurrentTraceContext(brave.propagation.StrictCurrentTraceContext) Callable(java.util.concurrent.Callable) CurrentTraceContext(brave.propagation.CurrentTraceContext) SingleFromCallable(io.reactivex.internal.operators.single.SingleFromCallable) Single(io.reactivex.Single) SingleJust(io.reactivex.internal.operators.single.SingleJust) MaybeFromCallable(io.reactivex.internal.operators.maybe.MaybeFromCallable) ParallelFlowable(io.reactivex.parallel.ParallelFlowable) Flowable(io.reactivex.Flowable) CompletableFromCallable(io.reactivex.internal.operators.completable.CompletableFromCallable) After(org.junit.After) Observable(io.reactivex.Observable) Subscriber(org.reactivestreams.Subscriber) MaybeFilterSingle(io.reactivex.internal.operators.maybe.MaybeFilterSingle) Before(org.junit.Before) ObservablePublish(io.reactivex.internal.operators.observable.ObservablePublish) ConnectableObservable(io.reactivex.observables.ConnectableObservable) CompletableObserver(io.reactivex.CompletableObserver) ParallelFromPublisher(io.reactivex.internal.operators.parallel.ParallelFromPublisher) CompletableEmpty(io.reactivex.internal.operators.completable.CompletableEmpty) TestObserver(io.reactivex.observers.TestObserver) Test(org.junit.Test) RxJavaPlugins(io.reactivex.plugins.RxJavaPlugins) Predicate(io.reactivex.functions.Predicate) TraceContext(brave.propagation.TraceContext) MaybeFilter(io.reactivex.internal.operators.maybe.MaybeFilter) FlowablePublish(io.reactivex.internal.operators.flowable.FlowablePublish) ObservableFromCallable(io.reactivex.internal.operators.observable.ObservableFromCallable) SingleObserver(io.reactivex.SingleObserver) FlowableRange(io.reactivex.internal.operators.flowable.FlowableRange) MaybeJust(io.reactivex.internal.operators.maybe.MaybeJust) Observer(io.reactivex.Observer) Scope(brave.propagation.CurrentTraceContext.Scope) ObservableFilter(io.reactivex.internal.operators.observable.ObservableFilter) Scope(brave.propagation.CurrentTraceContext.Scope) Test(org.junit.Test)

Example 7 with ConnectableFlowable

use of io.reactivex.flowables.ConnectableFlowable in project brave by openzipkin.

the class CurrentTraceContextAssemblyTrackingMatrixTest method connectableFlowable_assembleInScope_subscribeInScope.

@Test
public void connectableFlowable_assembleInScope_subscribeInScope() {
    ConnectableFlowable<Integer> source, errorSource;
    try (Scope scope = currentTraceContext.newScope(assemblyContext)) {
        source = Flowable.range(1, 3).doOnNext(e -> assertInAssemblyContext()).doOnComplete(this::assertInAssemblyContext).publish();
        errorSource = Flowable.<Integer>error(new IllegalStateException()).doOnError(t -> assertInAssemblyContext()).doOnComplete(this::assertInAssemblyContext).publish();
    }
    subscribeInDifferentContext(source.autoConnect().toObservable(), errorSource.autoConnect().toObservable()).assertResult(1, 2, 3);
}
Also used : MaybeObserver(io.reactivex.MaybeObserver) ScalarCallable(io.reactivex.internal.fuseable.ScalarCallable) ObservableRange(io.reactivex.internal.operators.observable.ObservableRange) ParallelFilter(io.reactivex.internal.operators.parallel.ParallelFilter) FlowableFromCallable(io.reactivex.internal.operators.flowable.FlowableFromCallable) Completable(io.reactivex.Completable) FlowableFilter(io.reactivex.internal.operators.flowable.FlowableFilter) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) Maybe(io.reactivex.Maybe) ConnectableFlowable(io.reactivex.flowables.ConnectableFlowable) StrictCurrentTraceContext(brave.propagation.StrictCurrentTraceContext) Callable(java.util.concurrent.Callable) CurrentTraceContext(brave.propagation.CurrentTraceContext) SingleFromCallable(io.reactivex.internal.operators.single.SingleFromCallable) Single(io.reactivex.Single) SingleJust(io.reactivex.internal.operators.single.SingleJust) MaybeFromCallable(io.reactivex.internal.operators.maybe.MaybeFromCallable) ParallelFlowable(io.reactivex.parallel.ParallelFlowable) Flowable(io.reactivex.Flowable) CompletableFromCallable(io.reactivex.internal.operators.completable.CompletableFromCallable) After(org.junit.After) Observable(io.reactivex.Observable) Subscriber(org.reactivestreams.Subscriber) MaybeFilterSingle(io.reactivex.internal.operators.maybe.MaybeFilterSingle) Before(org.junit.Before) ObservablePublish(io.reactivex.internal.operators.observable.ObservablePublish) ConnectableObservable(io.reactivex.observables.ConnectableObservable) CompletableObserver(io.reactivex.CompletableObserver) ParallelFromPublisher(io.reactivex.internal.operators.parallel.ParallelFromPublisher) CompletableEmpty(io.reactivex.internal.operators.completable.CompletableEmpty) TestObserver(io.reactivex.observers.TestObserver) Test(org.junit.Test) RxJavaPlugins(io.reactivex.plugins.RxJavaPlugins) Predicate(io.reactivex.functions.Predicate) TraceContext(brave.propagation.TraceContext) MaybeFilter(io.reactivex.internal.operators.maybe.MaybeFilter) FlowablePublish(io.reactivex.internal.operators.flowable.FlowablePublish) ObservableFromCallable(io.reactivex.internal.operators.observable.ObservableFromCallable) SingleObserver(io.reactivex.SingleObserver) FlowableRange(io.reactivex.internal.operators.flowable.FlowableRange) MaybeJust(io.reactivex.internal.operators.maybe.MaybeJust) Observer(io.reactivex.Observer) Scope(brave.propagation.CurrentTraceContext.Scope) ObservableFilter(io.reactivex.internal.operators.observable.ObservableFilter) Scope(brave.propagation.CurrentTraceContext.Scope) Test(org.junit.Test)

Aggregations

ConnectableFlowable (io.reactivex.flowables.ConnectableFlowable)7 Observable (io.reactivex.Observable)4 Observer (io.reactivex.Observer)4 ConnectableObservable (io.reactivex.observables.ConnectableObservable)4 ParallelFlowable (io.reactivex.parallel.ParallelFlowable)4 CurrentTraceContext (brave.propagation.CurrentTraceContext)3 Scope (brave.propagation.CurrentTraceContext.Scope)3 StrictCurrentTraceContext (brave.propagation.StrictCurrentTraceContext)3 TraceContext (brave.propagation.TraceContext)3 Completable (io.reactivex.Completable)3 CompletableObserver (io.reactivex.CompletableObserver)3 Flowable (io.reactivex.Flowable)3 Maybe (io.reactivex.Maybe)3 MaybeObserver (io.reactivex.MaybeObserver)3 Single (io.reactivex.Single)3 SingleObserver (io.reactivex.SingleObserver)3 Predicate (io.reactivex.functions.Predicate)3 ScalarCallable (io.reactivex.internal.fuseable.ScalarCallable)3 CompletableEmpty (io.reactivex.internal.operators.completable.CompletableEmpty)3 CompletableFromCallable (io.reactivex.internal.operators.completable.CompletableFromCallable)3