當前位置: 首頁>>代碼示例>>Java>>正文


Java TestSubscriber.assertValues方法代碼示例

本文整理匯總了Java中io.reactivex.subscribers.TestSubscriber.assertValues方法的典型用法代碼示例。如果您正苦於以下問題:Java TestSubscriber.assertValues方法的具體用法?Java TestSubscriber.assertValues怎麽用?Java TestSubscriber.assertValues使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在io.reactivex.subscribers.TestSubscriber的用法示例。


在下文中一共展示了TestSubscriber.assertValues方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: testUpdatesChecked

import io.reactivex.subscribers.TestSubscriber; //導入方法依賴的package包/類
@Test
public void testUpdatesChecked() throws Exception {
    RxPaperBook book = RxPaperBook.with("UPDATES_CH", Schedulers.trampoline());
    final String key = "hello";
    final ComplexObject value = ComplexObject.random();
    final TestSubscriber<ComplexObject> updatesSubscriber = TestSubscriber.create();
    book.observe(key, ComplexObject.class, BackpressureStrategy.MISSING).subscribe(updatesSubscriber);
    updatesSubscriber.assertValueCount(0);
    book.write(key, value).subscribe();
    updatesSubscriber.assertValueCount(1);
    updatesSubscriber.assertValues(value);
    final ComplexObject newValue = ComplexObject.random();
    book.write(key, newValue).subscribe();
    updatesSubscriber.assertValueCount(2);
    updatesSubscriber.assertValues(value, newValue);
    // Error value
    final int wrongValue = 3;
    book.write(key, wrongValue).test().assertComplete().assertNoErrors();
    updatesSubscriber.assertValueCount(2);
    updatesSubscriber.assertValues(value, newValue);
    updatesSubscriber.assertNoErrors();
}
 
開發者ID:pakoito,項目名稱:RxPaper2,代碼行數:23,代碼來源:RxPaperBookTest.java

示例2: test_just_Flowable

import io.reactivex.subscribers.TestSubscriber; //導入方法依賴的package包/類
@Test
public void test_just_Flowable() {

	Flowable<String> observable = Flowable.just("mango", "papaya", "guava");
	TestSubscriber<String> testSubscriber = new TestSubscriber<>();

	observable.subscribe(testSubscriber);

	List<String> items = testSubscriber.values();
	testSubscriber.assertComplete();
	testSubscriber.assertSubscribed();
	testSubscriber.assertNoErrors();
	testSubscriber.assertValueCount(3);
	testSubscriber.assertValues("mango", "papaya", "guava");

}
 
開發者ID:PacktPublishing,項目名稱:Reactive-Programming-With-Java-9,代碼行數:17,代碼來源:Modern_Testing.java

示例3: testATestScheduler

import io.reactivex.subscribers.TestSubscriber; //導入方法依賴的package包/類
@Test
public void testATestScheduler() throws Exception {
    TestSubscriber<Long> testSubscriber = new TestSubscriber<>();
    TestScheduler testScheduler = new TestScheduler();

    Flowable.interval(5, TimeUnit.MILLISECONDS, testScheduler)
            .map(x -> x + 1)
            .filter(x -> x % 2 == 0)
            .subscribe(testSubscriber);

    testScheduler.advanceTimeBy(10, TimeUnit.MILLISECONDS);

    testSubscriber.assertNoErrors();
    testSubscriber.assertValues(2L);

    testScheduler.advanceTimeBy(10, TimeUnit.MILLISECONDS);

    testSubscriber.assertNoErrors();
    testSubscriber.assertValues(2L, 4L);
}
 
開發者ID:dhinojosa,項目名稱:rxjavatraining,代碼行數:21,代碼來源:ObservableTestingTest.java

示例4: oneToMany

import io.reactivex.subscribers.TestSubscriber; //導入方法依賴的package包/類
@Test
public void oneToMany() {
    RxGreeterGrpc.RxGreeterStub stub = RxGreeterGrpc.newRxStub(channel);
    Single<String> rxRequest = Single.just("World");
    Flowable<String> rxResponse = stub.sayHelloRespStream(rxRequest.map(this::toRequest)).map(this::fromResponse);

    TestSubscriber<String> test = rxResponse.test();
    test.awaitTerminalEvent(1, TimeUnit.SECONDS);

    test.assertNoErrors();
    test.assertValues("Hello World", "Hi World", "Greetings World");
}
 
開發者ID:salesforce,項目名稱:reactive-grpc,代碼行數:13,代碼來源:ReactiveClientStandardServerInteropTest.java

示例5: manyToMany

