本文整理汇总了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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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();
}
示例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);
}
示例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);
}
示例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);
}
示例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();
}