當前位置: 首頁>>代碼示例>>Java>>正文


Java Mockito.verifyNoMoreInteractions方法代碼示例

本文整理匯總了Java中org.mockito.Mockito.verifyNoMoreInteractions方法的典型用法代碼示例。如果您正苦於以下問題:Java Mockito.verifyNoMoreInteractions方法的具體用法?Java Mockito.verifyNoMoreInteractions怎麽用?Java Mockito.verifyNoMoreInteractions使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.mockito.Mockito的用法示例。


在下文中一共展示了Mockito.verifyNoMoreInteractions方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: testOnDrag

import org.mockito.Mockito; //導入方法依賴的package包/類
@Test
public void testOnDrag() {
    Mockito.verify(mMockController).getClipDataHelper();

    assertThat(mOnDragToTrashListener.onDrag(null, mBlockDragStartFromWorkspace)).isTrue();
    Mockito.verifyNoMoreInteractions(mMockController);

    mOnDragToTrashListener.onDrag(null, mBlockDragEntered);
    Mockito.verifyNoMoreInteractions(mMockController);

    mOnDragToTrashListener.onDrag(null, mBlockDragLocation);
    Mockito.verifyNoMoreInteractions(mMockController);

    mOnDragToTrashListener.onDrag(null, mBlockDragExited);
    Mockito.verifyNoMoreInteractions(mMockController);

    assertThat(mOnDragToTrashListener.onDrag(null, mBlockDrop)).isTrue();
    Mockito.verify(mMockController)
            .trashRootBlock(Mockito.any(Block.class));

    mOnDragToTrashListener.onDrag(null, mBlockDragEnded);
    Mockito.verifyNoMoreInteractions(mMockController);
}
 
開發者ID:Axe-Ishmael,項目名稱:Blockly,代碼行數:24,代碼來源:OnDragToTrashListenerTest.java

示例2: testOnSuccessThrowsError

import org.mockito.Mockito; //導入方法依賴的package包/類
@GwtIncompatible // Mockito
public void testOnSuccessThrowsError() throws Exception {
  class TestError extends Error {}
  TestError error = new TestError();
  String result = "result";
  SettableFuture<String> future = SettableFuture.create();
  @SuppressWarnings("unchecked") // Safe for a mock
  FutureCallback<String> callback = Mockito.mock(FutureCallback.class);
  addCallback(future, callback, directExecutor());
  Mockito.doThrow(error).when(callback).onSuccess(result);
  try {
    future.set(result);
    fail("Should have thrown");
  } catch (TestError e) {
    assertSame(error, e);
  }
  assertEquals(result, future.get());
  Mockito.verify(callback).onSuccess(result);
  Mockito.verifyNoMoreInteractions(callback);
}
 
開發者ID:zugzug90,項目名稱:guava-mock,代碼行數:21,代碼來源:FutureCallbackTest.java

示例3: testHandleReceiveRemoveEndpoint

import org.mockito.Mockito; //導入方法依賴的package包/類
@Test
public void testHandleReceiveRemoveEndpoint() throws Exception {
    final Map<Address, Optional<RemoteRpcEndpoint>> endpoints = ImmutableMap.of(
            endpointAddress, Optional.empty());
    testActorRef.tell(new UpdateRemoteEndpoints(endpoints), ActorRef.noSender());
    Mockito.verifyNoMoreInteractions(service, oldReg, newReg);
}
 
開發者ID:hashsdn,項目名稱:hashsdn-controller,代碼行數:8,代碼來源:RpcRegistrarTest.java

示例4: setTypeFaceForDismissButtonNullTypeFaceTest

import org.mockito.Mockito; //導入方法依賴的package包/類
@Test
public void setTypeFaceForDismissButtonNullTypeFaceTest() {
    Mockito.when(mTypeFaceProvider.getTypeFaceFromAssets(Matchers.anyString())).thenReturn(null);

    mPopUpCoachMarkPresenter.setTypeFaceForDismissButton(Matchers.anyString());

    Mockito.verify(mTypeFaceProvider, Mockito.times(1)).getTypeFaceFromAssets(Matchers.anyString());
    Mockito.verify(mPopUpCoachMarkPresentation, Mockito.times(0))
            .setTypeFaceForDismissButton((Typeface) Matchers.anyObject());

    Mockito.verifyNoMoreInteractions(mPopUpCoachMarkPresentation);
}
 
開發者ID:myntra,項目名稱:CoachMarks,代碼行數:13,代碼來源:PopUpCoachMarkPresenterTest.java

