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


Java TestSubscriber.assertError方法代碼示例

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


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

示例1: onErrorDelegates

import io.reactivex.subscribers.TestSubscriber; //導入方法依賴的package包/類
@Test
public void onErrorDelegates() {
    ClientCallStreamObserver<Object> obs = mock(ClientCallStreamObserver.class);
    RxConsumerStreamObserver rxObs = new RxConsumerStreamObserver();
    Subscriber<Object> sub = mock(Subscriber.class);

    rxObs.beforeStart(obs);
    rxObs.getRxConsumer().subscribe(sub);

    TestSubscriber<Object> testSubscriber = ((Flowable<Object>)rxObs.getRxConsumer()).test();

    Throwable obj = new Exception();
    rxObs.onError(obj);

    testSubscriber.awaitTerminalEvent(3, TimeUnit.SECONDS);
    testSubscriber.assertError(obj);
}
 
開發者ID:salesforce,項目名稱:reactive-grpc,代碼行數:18,代碼來源:RxConsumerStreamObserverTest.java

示例2: testGetOneWithError

import io.reactivex.subscribers.TestSubscriber; //導入方法依賴的package包/類
@Test
public void testGetOneWithError(){
    testStore.shouldThrowError(true);
    models.clear();
    List<TestModel> list = new ArrayList<>();
    list.add(new TestModel(10));
    list.add(new TestModel(20));
    list.add(new TestModel(30));
    memoryStore.insertOrUpdate(list);

    TestSubscriber<Optional<TestModel>> observer = new TestSubscriber<>();
    disposables.add(testStore.getOne()
            .subscribeOn(Schedulers.io())
            .subscribeWith(observer));

    observer.awaitTerminalEvent(2, SECONDS);
    observer.assertError(Throwable.class);
    observer.assertErrorMessage("getOne.error");

    testStore.shouldThrowError(false);

    Assert.assertEquals(3, models.size());
}
 
開發者ID:playmoweb,項目名稱:store2store,代碼行數:24,代碼來源:StoreServiceUnitTest.java

示例3: testInsertListWithError

import io.reactivex.subscribers.TestSubscriber; //導入方法依賴的package包/類
@Test
public void testInsertListWithError(){
    models.clear();
    testStore.shouldThrowError(true); // enable error

    List<TestModel> list = new ArrayList<>();
    list.add(new TestModel(1));
    list.add(new TestModel(2));
    list.add(new TestModel(3));

    TestSubscriber<Optional<List<TestModel>>> observer = new TestSubscriber<>();
    disposables.add(testStore.insert(list)
            .subscribeOn(Schedulers.io())
            .subscribeWith(observer));

    observer.awaitTerminalEvent(2, SECONDS);
    observer.assertError(Throwable.class);
    observer.assertErrorMessage("insert.error");

    testStore.shouldThrowError(false); // disable error

    Assert.assertEquals(0, models.size()); // should have been cleared
}
 
開發者ID:playmoweb,項目名稱:store2store,代碼行數:24,代碼來源:StoreServiceUnitTest.java

示例4: testInsertWithError

import io.reactivex.subscribers.TestSubscriber; //導入方法依賴的package包/類
@Test
public void testInsertWithError(){
    models.clear();
    testStore.shouldThrowError(true); // enable error

    TestModel model = new TestModel(99);

    TestSubscriber<Optional<TestModel>> observer = new TestSubscriber<>();
    disposables.add(testStore.insert(model)
            .subscribeOn(Schedulers.io())
            .subscribeWith(observer));

    observer.awaitTerminalEvent(2, SECONDS);
    observer.assertError(Throwable.class);
    observer.assertErrorMessage("insertSingle.error");

    testStore.shouldThrowError(false); // disable error
    Assert.assertEquals(0, models.size());
}
 
開發者ID:playmoweb,項目名稱:store2store,代碼行數:20,代碼來源:StoreServiceUnitTest.java

示例5: testDeleteAllWithError

