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


Java InOrder类代码示例

本文整理汇总了Java中org.mockito.InOrder的典型用法代码示例。如果您正苦于以下问题:Java InOrder类的具体用法?Java InOrder怎么用?Java InOrder使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: testTimeoutSelectorSubsequentThrows

import org.mockito.InOrder; //导入依赖的package包/类
@Test
public void testTimeoutSelectorSubsequentThrows() {
    PublishSubject<Integer> source = PublishSubject.create();
    final PublishSubject<Integer> timeout = PublishSubject.create();

    Function<Integer, Observable<Integer>> timeoutFunc = new Function<Integer, Observable<Integer>>() {
        @Override
        public Observable<Integer> apply(Integer t1) {
            throw new TestException();
        }
    };

    Observable<Integer> other = Observable.fromIterable(Arrays.asList(100));

    Observer<Object> o = TestHelper.mockObserver();
    InOrder inOrder = inOrder(o);

    source.timeout(timeout, timeoutFunc, other).subscribe(o);

    source.onNext(1);

    inOrder.verify(o).onNext(1);
    inOrder.verify(o).onError(any(TestException.class));
    verify(o, never()).onComplete();

}
 
开发者ID:akarnokd,项目名称:RxJava3-preview,代码行数:27,代码来源:ObservableTimeoutWithSelectorTest.java

示例2: shouldSynchronizeAllConfigurationsForPolicy_whenFullPolicyConfiguration

import org.mockito.InOrder; //导入依赖的package包/类
@Test
public void shouldSynchronizeAllConfigurationsForPolicy_whenFullPolicyConfiguration() {
    // given
    testee.setPolicyConfigurations(ImmutableList.of(policyConfigurationMock));

    // when
    testee.sync();

    // then
    InOrder order = inOrder(applicationConfiguratorMock,
            policyConfiguratorMock,
            conditionConfiguratorMock,
            externalServiceConditionConfiguratorMock,
            nrqlConditionConfiguratorMock,
            channelConfiguratorMock);
    order.verify(policyConfiguratorMock).sync(policyConfigurationMock);
    order.verify(conditionConfiguratorMock).sync(policyConfigurationMock);
    order.verify(externalServiceConditionConfiguratorMock).sync(policyConfigurationMock);
    order.verify(nrqlConditionConfiguratorMock).sync(policyConfigurationMock);
    order.verify(channelConfiguratorMock).sync(policyConfigurationMock);
    order.verifyNoMoreInteractions();
}
 
开发者ID:ocadotechnology,项目名称:newrelic-alerts-configurator,代码行数:23,代码来源:ConfiguratorTest.java

示例3: timestampWithScheduler

import org.mockito.InOrder; //导入依赖的package包/类
@Test
public void timestampWithScheduler() {
    TestScheduler scheduler = new TestScheduler();

    PublishSubject<Integer> source = PublishSubject.create();
    Observable<Timed<Integer>> m = source.timestamp(scheduler);
    m.subscribe(observer);

    source.onNext(1);
    scheduler.advanceTimeBy(100, TimeUnit.MILLISECONDS);
    source.onNext(2);
    scheduler.advanceTimeBy(100, TimeUnit.MILLISECONDS);
    source.onNext(3);

    InOrder inOrder = inOrder(observer);

    inOrder.verify(observer, times(1)).onNext(new Timed<Integer>(1, 0, TimeUnit.MILLISECONDS));
    inOrder.verify(observer, times(1)).onNext(new Timed<Integer>(2, 100, TimeUnit.MILLISECONDS));
    inOrder.verify(observer, times(1)).onNext(new Timed<Integer>(3, 200, TimeUnit.MILLISECONDS));

    verify(observer, never()).onError(any(Throwable.class));
    verify(observer, never()).onComplete();
}
 
开发者ID:akarnokd,项目名称:RxJava3-preview,代码行数:24,代码来源:ObservableTimestampTest.java

示例4: shouldNotRemoveUnusedUserChannel

