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


Java TestObserver.dispose方法代碼示例

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


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

示例1: testVerifyPasswordResetCode

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

    mockSuccessfulResultForTask(mockStringTask, "[email protected]");

    when(mockFirebaseAuth.verifyPasswordResetCode("code")).thenReturn(mockStringTask);

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

    RxFirebaseAuth.verifyPasswordResetCode(mockFirebaseAuth, "code").subscribe(obs);

    callOnComplete(mockStringTask);
    obs.dispose();

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

    obs.assertNoErrors();
    obs.assertComplete();
    obs.assertValueCount(1);
    obs.assertValue(new Predicate<String>() {
      @Override public boolean test(String result) throws Exception {
        return "[email protected]".equals(result);
      }
    });
  }
 
開發者ID:b3er,項目名稱:RxFirebase2,代碼行數:26,代碼來源:RxFirebaseAuthTest.java

示例2: testGetFile

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

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

  RxFirebaseStorage.getFile(mockStorageReference, mockFile).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

示例3: testGetStream_notSuccessful

import io.reactivex.observers.TestObserver; //導入方法依賴的package包/類
@Test public void testGetStream_notSuccessful() {
  mockNotSuccessfulResultForTask(mockStreamDownloadTask, new IllegalStateException());
  when(mockStorageReference.getStream()).thenReturn(mockStreamDownloadTask);

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

  RxFirebaseStorage.getStream(mockStorageReference).subscribe(obs);
  verifyAddOnCompleteListenerForTask(mockStreamDownloadTask);

  callOnComplete(mockStreamDownloadTask);
  obs.dispose();

  callOnComplete(mockStreamDownloadTask);

  obs.assertError(IllegalStateException.class);
  obs.assertNoValues();
}
 
開發者ID:b3er,項目名稱:RxFirebase2,代碼行數:18,代碼來源:RxFirebaseStorageTest.java

示例4: testDelete

