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


Java TestObserver.assertValue方法代碼示例

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


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

示例1: test

import io.reactivex.observers.TestObserver; //導入方法依賴的package包/類
@Test public void test() {

        MaybeSubject<String> subject = MaybeSubject.create();
        Maybe<String> maybeSource = subject.hide();


        TestObserver testObserver = new TestObserver();
        CompositeDisposable composite = new CompositeDisposable();
        Disposable disposable = maybeSource
                .compose(DisposableAttach.<String>to(composite))
                .subscribeWith(testObserver);

        subject.onSuccess("Foo");
        testObserver.assertValue("Foo");
        assertTrue(composite.size() == 1);
        composite.dispose();
        assertTrue(composite.size() == 0);
        assertTrue(composite.isDisposed());
        assertTrue(disposable.isDisposed());
        assertTrue(testObserver.isDisposed());
    }
 
開發者ID:cp949,項目名稱:DisposableAttach,代碼行數:22,代碼來源:DisposableAttachMaybeTest.java

示例2: testUpdateMetadata

import io.reactivex.observers.TestObserver; //導入方法依賴的package包/類
@Test public void testUpdateMetadata() {
  when(mockStorageMetadata.getName()).thenReturn("metadata");
  mockSuccessfulResultForTask(mockStorageMetadataTask, mockStorageMetadata);

  TestObserver<StorageMetadata> obs = TestObserver.create();
  when(mockStorageReference.updateMetadata(mockStorageMetadata)).thenReturn(
      mockStorageMetadataTask);

  RxFirebaseStorage.updateMetadata(mockStorageReference, mockStorageMetadata).subscribe(obs);

  verifyAddOnCompleteListenerForTask(mockStorageMetadataTask);

  callOnComplete(mockStorageMetadataTask);
  obs.dispose();

  callOnComplete(mockStorageMetadataTask);

  obs.assertNoErrors();
  obs.assertComplete();
  obs.assertValue(new Predicate<StorageMetadata>() {
    @Override public boolean test(StorageMetadata metadata) throws Exception {
      return "metadata".equals(metadata.getName());
    }
  });
}
 
開發者ID:b3er,項目名稱:RxFirebase2,代碼行數:26,代碼來源:RxFirebaseStorageTest.java

示例3: testPutFileWithMetadata

import io.reactivex.observers.TestObserver; //導入方法依賴的package包/類
@Test public void testPutFileWithMetadata() {
  mockSuccessfulResultForTask(mockUploadTask, mockUploadTaskSnapshot);
  when(mockStorageReference.putFile(mockUri, mockStorageMetadata)).thenReturn(mockUploadTask);
  when(mockUploadTaskSnapshot.getBytesTransferred()).thenReturn(1000L);
  when(mockUploadTaskSnapshot.getTotalByteCount()).thenReturn(1000L);

  TestObserver<UploadTask.TaskSnapshot> obs = TestObserver.create();

  RxFirebaseStorage.putFile(mockStorageReference, mockUri, mockStorageMetadata).subscribe(obs);

  verifyAddOnCompleteListenerForTask(mockUploadTask);

  callOnComplete(mockUploadTask);
  obs.dispose();

  callOnComplete(mockUploadTask);

  obs.assertNoErrors();
  obs.assertComplete();
  obs.assertValue(new Predicate<UploadTask.TaskSnapshot>() {
    @Override public boolean test(UploadTask.TaskSnapshot taskSnapshot) throws Exception {
      return taskSnapshot.getBytesTransferred() == taskSnapshot.getTotalByteCount()
          && taskSnapshot.getTotalByteCount() == 1000L;
    }
  });
}
 
開發者ID:b3er,項目名稱:RxFirebase2,代碼行數:27,代碼來源:RxFirebaseStorageTest.java

示例4: testGetFileUri

import io.reactivex.observers.TestObserver; //導入方法依賴的package包/類
@SuppressWarnings("Duplicates") @Test public void testGetFileUri() {
  mockSuccessfulResultForTask(mockFileDownloadTask, mockFileDownloadTaskSnapshot);
  when(mockStorageReference.getFile(mockUri)).thenReturn(mockFileDownloadTask);
  when(mockFileDownloadTaskSnapshot.getBytesTransferred()).thenReturn(1000L);
  when(mockFileDownloadTaskSnapshot.getTotalByteCount()).thenReturn(1000L);

  TestObserver<FileDownloadTask.TaskSnapshot> obs = TestObserver.create();

  RxFirebaseStorage.getFile(mockStorageReference, mockUri).subscribe(obs);

  verifyAddOnCompleteListenerForTask(mockFileDownloadTask);

  callOnComplete(mockFileDownloadTask);
  obs.dispose();

  callOnComplete(mockFileDownloadTask);

  obs.assertNoErrors();
  obs.assertComplete();
  obs.assertValue(new Predicate<FileDownloadTask.TaskSnapshot>() {
    @Override public boolean test(FileDownloadTask.TaskSnapshot taskSnapshot) throws Exception {
      return taskSnapshot.getBytesTransferred() == taskSnapshot.getTotalByteCount()
          && taskSnapshot.getTotalByteCount() == 1000;
    }
  });
}
 