示例5: batchInvokedWithTwoElements

import org.mockito.Mockito; //導入方法依賴的package包/類
@Test public void batchInvokedWithTwoElements() {
  Funnel.Batch<Integer, String> toSpell = funnel.through(batch::send);
  toSpell.accept(1);
  toSpell.accept(2);
  when(batch.send(asList(1, 2))).thenReturn(asList("one", "two"));
  assertThat(funnel.run()).containsExactly("one", "two").inOrder();
  Mockito.verify(batch).send(asList(1, 2));
  Mockito.verifyNoMoreInteractions(batch);
}
 
開發者ID:google,項目名稱:mug,代碼行數:10,代碼來源:FunnelTest.java

示例6: 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

示例7: testBeforeParse

import org.mockito.Mockito; //導入方法依賴的package包/類
@Test
public void testBeforeParse() {
    Document parse = XMLParser.parse(Templates.TEMPLATE_WITHOUT_CONTENT_WITH_FULLSCREEN);
    instance = spy(factory.getImgTemplateParser(parse.getDocumentElement(), moduleSocket));
    instance.beforeParse(mock(Node.class), null);
    verify(instance).beforeParse(Matchers.any(Node.class), Matchers.any(Widget.class));
    Mockito.verifyNoMoreInteractions(instance);
}
 
開發者ID:YoungDigitalPlanet,項目名稱:empiria.player,代碼行數:9,代碼來源:ImgTemplateParserJUnitTest.java

示例8: batchInvokedWithAftereffect

import org.mockito.Mockito; //導入方法依賴的package包/類
@Test public void batchInvokedWithAftereffect() {
  Funnel.Batch<Integer, String> toSpell = funnel.through(batch::send);
  AtomicReference<String> spelled = new AtomicReference<>();
  toSpell.accept(1, spelled::set);
  toSpell.accept(2);
  when(batch.send(asList(1, 2))).thenReturn(asList("one", "two"));
  assertThat(funnel.run()).containsExactly("one", "two").inOrder();
  assertThat(spelled.get()).isEqualTo("one");
  Mockito.verify(batch).send(asList(1, 2));
  Mockito.verifyNoMoreInteractions(batch);
}
 
開發者ID:google,項目名稱:mug,代碼行數:12,代碼來源:FunnelTest.java

示例9: shouldNotSendDeleteRequestIfResultIsEmpty

import org.mockito.Mockito; //導入方法依賴的package包/類
@Test
public void shouldNotSendDeleteRequestIfResultIsEmpty() {
    final List<Message> messages = Collections.emptyList();
    Mockito.when(this.channel.getMessages()).thenReturn(messages);
    assertThat(this.monitor.add(this.listener)).isTrue();
    Mockito.verify(this.channel).getQueueUuid();
    Mockito.verify(this.listener).getQueueUuid();
    Mockito.verify(this.executor).execute(this.monitor);

    this.monitor.run();

    Mockito.verify(this.channel).getMessages();
    Mockito.verifyNoMoreInteractions(this.listener);
    Mockito.verify(this.executor, Mockito.times(2)).execute(this.monitor);
}
 
開發者ID:riboseinc,項目名稱:aws-codecommit-trigger-plugin,代碼行數:16,代碼來源:SQSQueueMonitorImplTest.java

示例10: testHandleReceiveAddEndpoint

import org.mockito.Mockito; //導入方法依賴的package包/類
@Test
public void testHandleReceiveAddEndpoint() throws Exception {
    final Map<Address, Optional<RemoteRpcEndpoint>> endpoints = ImmutableMap.of(
            endpointAddress, Optional.of(firstEndpoint));
    testActorRef.tell(new UpdateRemoteEndpoints(endpoints), ActorRef.noSender());

    Mockito.verify(service).registerRpcImplementation(
            Mockito.any(RemoteRpcImplementation.class), Mockito.eq(firstEndpoint.getRpcs()));
    Mockito.verifyNoMoreInteractions(service, oldReg, newReg);
}
 
開發者ID:hashsdn,項目名稱:hashsdn-controller,代碼行數:11,代碼來源:RpcRegistrarTest.java

示例11: shouldNotStopBeforeLastListenerRemoved

import org.mockito.Mockito; //導入方法依賴的package包/類
@Test
public void shouldNotStopBeforeLastListenerRemoved() {
    this.monitor.add(this.listener);
    this.monitor.add(this.listener);
    Mockito.verify(this.executor).execute(this.monitor);

    final boolean result = this.monitor.remove(this.listener);

    assertThat(result).isFalse();
    Mockito.verifyNoMoreInteractions(this.executor);
    assertThat(this.monitor.isShutDown()).isFalse();
}
 
