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


Java Mockito.inOrder方法代码示例

本文整理汇总了Java中org.mockito.Mockito.inOrder方法的典型用法代码示例。如果您正苦于以下问题:Java Mockito.inOrder方法的具体用法?Java Mockito.inOrder怎么用?Java Mockito.inOrder使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.mockito.Mockito的用法示例。


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

示例1: should_override_default_answer_for_spy_beans

import org.mockito.Mockito; //导入方法依赖的package包/类
@Test
public void should_override_default_answer_for_spy_beans() {
	//given
	final MockitoDoubleConfiguration configuration = configurationParser.parseSpyConfiguration(ANY_NAME, AnyTest.withAnswer());

	//when
	configuration.createMockSettings(mockSettings);

	//then
	final InOrder defaultAnswer = Mockito.inOrder(mockSettings);
	defaultAnswer
			.verify(mockSettings)
			.defaultAnswer(argThat(HasDefaultAnswer.hasAnswerOfType(CallsRealMethods.class)));

	defaultAnswer
			.verify(mockSettings)
			.defaultAnswer(argThat(HasDefaultAnswer.hasAnswerOfType(DoesNothing.class)));
}
 
开发者ID:pchudzik,项目名称:springmock,代码行数:19,代码来源:MockitoDoubleConfigurationParserTest.java

示例2: shouldSetContent

import org.mockito.Mockito; //导入方法依赖的package包/类
@Test
public void shouldSetContent() {
    // given
    String itemId = "content";
    SourcelistItemValue item = new SourcelistItemValue(SourcelistItemType.IMAGE, "value", itemId);

    when(sourceListManagerAdapter.getItemById(itemId)).thenReturn(item);

    // when
    presenter.setContent(itemId);

    // then
    InOrder inOrder = Mockito.inOrder(view, model);
    inOrder.verify(view).setItemContent(item, inlineBodyGeneratorSocket);
    inOrder.verify(model).addAnswer(itemId);
}
 
开发者ID:YoungDigitalPlanet,项目名称:empiria.player,代码行数:17,代码来源:DragGapPresenterImplJUnitTest.java

示例3: shouldNotifyClientsOnStateChanged_bothClients

import org.mockito.Mockito; //导入方法依赖的package包/类
@Test
public void shouldNotifyClientsOnStateChanged_bothClients() {
    // given
    StateChangeEvent event = mockStateChangeEvent(true, false);
    doAnswer(new Answer<Void>() {

        @Override
        public Void answer(InvocationOnMock invocation) throws Throwable {
            EndHandler handler = (EndHandler) invocation.getArguments()[0];
            handler.onEnd();
            return null;
        }
    }).when(tutor).processUserInteraction(any(EndHandler.class));
    mediator.registerTutor(tutor);
    mediator.registerBonus(bonus);

    // when
    stateChangedHandler.onStateChange(event);

    // then
    InOrder inOrder = Mockito.inOrder(tutor, bonus);
    inOrder.verify(tutor).processUserInteraction(any(EndHandler.class));
    inOrder.verify(bonus).processUserInteraction();
}
 
开发者ID:YoungDigitalPlanet,项目名称:empiria.player,代码行数:25,代码来源:PowerFeedbackMediatorTest.java

示例4: shouldBuildViewAndInitializeSubModules

