当前位置: 首页>>代码示例>>Java>>正文


Java TestObserver.assertComplete方法代码示例

本文整理汇总了Java中io.reactivex.observers.TestObserver.assertComplete方法的典型用法代码示例。如果您正苦于以下问题:Java TestObserver.assertComplete方法的具体用法?Java TestObserver.assertComplete怎么用?Java TestObserver.assertComplete使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在io.reactivex.observers.TestObserver的用法示例。


在下文中一共展示了TestObserver.assertComplete方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testGetToken

import io.reactivex.observers.TestObserver; //导入方法依赖的package包/类
@Test public void testGetToken() {
  mockSuccessfulTokenResult("token");
  when(mockFirebaseUser.getToken(true)).thenReturn(mockGetTokenTaskResult);

  TestObserver<String> obs = TestObserver.create();

  RxFirebaseUser.getToken(mockFirebaseUser, true).subscribe(obs);

  callOnComplete(mockGetTokenTaskResult);
  obs.dispose();

  // Ensure no more values are emitted after unsubscribe
  callOnComplete(mockGetTokenTaskResult);

  obs.assertNoErrors();
  obs.assertComplete();
  obs.assertValue("token");
}
 
开发者ID:b3er,项目名称:RxFirebase2,代码行数:19,代码来源:RxFirebaseUserTest.java

示例2: testBindUntilEvent

import io.reactivex.observers.TestObserver; //导入方法依赖的package包/类
private void testBindUntilEvent(ActivityController<? extends LifecycleProvider<ActivityEvent>> controller) {
    LifecycleProvider<ActivityEvent> activity = controller.get();

    TestObserver<Object> testObserver = observable.compose(activity.bindUntilEvent(STOP)).test();

    controller.create();
    testObserver.assertNotComplete();
    controller.start();
    testObserver.assertNotComplete();
    controller.resume();
    testObserver.assertNotComplete();
    controller.pause();
    testObserver.assertNotComplete();
    controller.stop();
    testObserver.assertComplete();
}
 
开发者ID:xufreshman,项目名称:RxLifeCycle,代码行数:17,代码来源:RxActivityLifecycleTest.java

示例3: addDefaultCityAndGetItById

import io.reactivex.observers.TestObserver; //导入方法依赖的package包/类
@Test public void addDefaultCityAndGetItById() {
  dbHelper.addDefaultCity().subscribe();
  // check if the city is added
  assertEquals(1, dbHelper.getCitiesCount().intValue());

  CityDetailsModel defaultCity = dbHelper.getSelectedCityModel();

  // verify city by id
  TestObserver<CityDetailsModel> testSubscriber = new TestObserver<>();

  dbHelper.getCityById(defaultCity.getId()).subscribe(testSubscriber);

  testSubscriber.assertNoErrors();
  testSubscriber.assertComplete();
  testSubscriber.assertValue(defaultCity);
}
 
开发者ID:nikacotAndroid,项目名称:Weather-Guru-MVP,代码行数:17,代码来源:DbHelperTest.java

示例4: testGetMetadata

import io.reactivex.observers.TestObserver; //导入方法依赖的package包/类
@Test public void testGetMetadata() {
  mockSuccessfulResultForTask(mockStorageMetadataTask, mockStorageMetadata);
  when(mockStorageReference.getMetadata()).thenReturn(mockStorageMetadataTask);
  when(mockStorageMetadata.getName()).thenReturn("Test");

  TestObserver<StorageMetadata> obs = TestObserver.create();

  RxFirebaseStorage.getMetadata(mockStorageReference).subscribe(obs);

  verifyAddOnCompleteListenerForTask(mockStorageMetadataTask);

  callOnComplete(mockStorageMetadataTask);
  obs.dispose();

  callOnComplete(mockStorageMetadataTask);

  obs.assertNoErrors();
  obs.assertComplete();
  obs.assertValue(new Predicate<StorageMetadata>() {
    @Override public boolean test(StorageMetadata storageMetadata) throws Exception {
      return "Test".equals(storageMetadata.getName());
    }
  });
}
 
