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


Java TestSubscriber.assertError方法代碼示例

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


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

示例1: searchUsers_OtherHttpError_SearchTerminatedWithError

import rx.observers.TestSubscriber; //導入方法依賴的package包/類
@Test
public void searchUsers_OtherHttpError_SearchTerminatedWithError() {
    //Given
    when(githubUserRestService.searchGithubUsers(anyString())).thenReturn(get403ForbiddenError());

    //When
    TestSubscriber<List<User>> subscriber = new TestSubscriber<>();
    userRepository.searchUsers(USER_LOGIN_MOYHEEN).subscribe(subscriber);

    //Then
    subscriber.awaitTerminalEvent();
    subscriber.assertError(HttpException.class);

    verify(githubUserRestService).searchGithubUsers(USER_LOGIN_MOYHEEN);
    verify(githubUserRestService, never()).getUser(USER_LOGIN_MOYHEEN);
    verify(githubUserRestService, never()).getUser(USER_LOGIN_2_MOYHEEN);
}
 
開發者ID:moyheen,項目名稱:github-user-search,代碼行數:18,代碼來源:UserRepositoryImplTest.java

示例2: callOnErrorIfApiReturnsAnError

import rx.observers.TestSubscriber; //導入方法依賴的package包/類
@Test
public void callOnErrorIfApiReturnsAnError() {
  OffsetDateTime lastUpdated = OffsetDateTime.of(2016, 1, 1, 0, 0, 0, 0, ZoneOffset.UTC);
  when(libraryService.lastUpdated()).thenReturn(Observable.just(lastUpdated));

  Throwable apiError = new Throwable();
  when(disclosureApi.allLibraries(any(), anyInt(), anyInt())).thenReturn(
      Observable.error(apiError));

  TestSubscriber<List<Library>> testSubscriber = new TestSubscriber<>();
  syncLibraries.run()
      .toBlocking()
      .subscribe(testSubscriber);

  testSubscriber.assertError(apiError);
}
 
開發者ID:philipphager,項目名稱:disclosure-android-app,代碼行數:17,代碼來源:SyncLibrariesShould.java

示例3: rxCompletableFailWithoutFallback

import rx.observers.TestSubscriber; //導入方法依賴的package包/類
@Test
public void rxCompletableFailWithoutFallback() {
  server.enqueue(new MockResponse().setResponseCode(500));

  TestInterface api = HystrixFeign.builder()
      .target(TestInterface.class, "http://localhost:" + server.getPort());

  Completable completable = api.completable();

  assertThat(completable).isNotNull();
  assertThat(server.getRequestCount()).isEqualTo(0);

  TestSubscriber<String> testSubscriber = new TestSubscriber<String>();
  completable.subscribe(testSubscriber);
  testSubscriber.awaitTerminalEvent();

  testSubscriber.assertError(HystrixRuntimeException.class);
}
 
開發者ID:wenwu315,項目名稱:XXXX,代碼行數:19,代碼來源:HystrixBuilderTest.java

示例4: searchMakeUp_OtherHttpError_searchTerminatedWithError

import rx.observers.TestSubscriber; //導入方法依賴的package包/類
@Test
public void searchMakeUp_OtherHttpError_searchTerminatedWithError() {
    // Given
    when(makeUpProductRestService.searchMakeUpProducts(anyString(), anyString())).thenReturn
            (get403ForbiddenError().toList());

    // When
    TestSubscriber<List<MakeUp>> subscriber = new TestSubscriber<>();
    makeUpRepository.searchMakeUp(BRAND_COVERGIRL, PRODUCT_TYPE_LIPSTICK).subscribe(subscriber);

    // Then
    subscriber.awaitTerminalEvent();
    subscriber.assertError(HttpException.class);

    verify(makeUpProductRestService).searchMakeUpProducts(BRAND_COVERGIRL,
            PRODUCT_TYPE_LIPSTICK);
}
 
開發者ID:moyheen,項目名稱:MakeUpSearch,代碼行數:18,代碼來源:MakeUpRepositoryImplTest.java

示例5: groupApishouldReturnBadRequest

import rx.observers.TestSubscriber; //導入方法依賴的package包/類
@Test
public void groupApishouldReturnBadRequest() {
    // Given
    login = "wrongLogin";
    password = "wrongPassword";
    TestSubscriber<SigfoxData<Group>> testObserver = new TestSubscriber<>();

    // When
    sigfoxClient.getGroupList(null, null, null).subscribe(testObserver);

    // Then
    testObserver.assertError(HttpException.class);
    List<Throwable> errorEvents = testObserver.getOnErrorEvents();
    assertThat(errorEvents).isNotNull().isNotEmpty();
    assertThat(errorEvents.get(0)).hasMessage("HTTP 400 Bad Request");
}
 
開發者ID:Rtone,項目名稱:sigfox-rest-client,代碼行數:17,代碼來源:SigfoxClientIT.java

