当前位置: 首页>>代码示例>>Java>>正文


Java BlockingObservable.from方法代码示例

本文整理汇总了Java中rx.observables.BlockingObservable.from方法的典型用法代码示例。如果您正苦于以下问题:Java BlockingObservable.from方法的具体用法?Java BlockingObservable.from怎么用?Java BlockingObservable.from使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在rx.observables.BlockingObservable的用法示例。


在下文中一共展示了BlockingObservable.from方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testToIterableNextOnlyTwice

import rx.observables.BlockingObservable; //导入方法依赖的package包/类
@Test(expected = NoSuchElementException.class)
public void testToIterableNextOnlyTwice() {
    BlockingObservable<Integer> obs = BlockingObservable.from(Observable.just(1, 2, 3));

    Iterator<Integer> it = obs.toIterable().iterator();

    Assert.assertEquals((Integer) 1, it.next());
    Assert.assertEquals((Integer) 2, it.next());
    Assert.assertEquals((Integer) 3, it.next());

    boolean exc = false;
    try {
        it.next();
    } catch (NoSuchElementException ex) {
        exc = true;
    }
    Assert.assertEquals(true, exc);

    it.next();
}
 
开发者ID:akarnokd,项目名称:RxJavaFlow,代码行数:21,代码来源:BlockingObservableTest.java

示例2: testToIterableManyTimes

import rx.observables.BlockingObservable; //导入方法依赖的package包/类
@Test
public void testToIterableManyTimes() {
    BlockingObservable<Integer> obs = BlockingObservable.from(Observable.just(1, 2, 3));

    Iterable<Integer> iter = obs.toIterable();

    for (int j = 0; j < 3; j++) {
        Iterator<Integer> it = iter.iterator();

        Assert.assertTrue(it.hasNext());
        Assert.assertEquals((Integer) 1, it.next());
        Assert.assertTrue(it.hasNext());
        Assert.assertEquals((Integer) 2, it.next());
        Assert.assertTrue(it.hasNext());
        Assert.assertEquals((Integer) 3, it.next());
        Assert.assertFalse(it.hasNext());
    }
}
 
开发者ID:akarnokd,项目名称:RxJavaFlow,代码行数:19,代码来源:BlockingObservableTest.java

示例3: testToIterableWithException

import rx.observables.BlockingObservable; //导入方法依赖的package包/类
@Test(expected = TestException.class)
public void testToIterableWithException() {
    BlockingObservable<String> obs = BlockingObservable.from(Observable.create(new Observable.OnSubscribe<String>() {

        @Override
        public void call(Subscriber<? super String> observer) {
            observer.onNext("one");
            observer.onError(new TestException());
        }
    }));

    Iterator<String> it = obs.toIterable().iterator();

    assertEquals(true, it.hasNext());
    assertEquals("one", it.next());

    assertEquals(true, it.hasNext());
    it.next();

}
 
开发者ID:akarnokd,项目名称:RxJavaFlow,代码行数:21,代码来源:BlockingObservableTest.java

示例4: testLastOrDefault

import rx.observables.BlockingObservable; //导入方法依赖的package包/类
@Test
public void testLastOrDefault() {
    BlockingObservable<Integer> observable = BlockingObservable.from(Observable.just(1, 0, -1));
    int last = observable.lastOrDefault(-100, new Function<Integer, Boolean>() {
        @Override
        public Boolean call(Integer args) {
            return args >= 0;
        }
    });
    assertEquals(0, last);
}
 
开发者ID:akarnokd,项目名称:RxJavaFlow,代码行数:12,代码来源:BlockingObservableTest.java

示例5: testFirstOrDefaultWithPredicateAndEmpty

import rx.observables.BlockingObservable; //导入方法依赖的package包/类
@Test
public void testFirstOrDefaultWithPredicateAndEmpty() {
    BlockingObservable<String> observable = BlockingObservable.from(Observable.just("one", "two", "three"));
    String first = observable.firstOrDefault("default", new Function<String, Boolean>() {
        @Override
        public Boolean call(String args) {
            return args.length() > 5;
        }
    });
    assertEquals("default", first);
}
 
开发者ID:akarnokd,项目名称:RxJavaFlow,代码行数:12,代码来源:BlockingObservableTest.java

示例6: testLastOrDefaultWithPredicate

import rx.observables.BlockingObservable; //导入方法依赖的package包/类
@Test
public void testLastOrDefaultWithPredicate() {
    BlockingObservable<Integer> observable = BlockingObservable.from(Observable.just(1, 0, -1));
    int last = observable.lastOrDefault(0, new Function<Integer, Boolean>() {
        @Override
        public Boolean call(Integer args) {
            return args < 0;
        }
    });

    assertEquals(-1, last);
}
 
