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


Java TestSubscriber.assertNoValues方法代碼示例

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


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

示例1: testOneGist

import io.reactivex.subscribers.TestSubscriber; //導入方法依賴的package包/類
@Test
public void testOneGist() {
    ServiceLocator.put(OkHttpClient.class, OkHttpClientUtil.getOkHttpClient(null, MockBehavior.MOCK));
    Flowable<Gist> flowable = ServiceInjector.resolve(RxEndpoints.class).getGist("3d7cbc2f66cf5d61b8014d957a270c7c");
    TestSubscriber<Gist> testSubscriber = new TestSubscriber<>();
    flowable.subscribe(testSubscriber);
    testSubscriber.assertComplete();
    List<Gist> gistList = testSubscriber.values();
    Gist gist = gistList.get(0);
    assertEquals("Bootstrap Customizer Config", gist.getDescription());
    GistFile file = gist.getFile(gist.getFilenames().iterator().next());
    assertEquals(file.getContent().length(), file.getSize());
    assertEquals("config.json", file.getFilename());
    flowable = ServiceInjector.resolve(RxEndpoints.class).getGist("not actually an ID");
    testSubscriber = new TestSubscriber<>();
    flowable.subscribe(testSubscriber);
    testSubscriber.assertNotComplete();
    testSubscriber.assertNoValues();
    List<Throwable> errorList = testSubscriber.errors();
    assertEquals(errorList.size(), 1);
    assertEquals("Not Found", errorList.get(0).getMessage());
}
 
開發者ID:politedog,項目名稱:mock-interceptor,代碼行數:23,代碼來源:GistTest.java

示例2: noStreamIdEmittedIfNoStreamIsProvided

import io.reactivex.subscribers.TestSubscriber; //導入方法依賴的package包/類
@Test
public void noStreamIdEmittedIfNoStreamIsProvided() {
    TestSubscriber<StreamId<?>> subscriber = new TestSubscriber<>();
    Flowable.fromPublisher(newStreamHook()).subscribe(subscriber);

    subscriber.awaitTerminalEvent(1, SECONDS);
    subscriber.assertNoValues();
}
 
開發者ID:streamingpool,項目名稱:streamingpool-core,代碼行數:9,代碼來源:LocalPoolHookTest.java

示例3: shouldReturnEmptyWhenUserIsNotFound

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

    when(userRepository.getUser(anyString())).thenReturn(Flowable.empty());

    final TestSubscriber<User> userTestSubscriber = new TestSubscriber<>();
    final Flowable<User> userByNick = profileViewModel.getUserByNick("non existing user");
    userByNick.subscribe(userTestSubscriber);

    userTestSubscriber.assertNoErrors();
    userTestSubscriber.assertNoValues();
}
 
開發者ID:charafau,項目名稱:TurboChat,代碼行數:13,代碼來源:ProfileViewModelTest.java

示例4: shouldReturnLocalStream

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

    final TestSubscriber<Message> userTestSubscriber = new TestSubscriber<>();
    final Observable<Message> messageViewModelMessages = messageViewModel.localMessageStream();
    messageViewModelMessages.toFlowable(BackpressureStrategy.LATEST).subscribe(userTestSubscriber);

    userTestSubscriber.assertNoErrors();
    userTestSubscriber.assertNoValues();

}
 
開發者ID:charafau,項目名稱:TurboChat,代碼行數:12,代碼來源:MessageViewModelTest.java

示例5: shouldReturnApiStream

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

    final TestSubscriber<Message> userTestSubscriber = new TestSubscriber<>();
    final Observable<Message> messageViewModelMessages = messageViewModel.apiSendMessageStream();
    messageViewModelMessages.toFlowable(BackpressureStrategy.LATEST).subscribe(userTestSubscriber);

    userTestSubscriber.assertNoErrors();
    userTestSubscriber.assertNoValues();

}
 
開發者ID:charafau,項目名稱:TurboChat,代碼行數:12,代碼來源:MessageViewModelTest.java

示例6: testExceptionHandlingFault

import io.reactivex.subscribers.TestSubscriber; //導入方法依賴的package包/類
@Test
public void testExceptionHandlingFault()
{
    // setup
    final AtomicBoolean exceptionEncountered = new AtomicBoolean(false);
    final AtomicInteger counter = new AtomicInteger(0);
    Disposable faultSubscription = source.faults()
            .subscribe(new Consumer<String>() {
                @Override
                public void accept(String key) {
                    if (counter.incrementAndGet() <= 1) {
                        throw new RuntimeException("Explosions!");
                    }

                    source.onNext(key, counter.get());
                }
            }, new Consumer<Throwable>() {
                @Override
                public void accept(Throwable throwable) {
                    assertTrue(throwable instanceof RuntimeException);

                    exceptionEncountered.set(true);
                }
            });

    TestSubscriber<Integer> testSubscriber1 = new TestSubscriber<>();
    Flowable<Integer> helloValue = source.get("hello");

    subscribe(helloValue, testSubscriber1);

    testSubscriber1.assertNoValues();

    assertTrue(exceptionEncountered.get());

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

示例7: shouldReturnValuesFromNonEmptyList

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

    final TestScheduler testScheduler = new TestScheduler();
    List<Message> emptyList = Collections.emptyList();

    when(messageCache.getMessages()).thenReturn(Observable.just(emptyList));

    List<Message> apiMessages = new ArrayList<>();
    apiMessages.add(TestUtils.createMessage());

    final Observable<List<Message>> apiObservable = Observable
            .fromArray(apiMessages).delay(10, TimeUnit.SECONDS, testScheduler);

    when(messageRepository.getMessages()).thenReturn(apiObservable);

    final TestSubscriber<List<Message>> userTestSubscriber = new TestSubscriber<>();
    final Observable<List<Message>> messageViewModelMessages = messageViewModel.getMessages();


    messageViewModelMessages.toFlowable(BackpressureStrategy.LATEST)
            .subscribeOn(testScheduler).subscribe(userTestSubscriber);

    userTestSubscriber.assertNoValues();
    userTestSubscriber.assertNotComplete();


    testScheduler.advanceTimeBy(5, TimeUnit.SECONDS);

    userTestSubscriber.assertNoErrors();
    userTestSubscriber.assertValueCount(0);
    testScheduler.advanceTimeBy(5, TimeUnit.SECONDS);
    userTestSubscriber.assertComplete();
    userTestSubscriber.assertValueCount(1);
    userTestSubscriber.assertResult(apiMessages);
}
 
開發者ID:charafau,項目名稱:TurboChat,代碼行數:37,代碼來源:MessageViewModelTest.java


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