import org.mockito.Mockito; //导入方法依赖的package包/类
@Test
public void shouldBuildViewAndInitializeSubModules() throws Exception {
    // given
    InlineBodyGeneratorSocket bodyGenerator = Mockito.mock(InlineBodyGeneratorSocket.class);
    when(socket.getInlineBodyGeneratorSocket()).thenReturn(bodyGenerator);

    List<String> itemsOrder = Lists.newArrayList("item1", "item2");
    when(orderingItemsDao.getItemsOrder()).thenReturn(itemsOrder);

    List<String> responseAnswers = Lists.newArrayList("resp1", "resp2");
    when(itemsResponseOrderController.getResponseAnswersByItemsOrder(itemsOrder)).thenReturn(responseAnswers);

    // when
    testObj.bindView();

    // then
    InOrder inOrder = Mockito.inOrder(interactionView, itemsMarkingController, itemsResponseOrderController, orderInteractionModuleFactory, viewBuilder,
            orderingResetController, showingAnswersController);
    inOrder.verify(viewBuilder).buildView(bean, bodyGenerator);
    inOrder.verify(itemsResponseOrderController).updateResponseWithNewOrder(itemsOrder);
    inOrder.verify(orderingResetController).reset();
    inOrder.verify(interactionView).setChildrenOrder(itemsOrder);
}
 
开发者ID:YoungDigitalPlanet,项目名称:empiria.player,代码行数:24,代码来源:OrderInteractionPresenterImplTest.java

示例5: shouldUpdateitemsorder

import org.mockito.Mockito; //导入方法依赖的package包/类
@Test
public void shouldUpdateitemsorder() {
    // given
    List<String> itemsOrder = Lists.newArrayList("a", "b");

    // when
    testObj.updateItemsOrder(itemsOrder);

    // then
    InOrder inOrder = Mockito.inOrder(orderingItemsDao, interactionView, itemsResponseOrderController, model);
    inOrder.verify(orderingItemsDao).setItemsOrder(itemsOrder);
    inOrder.verify(interactionView).setChildStyles(item1);
    inOrder.verify(interactionView).setChildStyles(item2);
    inOrder.verify(interactionView).setChildrenOrder(itemsOrder);
    inOrder.verify(itemsResponseOrderController).updateResponseWithNewOrder(itemsOrder);
    inOrder.verify(model).onModelChange();
}
 
开发者ID:YoungDigitalPlanet,项目名称:empiria.player,代码行数:18,代码来源:OrderInteractionPresenterImplTest.java

示例6: canVisitOldestDirsFirst

