当前位置: 首页>>代码示例>>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;未经允许,请勿转载。