當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。