org.mockito.Mockito.anyList()方法的使用及代码示例

x33g5p2x  于2022-01-24 转载在 其他  
字(15.2k)|赞(0)|评价(0)|浏览(621)

本文整理了Java中org.mockito.Mockito.anyList()方法的一些代码示例,展示了Mockito.anyList()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Mockito.anyList()方法的具体详情如下:
包路径:org.mockito.Mockito
类名称:Mockito
方法名:anyList

Mockito.anyList介绍

暂无

代码示例

代码示例来源:origin: AxonFramework/AxonFramework

@SuppressWarnings("unchecked")
private static List<DomainEventMessage<?>> anyEventList() {
  return anyList();
}

代码示例来源:origin: ReactiveX/RxJava

@Test
public void testSkipAndCountGaplessBuffers() {
  Observable<String> source = Observable.just("one", "two", "three", "four", "five");
  Observable<List<String>> buffered = source.buffer(3, 3);
  buffered.subscribe(observer);
  InOrder inOrder = Mockito.inOrder(observer);
  inOrder.verify(observer, Mockito.times(1)).onNext(list("one", "two", "three"));
  inOrder.verify(observer, Mockito.times(1)).onNext(list("four", "five"));
  inOrder.verify(observer, Mockito.never()).onNext(Mockito.<String>anyList());
  inOrder.verify(observer, Mockito.never()).onError(Mockito.any(Throwable.class));
  inOrder.verify(observer, Mockito.times(1)).onComplete();
}

代码示例来源:origin: ReactiveX/RxJava

@Test
public void testSkipAndCountBuffersWithGaps() {
  Observable<String> source = Observable.just("one", "two", "three", "four", "five");
  Observable<List<String>> buffered = source.buffer(2, 3);
  buffered.subscribe(observer);
  InOrder inOrder = Mockito.inOrder(observer);
  inOrder.verify(observer, Mockito.times(1)).onNext(list("one", "two"));
  inOrder.verify(observer, Mockito.times(1)).onNext(list("four", "five"));
  inOrder.verify(observer, Mockito.never()).onNext(Mockito.<String>anyList());
  inOrder.verify(observer, Mockito.never()).onError(Mockito.any(Throwable.class));
  inOrder.verify(observer, Mockito.times(1)).onComplete();
}

代码示例来源:origin: ReactiveX/RxJava

@Test
public void testComplete() {
  Observable<String> source = Observable.empty();
  Observable<List<String>> buffered = source.buffer(3, 3);
  buffered.subscribe(observer);
  Mockito.verify(observer, Mockito.never()).onNext(Mockito.<String>anyList());
  Mockito.verify(observer, Mockito.never()).onError(Mockito.any(Throwable.class));
  Mockito.verify(observer, Mockito.times(1)).onComplete();
}

代码示例来源:origin: ReactiveX/RxJava

@Test
public void testComplete() {
  Flowable<String> source = Flowable.empty();
  Flowable<List<String>> buffered = source.buffer(3, 3);
  buffered.subscribe(subscriber);
  Mockito.verify(subscriber, Mockito.never()).onNext(Mockito.<String>anyList());
  Mockito.verify(subscriber, Mockito.never()).onError(Mockito.any(Throwable.class));
  Mockito.verify(subscriber, Mockito.times(1)).onComplete();
}

代码示例来源:origin: ReactiveX/RxJava

@Test
public void testSkipAndCountBuffersWithGaps() {
  Flowable<String> source = Flowable.just("one", "two", "three", "four", "five");
  Flowable<List<String>> buffered = source.buffer(2, 3);
  buffered.subscribe(subscriber);
  InOrder inOrder = Mockito.inOrder(subscriber);
  inOrder.verify(subscriber, Mockito.times(1)).onNext(list("one", "two"));
  inOrder.verify(subscriber, Mockito.times(1)).onNext(list("four", "five"));
  inOrder.verify(subscriber, Mockito.never()).onNext(Mockito.<String>anyList());
  inOrder.verify(subscriber, Mockito.never()).onError(Mockito.any(Throwable.class));
  inOrder.verify(subscriber, Mockito.times(1)).onComplete();
}

代码示例来源:origin: ReactiveX/RxJava