开发者ID:b3er,项目名称:RxFirebase2,代码行数:25,代码来源:RxFirebaseStorageTest.java

示例5: testUnlink

import io.reactivex.observers.TestObserver; //导入方法依赖的package包/类
@Test public void testUnlink() {
  mockSuccessfulAuthResult();
  when(mockFirebaseUser.unlink("provider")).thenReturn(mockAuthTaskResult);

  TestObserver<AuthResult> obs = TestObserver.create();

  RxFirebaseUser.unlink(mockFirebaseUser, "provider").subscribe(obs);

  callOnComplete(mockAuthTaskResult);
  obs.dispose();

  // Ensure no more values are emitted after unsubscribe
  callOnComplete(mockAuthTaskResult);

  obs.assertNoErrors();
  obs.assertComplete();
  obs.assertValueCount(1);
}
 
开发者ID:b3er,项目名称:RxFirebase2,代码行数:19,代码来源:RxFirebaseUserTest.java

示例6: testReload

import io.reactivex.observers.TestObserver; //导入方法依赖的package包/类
@Test public void testReload() {
  mockVoidResult(true);
  when(mockFirebaseUser.reload()).thenReturn(mockVoidTaskResult);

  TestObserver obs = TestObserver.create();

  RxFirebaseUser.reload(mockFirebaseUser).subscribe(obs);

  callOnComplete(mockVoidTaskResult);
  obs.dispose();

  // Ensure no more values are emitted after unsubscribe
  callOnComplete(mockVoidTaskResult);

  obs.assertNoErrors();
  obs.assertComplete();
}
 
开发者ID:b3er,项目名称:RxFirebase2,代码行数:18,代码来源:RxFirebaseUserTest.java

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

示例8: testPutStream

