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


Java TestObserver.create方法代码示例

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


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

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

示例2: shouldCompleteBlocking

import io.reactivex.observers.TestObserver; //导入方法依赖的package包/类
@Test
public void shouldCompleteBlocking() {
    TestObserver<String> testObserver = TestObserver.create();

    wordService
            .enumerate(Observable.fromArray(STRINGS))
            .subscribeOn(Schedulers.computation())
            .blockingSubscribe(testObserver);

    testObserver
            .assertSubscribed()
            .assertComplete()
            .assertNoErrors()
            .assertValueCount(9)
            .assertValues(
                    " 1. the",
                    " 2. quick",
                    " 3. brown",
                    " 4. fox",
                    " 5. jumped",
                    " 6. over",
                    " 7. the",
                    " 8. lazy",
                    " 9. dog"
            );
}
 
开发者ID:OlegDokuka,项目名称:reactive-playing,代码行数:27,代码来源:WordServiceTest.java

示例3: testChildEvents_remove

import io.reactivex.observers.TestObserver; //导入方法依赖的package包/类
@Test public void testChildEvents_remove() {
  TestObserver<ChildEvent> sub = TestObserver.create();

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

  verifyAddChildEventListener();
  callOnChildRemoved();
  callOnChildRemoved();

  sub.assertNotComplete();
  sub.assertNoErrors();
  sub.assertValueCount(2);

  List events = sub.getEvents().get(0);
  for (Object event : events) {
    assertThat(event).isInstanceOf(ChildEvent.class);
    assertThat(event).isInstanceOf(ChildRemoveEvent.class);
  }

  sub.dispose();

  callOnChildRemoved();

  // Ensure no more values are emitted after unsubscrube
  sub.assertValueCount(2);
}
 
开发者ID:b3er,项目名称:RxFirebase2,代码行数:27,代码来源:RxFirebaseDatabaseTest.java

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

示例5: testPutStream_notSuccessful

import io.reactivex.observers.TestObserver; //导入方法依赖的package包/类
@Test public void testPutStream_notSuccessful() {
  mockNotSuccessfulResultForTask(mockUploadTask, new IllegalStateException());
  when(mockStorageReference.putStream(mockInputStream)).thenReturn(mockUploadTask);

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

  RxFirebaseStorage.putStream(mockStorageReference, mockInputStream).subscribe(obs);
  verifyAddOnCompleteListenerForTask(mockUploadTask);

  callOnComplete(mockUploadTask);
  obs.dispose();

  callOnComplete(mockUploadTask);

  obs.assertError(IllegalStateException.class);
  obs.assertNoValues();
}
 
开发者ID:b3er,项目名称:RxFirebase2,代码行数:18,代码来源:RxFirebaseStorageTest.java

示例6: start_user_shouldDisplayUser

import io.reactivex.observers.TestObserver; //导入方法依赖的package包/类
@Test
public void start_user_shouldDisplayUser() {
  // given
  TestObserver<UserSelectedEvent> userSelected$ = TestObserver.create();
  User user = mock(User.class);
  given(view.userSelection$()).willReturn(noTriggers());
  UserPresenter presenter = new UserPresenter(Sink.of(userSelected$));

  // when
  presenter.start(user, view);

  // then
  then(view).should().displayUser(user);
  then(view).should().userSelection$();
  then(view).shouldHaveNoMoreInteractions();
  userSelected$.assertNoValues();
}
 
开发者ID:xemantic,项目名称:github-users,代码行数:18,代码来源:UserPresenterTest.java

示例7: testReauthenticate

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

  TestObserver obs = TestObserver.create();

  RxFirebaseUser.reauthenticate(mockFirebaseUser, mockAuthCredential).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

示例8: testSingleSuccessful

import io.reactivex.observers.TestObserver; //导入方法依赖的package包/类
@Test
public void testSingleSuccessful() {
    final String hello = "Hello, world!";
    when(mockHelloTask.getResult())
            .thenReturn(hello);
    when(mockHelloTask.isSuccessful())
            .thenReturn(true);
    when(mockHelloTask.addOnCompleteListener(onComplete.capture()))
            .thenReturn(mockHelloTask);

    TestObserver<String> obs = TestObserver.create();
    RxTask.single(mockHelloTask).subscribe(obs);
    verify(mockHelloTask).addOnCompleteListener(onComplete.capture());
    onComplete.getValue().onComplete(mockHelloTask);

    obs.assertValue(hello)
       .assertNoErrors()
       .assertComplete();

    verify(mockHelloTask).addOnCompleteListener(any(OnCompleteListener.class));
    verify(mockHelloTask).getResult();
}
 
开发者ID:yongjhih,项目名称:rxtasks,代码行数:23,代码来源:RxTaskTest.java

示例9: testChildEvents_change

import io.reactivex.observers.TestObserver; //导入方法依赖的package包/类
@Test public void testChildEvents_change() {
  TestObserver<ChildEvent> sub = TestObserver.create();

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

  verifyAddChildEventListener();
  callOnChildChanged("foo");
  callOnChildChanged("foo");

  sub.assertNotComplete();
  sub.assertNoErrors();
  sub.assertValueCount(2);

  List events = sub.getEvents().get(0);
  for (Object event : events) {
    assertThat(event).isInstanceOf(ChildEvent.class);
    assertThat(event).isInstanceOf(ChildChangeEvent.class);
    assertThat(((ChildChangeEvent) event).previousChildName()).isEqualTo("foo");
  }

  sub.dispose();

  callOnChildChanged("foo");

  // Ensure no more values are emitted after unsubscrube
  sub.assertValueCount(2);
}
 
