當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。