import io.reactivex.subscribers.TestSubscriber; //導入方法依賴的package包/類
@Test
public void manyToMany() {
    RxGreeterGrpc.RxGreeterStub stub = RxGreeterGrpc.newRxStub(channel);
    Flowable<String> rxRequest = Flowable.just("A", "B", "C", "D");
    Flowable<String> rxResponse = stub.sayHelloBothStream(rxRequest.map(this::toRequest)).map(this::fromResponse);

    TestSubscriber<String> test = rxResponse.test();
    test.awaitTerminalEvent(1, TimeUnit.SECONDS);

    test.assertNoErrors();
    test.assertValues("Hello A and B", "Hello C and D");
}
 
開發者ID:salesforce,項目名稱:reactive-grpc,代碼行數:13,代碼來源:ReactiveClientStandardServerInteropTest.java

示例6: testRemoveTransform

import io.reactivex.subscribers.TestSubscriber; //導入方法依賴的package包/類
@Test
public void testRemoveTransform()
{
    SimpleFlowableList<Integer> list = new SimpleFlowableList<>(Arrays.asList(1, 2, 3, 4));

    TestSubscriber<Update<Flowable<String>>> testSubscriber = createIndexedList(list);

    testSubscriber.assertValueCount(1);

    List<Update<Flowable<String>>> onNextEvents = testSubscriber.values();

    assertEquals(Arrays.asList(Change.reloaded()), onNextEvents.get(0).changes);

    List<Flowable<String>> list1 = onNextEvents.get(0).list;

    Flowable<String> item1 = list1.get(0);
    Flowable<String> item2 = list1.get(1);
    Flowable<String> item3 = list1.get(2);
    Flowable<String> item4 = list1.get(3);

    TestSubscriber<String> test1 = item1.test();
    TestSubscriber<String> test2 = item2.test();
    TestSubscriber<String> test3 = item3.test();
    TestSubscriber<String> test4 = item4.test();

    test1.assertValue("? < 1 > 2");
    test2.assertValue("1 < 2 > 3");
    test3.assertValue("2 < 3 > 4");
    test4.assertValue("3 < 4 > ?");

    list.remove(3);

    test3.assertValues("2 < 3 > 4", "2 < 3 > ?");

    list.remove(1);

    test1.assertValues("? < 1 > 2", "? < 1 > 3");
    test3.assertValues("2 < 3 > 4", "2 < 3 > ?", "1 < 3 > ?");
}
 
開發者ID:mproberts,項目名稱:rxtools,代碼行數:40,代碼來源:IndexedFlowableListTest.java

示例7: testBatchAddRemove

import io.reactivex.subscribers.TestSubscriber; //導入方法依賴的package包/類
@Test
public void testBatchAddRemove()
{
    final AtomicInteger counter = new AtomicInteger(0);
    TestSubscriber<Update<Integer>> testSubscriber = new TestSubscriber<>();

    list.updates().subscribe(testSubscriber);

    list.batch(new Consumer<SimpleFlowableList<Integer>>() {
        @Override
        public void accept(SimpleFlowableList<Integer> integerBaseObservableList)
        {
            list.add(counter.incrementAndGet());
            list.add(counter.incrementAndGet());
            list.remove(1);
            list.add(counter.incrementAndGet());
        }
    });

    testSubscriber.assertValues(
            new Update<>(Arrays.<Integer>asList(), Change.reloaded()),
            new Update<>(Arrays.asList(1, 3), Arrays.asList(
                    Change.inserted(0),
                    Change.inserted(1),
                    Change.removed(1),
                    Change.inserted(1)
            )));
}
 
開發者ID:mproberts,項目名稱:rxtools,代碼行數:29,代碼來源:BaseFlowableListTest.java

示例8: twoEvents

import io.reactivex.subscribers.TestSubscriber; //導入方法依賴的package包/類
@Test
public void twoEvents() {
    TestSubscriber<String> testSubscriber = stream
        .compose(RxLifecycle.<String, String>bindUntilEvent(lifecycle, "stop"))
        .test();

    stream.onNext("1");
    lifecycle.onNext("keep going");
    stream.onNext("2");
    lifecycle.onNext("stop");
    stream.onNext("3");

    testSubscriber.assertValues("1", "2");
    testSubscriber.assertComplete();
}
 
開發者ID:xufreshman,項目名稱:RxLifeCycle,代碼行數:16,代碼來源:UntilEventTransformerFlowableTest.java

示例9: testEmptyAnd

import io.reactivex.subscribers.TestSubscriber; //導入方法依賴的package包/類
@Test
public void testEmptyAnd()
{
    Flowable<Boolean> joined = BooleanFlowables.and();

    TestSubscriber<Boolean> results = new TestSubscriber<>();

    joined.subscribe(results);

    results.assertValues(false);
}
 
開發者ID:mproberts,項目名稱:rxtools,代碼行數:12,代碼來源:BooleanFlowablesTest.java

