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