import io.reactivex.subscribers.TestSubscriber; //導入方法依賴的package包/類
@Test
public void testDeleteAllWithError(){
    testStore.shouldThrowError(true);
    models.clear();

    List<TestModel> list = new ArrayList<>();
    list.add(new TestModel(1));
    list.add(new TestModel(2));
    list.add(new TestModel(3));
    memoryStore.insertOrUpdate(list);

    TestSubscriber<Integer> observer = new TestSubscriber<>();
    disposables.add(testStore.deleteAll()
            .subscribeOn(Schedulers.io())
            .subscribeWith(observer));

    observer.awaitTerminalEvent(5, SECONDS);
    observer.assertError(Throwable.class);
    observer.assertErrorMessage("deleteAll.error");

    testStore.shouldThrowError(false); // disable error
    Assert.assertEquals(3, models.size());
}
 
開發者ID:playmoweb,項目名稱:store2store,代碼行數:24,代碼來源:StoreServiceUnitTest.java

示例6: testInsertOrUpdateForInsertWithError

import io.reactivex.subscribers.TestSubscriber; //導入方法依賴的package包/類
@Test
public void testInsertOrUpdateForInsertWithError(){
    models.clear();
    testStore.shouldThrowError(true);

    final TestModel model = new TestModel(99);
    model.setAvailable(true);

    TestSubscriber<Optional<TestModel>> observer = new TestSubscriber<>();
    disposables.add(testStore.insertOrUpdate(model)
            .subscribeOn(Schedulers.io())
            .subscribeWith(observer));

    observer.awaitTerminalEvent(4, SECONDS);
    observer.assertError(Throwable.class);
    observer.assertErrorMessage("insertOrUpdateSingle.error");

    testStore.shouldThrowError(false);

    Assert.assertEquals(0, models.size());
}
 
開發者ID:playmoweb,項目名稱:store2store,代碼行數:22,代碼來源:StoreServiceUnitTest.java

示例7: testErrorHandlingInValueProvider

import io.reactivex.subscribers.TestSubscriber; //導入方法依賴的package包/類
@Test
public void testErrorHandlingInValueProvider()
{
    // setup
    final AtomicBoolean missHandlerCalled = new AtomicBoolean(false);
    TestSubscriber<Integer> testSubscriber1 = new TestSubscriber<>();

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

    source.onNext("hello", new Callable<Integer>() {
        @Override
        public Integer call() throws Exception
        {
            throw new RuntimeException("Boom");
        }
    }, new Action() {
        @Override
        public void run()
        {
            missHandlerCalled.set(true);
        }
    });

    testSubscriber1.assertError(RuntimeException.class);
}
 
開發者ID:mproberts,項目名稱:rxtools,代碼行數:26,代碼來源:SubjectMapTest.java

示例8: oneToMany

import io.reactivex.subscribers.TestSubscriber; //導入方法依賴的package包/類
@Test
public void oneToMany() {
    RxGreeterGrpc.RxGreeterStub stub = RxGreeterGrpc.newRxStub(channel);
    Flowable<HelloResponse> resp = stub.sayHelloRespStream(Single.just(HelloRequest.getDefaultInstance()));
    TestSubscriber<HelloResponse> test = resp
            .doOnNext(msg -> System.out.println(msg))
            .doOnError(throwable -> System.out.println(throwable.getMessage()))
            .doOnComplete(() -> System.out.println("Completed"))
            .doOnCancel(() -> System.out.println("Client canceled"))
            .test();

    test.awaitTerminalEvent(3, TimeUnit.SECONDS);
    test.assertError(t -> t instanceof StatusRuntimeException);
    test.assertError(t -> ((StatusRuntimeException)t).getStatus() == Status.INTERNAL);
}
 
開發者ID:salesforce,項目名稱:reactive-grpc,代碼行數:16,代碼來源:ServerErrorIntegrationTest.java

示例9: manyToMany

