本文整理了Java中io.reactivex.Observable.contains()
方法的一些代码示例,展示了Observable.contains()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Observable.contains()
方法的具体详情如下:
包路径:io.reactivex.Observable
类名称:Observable
方法名:contains
[英]Returns a Single that emits a Boolean that indicates whether the source ObservableSource emitted a specified item.
Scheduler: contains does not operate by default on a particular Scheduler.
[中]返回发出布尔值的单个值,该布尔值指示源ObservableSource是否发出指定项。
调度程序:默认情况下,contains不会在特定调度程序上运行。
代码示例来源:origin: ReactiveX/RxJava
@Test(expected = NullPointerException.class)
public void containsNull() {
just1.contains(null);
}
代码示例来源:origin: ReactiveX/RxJava
@Test
public void testContains() {
Single<Boolean> o = Observable.just("a", "b", "c").contains("b"); // FIXME nulls not allowed, changed to "c"
SingleObserver<Boolean> observer = TestHelper.mockSingleObserver();
o.subscribe(observer);
verify(observer, times(1)).onSuccess(true);
verify(observer, never()).onSuccess(false);
verify(observer, never()).onError(
any(Throwable.class));
}
代码示例来源:origin: ReactiveX/RxJava
@Test
public void testContainsObservable() {
Observable<Boolean> o = Observable.just("a", "b", "c").contains("b").toObservable();
Observer<Boolean> observer = TestHelper.mockObserver();
o.subscribe(observer);
verify(observer, times(1)).onNext(true);
verify(observer, never()).onNext(false);
verify(observer, never()).onError(
any(Throwable.class));
verify(observer, times(1)).onComplete();
}
代码示例来源:origin: ReactiveX/RxJava
@Test
public void testContainsWithInexistence() {
Single<Boolean> o = Observable.just("a", "b").contains("c"); // FIXME null values are not allowed, removed
SingleObserver<Object> observer = TestHelper.mockSingleObserver();
o.subscribe(observer);
verify(observer, times(1)).onSuccess(false);
verify(observer, never()).onSuccess(true);
verify(observer, never()).onError(
any(Throwable.class));
}
代码示例来源:origin: ReactiveX/RxJava
@Test
public void testContainsWithInexistenceObservable() {
Observable<Boolean> o = Observable.just("a", "b").contains("c").toObservable();
Observer<Object> observer = TestHelper.mockObserver();
o.subscribe(observer);
verify(observer, times(1)).onNext(false);
verify(observer, never()).onNext(true);
verify(observer, never()).onError(
any(Throwable.class));
verify(observer, times(1)).onComplete();
}
代码示例来源:origin: ReactiveX/RxJava
@Test
@Ignore("null values are not allowed")
public void testContainsWithNull() {
Single<Boolean> o = Observable.just("a", "b", null).contains(null);
SingleObserver<Object> observer = TestHelper.mockSingleObserver();
o.subscribe(observer);
verify(observer, times(1)).onSuccess(true);
verify(observer, never()).onSuccess(false);
verify(observer, never()).onError(
any(Throwable.class));
}
代码示例来源:origin: ReactiveX/RxJava
@Test
public void testContainsWithEmptyObservable() {
Single<Boolean> o = Observable.<String> empty().contains("a");
SingleObserver<Object> observer = TestHelper.mockSingleObserver();
o.subscribe(observer);
verify(observer, times(1)).onSuccess(false);
verify(observer, never()).onSuccess(true);
verify(observer, never()).onError(
any(Throwable.class));
}
代码示例来源:origin: ReactiveX/RxJava
@Test
@Ignore("null values are not allowed")
public void testContainsWithNullObservable() {
Observable<Boolean> o = Observable.just("a", "b", null).contains(null).toObservable();
Observer<Object> observer = TestHelper.mockObserver();
o.subscribe(observer);
verify(observer, times(1)).onNext(true);
verify(observer, never()).onNext(false);
verify(observer, never()).onError(
any(Throwable.class));
verify(observer, times(1)).onComplete();
}
代码示例来源:origin: ReactiveX/RxJava
@Test
public void testContainsWithEmptyObservableObservable() {
Observable<Boolean> o = Observable.<String> empty().contains("a").toObservable();
Observer<Object> observer = TestHelper.mockObserver();
o.subscribe(observer);
verify(observer, times(1)).onNext(false);
verify(observer, never()).onNext(true);
verify(observer, never()).onError(
any(Throwable.class));
verify(observer, times(1)).onComplete();
}
代码示例来源:origin: AppStoreFoundation/asf-sdk
@Override public Single<BDSChannel> createChannel(ECKey senderECKey, Address receiverAddress,
BigInteger balance) {
return Single.fromCallable(
() -> microRaidenClient.createChannel(senderECKey, receiverAddress, balance))
.map(openBlockNumber -> new BDSChannelImpl(senderECKey, receiverAddress, openBlockNumber,
microRaidenClient, bdsMicroRaidenApi, BigInteger.ZERO, balance))
.flatMap(
bdsChannel -> bdsMicroRaidenApi.listAllChannels(Address.from(senderECKey.getAddress()),
false)
.flatMapIterable(ListAllChannelsResponse::getResult)
.map(ListAllChannelsResponse.Result::getBlock)
.contains(bdsChannel.getOpenBlockNumber()
.intValue())
.doOnSuccess(aBoolean -> {
if (!aBoolean) {
throw new RuntimeException();
}
})
.retry()
.map(aBoolean -> bdsChannel));
}
内容来源于网络,如有侵权,请联系作者删除!