import org.mockito.InOrder; //导入依赖的package包/类
@Test
public void shouldNotRemoveUnusedUserChannel() {
    // given
    AlertsChannel userChannelInPolicy = channelInPolicy(savedUserChannel, POLICY_ID);
    when(alertsChannelsApiMock.list()).thenReturn(ImmutableList.of(userChannelInPolicy));
    when(alertsChannelsApiMock.deleteFromPolicy(POLICY_ID, userChannelInPolicy.getId()))
            .thenReturn(userChannelInPolicy);

    // when
    PolicyConfiguration policyConfiguration = buildPolicyConfiguration();
    testee.sync(policyConfiguration);

    // then
    AlertsPolicyChannels expected = AlertsPolicyChannels.builder()
            .policyId(POLICY_ID)
            .channelIds(emptySet())
            .build();

    InOrder order = inOrder(alertsChannelsApiMock, alertsPoliciesApiMock);
    order.verify(alertsChannelsApiMock).list();
    order.verify(alertsPoliciesApiMock).updateChannels(expected);
    order.verify(alertsChannelsApiMock).deleteFromPolicy(POLICY_ID, savedUserChannel.getId());
    order.verify(alertsChannelsApiMock, never()).delete(savedUserChannel.getId());
    order.verifyNoMoreInteractions();
}
 
开发者ID:ocadotechnology,项目名称:newrelic-alerts-configurator,代码行数:26,代码来源:ChannelConfiguratorTest.java

示例5: onTouchEvent_TOUCH_START_canSwypeTest

import org.mockito.InOrder; //导入依赖的package包/类
@Test
public void onTouchEvent_TOUCH_START_canSwypeTest() {
    // when
    when(touchEvent.getType()).thenReturn(TouchTypes.TOUCH_START);

    // when(multiPageController.isAnimationRunning()).thenReturn(true);
    NativeEvent nativeEvent = mock(NativeEvent.class);
    when(touchEvent.getNativeEvent()).thenReturn(nativeEvent);
    when(touchController.canSwype(multiPageController)).thenReturn(false);
    // given
    testObj.onTouchEvent(touchEvent);

    // then
    InOrder inOrder = inOrder(userAgentUtil, touchEventReader, touchController, touchEndTimerFactory, touchEndTimer, touchEvent, multiPageController);

    inOrder.verify(touchEvent).getType();
    inOrder.verify(touchEvent).getNativeEvent();
    inOrder.verify(touchController).canSwype(multiPageController);
}
 
开发者ID:YoungDigitalPlanet,项目名称:empiria.player,代码行数:20,代码来源:MultiPageTouchHandlerTest.java

示例6: testFirstOrDefaultWithPredicateFlowable

import org.mockito.InOrder; //导入依赖的package包/类
@Test
public void testFirstOrDefaultWithPredicateFlowable() {
    Flowable<Integer> observable = Flowable.just(1, 2, 3, 4, 5, 6)
            .filter(new Predicate<Integer>() {
                @Override
                public boolean test(Integer t1) {
                    return t1 % 2 == 0;
                }
            })
            .first(8);

    Subscriber<Integer> observer = TestHelper.mockSubscriber();
    observable.subscribe(observer);

    InOrder inOrder = inOrder(observer);
    inOrder.verify(observer, times(1)).onNext(2);
    inOrder.verify(observer, times(1)).onComplete();
    inOrder.verifyNoMoreInteractions();
}
 
开发者ID:akarnokd,项目名称:RxJava3-preview,代码行数:20,代码来源:FlowableFirstTest.java

示例7: shouldNotSynchronizeAnything_whenNoConfigurationsSet

import org.mockito.InOrder; //导入依赖的package包/类
@Test
public void shouldNotSynchronizeAnything_whenNoConfigurationsSet() {
    // given

    // when
    testee.sync();

    // then
    InOrder order = inOrder(applicationConfiguratorMock,
            policyConfiguratorMock,
            conditionConfiguratorMock,
            externalServiceConditionConfiguratorMock,
            nrqlConditionConfiguratorMock,
            channelConfiguratorMock);
    order.verifyNoMoreInteractions();
}
 
开发者ID:ocadotechnology,项目名称:newrelic-alerts-configurator,代码行数:17,代码来源:ConfiguratorTest.java

示例8: testOnMessageSuccessful