import io.reactivex.subscribers.TestSubscriber; //導入方法依賴的package包/類
@Test
public void manyToMany() {
    RxGreeterGrpc.RxGreeterStub stub = RxGreeterGrpc.newRxStub(channel);
    Flowable<HelloResponse> resp = stub.sayHelloBothStream(Flowable.just(HelloRequest.getDefaultInstance()));
    TestSubscriber<HelloResponse> test = resp.test();

    test.awaitTerminalEvent(3, TimeUnit.SECONDS);
    test.assertError(t -> t instanceof StatusRuntimeException);
    test.assertError(t -> ((StatusRuntimeException)t).getStatus() == Status.INTERNAL);
}
 
開發者ID:salesforce,項目名稱:reactive-grpc,代碼行數:11,代碼來源:ServerErrorIntegrationTest.java

示例10: oneToMany

import io.reactivex.subscribers.TestSubscriber; //導入方法依賴的package包/類
@Test
public void oneToMany() {
    RxGreeterGrpc.RxGreeterStub stub = RxGreeterGrpc.newRxStub(channel);
    Flowable<HelloResponse> resp = stub.sayHelloRespStream(Single.just(HelloRequest.getDefaultInstance()));
    TestSubscriber<HelloResponse> test = resp
            .doOnNext(msg -> System.out.println(msg))
            .doOnError(throwable -> System.out.println(throwable.getMessage()))
            .doOnComplete(() -> System.out.println("Completed"))
            .doOnCancel(() -> System.out.println("Client canceled"))
            .test();

    test.awaitTerminalEvent(3, TimeUnit.SECONDS);
    test.assertError(t -> t instanceof StatusRuntimeException);
    test.assertError(t -> ((StatusRuntimeException)t).getStatus().getCode() == Status.Code.INTERNAL);
}
 
開發者ID:salesforce,項目名稱:reactive-grpc,代碼行數:16,代碼來源:UnexpectedServerErrorIntegrationTest.java

示例11: manyToMany

import io.reactivex.subscribers.TestSubscriber; //導入方法依賴的package包/類
@Test
public void manyToMany() {
    RxGreeterGrpc.RxGreeterStub stub = RxGreeterGrpc.newRxStub(channel);
    Flowable<HelloRequest> req = Flowable.just(HelloRequest.getDefaultInstance());
    Flowable<HelloResponse> resp = stub.sayHelloBothStream(req);
    TestSubscriber<HelloResponse> test = resp.test();

    test.awaitTerminalEvent(3, TimeUnit.SECONDS);
    test.assertError(t -> t instanceof StatusRuntimeException);
    test.assertError(t -> ((StatusRuntimeException)t).getStatus().getCode() == Status.Code.CANCELLED);
}
 
開發者ID:salesforce,項目名稱:reactive-grpc,代碼行數:12,代碼來源:UnexpectedServerErrorIntegrationTest.java

示例12: testGetAllWithError

import io.reactivex.subscribers.TestSubscriber; //導入方法依賴的package包/類
@Test
public void testGetAllWithError(){
    models.clear();
    testStore.shouldThrowError(true); // enable error

    List<TestModel> list = new ArrayList<>();
    list.add(new TestModel(1));
    list.add(new TestModel(2));
    list.add(new TestModel(3));
    memoryStore.insertOrUpdate(list);

    TestSubscriber<Optional<List<TestModel>>> observer = new TestSubscriber<>();
    disposables.add(testStore.getAll(null, null)
            .subscribeOn(Schedulers.io())
            .subscribeWith(observer));

    observer.awaitTerminalEvent(2, SECONDS);
    observer.assertError(Throwable.class);
    observer.assertErrorMessage("getAll.error");

    testStore.shouldThrowError(false); // disable error
    Assert.assertEquals(models.size(), 3);

    int sum = 0;
    for(TestModel tm : models){
        sum += tm.getId();
    }

    Assert.assertEquals(6, sum);
}
 
開發者ID:playmoweb,項目名稱:store2store,代碼行數:31,代碼來源:StoreServiceUnitTest.java

示例13: testDeleteSingleWithError

