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


Java TestSubscriber.assertNoValues方法代碼示例

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


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

示例1: fetchSuggestionsCountTest

import rx.observers.TestSubscriber; //導入方法依賴的package包/類
@Test
public void fetchSuggestionsCountTest() throws Exception {
    final TestSubscriber<List<String>> testSubscriber = TestSubscriber.create();
    int maxSuggestions = 1;
    RxSuggestions.fetch("a", maxSuggestions).subscribe(testSubscriber);

    final List<List<String>> nextEvents = testSubscriber.getOnNextEvents();

    if (Util.isOnline()) {
        testSubscriber.assertValueCount(1);
        testSubscriber.assertCompleted();
        testSubscriber.assertNoErrors();
        assertTrue(!nextEvents.isEmpty() && nextEvents.size() == 1);
        assertTrue(nextEvents.get(0).size() == maxSuggestions);
    } else {
        testSubscriber.assertNoValues();
        assertTrue(testSubscriber.getOnErrorEvents().get(0) instanceof UnknownHostException);
    }
}
 
開發者ID:arunkumar9t2,項目名稱:rxSuggestions,代碼行數:20,代碼來源:RxSuggestionsTest.java

示例2: testUploadFailedUnhandledException

import rx.observers.TestSubscriber; //導入方法依賴的package包/類
@Test
public void testUploadFailedUnhandledException() throws Exception {
    final File file = getFile(TEST_FILE);
    final String jobId = "job-id";
    final Job job = Job.builder()
            .setId(jobId)
            .setStatus(Status.createQueued(jobId))
            .setMetadata(Collections.emptyMap())
            .setFilepath(file.getPath())
            .setMimeType("text/plain")
            .build();

    final UploadService service = mock(UploadService.class);
    when(service.upload(anyMap(), any(MultipartBody.Part.class)))
            .thenThrow(new RuntimeException(""));

    final Uploader uploader = new Uploader(service, Schedulers.io());
    final TestSubscriber<Status> ts = TestSubscriber.create();
    uploader.upload(job, file).subscribe(ts);

    ts.awaitTerminalEvent(1, TimeUnit.SECONDS);
    ts.assertError(RuntimeException.class);
    ts.assertNoValues();
}
 
開發者ID:jsaund,項目名稱:RxUploader,代碼行數:25,代碼來源:UploaderTest.java

示例3: testUploadFileNotFoundException

import rx.observers.TestSubscriber; //導入方法依賴的package包/類
@Test
public void testUploadFileNotFoundException() throws Exception {
    final File file = new File("invalid");
    final String jobId = "job-id";
     final Job job = Job.builder()
            .setId(jobId)
            .setStatus(Status.createQueued(jobId))
            .setMetadata(Collections.emptyMap())
            .setFilepath("invalid")
            .setMimeType("text/plain")
            .build();

    final UploadService service = mock(UploadService.class);

    final Uploader uploader = new Uploader(service, Schedulers.io());
    final TestSubscriber<Status> ts = TestSubscriber.create();
    uploader.upload(job, file).subscribe(ts);

    ts.awaitTerminalEvent(1, TimeUnit.SECONDS);
    ts.assertError(FileNotFoundException.class);
    ts.assertNoValues();
}
 
開發者ID:jsaund,項目名稱:RxUploader,代碼行數:23,代碼來源:UploaderTest.java

示例4: testUploadFileNotFound

import rx.observers.TestSubscriber; //導入方法依賴的package包/類
@Test
public void testUploadFileNotFound() throws Exception {
    final String jobId = "job-id";
    final Job job = Job.builder()
            .setId(jobId)
            .setFilepath("invalid")
            .setMetadata(Collections.emptyMap())
            .setMimeType("text/plain")
            .setStatus(Status.createQueued(jobId))
            .build();

    when(dataStore.get(jobId)).thenReturn(Observable.just(job));

    final TestSubscriber<Status> ts = TestSubscriber.create();
    uploadInteractor.upload(jobId).subscribe(ts);

    testScheduler.triggerActions();

    ts.awaitTerminalEvent(1, TimeUnit.SECONDS);
    ts.assertError(FileNotFoundException.class);
    ts.assertNoValues();

    verify(uploader, times(0)).upload(any(Job.class), any(File.class));
}
 
開發者ID:jsaund,項目名稱:RxUploader,代碼行數:25,代碼來源:UploadInteractorImplTest.java

示例5: fetchSuggestionsForEmptyString

import rx.observers.TestSubscriber; //導入方法依賴的package包/類
@Test
public void fetchSuggestionsForEmptyString() throws Exception {
    String searchTerm = "    ";
    final TestSubscriber<List<String>> testSubscriber = TestSubscriber.create();
    RxSuggestions.fetch(searchTerm).subscribe(testSubscriber);

    testSubscriber.assertNoErrors();
    testSubscriber.assertNoValues();
}
 
開發者ID:arunkumar9t2,項目名稱:rxSuggestions,代碼行數:10,代碼來源:RxSuggestionsTest.java

示例6: testGetAllEmpty

import rx.observers.TestSubscriber; //導入方法依賴的package包/類
@Test
public void testGetAllEmpty() throws Exception {
    final TestSubscriber<Job> ts = TestSubscriber.create();
    dataStore.getAll().subscribe(ts);

    ts.awaitTerminalEvent(1, TimeUnit.SECONDS);
    ts.assertNoErrors();
    ts.assertNoValues();
    ts.assertCompleted();
}
 
開發者ID:jsaund,項目名稱:RxUploader,代碼行數:11,代碼來源:SimpleUploadDataStoreTest.java

示例7: delete

import rx.observers.TestSubscriber; //導入方法依賴的package包/類
@SuppressLint("ApplySharedPref")
@Test
public void delete() throws Exception {
    final Job test = createTestJob();
    final String json = gson.toJson(test);
    final String key = SimpleUploadDataStore.jobIdKey(test.id());
    final Set<String> keys = new HashSet<>();
    keys.add(key);

    final SharedPreferences.Editor editor = sharedPreferences.edit();
    editor.putStringSet(SimpleUploadDataStore.KEY_JOB_IDS, keys);
    editor.putString(key, json);
    editor.commit();

    final TestSubscriber<Job> ts = TestSubscriber.create();
    dataStore.delete(test.id()).subscribe(ts);

    ts.awaitTerminalEvent(1, TimeUnit.SECONDS);
    ts.assertNoErrors();
    ts.assertValueCount(1);
    ts.assertValue(test);

    final TestSubscriber<Job> ts2 = TestSubscriber.create();
    dataStore.getAll().subscribe(ts2);

    ts2.awaitTerminalEvent(1, TimeUnit.SECONDS);
    ts2.assertNoErrors();
    ts2.assertCompleted();
    ts2.assertNoValues();
}
 
開發者ID:jsaund,項目名稱:RxUploader,代碼行數:31,代碼來源:SimpleUploadDataStoreTest.java

示例8: assertNoValuesAndOneError

import rx.observers.TestSubscriber; //導入方法依賴的package包/類
private void assertNoValuesAndOneError(TestSubscriber<List<String>> testSubscriber) {
    testSubscriber.assertNoValues();
    assertTrue(!testSubscriber.getOnErrorEvents().isEmpty());
}
 
開發者ID:arunkumar9t2,項目名稱:rxSuggestions,代碼行數:5,代碼來源:RxSuggestionsTest.java


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