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