开发者ID:b3er,项目名称:RxFirebase2,代码行数:28,代码来源:RxFirebaseDatabaseTest.java

示例10: shouldCompleteAndReplaceComputationOnTrampoline

import io.reactivex.observers.TestObserver; //导入方法依赖的package包/类
@Test
public void shouldCompleteAndReplaceComputationOnTrampoline() {
    TestObserver<String> testObserver = TestObserver.create();
    RxJavaPlugins.setComputationSchedulerHandler(old -> Schedulers.trampoline());

    try {
        wordService
                .enumerate(Observable.fromArray(STRINGS))
                .subscribeOn(Schedulers.computation())
                .subscribe(testObserver);

        testObserver
                .assertSubscribed()
                .assertComplete()
                .assertNoErrors()
                .assertValueCount(9)
                .assertValues(
                        " 1. the",
                        " 2. quick",
                        " 3. brown",
                        " 4. fox",
                        " 5. jumped",
                        " 6. over",
                        " 7. the",
                        " 8. lazy",
                        " 9. dog"
                );
    } finally {
        RxJavaPlugins.reset();
    }
}
 
开发者ID:OlegDokuka,项目名称:reactive-playing,代码行数:32,代码来源:WordServiceTest.java

示例11: testCreateUserWithEmailAndPassword

import io.reactivex.observers.TestObserver; //导入方法依赖的package包/类
@Test public void testCreateUserWithEmailAndPassword() {
  when(mockFirebaseUser.getEmail()).thenReturn("[email protected]");

  mockSuccessfulAuthResult();

  when(mockFirebaseAuth.createUserWithEmailAndPassword("[email protected]", "password")).thenReturn(
      mockAuthResultTask);

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

  RxFirebaseAuth.createUserWithEmailAndPassword(mockFirebaseAuth, "[email protected]", "password")
      .subscribe(obs);

  callOnComplete(mockAuthResultTask);
  obs.dispose();

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

  obs.assertNoErrors();
  obs.assertComplete();

  obs.assertValue(new Predicate<FirebaseUser>() {
    @Override public boolean test(FirebaseUser firebaseUser) throws Exception {
      return "[email protected]".equals(firebaseUser.getEmail());
    }
  });
}
 
开发者ID:b3er,项目名称:RxFirebase2,代码行数:29,代码来源:RxFirebaseAuthTest.java

示例12: fetchUsers_noErros_sucess

import io.reactivex.observers.TestObserver; //导入方法依赖的package包/类
@Test
public void fetchUsers_noErros_sucess() {
    TestObserver<UserResponse> subscriber = TestObserver.create();
    mApiEndPointHelper.fetchUsers(2).subscribe(subscriber);
    subscriber.onNext(new UserResponse());
    subscriber.assertNoErrors();
    subscriber.assertComplete();
}
 
开发者ID:rudsonlive,项目名称:liveomvp,代码行数:9,代码来源:HomeInteractorTest.java

示例13: testSendPasswordResetEmail_NotSuccessful

import io.reactivex.observers.TestObserver; //导入方法依赖的package包/类
@Test public void testSendPasswordResetEmail_NotSuccessful() {
  when(mockFirebaseAuth.sendPasswordResetEmail("email")).thenReturn(
      mockSendPasswordResetEmailTask);

  mockNotSuccessfulSendPasswordResetEmailResult(new IllegalStateException());

  TestObserver obs = TestObserver.create();

  RxFirebaseAuth.sendPasswordResetEmail(mockFirebaseAuth, "email").subscribe(obs);

  callOnComplete(mockSendPasswordResetEmailTask);
  obs.dispose();

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

  verify(mockFirebaseAuth).sendPasswordResetEmail("email");

  obs.assertError(IllegalStateException.class);
  obs.assertNotComplete();
}
 
开发者ID:b3er,项目名称:RxFirebase2,代码行数:22,代码来源: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: testGetCurrentUser_signedIn

import io.reactivex.observers.TestObserver; //导入方法依赖的package包/类
@Test public void testGetCurrentUser_signedIn() {
  when(mockFirebaseUser.getDisplayName()).thenReturn("John Doe");

  when(mockFirebaseAuth.getCurrentUser()).thenReturn(mockFirebaseUser);

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

  RxFirebaseAuth.getCurrentUser(mockFirebaseAuth).subscribe(obs);

  verify(mockFirebaseAuth).getCurrentUser();

  obs.dispose();

  obs.assertNoErrors();
  obs.assertComplete();

  obs.assertValue(new Predicate<FirebaseUser>() {
    @Override public boolean test(FirebaseUser firebaseUser) throws Exception {
      return "John Doe".equals(firebaseUser.getDisplayName());
    }
  });
}
 
开发者ID:b3er,项目名称:RxFirebase2,代码行数:23,代码来源:RxFirebaseAuthTest.java


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