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


Java TestObserver.assertNotComplete方法代碼示例

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


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

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

示例2: test_interval

import io.reactivex.observers.TestObserver; //導入方法依賴的package包/類
@Test
public void test_interval()
{
	TestScheduler testScheduler=new TestScheduler();
	Observable<Long>observable=Observable.interval(1, TimeUnit.SECONDS,testScheduler).take(5);
	TestObserver<Long> testObserver=new TestObserver<>();

	
	observable.subscribeOn(testScheduler).subscribe(testObserver);
	
	testObserver.assertNoValues();
	testObserver.assertNotComplete();
	testObserver.assertNoErrors();
	
	testScheduler.advanceTimeBy(1, TimeUnit.SECONDS);
	testObserver.assertValueCount(1);
	testObserver.assertValues(0l);
	
	testScheduler.advanceTimeTo(6, TimeUnit.SECONDS);
	testObserver.assertValueCount(5);
	testObserver.assertValues(0l,1l,2l,3l,4l);
}
 
開發者ID:PacktPublishing,項目名稱:Reactive-Programming-With-Java-9,代碼行數:23,代碼來源:Modern_Testing.java

示例3: executionObservables_notAllowingConcurrent_onlyExecutionOnce

import io.reactivex.observers.TestObserver; //導入方法依賴的package包/類
@Test
public void executionObservables_notAllowingConcurrent_onlyExecutionOnce() {
    RxCommand<String> command = RxCommand.create(o -> Observable.just((String) o)
            .subscribeOn(Schedulers.newThread())
            .delay(10, TimeUnit.MILLISECONDS)
    );

    TestObserver<Observable<String>> testObserver = new TestObserver<>();
    command.executionObservables().subscribe(testObserver);

    command.execute("1");
    command.execute("2");
    command.execute("3");

    // wait
    try {
        Thread.sleep(30);
    } catch (InterruptedException e) {
        e.printStackTrace();
    }

    testObserver.assertValueCount(1);
    testObserver.assertNoErrors();
    testObserver.assertNotComplete();
}
 
開發者ID:listenzz,項目名稱:RxCommand,代碼行數:26,代碼來源:RxCommandTest.java

示例4: testBindUntilLifecycleEvent

import io.reactivex.observers.TestObserver; //導入方法依賴的package包/類
@Test
public void testBindUntilLifecycleEvent() {
    BehaviorSubject<Lifecycle.Event> lifecycle = BehaviorSubject.create();

    TestObserver<Object> testObserver =
            observable.compose(RxLifecycle.bindUntilEvent(lifecycle, Lifecycle.Event.ON_STOP)).test();

    lifecycle.onNext(Lifecycle.Event.ON_CREATE);
    testObserver.assertNotComplete();
    lifecycle.onNext(Lifecycle.Event.ON_START);
    testObserver.assertNotComplete();
    lifecycle.onNext(Lifecycle.Event.ON_RESUME);
    testObserver.assertNotComplete();
    lifecycle.onNext(Lifecycle.Event.ON_PAUSE);
    testObserver.assertNotComplete();
    lifecycle.onNext(Lifecycle.Event.ON_STOP);
    testObserver.assertComplete();
}
 
開發者ID:xufreshman,項目名稱:RxLifeCycle,代碼行數:19,代碼來源:RxLifecycleTest.java

示例5: testBindUntilEvent

import io.reactivex.observers.TestObserver; //導入方法依賴的package包/類
@Test
public void testBindUntilEvent() {
    NaviEmitter fragment = createFragmentEmitter();
    LifecycleProvider<FragmentEvent> provider = createFragmentLifecycleProvider(fragment);

    Observable<Object> observable = create().hide();
    TestObserver<Object> testObserver = observable.compose(provider.bindUntilEvent(STOP)).test();

    fragment.onAttach(null);
    testObserver.assertNotComplete();
    fragment.onCreate(null);
    testObserver.assertNotComplete();
    fragment.onCreate(null);
    testObserver.assertNotComplete();
    fragment.onStart();
    testObserver.assertNotComplete();
    fragment.onResume();
    testObserver.assertNotComplete();
    fragment.onPause();
    testObserver.assertNotComplete();
    fragment.onStop();
    testObserver.assertComplete();
}
 
開發者ID:xufreshman,項目名稱:RxLifeCycle,代碼行數:24,代碼來源:NaviFragmentLifecycleTest.java

示例6: testUpdatePassword_notSuccessful