@Test
public void testSkipAndCountGaplessBuffers() {
  Flowable<String> source = Flowable.just("one", "two", "three", "four", "five");
  Flowable<List<String>> buffered = source.buffer(3, 3);
  buffered.subscribe(subscriber);
  InOrder inOrder = Mockito.inOrder(subscriber);
  inOrder.verify(subscriber, Mockito.times(1)).onNext(list("one", "two", "three"));
  inOrder.verify(subscriber, Mockito.times(1)).onNext(list("four", "five"));
  inOrder.verify(subscriber, Mockito.never()).onNext(Mockito.<String>anyList());
  inOrder.verify(subscriber, Mockito.never()).onError(Mockito.any(Throwable.class));
  inOrder.verify(subscriber, Mockito.times(1)).onComplete();
}

代码示例来源:origin: spring-projects/spring-security

@Test
public void hasPermissionReturnsTrueIfAclGrantsPermission() throws Exception {
  AclService service = mock(AclService.class);
  AclPermissionEvaluator pe = new AclPermissionEvaluator(service);
  ObjectIdentity oid = mock(ObjectIdentity.class);
  ObjectIdentityRetrievalStrategy oidStrategy = mock(ObjectIdentityRetrievalStrategy.class);
  when(oidStrategy.getObjectIdentity(any(Object.class))).thenReturn(oid);
  pe.setObjectIdentityRetrievalStrategy(oidStrategy);
  pe.setSidRetrievalStrategy(mock(SidRetrievalStrategy.class));
  Acl acl = mock(Acl.class);
  when(service.readAclById(any(ObjectIdentity.class), anyList())).thenReturn(acl);
  when(acl.isGranted(anyList(), anyList(), eq(false))).thenReturn(true);
  assertThat(pe.hasPermission(mock(Authentication.class), new Object(), "READ")).isTrue();
}

代码示例来源:origin: ReactiveX/RxJava

@Test
public void testSkipAndCountOverlappingBuffers() {
  Observable<String> source = Observable.unsafeCreate(new ObservableSource<String>() {
    @Override
    public void subscribe(Observer<? super String> observer) {
      observer.onSubscribe(Disposables.empty());
      observer.onNext("one");
      observer.onNext("two");
      observer.onNext("three");
      observer.onNext("four");
      observer.onNext("five");
    }
  });
  Observable<List<String>> buffered = source.buffer(3, 1);
  buffered.subscribe(observer);
  InOrder inOrder = Mockito.inOrder(observer);
  inOrder.verify(observer, Mockito.times(1)).onNext(list("one", "two", "three"));
  inOrder.verify(observer, Mockito.times(1)).onNext(list("two", "three", "four"));
  inOrder.verify(observer, Mockito.times(1)).onNext(list("three", "four", "five"));
  inOrder.verify(observer, Mockito.never()).onNext(Mockito.<String>anyList());
  inOrder.verify(observer, Mockito.never()).onError(Mockito.any(Throwable.class));
  inOrder.verify(observer, Mockito.never()).onComplete();
}

代码示例来源:origin: ReactiveX/RxJava

@Test
public void testSkipAndCountOverlappingBuffers() {
  Flowable<String> source = Flowable.unsafeCreate(new Publisher<String>() {
    @Override
    public void subscribe(Subscriber<? super String> subscriber) {
      subscriber.onSubscribe(new BooleanSubscription());
      subscriber.onNext("one");
      subscriber.onNext("two");
      subscriber.onNext("three");
      subscriber.onNext("four");
      subscriber.onNext("five");
    }
  });
  Flowable<List<String>> buffered = source.buffer(3, 1);
  buffered.subscribe(subscriber);
  InOrder inOrder = Mockito.inOrder(subscriber);
  inOrder.verify(subscriber, Mockito.times(1)).onNext(list("one", "two", "three"));
  inOrder.verify(subscriber, Mockito.times(1)).onNext(list("two", "three", "four"));
  inOrder.verify(subscriber, Mockito.times(1)).onNext(list("three", "four", "five"));
  inOrder.verify(subscriber, Mockito.never()).onNext(Mockito.<String>anyList());
  inOrder.verify(subscriber, Mockito.never()).onError(Mockito.any(Throwable.class));
  inOrder.verify(subscriber, Mockito.never()).onComplete();
}

代码示例来源:origin: ReactiveX/RxJava