import org.mockito.InOrder; //导入依赖的package包/类
@Test
public void testOnMessageSuccessful() throws IOException {
  InputStream mis = mock(InputStream.class, withSettings().extraInterfaces(Seekable.class, PositionedReadable.class));
  doReturn(42).when(mis).read(any(byte[].class), anyInt(), anyInt());

  FSDataInputStream fdis = new FSDataInputStream(mis);
  Response response = getResponse(7L, 4096, fdis);

  InOrder inOrder = Mockito.inOrder(mis);

  inOrder.verify((Seekable) mis).seek(7);
  inOrder.verify(mis).read(any(byte[].class), anyInt(), anyInt());

  assertEquals(42, ((DFS.GetFileDataResponse) response.pBody).getRead());
  assertEquals(42, response.dBodies[0].readableBytes());
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:17,代码来源:TestPDFSProtocol.java

示例9: concatVeryLongObservableOfObservablesTakeHalf

import org.mockito.InOrder; //导入依赖的package包/类
@Test
public void concatVeryLongObservableOfObservablesTakeHalf() {
    final int n = 10000;
    Flowable<Flowable<Integer>> source = Flowable.range(0, n).map(new Function<Integer, Flowable<Integer>>() {
        @Override
        public Flowable<Integer> apply(Integer v) {
            return Flowable.just(v);
        }
    });

    Flowable<List<Integer>> result = Flowable.concat(source).take(n / 2).toList();

    Subscriber<List<Integer>> o = TestHelper.mockSubscriber();
    InOrder inOrder = inOrder(o);

    result.subscribe(o);

    List<Integer> list = new ArrayList<Integer>(n);
    for (int i = 0; i < n / 2; i++) {
        list.add(i);
    }
    inOrder.verify(o).onNext(list);
    verify(o, never()).onError(any(Throwable.class));
}
 
开发者ID:akarnokd,项目名称:RxJava3-preview,代码行数:25,代码来源:FlowableConcatTest.java

示例10: testFirstOrDefaultWithPredicateAndEmpty

import org.mockito.InOrder; //导入依赖的package包/类
@Test
public void testFirstOrDefaultWithPredicateAndEmpty() {
    Single<Integer> observable = first(Flowable.just(1)
            .filter(new Predicate<Integer>() {
                @Override
                public boolean test(Integer t1) {
                    return t1 % 2 == 0;
                }
            })
            , 2);

    observable.subscribe(wo);

    InOrder inOrder = inOrder(wo);
    inOrder.verify(wo, times(1)).onSuccess(2);
    inOrder.verifyNoMoreInteractions();
}
 
开发者ID:akarnokd,项目名称:RxJava3-preview,代码行数:18,代码来源:FlowableFirstTest.java

示例11: shouldCreateGatewaySenderAfterRegions

import org.mockito.InOrder; //导入依赖的package包/类
@Test
public void shouldCreateGatewaySenderAfterRegions() {
  CacheCreation cacheCreation = new CacheCreation();
  GatewayReceiver receiver = mock(GatewayReceiver.class);
  cacheCreation.addGatewayReceiver(receiver);
  cacheCreation.addRootRegion(new RegionCreation(cacheCreation, "region"));
  GemFireCacheImpl cache = mock(GemFireCacheImpl.class);
  GatewayReceiverFactory receiverFactory = mock(GatewayReceiverFactory.class);
  when(cache.createGatewayReceiverFactory()).thenReturn(receiverFactory);
  when(receiverFactory.create()).thenReturn(receiver);

  InOrder inOrder = inOrder(cache, receiverFactory);
  cacheCreation.create(cache);

  inOrder.verify(cache).basicCreateRegion(eq("region"), any());
  inOrder.verify(cache).createGatewayReceiverFactory();
  inOrder.verify(receiverFactory).create();
}
 
开发者ID:ampool,项目名称:monarch,代码行数:19,代码来源:CacheCreationJUnitTest.java

示例12: testDelayWithFlowableSingleSend1

import org.mockito.InOrder; //导入依赖的package包/类
@Test
public void testDelayWithFlowableSingleSend1() {
    PublishProcessor<Integer> source = PublishProcessor.create();
    final PublishProcessor<Integer> delay = PublishProcessor.create();

    Function<Integer, Flowable<Integer>> delayFunc = new Function<Integer, Flowable<Integer>>() {

        @Override
        public Flowable<Integer> apply(Integer t1) {
            return delay;
        }
    };
    Subscriber<Object> o = TestHelper.mockSubscriber();
    InOrder inOrder = inOrder(o);

    source.delay(delayFunc).subscribe(o);

    source.onNext(1);
    delay.onNext(1);
    delay.onNext(2);

    inOrder.verify(o).onNext(1);
    inOrder.verifyNoMoreInteractions();
    verify(o, never()).onError(any(Throwable.class));
}
 
开发者ID:akarnokd,项目名称:RxJava3-preview,代码行数:26,代码来源:FlowableDelayTest.java

示例13: testNotifyDiscovering

import org.mockito.InOrder; //导入依赖的package包/类
@Test
public void testNotifyDiscovering() throws Exception {
    AdapterListener adapterListener1 = mock(AdapterListener.class);
    AdapterListener adapterListener2 = mock(AdapterListener.class);
    governor.addAdapterListener(adapterListener1);
    governor.addAdapterListener(adapterListener2);

    governor.notifyDiscovering(true);

    InOrder inOrder = inOrder(adapterListener1, adapterListener2);

    inOrder.verify(adapterListener1, times(1)).discovering(true);
    inOrder.verify(adapterListener2, times(1)).discovering(true);

    // this should be ignored by governor, a log message must be issued
    doThrow(Exception.class).when(adapterListener1).discovering(anyBoolean());

    governor.notifyDiscovering(true);
    inOrder.verify(adapterListener1, times(1)).discovering(true);
    inOrder.verify(adapterListener2, times(1)).discovering(true);
    inOrder.verifyNoMoreInteractions();
}
 
开发者ID:sputnikdev,项目名称:bluetooth-manager,代码行数:23,代码来源:AdapterGovernorImplTest.java

示例14: stopsProcessingOnExceptionAndThrowsExceptionWithRightCause

import org.mockito.InOrder; //导入依赖的package包/类
@Test
public void stopsProcessingOnExceptionAndThrowsExceptionWithRightCause() throws Exception {
    // Given
    final Exception expected = new ExecutionException("Test ExecutionException", new BogusTestException());
    InOrder inOrder = inOrder(mockFuture1, mockFuture2, mockRunnable);
    doThrow(expected).when(mockFuture1).get();

    // When
    try {
        subject.run();
        fail("Should have thrown an Exception");
    } catch (Exception e) {
        // Then
        assertThat(e.getCause(), is(instanceOf(ExecutionException.class)));
        assertThat((ExecutionException)e.getCause(), is(sameInstance(expected)));
        inOrder.verify(mockFuture1, times(1)).get();
        inOrder.verify(mockFuture2, times(0)).get();
        inOrder.verify(mockRunnable, times(0)).run();
        inOrder.verifyNoMoreInteractions();
    }
}
 
开发者ID:Hacker-Peers,项目名称:DependencyExecutorService,代码行数:22,代码来源:RunnableWithDependenciesTest.java

示例15: testSetsDelayOnEncoderAfterAddingFrame

import org.mockito.InOrder; //导入依赖的package包/类
@Test
public void testSetsDelayOnEncoderAfterAddingFrame() {
  when(gifEncoder.start(any(OutputStream.class))).thenReturn(true);
  when(gifEncoder.addFrame(any(Bitmap.class))).thenReturn(true);

  when(decoder.getFrameCount()).thenReturn(1);
  when(decoder.getNextFrame()).thenReturn(Bitmap.createBitmap(100, 100, Bitmap.Config.RGB_565));
  int expectedIndex = 34;
  when(decoder.getCurrentFrameIndex()).thenReturn(expectedIndex);
  int expectedDelay = 5000;
  when(decoder.getDelay(eq(expectedIndex))).thenReturn(expectedDelay);

  encoder.encode(resource, file, options);

  InOrder order = inOrder(gifEncoder, decoder);
  order.verify(decoder).advance();
  order.verify(gifEncoder).addFrame(any(Bitmap.class));
  order.verify(gifEncoder).setDelay(eq(expectedDelay));
  order.verify(decoder).advance();
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:21,代码来源:ReEncodingGifResourceEncoderTest.java


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