import io.reactivex.observers.TestObserver; //導入方法依賴的package包/類
@Test public void testDelete() {
  mockVoidResult(true);
  when(mockFirebaseUser.delete()).thenReturn(mockVoidTaskResult);

  TestObserver obs = TestObserver.create();

  RxFirebaseUser.delete(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

示例5: testData

import io.reactivex.observers.TestObserver; //導入方法依賴的package包/類
@Test public void testData() {
  TestObserver<DataSnapshot> sub = TestObserver.create();

  RxFirebaseDatabase.data(mockDatabaseReference).subscribe(sub);

  verifyAddListenerForSingleValueEvent();
  callValueEventOnDataChange("Foo");
  sub.dispose();

  // Ensure no more values are emitted after unsubscribe
  callValueEventOnDataChange("Foo");

  sub.assertNoErrors();
  sub.assertComplete();
  sub.assertValueCount(1);
}
 
開發者ID:b3er,項目名稱:RxFirebase2,代碼行數:17,代碼來源:RxFirebaseDatabaseTest.java

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

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

import io.reactivex.observers.TestObserver; //導入方法依賴的package包/類
@Test public void testDataOfClazz() {
  TestObserver<Optional<String>> sub = TestObserver.create();

  RxFirebaseDatabase.dataOf(mockDatabaseReference, String.class).subscribe(sub);

  verifyAddListenerForSingleValueEvent();
  callValueEventOnDataChange("Foo");

  sub.assertComplete();
  sub.assertNoErrors();

  sub.assertValue(new Predicate<Optional<String>>() {
    @Override public boolean test(Optional<String> stringOptional) throws Exception {
      return stringOptional.isPresent() && "Foo".equals(stringOptional.get());
    }
  });

  sub.dispose();

  callValueEventOnDataChange("Foo");

  // Ensure no more values are emitted after unsubscribe
  sub.assertValueCount(1);
}
 
開發者ID:b3er,項目名稱:RxFirebase2,代碼行數:25,代碼來源:RxFirebaseDatabaseTest.java

示例9: testGetStreamWithProcessor_notSuccessful

import io.reactivex.observers.TestObserver; //導入方法依賴的package包/類
@Test public void testGetStreamWithProcessor_notSuccessful() {
  mockNotSuccessfulResultForTask(mockStreamDownloadTask, new IllegalStateException());
  when(mockStorageReference.getStream(mockStreamProcessor)).thenReturn(mockStreamDownloadTask);

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

  RxFirebaseStorage.getStream(mockStorageReference, mockStreamProcessor).subscribe(obs);
  verifyAddOnCompleteListenerForTask(mockStreamDownloadTask);

  callOnComplete(mockStreamDownloadTask);
  obs.dispose();

  callOnComplete(mockStreamDownloadTask);

  obs.assertError(IllegalStateException.class);
  obs.assertNoValues();
}
 
開發者ID:b3er,項目名稱:RxFirebase2,代碼行數:18,代碼來源:RxFirebaseStorageTest.java

示例10: testGetStreamWithProcessor

import io.reactivex.observers.TestObserver; //導入方法依賴的package包/類
@Test public void testGetStreamWithProcessor() {
  mockSuccessfulResultForTask(mockStreamDownloadTask, mockStreamDownloadTaskSnapshot);
  when(mockStorageReference.getStream(mockStreamProcessor)).thenReturn(mockStreamDownloadTask);
  when(mockStreamDownloadTaskSnapshot.getTotalByteCount()).thenReturn(1000L);
  when(mockStreamDownloadTaskSnapshot.getBytesTransferred()).thenReturn(1000L);

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

  RxFirebaseStorage.getStream(mockStorageReference, mockStreamProcessor).subscribe(obs);

  verifyAddOnCompleteListenerForTask(mockStreamDownloadTask);

  callOnComplete(mockStreamDownloadTask);
  obs.dispose();

  callOnComplete(mockStreamDownloadTask);

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

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

示例12: testGetBytes

import io.reactivex.observers.TestObserver; //導入方法依賴的package包/類
@Test public void testGetBytes() {
  mockSuccessfulResultForTask(mockBytesTask, new byte[] { 1, 2, 3 });
  Mockito.when(mockStorageReference.getBytes(3)).thenReturn(mockBytesTask);

  TestObserver<byte[]> obs = TestObserver.create();

  RxFirebaseStorage.getBytes(mockStorageReference, 3).subscribe(obs);
  verifyAddOnCompleteListenerForTask(mockBytesTask);

  callOnComplete(mockBytesTask);
  obs.dispose();

  callOnComplete(mockBytesTask);

  obs.assertNoErrors();
  obs.assertComplete();
  obs.assertValue(new Predicate<byte[]>() {
    @Override public boolean test(byte[] bytes) throws Exception {
      return Arrays.equals(bytes, new byte[] { 1, 2, 3 });
    }
  });
}
 
開發者ID:b3er,項目名稱:RxFirebase2,代碼行數:23,代碼來源:RxFirebaseStorageTest.java

示例13: testPutBytes_notSuccessful

import io.reactivex.observers.TestObserver; //導入方法依賴的package包/類
@Test public void testPutBytes_notSuccessful() {
  mockNotSuccessfulResultForTask(mockUploadTask, new IllegalStateException());
  when(mockStorageReference.putBytes(new byte[] { 1, 2, 3 })).thenReturn(mockUploadTask);

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

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

  callOnComplete(mockUploadTask);
  obs.dispose();

  callOnComplete(mockUploadTask);

  obs.assertError(IllegalStateException.class);
  obs.assertNoValues();
}
 
開發者ID:b3er,項目名稱:RxFirebase2,代碼行數:18,代碼來源:RxFirebaseStorageTest.java

示例14: testUpdateProfile

import io.reactivex.observers.TestObserver; //導入方法依賴的package包/類
@Test public void testUpdateProfile() {
  mockVoidResult(true);
  when(mockFirebaseUser.updateProfile(mockProfileChangeRequest)).thenReturn(mockVoidTaskResult);

  TestObserver obs = TestObserver.create();

  RxFirebaseUser.updateProfile(mockFirebaseUser, mockProfileChangeRequest).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

示例15: testChildEvents_notSuccessful

import io.reactivex.observers.TestObserver; //導入方法依賴的package包/類
@Test public void testChildEvents_notSuccessful() {
  TestObserver<ChildEvent> sub = TestObserver.create();

  RxFirebaseDatabase.childEvents(mockDatabaseReference).subscribe(sub);

  verifyAddChildEventListener();
  callChildOnCancelled();

  sub.assertNoValues();
  assertThat(sub.errorCount()).isEqualTo(1);

  sub.dispose();

  callChildOnCancelled();

  // Ensure no more values are emitted after unsubscribe
  assertThat(sub.errorCount()).isEqualTo(1);
}
 
開發者ID:b3er,項目名稱:RxFirebase2,代碼行數:19,代碼來源:RxFirebaseDatabaseTest.java


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