import io.reactivex.subscribers.TestSubscriber; //導入方法依賴的package包/類
@Test
public void testDeleteSingleWithError(){
    models.clear();
    testStore.shouldThrowError(true);

    List<TestModel> list = new ArrayList<>();
    list.add(new TestModel(1));
    list.add(new TestModel(2));
    list.add(new TestModel(3));
    memoryStore.insertOrUpdate(list);

    TestModel model = new TestModel(2);
    TestSubscriber<Integer> observer = new TestSubscriber<>();
    disposables.add(testStore.delete(model)
            .subscribeOn(Schedulers.io())
            .subscribeWith(observer));

    observer.awaitTerminalEvent(2, SECONDS);
    observer.assertError(Throwable.class);
    observer.assertErrorMessage("deleteSingle.error");

    int sum = 0;
    for(TestModel tm : models){
        sum += tm.getId();
    }

    testStore.shouldThrowError(false); // disable error

    Assert.assertEquals(3, models.size());
    Assert.assertEquals(6, sum);
}
 
開發者ID:playmoweb,項目名稱:store2store,代碼行數:32,代碼來源:StoreServiceUnitTest.java

示例14: testInsertOrUpdateForUpdateWithError

import io.reactivex.subscribers.TestSubscriber; //導入方法依賴的package包/類
@Test
public void testInsertOrUpdateForUpdateWithError(){
    models.clear();
    final TestModel model = new TestModel(99);
    model.setAvailable(true); // should be rollback to this version
    models.add(model);

    testStore.shouldThrowError(true);

    final TestModel otherModelReferenceWithSameId = new TestModel(99);
    otherModelReferenceWithSameId.setAvailable(false);

    TestSubscriber<Optional<TestModel>> observer = new TestSubscriber<>();
    disposables.add(testStore.insertOrUpdate(otherModelReferenceWithSameId)
            .subscribeOn(Schedulers.io())
            .subscribeWith(observer));

    observer.awaitTerminalEvent(5, SECONDS);
    observer.assertError(Throwable.class);
    observer.assertErrorMessage("insertOrUpdateSingle.error");

    testStore.shouldThrowError(false);

    final TestModel output = models.get(0);
    Assert.assertEquals(1, models.size());
    Assert.assertNotNull(output);
    Assert.assertTrue(output.isAvailable()); // rollback to first version
}
 
開發者ID:playmoweb,項目名稱:store2store,代碼行數:29,代碼來源:StoreServiceUnitTest.java

示例15: testInsertOrUpdateManyWithError

import io.reactivex.subscribers.TestSubscriber; //導入方法依賴的package包/類
@Test
public void testInsertOrUpdateManyWithError(){
    models.clear();
    testStore.shouldThrowError(true);

    List<TestModel> list = new ArrayList<>();
    list.add(new TestModel(10));
    list.add(new TestModel(20));
    list.add(new TestModel(30));
    memoryStore.insertOrUpdate(list);

    List<TestModel> listToInsertOrUpdate = new ArrayList<>();
    final TestModel first = new TestModel(20);
    first.setAvailable(true);
    final TestModel second = new TestModel(99);
    second.setAvailable(true);

    listToInsertOrUpdate.add(first);
    listToInsertOrUpdate.add(second);

    TestSubscriber<Optional<List<TestModel>>> observer = new TestSubscriber<>();
    disposables.add(testStore.insertOrUpdate(listToInsertOrUpdate)
            .subscribeOn(Schedulers.io())
            .subscribeWith(observer));

    observer.awaitTerminalEvent(5, SECONDS);
    observer.assertError(Throwable.class);
    observer.assertErrorMessage("insertOrUpdate.error");

    testStore.shouldThrowError(false);

    for(TestModel tm : MemoryDao.models){
        Assert.assertFalse(tm.isAvailable());
    }

    Assert.assertEquals(3, MemoryDao.models.size());
}
 
開發者ID:playmoweb,項目名稱:store2store,代碼行數:38,代碼來源:StoreServiceUnitTest.java


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