本文整理汇总了Java中io.reactivex.subjects.SingleSubject.onSuccess方法的典型用法代码示例。如果您正苦于以下问题:Java SingleSubject.onSuccess方法的具体用法?Java SingleSubject.onSuccess怎么用?Java SingleSubject.onSuccess使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类io.reactivex.subjects.SingleSubject
的用法示例。
在下文中一共展示了SingleSubject.onSuccess方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testShutdownWithPendingPermits
import io.reactivex.subjects.SingleSubject; //导入方法依赖的package包/类
@Test
public void testShutdownWithPendingPermits() {
SingleSubject<List<SqsMessage<String>>> singleSubject = SingleSubject.create();
when(sqsQueueMock.deleteMessage(any(String.class))).thenReturn(Completable.complete());
when(sqsQueueMock.receiveMessages(anyInt(), any(Optional.class))).thenReturn(singleSubject);
consumer.setMessageBuffer(messageBufferSmall);
consumer.processNextMessage(consumer.getNextMessage());
//handler does not ack here, so permits will be pending forever
Completable shutdownCompletable = consumer.shutdownAsync();
singleSubject.onSuccess(Collections.emptyList());
shutdownCompletable.test().assertNotComplete();
}
示例2: testHandlerDeleteAndShutdown
import io.reactivex.subjects.SingleSubject; //导入方法依赖的package包/类
@Test
public void testHandlerDeleteAndShutdown() {
SingleSubject<List<SqsMessage<String>>> singleSubject = SingleSubject.create();
when(sqsQueueMock.deleteMessage(any(String.class))).thenReturn(Completable.complete());
when(sqsQueueMock.receiveMessages(anyInt(), any(Optional.class))).thenReturn(singleSubject);
doAnswer((invocation -> {
((MessageAcknowledger) invocation.getArgument(1)).delete();
return null;
})).when(consumerHandlerMock).handleMessage(any(), any());
consumer.setMessageBuffer(messageBufferSmall);
consumer.processNextMessage(consumer.getNextMessage());
Completable shutdownCompletable = consumer.shutdownAsync();
singleSubject.onSuccess(Collections.emptyList());
shutdownCompletable.test().assertComplete();
verify(sqsQueueMock).deleteMessage(any(String.class));
}
示例3: testHandlerIgnoreAndShutdown
import io.reactivex.subjects.SingleSubject; //导入方法依赖的package包/类
@Test
public void testHandlerIgnoreAndShutdown() {
SingleSubject<List<SqsMessage<String>>> singleSubject = SingleSubject.create();
when(sqsQueueMock.deleteMessage(any(String.class))).thenReturn(Completable.complete());
when(sqsQueueMock.receiveMessages(anyInt(), any(Optional.class))).thenReturn(singleSubject);
doAnswer((invocation -> {
((MessageAcknowledger) invocation.getArgument(1)).ignore();
return null;
})).when(consumerHandlerMock).handleMessage(any(), any());
consumer.setMessageBuffer(messageBufferSmall);
consumer.processNextMessage(consumer.getNextMessage());
Completable shutdownCompletable = consumer.shutdownAsync();
singleSubject.onSuccess(Collections.emptyList());
shutdownCompletable.test().assertComplete();
verify(sqsQueueMock, never()).deleteMessage(any(String.class));
}
示例4: test
import io.reactivex.subjects.SingleSubject; //导入方法依赖的package包/类
@Test public void test() {
SingleSubject<String> subject = SingleSubject.create();
Single<String> singleSource = subject.hide();
TestObserver testObserver = new TestObserver();
CompositeDisposable composite = new CompositeDisposable();
Disposable disposable = singleSource
.compose(DisposableAttach.<String>to(composite))
.subscribeWith(testObserver);
subject.onSuccess("Foo");
testObserver.assertValue("Foo");
assertTrue(composite.size() == 1);
composite.dispose();
assertTrue(composite.size() == 0);
assertTrue(composite.isDisposed());
assertTrue(disposable.isDisposed());
assertTrue(testObserver.isDisposed());
}
示例5: autoDispose_withMaybe_normal
import io.reactivex.subjects.SingleSubject; //导入方法依赖的package包/类
@Test public void autoDispose_withMaybe_normal() {
RecordingObserver<Integer> o = new RecordingObserver<>(LOGGER);
SingleSubject<Integer> source = SingleSubject.create();
MaybeSubject<Integer> lifecycle = MaybeSubject.create();
source.as(AutoDispose.<Integer>autoDisposable(lifecycle))
.subscribe(o);
o.takeSubscribe();
assertThat(source.hasObservers()).isTrue();
assertThat(lifecycle.hasObservers()).isTrue();
// Got the event
source.onSuccess(1);
assertThat(o.takeSuccess()).isEqualTo(1);
// Nothing more, lifecycle disposed too
o.assertNoMoreEvents();
assertThat(source.hasObservers()).isFalse();
assertThat(lifecycle.hasObservers()).isFalse();
}
示例6: autoDispose_withMaybe_interrupted
import io.reactivex.subjects.SingleSubject; //导入方法依赖的package包/类
@Test public void autoDispose_withMaybe_interrupted() {
RecordingObserver<Integer> o = new RecordingObserver<>(LOGGER);
SingleSubject<Integer> source = SingleSubject.create();
MaybeSubject<Integer> lifecycle = MaybeSubject.create();
source.as(AutoDispose.<Integer>autoDisposable(lifecycle))
.subscribe(o);
o.takeSubscribe();
assertThat(source.hasObservers()).isTrue();
assertThat(lifecycle.hasObservers()).isTrue();
// Lifecycle ends
lifecycle.onSuccess(2);
assertThat(source.hasObservers()).isFalse();
assertThat(lifecycle.hasObservers()).isFalse();
// Event if upstream emits, no one is listening
source.onSuccess(2);
o.assertNoMoreEvents();
}
示例7: autoDispose_withProvider
import io.reactivex.subjects.SingleSubject; //导入方法依赖的package包/类
@Test public void autoDispose_withProvider() {
RecordingObserver<Integer> o = new RecordingObserver<>(LOGGER);
SingleSubject<Integer> source = SingleSubject.create();
MaybeSubject<Integer> scope = MaybeSubject.create();
ScopeProvider provider = makeProvider(scope);
source.as(AutoDispose.<Integer>autoDisposable(provider))
.subscribe(o);
o.takeSubscribe();
assertThat(source.hasObservers()).isTrue();
assertThat(scope.hasObservers()).isTrue();
source.onSuccess(3);
o.takeSuccess();
// All cleaned up
o.assertNoMoreEvents();
assertThat(source.hasObservers()).isFalse();
assertThat(scope.hasObservers()).isFalse();
}
示例8: autoDispose_withProvider_interrupted
import io.reactivex.subjects.SingleSubject; //导入方法依赖的package包/类
@Test public void autoDispose_withProvider_interrupted() {
RecordingObserver<Integer> o = new RecordingObserver<>(LOGGER);
SingleSubject<Integer> source = SingleSubject.create();
MaybeSubject<Integer> scope = MaybeSubject.create();
ScopeProvider provider = makeProvider(scope);
source.as(AutoDispose.<Integer>autoDisposable(provider))
.subscribe(o);
o.takeSubscribe();
assertThat(source.hasObservers()).isTrue();
assertThat(scope.hasObservers()).isTrue();
// Lifecycle ends
scope.onSuccess(3);
assertThat(source.hasObservers()).isFalse();
assertThat(scope.hasObservers()).isFalse();
// No one is listening even if upstream finally does emit
source.onSuccess(3);
o.assertNoMoreEvents();
}
示例9: autoDispose_withLifecycleProvider
import io.reactivex.subjects.SingleSubject; //导入方法依赖的package包/类
@Test public void autoDispose_withLifecycleProvider() {
RecordingObserver<Integer> o = new RecordingObserver<>(LOGGER);
SingleSubject<Integer> source = SingleSubject.create();
BehaviorSubject<Integer> lifecycle = BehaviorSubject.createDefault(0);
LifecycleScopeProvider<Integer> provider = makeLifecycleProvider(lifecycle);
source.as(AutoDispose.<Integer>autoDisposable(provider))
.subscribe(o);
o.takeSubscribe();
assertThat(source.hasObservers()).isTrue();
assertThat(lifecycle.hasObservers()).isTrue();
lifecycle.onNext(1);
assertThat(source.hasObservers()).isTrue();
assertThat(lifecycle.hasObservers()).isTrue();
source.onSuccess(3);
o.takeSuccess();
// All cleaned up
o.assertNoMoreEvents();
assertThat(source.hasObservers()).isFalse();
assertThat(lifecycle.hasObservers()).isFalse();
}
示例10: autoDispose_withLifecycleProvider_interrupted
import io.reactivex.subjects.SingleSubject; //导入方法依赖的package包/类
@Test public void autoDispose_withLifecycleProvider_interrupted() {
RecordingObserver<Integer> o = new RecordingObserver<>(LOGGER);
SingleSubject<Integer> source = SingleSubject.create();
BehaviorSubject<Integer> lifecycle = BehaviorSubject.createDefault(0);
LifecycleScopeProvider<Integer> provider = makeLifecycleProvider(lifecycle);
source.as(AutoDispose.<Integer>autoDisposable(provider))
.subscribe(o);
o.takeSubscribe();
assertThat(source.hasObservers()).isTrue();
assertThat(lifecycle.hasObservers()).isTrue();
lifecycle.onNext(1);
assertThat(source.hasObservers()).isTrue();
assertThat(lifecycle.hasObservers()).isTrue();
// Lifecycle ends
lifecycle.onNext(3);
assertThat(source.hasObservers()).isFalse();
assertThat(lifecycle.hasObservers()).isFalse();
// No one is listening even if upstream finally does emit
source.onSuccess(3);
o.assertNoMoreEvents();
}
示例11: unbound_shouldStillPassValues
import io.reactivex.subjects.SingleSubject; //导入方法依赖的package包/类
@Test public void unbound_shouldStillPassValues() {
SingleSubject<Integer> s = SingleSubject.create();
TestObserver<Integer> o = s
.as(AutoDispose.<Integer>autoDisposable(ScopeProvider.UNBOUND))
.test();
s.onSuccess(1);
o.assertValue(1);
}