開發者ID:b3er,項目名稱:RxFirebase2,代碼行數:27,代碼來源:RxFirebaseStorageTest.java

示例5: rxActivity_shouldCallback_onLowMemory

import io.reactivex.observers.TestObserver; //導入方法依賴的package包/類
@Test
public void rxActivity_shouldCallback_onLowMemory() {
  ActivityController<EmptyActivity> activityController = buildActivity(EmptyActivity.class);
  RibActivity activity = activityController.setup().get();
  TestObserver<ActivityCallbackEvent> testSub = new TestObserver<>();
  activity
      .callbacks()
      .filter(
          new Predicate<ActivityCallbackEvent>() {
            @Override
            public boolean test(ActivityCallbackEvent activityEvent) throws Exception {
              return activityEvent.getType() == ActivityCallbackEvent.Type.LOW_MEMORY;
            }
          })
      .subscribe(testSub);

  activity.onLowMemory();

  testSub.assertValue(ActivityCallbackEvent.create(ActivityCallbackEvent.Type.LOW_MEMORY));
}
 
開發者ID:uber,項目名稱:RIBs,代碼行數:21,代碼來源:RibActivityTest.java

示例6: test

import io.reactivex.observers.TestObserver; //導入方法依賴的package包/類
@Test public void test() {
    SingleSubject<String> subject = SingleSubject.create();
    Single<String> singleSource = subject.hide();


    TestObserver testObserver = new TestObserver();
    CompositeDisposable composite = new CompositeDisposable();
    Disposable disposable = singleSource
            .compose(DisposableAttach.<String>to(composite))
            .subscribeWith(testObserver);

    subject.onSuccess("Foo");
    testObserver.assertValue("Foo");
    assertTrue(composite.size() == 1);
    composite.dispose();
    assertTrue(composite.size() == 0);
    assertTrue(composite.isDisposed());
    assertTrue(disposable.isDisposed());
    assertTrue(testObserver.isDisposed());
}
 
開發者ID:cp949,項目名稱:DisposableAttach,代碼行數:21,代碼來源:DisposableAttachSingleTest.java

示例7: should_process_the_json_payload_from_provider

import io.reactivex.observers.TestObserver; //導入方法依賴的package包/類
@Test
@PactVerification("our_provider")
public void should_process_the_json_payload_from_provider() {
  TestObserver<ServiceResponse> observer = service.fetchResponse(DATE_TIME).test();
  observer.assertNoErrors();
  observer.assertValue(ServiceResponse.create(DATE_TIME, Arrays.asList(
      Animal.create("Doggy", "dog"),
      Animal.create("Doggy", "dog"),
      Animal.create("Doggy", "dog")
  )));
}
 
開發者ID:DiUS,項目名稱:pact-workshop-android,代碼行數:12,代碼來源:ServicePactTest.java

示例8: testPutBytesWithMetadata

import io.reactivex.observers.TestObserver; //導入方法依賴的package包/類
@Test public void testPutBytesWithMetadata() {
  mockSuccessfulResultForTask(mockUploadTask, mockUploadTaskSnapshot);
  when(mockStorageReference.putBytes(new byte[] { 1, 2, 3 }, mockStorageMetadata)).thenReturn(
      mockUploadTask);
  when(mockUploadTaskSnapshot.getBytesTransferred()).thenReturn(1000L);
  when(mockUploadTaskSnapshot.getTotalByteCount()).thenReturn(1000L);

  TestObserver<UploadTask.TaskSnapshot> obs = TestObserver.create();

  RxFirebaseStorage.putBytes(mockStorageReference, new byte[] { 1, 2, 3 }, mockStorageMetadata)
      .subscribe(obs);

  verifyAddOnCompleteListenerForTask(mockUploadTask);

  callOnComplete(mockUploadTask);
  obs.dispose();

  callOnComplete(mockUploadTask);

  obs.assertNoErrors();
  obs.assertComplete();
  obs.assertValue(new Predicate<UploadTask.TaskSnapshot>() {
    @Override public boolean test(UploadTask.TaskSnapshot taskSnapshot) throws Exception {
      return taskSnapshot.getBytesTransferred() == taskSnapshot.getTotalByteCount()
          && taskSnapshot.getTotalByteCount() == 1000L;
    }
  });
}
 