import io.reactivex.observers.TestObserver; //導入方法依賴的package包/類
@Test public void testUpdatePassword_notSuccessful() {
  mockNotSuccessfulVoidResult(new IllegalStateException());
  when(mockFirebaseUser.updatePassword("password")).thenReturn(mockVoidTaskResult);

  TestObserver obs = TestObserver.create();

  RxFirebaseUser.updatePassword(mockFirebaseUser, "password").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

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

示例8: testDataChangesOfClazz

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

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

  verifyAddValueEventListener();
  callValueEventOnDataChange("Foo");

  sub.assertNotComplete();
  sub.assertValueCount(1);
  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,代碼行數:24,代碼來源:RxFirebaseDatabaseTest.java

示例9: testReauthenticate_notSuccessful

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

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

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

示例12: anErrorOccurredDuringExecution_noValue

import io.reactivex.observers.TestObserver; //導入方法依賴的package包/類
@Test
public void anErrorOccurredDuringExecution_noValue() {
    final Throwable throwable = new Exception("something wrong");
    RxCommand<String> command = RxCommand.create(o -> Observable.error(throwable));

    TestObserver<String> testObserver = new TestObserver<>();
    command.switchToLatest().subscribe(testObserver);

    command.execute(null);

    testObserver.assertNoValues();
    testObserver.assertNoErrors();
    testObserver.assertNotComplete();
}
 
開發者ID:listenzz,項目名稱:RxCommand,代碼行數:15,代碼來源:RxCommandTest.java

示例13: testBindToLifecycle

import io.reactivex.observers.TestObserver; //導入方法依賴的package包/類
@Test
public void testBindToLifecycle() {
    NaviEmitter activity = createActivityEmitter();
    LifecycleProvider<ActivityEvent> provider = createActivityLifecycleProvider(activity);

    Observable<Object> observable = create().hide();

    activity.onCreate(null);
    TestObserver<Object> createObserver = observable.compose(provider.bindToLifecycle()).test();

    activity.onStart();
    createObserver.assertNotComplete();
    TestObserver<Object> startObserver = observable.compose(provider.bindToLifecycle()).test();

    activity.onResume();
    createObserver.assertNotComplete();
    startObserver.assertNotComplete();
    TestObserver<Object> resumeTestSub = observable.compose(provider.bindToLifecycle()).test();

    activity.onPause();
    createObserver.assertNotComplete();
    startObserver.assertNotComplete();
    resumeTestSub.assertComplete();
    TestObserver<Object> pauseObserver = observable.compose(provider.bindToLifecycle()).test();

    activity.onStop();
    createObserver.assertNotComplete();
    startObserver.assertComplete();
    pauseObserver.assertComplete();
    TestObserver<Object> stopObserver = observable.compose(provider.bindToLifecycle()).test();

    activity.onDestroy();
    createObserver.assertComplete();
    stopObserver.assertComplete();
}
 
開發者ID:xufreshman,項目名稱:RxLifeCycle,代碼行數:36,代碼來源:NaviActivityLifecycleTest.java

示例14: asObservable_withActiveLifecycle_shouldEmitWithoutWaiting

import io.reactivex.observers.TestObserver; //導入方法依賴的package包/類
@Test
public void asObservable_withActiveLifecycle_shouldEmitWithoutWaiting() {
  Object returnValue = new Object();
  TestObserver<Optional<Step.Data<Object, ActionableItem>>> testSubscriber = new TestObserver<>();

  interactorLifecycleSubject.onNext(InteractorEvent.ACTIVE);

  step.asObservable().subscribe(testSubscriber);

  testSubscriber.assertNoValues();
  testSubscriber.assertNoErrors();
  testSubscriber.assertNotComplete();

  returnValueSubject.onNext(
      Optional.of(
          new Step.Data<Object, ActionableItem>(
              returnValue,
              new ActionableItem() {
                @NonNull
                @Override
                public Observable<InteractorEvent> lifecycle() {
                  return interactorLifecycleSubject;
                }
              })));
  returnValueSubject.onComplete();

  testSubscriber.assertValueCount(1);
  assertThat(testSubscriber.values().get(0).get().getValue()).isEqualTo(returnValue);
  testSubscriber.assertComplete();
  testSubscriber.assertNoErrors();
}
 
開發者ID:uber,項目名稱:RIBs,代碼行數:32,代碼來源:StepTest.java

示例15: testBindToLifecycle

import io.reactivex.observers.TestObserver; //導入方法依賴的package包/類
private void testBindToLifecycle(LifecycleOwner owner) {
    Fragment fragment = (Fragment) owner;
    LifecycleProvider<Lifecycle.Event> provider = AndroidLifecycle.createLifecycleProvider(owner);
    ActivityController<?> controller = startFragment(fragment);

    TestObserver<Object> createObserver = observable.compose(provider.bindToLifecycle()).test();

    controller.start();
    createObserver.assertNotComplete();
    TestObserver<Object> startObserver = observable.compose(provider.bindToLifecycle()).test();

    controller.resume();
    createObserver.assertNotComplete();
    startObserver.assertNotComplete();
    TestObserver<Object> resumeObserver = observable.compose(provider.bindToLifecycle()).test();

    controller.pause();
    createObserver.assertNotComplete();
    startObserver.assertNotComplete();
    resumeObserver.assertComplete();
    TestObserver<Object> pauseObserver = observable.compose(provider.bindToLifecycle()).test();

    controller.stop();
    createObserver.assertNotComplete();
    startObserver.assertComplete();
    pauseObserver.assertComplete();
    TestObserver<Object> stopObserver = observable.compose(provider.bindToLifecycle()).test();

    controller.destroy();
    createObserver.assertComplete();
    stopObserver.assertComplete();
}
 
開發者ID:xufreshman,項目名稱:RxLifeCycle,代碼行數:33,代碼來源:AndroidLifecycleFragmentTest.java


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