示例10: testOperator_test1

import io.reactivex.subscribers.TestSubscriber; //導入方法依賴的package包/類
@Test
public void testOperator_test1() {
	TestSubscriber<Long> test_Subscriber = Flowable.rangeLong(10, 5).test(2);
	test_Subscriber.assertValues(10l, 11l);
	// test_Subscriber.requestMore(2);
	test_Subscriber.assertValues(10l, 11l, 12l, 13l);
	test_Subscriber.requestMore(1);
	test_Subscriber.assertValues(10l, 11l, 12l, 13l, 14l);
}
 
開發者ID:PacktPublishing,項目名稱:Reactive-Programming-With-Java-9,代碼行數:10,代碼來源:Test_test_operator.java

示例11: oneStartEvent

import io.reactivex.subscribers.TestSubscriber; //導入方法依賴的package包/類
@Test
public void oneStartEvent() {
    TestSubscriber<String> testSubscriber = stream
        .compose(RxLifecycle.<String, String>bind(lifecycle, CORRESPONDING_EVENTS))
        .test();

    lifecycle.onNext("create");
    stream.onNext("1");
    stream.onNext("2");

    testSubscriber.assertValues("1", "2");
    testSubscriber.assertNotTerminated();
}
 
開發者ID:xufreshman,項目名稱:RxLifeCycle,代碼行數:14,代碼來源:UntilCorrespondingEventTransformerFlowableTest.java

示例12: testATestSubscriber

import io.reactivex.subscribers.TestSubscriber; //導入方法依賴的package包/類
@Test
public void testATestSubscriber() throws Exception {
    TestSubscriber<Integer> testSubscriber = new TestSubscriber<>();
    Flowable.just(1, 2, 3, 4)
            .map(x -> x + 1)
            .filter(x -> x % 2 == 0)
            .subscribe(testSubscriber);

    testSubscriber.assertNoErrors();
    testSubscriber.assertValues(2, 4);
}
 
開發者ID:dhinojosa,項目名稱:rxjavatraining,代碼行數:12,代碼來源:ObservableTestingTest.java

示例13: openAndCloseEvent

import io.reactivex.subscribers.TestSubscriber; //導入方法依賴的package包/類
@Test
public void openAndCloseEvent() {
    TestSubscriber<String> testSubscriber = stream
        .compose(RxLifecycle.<String, String>bind(lifecycle, CORRESPONDING_EVENTS))
        .test();

    lifecycle.onNext("create");
    stream.onNext("1");
    lifecycle.onNext("destroy");
    stream.onNext("2");

    testSubscriber.assertValues("1");
    testSubscriber.assertComplete();
}
 
開發者ID:xufreshman,項目名稱:RxLifeCycle,代碼行數:15,代碼來源:UntilCorrespondingEventTransformerFlowableTest.java

示例14: noEvent

import io.reactivex.subscribers.TestSubscriber; //導入方法依賴的package包/類
@Test
public void noEvent() {
    TestSubscriber<String> testSubscriber = stream
        .compose(RxLifecycle.<String, String>bind(lifecycle))
        .test();

    stream.onNext("1");
    stream.onNext("2");
    testSubscriber.assertValues("1", "2");
    testSubscriber.assertNotTerminated();
}
 
開發者ID:xufreshman,項目名稱:RxLifeCycle,代碼行數:12,代碼來源:UntilLifecycleTransformerFlowableTest.java

示例15: testQueryAndIncrementOnFault

import io.reactivex.subscribers.TestSubscriber; //導入方法依賴的package包/類
@Test
public void testQueryAndIncrementOnFault()
{
    // setup
    AtomicInteger counter = new AtomicInteger(0);
    Disposable faultSubscription = source.faults()
            .subscribe(new IncrementingFaultSatisfier<>(source, counter));

    TestSubscriber<Integer> testSubscriber1 = new TestSubscriber<>();
    TestSubscriber<Integer> testSubscriber2 = new TestSubscriber<>();
    TestSubscriber<Integer> testSubscriber3 = new TestSubscriber<>();

    subscribe(source.get("hello"), testSubscriber1);
    System.gc();

    testSubscriber1.assertValues(1);

    subscribe(source.get("hello"), testSubscriber2);
    System.gc();

    testSubscriber1.assertValues(1);
    testSubscriber2.assertValues(1);

    unsubscribeAll();
    System.gc();

    subscribe(source.get("hello"), testSubscriber3);

    testSubscriber3.assertValues(2);

    // cleanup
    faultSubscription.dispose();
}
 
開發者ID:mproberts,項目名稱:rxtools,代碼行數:34,代碼來源:SubjectMapTest.java


注:本文中的io.reactivex.subscribers.TestSubscriber.assertValues方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。