@Test
public void testTimed() {
  Observable<String> source = Observable.unsafeCreate(new ObservableSource<String>() {
    @Override
    public void subscribe(Observer<? super String> observer) {
      observer.onSubscribe(Disposables.empty());
      push(observer, "one", 97);
      push(observer, "two", 98);
      /**
       * Changed from 100. Because scheduling the cut to 100ms happens before this
       * Observable even runs due how lift works, pushing at 100ms would execute after the
       * buffer cut.
       */
      push(observer, "three", 99);
      push(observer, "four", 101);
      push(observer, "five", 102);
      complete(observer, 150);
    }
  });
  Observable<List<String>> buffered = source.buffer(100, TimeUnit.MILLISECONDS, scheduler);
  buffered.subscribe(observer);
  InOrder inOrder = Mockito.inOrder(observer);
  scheduler.advanceTimeTo(101, TimeUnit.MILLISECONDS);
  inOrder.verify(observer, Mockito.times(1)).onNext(list("one", "two", "three"));
  scheduler.advanceTimeTo(201, TimeUnit.MILLISECONDS);
  inOrder.verify(observer, Mockito.times(1)).onNext(list("four", "five"));
  inOrder.verify(observer, Mockito.never()).onNext(Mockito.<String>anyList());
  inOrder.verify(observer, Mockito.never()).onError(Mockito.any(Throwable.class));
  inOrder.verify(observer, Mockito.times(1)).onComplete();
}

代码示例来源:origin: ReactiveX/RxJava

@Test
public void testTimedAndCount() {
  Observable<String> source = Observable.unsafeCreate(new ObservableSource<String>() {
    @Override
    public void subscribe(Observer<? super String> observer) {
      observer.onSubscribe(Disposables.empty());
      push(observer, "one", 10);
      push(observer, "two", 90);
      push(observer, "three", 110);
      push(observer, "four", 190);
      push(observer, "five", 210);
      complete(observer, 250);
    }
  });
  Observable<List<String>> buffered = source.buffer(100, TimeUnit.MILLISECONDS, scheduler, 2);
  buffered.subscribe(observer);
  InOrder inOrder = Mockito.inOrder(observer);
  scheduler.advanceTimeTo(100, TimeUnit.MILLISECONDS);
  inOrder.verify(observer, Mockito.times(1)).onNext(list("one", "two"));
  scheduler.advanceTimeTo(200, TimeUnit.MILLISECONDS);
  inOrder.verify(observer, Mockito.times(1)).onNext(list("three", "four"));
  scheduler.advanceTimeTo(300, TimeUnit.MILLISECONDS);
  inOrder.verify(observer, Mockito.times(1)).onNext(list("five"));
  inOrder.verify(observer, Mockito.never()).onNext(Mockito.<String>anyList());
  inOrder.verify(observer, Mockito.never()).onError(Mockito.any(Throwable.class));
  inOrder.verify(observer, Mockito.times(1)).onComplete();
}

代码示例来源:origin: ReactiveX/RxJava

inOrder.verify(observer, Mockito.times(1)).onNext(list("three", "four"));
inOrder.verify(observer, Mockito.times(1)).onNext(list("five"));
inOrder.verify(observer, Mockito.never()).onNext(Mockito.<String>anyList());
inOrder.verify(observer, Mockito.never()).onError(Mockito.any(Throwable.class));
inOrder.verify(observer, Mockito.times(1)).onComplete();

代码示例来源:origin: ReactiveX/RxJava

inOrder.verify(observer, Mockito.times(1)).onNext(list("two", "three"));
inOrder.verify(observer, Mockito.times(1)).onNext(list("five"));
inOrder.verify(observer, Mockito.never()).onNext(Mockito.<String>anyList());
inOrder.verify(observer, Mockito.never()).onError(Mockito.any(Throwable.class));
inOrder.verify(observer, Mockito.times(1)).onComplete();

代码示例来源:origin: ReactiveX/RxJava

inOrder.verify(subscriber, Mockito.times(1)).onNext(list("three", "four"));
inOrder.verify(subscriber, Mockito.times(1)).onNext(list("five"));
inOrder.verify(subscriber, Mockito.never()).onNext(Mockito.<String>anyList());
inOrder.verify(subscriber, Mockito.never()).onError(Mockito.any(Throwable.class));
inOrder.verify(subscriber, Mockito.times(1)).onComplete();

代码示例来源:origin: ReactiveX/RxJava