開發者ID:riboseinc,項目名稱:aws-codecommit-trigger-plugin,代碼行數:13,代碼來源:SQSQueueMonitorImplTest.java

示例12: testFakeScheduledExecutorService_taskScheduleAnotherTask

import org.mockito.Mockito; //導入方法依賴的package包/類
@Test public void testFakeScheduledExecutorService_taskScheduleAnotherTask() {
  Runnable runnable = mock(Runnable.class);
  Runnable scheduled = () -> executor.schedule(runnable, 3, TimeUnit.MILLISECONDS);
  executor.schedule(scheduled, 2, TimeUnit.MILLISECONDS);
  elapse(Duration.ofMillis(2));
  elapse(Duration.ofMillis(3));
  verify(runnable).run();
  Mockito.verifyNoMoreInteractions(runnable);
}
 
開發者ID:google,項目名稱:mug,代碼行數:10,代碼來源:RetryerTest.java

示例13: deleteMessageFromFactoryWhenS3FactoryExists

import org.mockito.Mockito; //導入方法依賴的package包/類
@Test
public void deleteMessageFromFactoryWhenS3FactoryExists() {
    AmazonSQSClient sqs = Mockito.mock(AmazonSQSClient.class);
    AmazonS3Client s3 = Mockito.mock(AmazonS3Client.class);
    String s3Id = "123";
    SqsMessage m = new SqsMessage(RECEIPT_HANDLE, new byte[] {}, 1000, Optional.of(s3Id),
            new SqsMessage.Service(Optional.of(() -> s3), () -> sqs, Optional.of(s3), sqs,
                    QUEUE, Optional.of(BUCKET)));
    Mockito.when(sqs.deleteMessage(QUEUE, RECEIPT_HANDLE))
            .thenReturn(new DeleteMessageResult());
    m.deleteMessage(Client.FROM_FACTORY);
    InOrder inorder = Mockito.inOrder(sqs, s3);
    inorder.verify(s3, Mockito.times(1)).deleteObject(BUCKET, s3Id);
    inorder.verify(sqs, Mockito.times(1)).deleteMessage(QUEUE, RECEIPT_HANDLE);
    inorder.verify(s3, Mockito.times(1)).shutdown();
    inorder.verify(sqs, Mockito.times(1)).shutdown();
    Mockito.verifyNoMoreInteractions(sqs, s3);
}
 
開發者ID:davidmoten,項目名稱:rxjava2-aws,代碼行數:19,代碼來源:SqsMessageTest.java

示例14: testOnSuccessThrowsRuntimeException

import org.mockito.Mockito; //導入方法依賴的package包/類
@GwtIncompatible // Mockito
public void testOnSuccessThrowsRuntimeException() throws Exception {
  RuntimeException exception = new RuntimeException();
  String result = "result";
  SettableFuture<String> future = SettableFuture.create();
  @SuppressWarnings("unchecked") // Safe for a mock
  FutureCallback<String> callback = Mockito.mock(FutureCallback.class);
  addCallback(future, callback, directExecutor());
  Mockito.doThrow(exception).when(callback).onSuccess(result);
  future.set(result);
  assertEquals(result, future.get());
  Mockito.verify(callback).onSuccess(result);
  Mockito.verifyNoMoreInteractions(callback);
}
 
開發者ID:paul-hammant,項目名稱:googles-monorepo-demo,代碼行數:15,代碼來源:FutureCallbackTest.java

示例15: shouldStopIfLastListenerRemoved

import org.mockito.Mockito; //導入方法依賴的package包/類
@Test
public void shouldStopIfLastListenerRemoved() {
    this.monitor.add(this.listener);
    this.monitor.add(this.listener);
    this.monitor.remove(this.listener);
    Mockito.verify(this.executor).execute(this.monitor);

    final boolean result = this.monitor.remove(this.listener);

    assertThat(result).isTrue();
    Mockito.verifyNoMoreInteractions(this.executor);
    assertThat(this.monitor.isShutDown()).isTrue();
}
 
開發者ID:riboseinc,項目名稱:aws-codecommit-trigger-plugin,代碼行數:14,代碼來源:SQSQueueMonitorImplTest.java


注:本文中的org.mockito.Mockito.verifyNoMoreInteractions方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。