import org.mockito.Mockito; //导入方法依赖的package包/类
@Test
public void canVisitOldestDirsFirst()
{
    File cacheRoot = new File(TempFileProvider.getTempDir(), GUID.generate());
    cacheRoot.deleteOnExit();
    contentCache.setCacheRoot(cacheRoot);
    
    File f1 = tempfile(createDirs("2000/3/30/17/45/31"), "files-are-unsorted.bin");
    File f2 = tempfile(createDirs("2000/3/4/17/45/31"), "another-file.bin");
    File f3 = tempfile(createDirs("2010/12/24/23/59/58"), "a-second-before.bin");
    File f4 = tempfile(createDirs("2010/12/24/23/59/59"), "last-one.bin");
    File f5 = tempfile(createDirs("2000/1/7/2/7/12"), "first-one.bin");
    
    // Check that directories and files are visited in correct order
    FileHandler handler = Mockito.mock(FileHandler.class);
    contentCache.processFiles(handler);
    
    InOrder inOrder = Mockito.inOrder(handler);
    inOrder.verify(handler).handle(f5);
    inOrder.verify(handler).handle(f2);
    inOrder.verify(handler).handle(f1);
    inOrder.verify(handler).handle(f3);
    inOrder.verify(handler).handle(f4);
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:25,代码来源:ContentCacheImplTest.java

示例7: shutdownGracefullyPropagatesAwaitInterrupt

import org.mockito.Mockito; //导入方法依赖的package包/类
@Test
public void shutdownGracefullyPropagatesAwaitInterrupt() throws Exception {
    final Server server = mock(Server.class);
    final long maxWaitTimeInMillis = ThreadLocalRandom.current().nextLong(1, 10000);

    final InterruptedException interruptedException = new InterruptedException();

    when(server.awaitTermination(anyLong(), any())).thenThrow(interruptedException);

    assertThatThrownBy(() -> Servers.shutdownGracefully(server, maxWaitTimeInMillis))
            .isSameAs(interruptedException);

    InOrder inOrder = Mockito.inOrder(server);

    inOrder.verify(server).shutdown();
    inOrder.verify(server).awaitTermination(eq(maxWaitTimeInMillis), eq(TimeUnit.MILLISECONDS));
    inOrder.verify(server).shutdownNow();
}
 
开发者ID:salesforce,项目名称:grpc-java-contrib,代码行数:19,代码来源:ServersTest.java

示例8: testPresenterLifeCycleIsRespectedOnStart

import org.mockito.Mockito; //导入方法依赖的package包/类
@Test
public void testPresenterLifeCycleIsRespectedOnStart()
{
    final Presenter presenter = Mockito.spy(Presenter.class);
    final ActivityTest activity = Mockito.spy(new ActivityTest());

    activity.onLoadFinished(null, presenter);
    activity.onStart();

    // Verify onViewAttached and onStart are called in right order
    final InOrder inOrder = Mockito.inOrder(presenter);
    inOrder.verify(presenter).onViewAttached(Mockito.eq(activity));
    inOrder.verify(presenter).onStart(Mockito.anyBoolean());
}
 
开发者ID:benoitletondor,项目名称:mvp-core,代码行数:15,代码来源:BaseMVPActivityTest.java

示例9: test

import org.mockito.Mockito; //导入方法依赖的package包/类
@Test
public void test() {
  executor.execute();

  InOrder inOrder = Mockito.inOrder(handler, sensor);

  inOrder.verify(handler).onSensorsPhase(ArgumentMatchers.argThat(new EventMatcher(true)));
  inOrder.verify(sensor).analyse(project, context);
  inOrder.verify(handler).onSensorsPhase(ArgumentMatchers.argThat(new EventMatcher(false)));
}
 
开发者ID:instalint-org,项目名称:instalint,代码行数:11,代码来源:AllSensorsExecutorTest.java

示例10: testAddingBundle

import org.mockito.Mockito; //导入方法依赖的package包/类
@Test
public void testAddingBundle() throws Exception {
    assertEquals(primaryValue, extensibleBundleTracker.addingBundle(bundle, bundleEvent).get());
    InOrder inOrder = Mockito.inOrder(primaryTracker, additionalTracker);
    inOrder.verify(primaryTracker).addingBundle(bundle, bundleEvent);
    inOrder.verify(additionalTracker).addingBundle(bundle, bundleEvent);
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:8,代码来源:ExtensibleBundleTrackerTest.java

示例11: shouldSetLockedAndUpdateStylesOnView

import org.mockito.Mockito; //导入方法依赖的package包/类
@Test
public void shouldSetLockedAndUpdateStylesOnView() throws Exception {
    testObj.setLocked(true);

    InOrder inOrder = Mockito.inOrder(item1, item2, interactionView);
    inOrder.verify(item1).setLocked(true);
    inOrder.verify(item2).setLocked(true);
    inOrder.verify(interactionView).setChildStyles(item1);
    inOrder.verify(interactionView).setChildStyles(item2);
}
 
开发者ID:YoungDigitalPlanet,项目名称:empiria.player,代码行数:11,代码来源:OrderInteractionPresenterImplTest.java

示例12: testPresenterLifeCycleIsRespectedOnStop

import org.mockito.Mockito; //导入方法依赖的package包/类
@Test
public void testPresenterLifeCycleIsRespectedOnStop()
{
    final Presenter presenter = Mockito.spy(Presenter.class);
    final ActivityTest activity = Mockito.spy(new ActivityTest());

    activity.onLoadFinished(null, presenter);
    activity.onStart();
    activity.onStop();

    // Verify onStop and onViewDetached are called in right order
    final InOrder inOrder = Mockito.inOrder(presenter);
    inOrder.verify(presenter).onStop();
    inOrder.verify(presenter).onViewDetached();
}
 
开发者ID:benoitletondor,项目名称:mvp-core,代码行数:16,代码来源:BaseMVPActivityTest.java

示例13: testClientFromFactory

import org.mockito.Mockito; //导入方法依赖的package包/类
@Test
public void testClientFromFactory() {
    AmazonSQSClient sqs = Mockito.mock(AmazonSQSClient.class);
    SqsMessage m = new SqsMessage(RECEIPT_HANDLE, new byte[] {}, 1000, Optional.empty(),
            new SqsMessage.Service(Optional.empty(), () -> sqs, Optional.empty(), sqs, QUEUE,
                    Optional.empty()));
    Mockito.when(sqs.deleteMessage(QUEUE, RECEIPT_HANDLE))
            .thenReturn(new DeleteMessageResult());
    m.deleteMessage(Client.FROM_FACTORY);
    InOrder inorder = Mockito.inOrder(sqs);
    inorder.verify(sqs, Mockito.times(1)).deleteMessage(QUEUE, RECEIPT_HANDLE);
    inorder.verify(sqs, Mockito.times(1)).shutdown();
    Mockito.verifyNoMoreInteractions(sqs);
}
 
开发者ID:davidmoten,项目名称:rxjava2-aws,代码行数:15,代码来源:SqsMessageTest.java

示例14: testPresenterLifeCycleIsRespectedOnStart

import org.mockito.Mockito; //导入方法依赖的package包/类
@Test
public void testPresenterLifeCycleIsRespectedOnStart()
{
    final Presenter presenter = Mockito.spy(Presenter.class);
    final FragmentTest activity = Mockito.spy(new FragmentTest());

    activity.onLoadFinished(null, presenter);
    activity.onStart();

    // Verify onViewAttached and onStart are called in right order
    final InOrder inOrder = Mockito.inOrder(presenter);
    inOrder.verify(presenter).onViewAttached(Mockito.eq(activity));
    inOrder.verify(presenter).onStart(Mockito.anyBoolean());
}
 
开发者ID:benoitletondor,项目名称:mvp-core,代码行数:15,代码来源:BaseMVPFragmentTest.java

示例15: reports_ill_during_initial_replay

import org.mockito.Mockito; //导入方法依赖的package包/类
@Test
public void reports_ill_during_initial_replay() throws Exception {
    BlockingEventHandler eventProcessing = new BlockingEventHandler();
    store.write(stream, Arrays.asList(newEvent(), newEvent(), newEvent()));
    subscription = subscription(EndToEndTest::deserialize, eventProcessing);
    subscription.start();

    eventually(() -> {
        assertThat(subscription.health().get(), is(ill));
        assertThat(statusComponent().getReport(), is(new Report(OK, "Stale, catching up. No events processed yet. (Stale for PT0S)")));
    });

    eventProcessing.allowProcessing(1);
    eventually(() -> {
        assertThat(statusComponent().getReport(), is(new Report(OK, "Stale, catching up. Currently at version 1. (Stale for PT0S)")));
    });

    clock.bumpSeconds(123);
    eventProcessing.allowProcessing(2);

    eventually(() -> {
        assertThat(subscription.health().get(), is(healthy));
        assertThat(statusComponent().getReport(), is(new Report(OK, "Caught up at version 3. Initial replay took PT2M3S")));
        assertThat(eventSink.events(), Contains.only(StructuredEventMatcher.ofType("InitialReplayCompleted")));
    });

    InOrder inOrder = Mockito.inOrder(listener);
    inOrder.verify(listener, Mockito.atLeastOnce()).staleAtVersion(Mockito.eq(Optional.empty()));
    inOrder.verify(listener, Mockito.atLeastOnce()).caughtUpAt(argThat(inMemoryPosition(3)));
    Mockito.verify(listener, Mockito.never()).terminated(Mockito.any(), Mockito.any());
}
 
开发者ID:tim-group,项目名称:tg-eventstore,代码行数:32,代码来源:EndToEndTest.java


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