開發者ID:b3er,項目名稱:RxFirebase2,代碼行數:29,代碼來源:RxFirebaseStorageTest.java

示例9: loadCollectionIcons

import io.reactivex.observers.TestObserver; //導入方法依賴的package包/類
@Test
public void loadCollectionIcons() {
    IconsResponse responseModel = TestModels.getIconsResponseModel(5);

    when(apiInterface.getCollectionIcons(anyInt(), ArgumentMatchers.<String, String>anyMap()))
            .thenReturn(Observable.just(responseModel));
    TestObserver<IconsResponse> testSubscriber = new TestObserver<>();

    appApiHelper.getCollectionIcons(29508, options).subscribe(testSubscriber);

    testSubscriber.assertNoErrors();
    testSubscriber.assertComplete();
    testSubscriber.assertValueCount(1);
    testSubscriber.assertValue(responseModel);
}
 
開發者ID:graviton57,項目名稱:TheNounProject,代碼行數:16,代碼來源:ApiHelperTest.java

示例10: diffResults_WhenNoSubscribers_CachesResult

import io.reactivex.observers.TestObserver; //導入方法依賴的package包/類
@Test
public void diffResults_WhenNoSubscribers_CachesResult() {
    // Given
    mDiffRequestManager.receive(mRxDiffResult);

    // When
    final TestObserver<RxDiffResult> testObserver = new TestObserver<>();
    mDiffRequestManager.diffResults()
            .subscribe(testObserver);

    // Then
    testObserver.assertValue(mRxDiffResult);
}
 
開發者ID:storix,項目名稱:RxDiffUtil,代碼行數:14,代碼來源:DiffRequestManagerRoboTest.java

示例11: rx_CountryNameInCapitals

import io.reactivex.observers.TestObserver; //導入方法依賴的package包/類
@Test
public void rx_CountryNameInCapitals() {
    Country testCountry = CountriesTestProvider.countries().get(0);
    String expected = testCountry.name.toUpperCase(Locale.US);
    TestObserver<String> testObserver = countriesService
            .countryNameInCapitals(testCountry)
            .test();
    testObserver.assertNoErrors();
    testObserver.assertValue(expected);
}
 
開發者ID:sergiiz,項目名稱:RxBasicsKata,代碼行數:11,代碼來源:CountriesServiceSolvedTest.java

示例12: oneWrongEvent

import io.reactivex.observers.TestObserver; //導入方法依賴的package包/類
@Test
public void oneWrongEvent() {
    TestObserver<String> testObserver = Single.just("1")
        .delay(1, TimeUnit.MILLISECONDS, testScheduler)
        .compose(RxLifecycle.<String, String>bindUntilEvent(lifecycle, "stop"))
        .test();

    testObserver.assertNoValues();

    lifecycle.onNext("keep going");
    testScheduler.advanceTimeBy(1, TimeUnit.MILLISECONDS);

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

示例13: loadCities

import io.reactivex.observers.TestObserver; //導入方法依賴的package包/類
@Test public void loadCities() {
  SearchApiResponseModel responseModel = TestModels.getSearchResponseModel(5);

  when(apiInterface.getLocations(anyString(), anyString(), anyString())).thenReturn(
      Observable.just(responseModel));
  TestObserver<SearchApiResponseModel> testSubscriber = new TestObserver<>();

  appApiHelper.locationsApiRequest("test").subscribe(testSubscriber);

  testSubscriber.assertNoErrors();
  testSubscriber.assertComplete();
  testSubscriber.assertValueCount(1);
  testSubscriber.assertValue(responseModel);
}
 
開發者ID:nikacotAndroid,項目名稱:Weather-Guru-MVP,代碼行數:15,代碼來源:ApiHelperTest.java

示例14: oneWrongEvent

import io.reactivex.observers.TestObserver; //導入方法依賴的package包/類
@Test
public void oneWrongEvent() {
    TestObserver<String> testObserver = maybe
        .compose(RxLifecycle.<String, String>bindUntilEvent(lifecycle, "stop"))
        .test();

    lifecycle.onNext("keep going");
    subject.onNext("1");
    testObserver.assertValue("1");
    testObserver.assertComplete();
}
 
開發者ID:xufreshman,項目名稱:RxLifeCycle,代碼行數:12,代碼來源:UntilEventTransformerMaybeTest.java

示例15: oneStartEvent

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

    lifecycle.onNext("create");
    subject.onNext("1");
    testObserver.assertValue("1");
    testObserver.assertComplete();
}
 
開發者ID:xufreshman,項目名稱:RxLifeCycle,代碼行數:12,代碼來源:UntilCorrespondingEventTransformerMaybeTest.java


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