开发者ID:akarnokd,项目名称:RxJavaFlow,代码行数:13,代码来源:BlockingObservableTest.java

示例7: testFirstWithPredicateAndEmpty

import rx.observables.BlockingObservable; //导入方法依赖的package包/类
@Test(expected = NoSuchElementException.class)
public void testFirstWithPredicateAndEmpty() {
    BlockingObservable<String> observable = BlockingObservable.from(Observable.just("one", "two", "three"));
    observable.first(new Function<String, Boolean>() {
        @Override
        public Boolean call(String args) {
            return args.length() > 5;
        }
    });
}
 
开发者ID:akarnokd,项目名称:RxJavaFlow,代码行数:11,代码来源:BlockingObservableTest.java

示例8: testLastWithPredicate

import rx.observables.BlockingObservable; //导入方法依赖的package包/类
@Test
public void testLastWithPredicate() {
    BlockingObservable<String> obs = BlockingObservable.from(Observable.just("one", "two", "three"));
    assertEquals("two", obs.last(new Function<String, Boolean>() {
        @Override
        public Boolean call(String s) {
            return s.length() == 3;
        }
    }));
}
 
开发者ID:akarnokd,项目名称:RxJavaFlow,代码行数:11,代码来源:BlockingObservableTest.java

示例9: testFirstWithPredicate

import rx.observables.BlockingObservable; //导入方法依赖的package包/类
@Test
public void testFirstWithPredicate() {
    BlockingObservable<String> observable = BlockingObservable.from(Observable.just("one", "two", "three"));
    String first = observable.first(new Function<String, Boolean>() {
        @Override
        public Boolean call(String args) {
            return args.length() > 3;
        }
    });
    assertEquals("three", first);
}
 
开发者ID:akarnokd,项目名称:RxJavaFlow,代码行数:12,代码来源:BlockingObservableTest.java

示例10: testSingleDefaultPredicateMatchesNothing

import rx.observables.BlockingObservable; //导入方法依赖的package包/类
@Test
public void testSingleDefaultPredicateMatchesNothing() {
    BlockingObservable<String> observable = BlockingObservable.from(Observable.just("one", "two"));
    String result = observable.singleOrDefault("default", new Function<String, Boolean>() {
        @Override
        public Boolean call(String args) {
            return args.length() == 4;
        }
    });
    assertEquals("default", result);
}
 
开发者ID:akarnokd,项目名称:RxJavaFlow,代码行数:12,代码来源:BlockingObservableTest.java

示例11: testSingleWrongPredicate

import rx.observables.BlockingObservable; //导入方法依赖的package包/类
@Test(expected = NoSuchElementException.class)
public void testSingleWrongPredicate() {
    BlockingObservable<Integer> observable = BlockingObservable.from(Observable.just(-1));
    observable.single(new Function<Integer, Boolean>() {
        @Override
        public Boolean call(Integer args) {
            return args > 0;
        }
    });
}
 
开发者ID:akarnokd,项目名称:RxJavaFlow,代码行数:11,代码来源:BlockingObservableTest.java

示例12: testToIterableNextOnly

import rx.observables.BlockingObservable; //导入方法依赖的package包/类
@Test(expected = NoSuchElementException.class)
public void testToIterableNextOnly() {
    BlockingObservable<Integer> obs = BlockingObservable.from(Observable.just(1, 2, 3));

    Iterator<Integer> it = obs.toIterable().iterator();

    Assert.assertEquals((Integer) 1, it.next());
    Assert.assertEquals((Integer) 2, it.next());
    Assert.assertEquals((Integer) 3, it.next());

    it.next();
}
 
开发者ID:akarnokd,项目名称:RxJavaFlow,代码行数:13,代码来源:BlockingObservableTest.java

示例13: toBlocking

import rx.observables.BlockingObservable; //导入方法依赖的package包/类
public final BlockingObservable<T> toBlocking() {
    return BlockingObservable.from(this);
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:4,代码来源:Observable.java

示例14: testLast

import rx.observables.BlockingObservable; //导入方法依赖的package包/类
@Test
public void testLast() {
    BlockingObservable<String> obs = BlockingObservable.from(Observable.just("one", "two", "three"));

    assertEquals("three", obs.last());
}
 
开发者ID:akarnokd,项目名称:RxJavaFlow,代码行数:7,代码来源:BlockingObservableTest.java

示例15: testLastEmptyObservable

import rx.observables.BlockingObservable; //导入方法依赖的package包/类
@Test(expected = NoSuchElementException.class)
public void testLastEmptyObservable() {
    BlockingObservable<Object> obs = BlockingObservable.from(Observable.empty());
    obs.last();
}
 
开发者ID:akarnokd,项目名称:RxJavaFlow,代码行数:6,代码来源:BlockingObservableTest.java


注:本文中的rx.observables.BlockingObservable.from方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。