@Test
public void testTimed() {
  Flowable<String> source = Flowable.unsafeCreate(new Publisher<String>() {
    @Override
    public void subscribe(Subscriber<? super String> subscriber) {
      subscriber.onSubscribe(new BooleanSubscription());
      push(subscriber, "one", 97);
      push(subscriber, "two", 98);
      /**
       * Changed from 100. Because scheduling the cut to 100ms happens before this
       * Flowable even runs due how lift works, pushing at 100ms would execute after the
       * buffer cut.
       */
      push(subscriber, "three", 99);
      push(subscriber, "four", 101);
      push(subscriber, "five", 102);
      complete(subscriber, 150);
    }
  });
  Flowable<List<String>> buffered = source.buffer(100, TimeUnit.MILLISECONDS, scheduler);
  buffered.subscribe(subscriber);
  InOrder inOrder = Mockito.inOrder(subscriber);
  scheduler.advanceTimeTo(101, TimeUnit.MILLISECONDS);
  inOrder.verify(subscriber, Mockito.times(1)).onNext(list("one", "two", "three"));
  scheduler.advanceTimeTo(201, TimeUnit.MILLISECONDS);
  inOrder.verify(subscriber, Mockito.times(1)).onNext(list("four", "five"));
  inOrder.verify(subscriber, Mockito.never()).onNext(Mockito.<String>anyList());
  inOrder.verify(subscriber, Mockito.never()).onError(Mockito.any(Throwable.class));
  inOrder.verify(subscriber, Mockito.times(1)).onComplete();
}

代码示例来源:origin: ReactiveX/RxJava

@Test
public void testTimedAndCount() {
  Flowable<String> source = Flowable.unsafeCreate(new Publisher<String>() {
    @Override
    public void subscribe(Subscriber<? super String> subscriber) {
      subscriber.onSubscribe(new BooleanSubscription());
      push(subscriber, "one", 10);
      push(subscriber, "two", 90);
      push(subscriber, "three", 110);
      push(subscriber, "four", 190);
      push(subscriber, "five", 210);
      complete(subscriber, 250);
    }
  });
  Flowable<List<String>> buffered = source.buffer(100, TimeUnit.MILLISECONDS, scheduler, 2);
  buffered.subscribe(subscriber);
  InOrder inOrder = Mockito.inOrder(subscriber);
  scheduler.advanceTimeTo(100, TimeUnit.MILLISECONDS);
  inOrder.verify(subscriber, Mockito.times(1)).onNext(list("one", "two"));
  scheduler.advanceTimeTo(200, TimeUnit.MILLISECONDS);
  inOrder.verify(subscriber, Mockito.times(1)).onNext(list("three", "four"));
  scheduler.advanceTimeTo(300, TimeUnit.MILLISECONDS);
  inOrder.verify(subscriber, Mockito.times(1)).onNext(list("five"));
  inOrder.verify(subscriber, Mockito.never()).onNext(Mockito.<String>anyList());
  inOrder.verify(subscriber, Mockito.never()).onError(Mockito.any(Throwable.class));
  inOrder.verify(subscriber, Mockito.times(1)).onComplete();
}

代码示例来源:origin: gocd/gocd

@Test
public void shouldNotRegisterPluginInterestsOnPluginLoadIfPluginIfPluginIsNotOfNotificationType() {
  NotificationPluginRegistrar notificationPluginRegistrar = new NotificationPluginRegistrar(pluginManager, notificationExtension, notificationPluginRegistry);
  notificationPluginRegistrar.pluginLoaded(new GoPluginDescriptor(PLUGIN_ID_4, null, null, null, null, true));
  verify(notificationPluginRegistry, never()).registerPluginInterests(anyString(), anyList());
}

代码示例来源:origin: ReactiveX/RxJava

inOrder.verify(subscriber, Mockito.times(1)).onNext(list("two", "three"));
inOrder.verify(subscriber, Mockito.times(1)).onNext(list("five"));
inOrder.verify(subscriber, Mockito.never()).onNext(Mockito.<String>anyList());
inOrder.verify(subscriber, Mockito.never()).onError(Mockito.any(Throwable.class));
inOrder.verify(subscriber, Mockito.times(1)).onComplete();

代码示例来源:origin: Alluxio/alluxio

@Test
public void run() throws Exception {
 JobCoordinator coordinator = PowerMockito.mock(JobCoordinator.class);
 PowerMockito.mockStatic(JobCoordinator.class);
 Mockito.when(
   JobCoordinator.create(Mockito.any(CommandManager.class), Mockito.any(UfsManager.class),
     Mockito.anyList(), Mockito.anyLong(), Mockito.any(JobConfig.class), Mockito.any(null)))
   .thenReturn(coordinator);
 TestJobConfig jobConfig = new TestJobConfig("/test");
 for (long i = 0; i < TEST_JOB_MASTER_JOB_CAPACITY; i++) {
  mJobMaster.run(jobConfig);
 }
 Assert.assertEquals(TEST_JOB_MASTER_JOB_CAPACITY, mJobMaster.list().size());
}

相关文章