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


Java TestObserver.assertError方法代碼示例

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


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

示例1: testUpdateEmail_notSuccessful

import io.reactivex.observers.TestObserver; //導入方法依賴的package包/類
@Test public void testUpdateEmail_notSuccessful() {
  mockNotSuccessfulVoidResult(new IllegalStateException());
  when(mockFirebaseUser.updateEmail("[email protected]")).thenReturn(mockVoidTaskResult);

  TestObserver obs = TestObserver.create();

  RxFirebaseUser.updateEmail(mockFirebaseUser, "[email protected]").subscribe(obs);

  callOnComplete(mockVoidTaskResult);
  obs.dispose();

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

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

示例2: test_error

import io.reactivex.observers.TestObserver; //導入方法依賴的package包/類
@Test
public void test_error() {
	Observable<String> observable = Observable.error(new Exception("We got an Exception"));
	TestObserver<String> testObserver = new TestObserver<>();

	observable.subscribe(testObserver);

	testObserver.assertError(Exception.class);
	testObserver.assertNotComplete();
	testObserver.assertErrorMessage("We got an Exception");
	testObserver.assertFailure(exception -> {
		return exception instanceof Exception;
	});

	testObserver.assertFailureAndMessage(Exception.class, "We got an Exception");
}
 
開發者ID:PacktPublishing,項目名稱:Reactive-Programming-With-Java-9,代碼行數:17,代碼來源:Modern_Testing.java

示例3: testDelete_notSuccessful

import io.reactivex.observers.TestObserver; //導入方法依賴的package包/類
@Test public void testDelete_notSuccessful() {
  mockNotSuccessfulVoidResult(new IllegalStateException());
  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.assertError(IllegalStateException.class);
  obs.assertNotComplete();
}
 
開發者ID:b3er,項目名稱:RxFirebase2,代碼行數:18,代碼來源:RxFirebaseUserTest.java

示例4: testUnlink_notSuccessful

import io.reactivex.observers.TestObserver; //導入方法依賴的package包/類
@Test public void testUnlink_notSuccessful() {
  mockNotSuccessfulAuthResult(new IllegalStateException());
  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.assertError(IllegalStateException.class);
  obs.assertNoValues();
}
 
開發者ID:b3er,項目名稱:RxFirebase2,代碼行數:18,代碼來源:RxFirebaseUserTest.java

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

示例6: testGetToken_notSuccessful

import io.reactivex.observers.TestObserver; //導入方法依賴的package包/類
@Test public void testGetToken_notSuccessful() {
  mockNotSuccessfulTokenResult(new IllegalStateException());
  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.assertError(IllegalStateException.class);
  obs.assertNoValues();
}
 
開發者ID:b3er,項目名稱:RxFirebase2,代碼行數:18,代碼來源:RxFirebaseUserTest.java

示例7: testCheckWidgetCalledFromNonMainThread

import io.reactivex.observers.TestObserver; //導入方法依賴的package包/類
@Test
public void testCheckWidgetCalledFromNonMainThread() throws InterruptedException, TimeoutException {
	TestObserver<?> testObserver = getEmptySubscribedTestObserver();

	AtomicBoolean atomic = new AtomicBoolean(false);

	Thread thread = new Thread(() -> {
		boolean checkWidget = Preconditions.checkWidget(testObserver, shell);

		assertThat(checkWidget, is(false));

		testObserver.assertError(IllegalStateException.class);
		testObserver.assertErrorMessage(
				"Expected to be called on the main thread but was " + Thread.currentThread().getName());
		atomic.set(true);
	});
	thread.start();

	await().untilTrue(atomic);
}
 
開發者ID:SimonScholz,項目名稱:RxSWT,代碼行數:21,代碼來源:PreconditionsTest.java

示例8: testGetMetaData_notSuccessful

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

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

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

  callOnComplete(mockStorageMetadataTask);
  obs.dispose();

  callOnComplete(mockStorageMetadataTask);

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

示例9: oneToOne

import io.reactivex.observers.TestObserver; //導入方法依賴的package包/類
@Test
public void oneToOne() {
    RxGreeterGrpc.RxGreeterStub stub = RxGreeterGrpc.newRxStub(channel);
    Single<HelloResponse> resp = stub.sayHello(Single.just(HelloRequest.getDefaultInstance()));
    TestObserver<HelloResponse> test = resp.test();

    test.awaitTerminalEvent(3, TimeUnit.SECONDS);
    test.assertError(t -> t instanceof StatusRuntimeException);
    test.assertError(t -> ((StatusRuntimeException)t).getStatus() == Status.INTERNAL);
}
 
開發者ID:salesforce,項目名稱:reactive-grpc,代碼行數:11,代碼來源:ServerErrorIntegrationTest.java

示例10: manyToOne

import io.reactivex.observers.TestObserver; //導入方法依賴的package包/類
@Test
public void manyToOne() {
    RxGreeterGrpc.RxGreeterStub stub = RxGreeterGrpc.newRxStub(channel);
    Single<HelloResponse> resp = stub.sayHelloReqStream(Flowable.just(HelloRequest.getDefaultInstance()));
    TestObserver<HelloResponse> test = resp.test();

    test.awaitTerminalEvent(3, TimeUnit.SECONDS);
    test.assertError(t -> t instanceof StatusRuntimeException);
    test.assertError(t -> ((StatusRuntimeException)t).getStatus() == Status.INTERNAL);
}
 
開發者ID:salesforce,項目名稱:reactive-grpc,代碼行數:11,代碼來源:ServerErrorIntegrationTest.java

示例11: serverCanCancelClientStreamExplicitly

import io.reactivex.observers.TestObserver; //導入方法依賴的package包/類
@Test
public void serverCanCancelClientStreamExplicitly() {
    RxNumbersGrpc.RxNumbersStub stub = RxNumbersGrpc.newRxStub(channel);

    svc.setExplicitCancel(true);

    AtomicBoolean requestWasCanceled = new AtomicBoolean(false);
    AtomicBoolean requestDidProduce = new AtomicBoolean(false);

    Flowable<NumberProto.Number> request = Flowable
            .fromIterable(IntStream.range(0, NUMBER_OF_STREAM_ELEMENTS)::iterator)
            .delay(10, TimeUnit.MILLISECONDS)
            .map(CancellationPropagationIntegrationTest::protoNum)
            .doOnNext(n -> {
                requestDidProduce.set(true);
                System.out.println("P: " + n.getNumber(0));
            })
            .doOnCancel(() -> {
                requestWasCanceled.set(true);
                System.out.println("Client canceled");
            });

    TestObserver<NumberProto.Number> observer = stub
            .requestPressure(request)
            .doOnSuccess(number -> System.out.println(number.getNumber(0)))
            .doOnError(throwable -> System.out.println(throwable.getMessage()))
            .test();

    observer.awaitTerminalEvent();
    observer.assertError(StatusRuntimeException.class);
    observer.assertTerminated();
    assertThat(requestWasCanceled.get()).isTrue();
    assertThat(requestDidProduce.get()).isTrue();
}
 
開發者ID:salesforce,項目名稱:reactive-grpc,代碼行數:35,代碼來源:CancellationPropagationIntegrationTest.java

示例12: testGetBytes_notSuccessful

import io.reactivex.observers.TestObserver; //導入方法依賴的package包/類
@Test public void testGetBytes_notSuccessful() {
  mockNotSuccessfulResultForTask(mockBytesTask, new IllegalStateException());
  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.assertError(IllegalStateException.class);
  obs.assertNoValues();
}
 
開發者ID:b3er,項目名稱:RxFirebase2,代碼行數:19,代碼來源:RxFirebaseStorageTest.java

示例13: testCheckActionCode_NotSuccessful

import io.reactivex.observers.TestObserver; //導入方法依賴的package包/類
@Test public void testCheckActionCode_NotSuccessful() {
  mockNotSuccessfulResultForTask(mockActionCodeResultTask, new IllegalStateException());

  when(mockFirebaseAuth.checkActionCode("code")).thenReturn(mockActionCodeResultTask);

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

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

  callOnComplete(mockActionCodeResultTask);
  obs.dispose();

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

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

示例14: testDataChanges_onCancelled

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

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

  verifyAddValueEventListener();
  callValueEventOnCancelled(new DatabaseException("foo"));

  sub.assertError(DatabaseException.class);
  sub.assertNoValues();

  sub.dispose();

  callValueEventOnCancelled(new DatabaseException("foo"));

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

示例15: testUpdateChildren_notSuccessful

import io.reactivex.observers.TestObserver; //導入方法依賴的package包/類
@Test public void testUpdateChildren_notSuccessful() {
  Map<String, Object> map = new HashMap<>();

  when(mockDatabaseReference.updateChildren(map)).thenReturn(mockTask);

  TestObserver sub = TestObserver.create();

  RxFirebaseDatabase.updateChildren(mockDatabaseReference, map).subscribe(sub);

  verifyAddOnCompleteListenerForTask();
  callTaskOnCompleteWithError(new IllegalStateException());

  sub.assertNotComplete();
  sub.assertError(IllegalStateException.class);

  sub.dispose();
}
 
開發者ID:b3er,項目名稱:RxFirebase2,代碼行數:18,代碼來源:RxFirebaseDatabaseTest.java


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