import io.reactivex.observers.TestObserver; //导入方法依赖的package包/类
@Test public void testPutStream() {
  mockSuccessfulResultForTask(mockUploadTask, mockUploadTaskSnapshot);
  when(mockStorageReference.putStream(mockInputStream)).thenReturn(mockUploadTask);
  when(mockUploadTaskSnapshot.getBytesTransferred()).thenReturn(1000L);
  when(mockUploadTaskSnapshot.getTotalByteCount()).thenReturn(1000L);

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

  RxFirebaseStorage.putStream(mockStorageReference, mockInputStream).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

示例9: createAccount

import io.reactivex.observers.TestObserver; //导入方法依赖的package包/类
private Wallet createAccount() {
	TestObserver<Wallet> subscriber = new TestObserver<>();
	accountRepository
			.createWallet("1234")
			.toObservable()
			.subscribe(subscriber);
	subscriber.awaitTerminalEvent();
	subscriber.assertComplete();
	Assert.assertEquals(subscriber.valueCount(), 1);
	return subscriber.values().get(0);
}
 
开发者ID:TrustWallet,项目名称:trust-wallet-android,代码行数:12,代码来源:WalletRepoTest.java

示例10: loadWeather

import io.reactivex.observers.TestObserver; //导入方法依赖的package包/类
@Test public void loadWeather() {
  WeatherResponseModel responseModel = TestModels.getWeatherResponseModel(5);

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

  appApiHelper.weatherApiRequest("test", "test").subscribe(testSubscriber);

  testSubscriber.assertNoErrors();
  testSubscriber.assertComplete();
  testSubscriber.assertValueCount(1);
  testSubscriber.assertValue(responseModel);
}
 
开发者ID:nikacotAndroid,项目名称:Weather-Guru-MVP,代码行数:15,代码来源:ApiHelperTest.java

示例11: testSetValueWithPriority

import io.reactivex.observers.TestObserver; //导入方法依赖的package包/类
@Test public void testSetValueWithPriority() {
  when(mockDatabaseReference.setValue(1, 1)).thenReturn(mockTask);

  TestObserver sub = TestObserver.create();

  RxFirebaseDatabase.setValue(mockDatabaseReference, 1, 1).subscribe(sub);

  verifyAddOnCompleteListenerForTask();
  callTaskOnComplete();

  sub.assertComplete();
  sub.assertNoErrors();
  sub.dispose();
}
 
开发者ID:b3er,项目名称:RxFirebase2,代码行数:15,代码来源:RxFirebaseDatabaseTest.java

示例12: noEvent

import io.reactivex.observers.TestObserver; //导入方法依赖的package包/类
@Test
public void noEvent() {
    TestObserver<String> testObserver = maybe
        .compose(RxLifecycle.<String, String>bind(lifecycle))
        .test();

    stream.onNext("1");
    testObserver.assertValue("1");
    testObserver.assertComplete();
}
 
开发者ID:xufreshman,项目名称:RxLifeCycle,代码行数:11,代码来源:UntilLifecycleTransformerMaybeTest.java

示例13: testBindLifecycle

import io.reactivex.observers.TestObserver; //导入方法依赖的package包/类
@Test
public void testBindLifecycle() {
    BehaviorSubject<Lifecycle.Event> lifecycle = BehaviorSubject.create();

    lifecycle.onNext(Lifecycle.Event.ON_CREATE);
    TestObserver<Object> createObserver = observable.compose(RxLifecycleAndroidLifecycle.bindLifecycle(lifecycle)).test();

    lifecycle.onNext(Lifecycle.Event.ON_START);
    createObserver.assertNotComplete();
    TestObserver<Object> startObserver = observable.compose(RxLifecycleAndroidLifecycle.bindLifecycle(lifecycle)).test();

    lifecycle.onNext(Lifecycle.Event.ON_RESUME);
    createObserver.assertNotComplete();
    startObserver.assertNotComplete();
    TestObserver<Object> resumeObserver = observable.compose(RxLifecycleAndroidLifecycle.bindLifecycle(lifecycle)).test();

    lifecycle.onNext(Lifecycle.Event.ON_PAUSE);
    createObserver.assertNotComplete();
    startObserver.assertNotComplete();
    resumeObserver.assertComplete();

    TestObserver<Object> pauseObserver = observable.compose(RxLifecycleAndroidLifecycle.bindLifecycle(lifecycle)).test();
    lifecycle.onNext(Lifecycle.Event.ON_STOP);
    createObserver.assertNotComplete();
    startObserver.assertComplete();
    pauseObserver.assertComplete();
    TestObserver<Object> stopObserver = observable.compose(RxLifecycleAndroidLifecycle.bindLifecycle(lifecycle)).test();

    lifecycle.onNext(Lifecycle.Event.ON_DESTROY);
    createObserver.assertComplete();
    stopObserver.assertComplete();
}
 
开发者ID:xufreshman,项目名称:RxLifeCycle,代码行数:33,代码来源:RxLifecycleTest.java

示例14: testParseUriNullFd

import io.reactivex.observers.TestObserver; //导入方法依赖的package包/类
@Test
public void testParseUriNullFd() throws FileNotFoundException {
  ContentResolver resolver = mock(ContentResolver.class);
  when(resolver.openFileDescriptor(any(Uri.class), anyString())).thenReturn(null);
  when(appContext.getContentResolver()).thenReturn(resolver);

  TestObserver<BufferedSource> observer = new TestObserver<>();
  presenter.parseUri(Uri.EMPTY)
      .subscribe(observer);
  observer.awaitTerminalEvent();
  observer.assertComplete();
  observer.assertValueCount(0);
  observer.assertNoErrors();
}
 
开发者ID:Elias33,项目名称:Quran,代码行数:15,代码来源:QuranImportPresenterTest.java

示例15: testEndsImmediatelyOutsideActivityLifecycle

import io.reactivex.observers.TestObserver; //导入方法依赖的package包/类
@Test
public void testEndsImmediatelyOutsideActivityLifecycle() {
    BehaviorSubject<ActivityEvent> lifecycle = BehaviorSubject.create();
    lifecycle.onNext(ActivityEvent.DESTROY);

    TestObserver<Object> testObserver = observable.compose(RxLifecycleAndroid.bindActivity(lifecycle)).test();
    testObserver.assertComplete();
}
 
开发者ID:xufreshman,项目名称:RxLifeCycle,代码行数:9,代码来源:RxLifecycleTest.java


注:本文中的io.reactivex.observers.TestObserver.assertComplete方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。