示例6: 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

示例7: 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

示例8: 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

示例9: failure

import rx.observers.TestSubscriber; //導入方法依賴的package包/類
@Test public void failure() throws InterruptedException {
  TestSubscriber<Void> subscriber = new TestSubscriber<>();
  service.completable().subscribe(subscriber);
  assertFalse(subscriber.awaitValueCount(1, 1, SECONDS));

  server.enqueue(new MockResponse().setSocketPolicy(DISCONNECT_AFTER_REQUEST));
  subscriber.awaitTerminalEvent(1, SECONDS);
  subscriber.assertError(IOException.class);
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:10,代碼來源:AsyncTest.java

示例10: thatMissingClosingIfThrowsException

import rx.observers.TestSubscriber; //導入方法依賴的package包/類
@Test public void thatMissingClosingIfThrowsException() {
    TestSubscriber<String> testSubscriber = new TestSubscriber<String>();

    MigrationManager.migrate(OLD_INDENTATION_MARKS, new FileUtils()
            .getFileLines("bonus1.txt"))
            .subscribe(testSubscriber);

    testSubscriber.assertError(SyntaxBlockVerifier.MissingBlockException.class);
}
 
開發者ID:VigoTech,項目名稱:reto,代碼行數:10,代碼來源:MigrationManagerTest.java

示例11: thatMissingSeveralClosingPartsThrowsException

import rx.observers.TestSubscriber; //導入方法依賴的package包/類
@Test public void thatMissingSeveralClosingPartsThrowsException() {
    TestSubscriber<String> testSubscriber = new TestSubscriber<String>();

    MigrationManager.migrate(OLD_INDENTATION_MARKS, new FileUtils()
            .getFileLines("bonus2.txt"))
            .subscribe(testSubscriber);

    testSubscriber.assertError(SyntaxBlockVerifier.MissingBlockException.class);
}
 
開發者ID:VigoTech,項目名稱:reto,代碼行數:10,代碼來源:MigrationManagerTest.java

示例12: thatMissingClosingForThrowsException

import rx.observers.TestSubscriber; //導入方法依賴的package包/類
@Test public void thatMissingClosingForThrowsException() {
    TestSubscriber<String> testSubscriber = new TestSubscriber<String>();

    MigrationManager.migrate(OLD_INDENTATION_MARKS, new FileUtils()
            .getFileLines("bonus3.txt"))
            .subscribe(testSubscriber);

    testSubscriber.assertError(SyntaxBlockVerifier.MissingBlockException.class);
}
 
開發者ID:VigoTech,項目名稱:reto,代碼行數:10,代碼來源:MigrationManagerTest.java

示例13: thatUselessMissingBlocksThrowsException

import rx.observers.TestSubscriber; //導入方法依賴的package包/類
@Test public void thatUselessMissingBlocksThrowsException() {
    TestSubscriber<String> testSubscriber = new TestSubscriber<String>();

    MigrationManager.migrate(OLD_INDENTATION_MARKS, new FileUtils()
            .getFileLines("bonus4.txt"))
            .subscribe(testSubscriber);

    testSubscriber.assertError(EmptyStackException.class);
}
 
開發者ID:VigoTech,項目名稱:reto,代碼行數:10,代碼來源:MigrationManagerTest.java

示例14: failZipMapIfStreamFails

import rx.observers.TestSubscriber; //導入方法依賴的package包/類
@Test public void failZipMapIfStreamFails() {
  String mockItemOne = "mockItemOne";

  Observable<String> streamOne = Observable.just(mockItemOne);
  Observable<String> streamTwo = Observable.error(new IllegalStateException());

  TestSubscriber<List<String>> testSubscriber = new TestSubscriber<>();

  RxUtils.zipMap(streamOne, streamTwo, (s1, s2) -> Observable.just(Arrays.asList(s1, s2)))
      .toBlocking()
      .subscribe(testSubscriber);

  testSubscriber.assertError(IllegalStateException.class);
}
 
開發者ID:philipphager,項目名稱:disclosure-android-app,代碼行數:15,代碼來源:RxUtilsShould.java

示例15: testUploadError

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

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

    final Status[] statuses = new Status[] {
            Status.createSending(jobId, 0), Status.createSending(jobId, 10),
            Status.createSending(jobId, 20), Status.createSending(jobId, 30),
    };

    when(uploader.upload(eq(job), any(File.class))).thenReturn(
            Observable.from(statuses).concatWith(Observable.error(new IOException("error"))));

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

    testScheduler.triggerActions();

    ts.awaitTerminalEvent(1, TimeUnit.SECONDS);

    ts.assertValues(statuses);
    ts.assertError(IOException.class);
}
 
開發者ID:jsaund,項目名稱:RxUploader,代碼行數:33,代碼來源:UploadInteractorImplTest.java


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