本文整理了Java中org.mockito.Mockito.clearInvocations()
方法的一些代码示例,展示了Mockito.clearInvocations()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Mockito.clearInvocations()
方法的具体详情如下:
包路径:org.mockito.Mockito
类名称:Mockito
方法名:clearInvocations
[英]Use this method in order to only clear invocations, when stubbing is non-trivial. Use-cases can be:
代码示例来源:origin: apache/storm
private KafkaSpoutMessageId emitOne() {
ArgumentCaptor<KafkaSpoutMessageId> messageId = ArgumentCaptor.forClass(KafkaSpoutMessageId.class);
spout.nextTuple();
verify(collector).emit(anyString(), anyList(), messageId.capture());
clearInvocations(collector);
return messageId.getValue();
}
代码示例来源:origin: iSoron/uhabits
@Override
public void setUp() throws Exception
{
super.setUp();
behavior =
new ListHabitsMenuBehavior(screen, adapter, prefs, themeSwitcher);
clearInvocations(adapter);
}
代码示例来源:origin: apache/storm
inOrder.verify(listenerMock).onPartitionsAssigned(new HashSet<>(onePartition));
clearInvocations(consumerMock, listenerMock);
代码示例来源:origin: iSoron/uhabits
@Test
public void testOnToggleShowCompleted()
{
behavior.onToggleShowCompleted();
verify(adapter).setFilter(matcherCaptor.capture());
assertTrue(matcherCaptor.getValue().isCompletedAllowed());
clearInvocations(adapter);
behavior.onToggleShowCompleted();
verify(adapter).setFilter(matcherCaptor.capture());
assertFalse(matcherCaptor.getValue().isCompletedAllowed());
}
代码示例来源:origin: iSoron/uhabits
@Test
public void testOnToggleShowArchived()
{
behavior.onToggleShowArchived();
verify(adapter).setFilter(matcherCaptor.capture());
assertTrue(matcherCaptor.getValue().isArchivedAllowed());
clearInvocations(adapter);
behavior.onToggleShowArchived();
verify(adapter).setFilter(matcherCaptor.capture());
assertFalse(matcherCaptor.getValue().isArchivedAllowed());
}
代码示例来源:origin: apache/geode
@Before
public void setUp() {
MessageFactory messageFactory = new ParameterizedMessageFactory();
mockedLogger = mock(ExtendedLogger.class);
mockedMarker = mock(Marker.class);
when(mockedLogger.getMessageFactory()).thenReturn(messageFactory);
when(mockedLogger.getName()).thenReturn(LOGGER_NAME);
when(mockedLogger.getLevel()).thenReturn(Level.INFO);
when(mockedMarker.getName()).thenReturn(MARKER_NAME);
fastLogger = new FastLogger(mockedLogger);
FastLogger.setDelegating(true);
clearInvocations(mockedLogger);
assertThat(mockedLogger.getLevel()).isEqualTo(Level.INFO);
}
代码示例来源:origin: confluentinc/ksql
@Test
public void shouldResetStatusMessage() {
// Given:
final StatusClosable closable = terminal.setStatusMessage("test message");
clearInvocations(statusBar);
// When:
closable.close();
// Then:
verify(statusBar)
.update(ImmutableList.of(new AttributedString("", AttributedStyle.DEFAULT)));
}
}
代码示例来源:origin: apache/storm
clearInvocations(collectorMock);
Time.advanceTime(KafkaSpout.TIMER_DELAY_MS + commitOffsetPeriodMs);
spout.ack(failedIdReplayCaptor.getValue());
代码示例来源:origin: iSoron/uhabits
@Test
public void testInitialFilter()
{
when(prefs.getShowArchived()).thenReturn(true);
when(prefs.getShowCompleted()).thenReturn(true);
behavior =
new ListHabitsMenuBehavior(screen, adapter, prefs, themeSwitcher);
verify(adapter).setFilter(matcherCaptor.capture());
verify(adapter).refresh();
verifyNoMoreInteractions(adapter);
clearInvocations(adapter);
assertTrue(matcherCaptor.getValue().isArchivedAllowed());
assertTrue(matcherCaptor.getValue().isCompletedAllowed());
when(prefs.getShowArchived()).thenReturn(false);
when(prefs.getShowCompleted()).thenReturn(false);
behavior =
new ListHabitsMenuBehavior(screen, adapter, prefs, themeSwitcher);
verify(adapter).setFilter(matcherCaptor.capture());
verify(adapter).refresh();
verifyNoMoreInteractions(adapter);
assertFalse(matcherCaptor.getValue().isArchivedAllowed());
assertFalse(matcherCaptor.getValue().isCompletedAllowed());
}
代码示例来源:origin: apache/storm
@Test
public void testAtMostOnceModeDoesNotCommitAckedTuples() throws Exception {
//When tuple tracking is enabled, the spout must not commit acked tuples in at-most-once mode because they were committed before being emitted
KafkaSpoutConfig<String, String> spoutConfig = createKafkaSpoutConfigBuilder(mock(TopicFilter.class), mock(ManualPartitioner.class), -1)
.setProcessingGuarantee(KafkaSpoutConfig.ProcessingGuarantee.AT_MOST_ONCE)
.setTupleTrackingEnforced(true)
.build();
try (SimulatedTime time = new SimulatedTime()) {
KafkaSpout<String, String> spout = SpoutWithMockedConsumerSetupHelper.setupSpout(spoutConfig, conf, contextMock, collectorMock, consumerMock, partition);
when(consumerMock.poll(anyLong())).thenReturn(new ConsumerRecords<>(Collections.singletonMap(partition,
SpoutWithMockedConsumerSetupHelper.createRecords(partition, 0, 1))));
spout.nextTuple();
clearInvocations(consumerMock);
ArgumentCaptor<KafkaSpoutMessageId> msgIdCaptor = ArgumentCaptor.forClass(KafkaSpoutMessageId.class);
verify(collectorMock).emit(eq(SingleTopicKafkaSpoutConfiguration.STREAM), anyList(), msgIdCaptor.capture());
assertThat("Should have captured a message id", msgIdCaptor.getValue(), not(nullValue()));
spout.ack(msgIdCaptor.getValue());
Time.advanceTime(KafkaSpout.TIMER_DELAY_MS + spoutConfig.getOffsetsCommitPeriodMs());
when(consumerMock.poll(anyLong())).thenReturn(new ConsumerRecords<>(Collections.emptyMap()));
spout.nextTuple();
verify(consumerMock, never()).commitSync(argThat((Map<TopicPartition, OffsetAndMetadata> arg) -> {
return !arg.containsKey(partition);
}));
}
}
代码示例来源:origin: apache/storm
clearInvocations(consumerSpy);
clearInvocations(collector);
spout.nextTuple();
verify(collector, never()).emit(any(), any(), any());
代码示例来源:origin: iSoron/uhabits
@Override
@Before
public void setUp() throws Exception
{
super.setUp();
habit1 = fixtures.createShortHabit();
habit2 = fixtures.createNumericalHabit();
habitList.add(habit1);
habitList.add(habit2);
clearInvocations(habitList);
behavior = new ListHabitsBehavior(habitList, dirFinder, taskRunner, screen,
commandRunner, prefs, bugReporter);
}
代码示例来源:origin: stripe/stripe-android
@Test
public void addVisaPrefix_callsBrandListener() {
// We reset because just attaching the listener calls the method once.
clearInvocations(mCardBrandChangeListener);
// There is only one Visa Prefix.
mCardNumberEditText.append(Card.PREFIXES_VISA[0]);
verify(mCardBrandChangeListener, times(1)).onCardBrandChanged(Card.VISA);
}
代码示例来源:origin: stripe/stripe-android
@Test
public void enterCompleteNumberInParts_onlyCallsBrandListenerOnce() {
clearInvocations(mCardBrandChangeListener);
String prefix = VALID_AMEX_WITH_SPACES.substring(0, 2);
String suffix = VALID_AMEX_WITH_SPACES.substring(2);
mCardNumberEditText.append(prefix);
mCardNumberEditText.append(suffix);
verify(mCardBrandChangeListener, times(1)).onCardBrandChanged(Card.AMERICAN_EXPRESS);
}
代码示例来源:origin: stripe/stripe-android
@Test
public void enterBrandPrefix_thenClearAllText_callsUpdateWithUnknown() {
clearInvocations(mCardBrandChangeListener);
String prefixVisa = Card.PREFIXES_VISA[0];
mCardNumberEditText.append(prefixVisa);
verify(mCardBrandChangeListener, times(1)).onCardBrandChanged(Card.VISA);
// Just adding some other text. Not enough to invalidate the card or complete it.
mCardNumberEditText.append("123");
verify(mCardBrandChangeListener, times(0)).onCardBrandChanged(Card.UNKNOWN);
// This simulates the user selecting all text and deleting it.
mCardNumberEditText.setText("");
verify(mCardBrandChangeListener, times(1)).onCardBrandChanged(Card.UNKNOWN);
}
代码示例来源:origin: stripe/stripe-android
@Test
public void addDinersClubPrefix_callsBrandListener() {
for (String prefix : Card.PREFIXES_DINERS_CLUB) {
clearInvocations(mCardBrandChangeListener);
mCardNumberEditText.append(prefix);
verify(mCardBrandChangeListener, times(1)).onCardBrandChanged(Card.DINERS_CLUB);
mCardNumberEditText.setText("");
}
}
代码示例来源:origin: stripe/stripe-android
@Test
public void addAmExPrefix_callsBrandListener() {
for (String prefix : Card.PREFIXES_AMERICAN_EXPRESS) {
// Reset inside the loop so we don't count each prefix
clearInvocations(mCardBrandChangeListener);
mCardNumberEditText.append(prefix);
verify(mCardBrandChangeListener, times(1)).onCardBrandChanged(Card.AMERICAN_EXPRESS);
mCardNumberEditText.setText("");
}
}
代码示例来源:origin: stripe/stripe-android
@Test
public void addMasterCardPrefix_callsBrandListener() {
for (String prefix : Card.PREFIXES_MASTERCARD) {
clearInvocations(mCardBrandChangeListener);
mCardNumberEditText.append(prefix);
verify(mCardBrandChangeListener, times(1)).onCardBrandChanged(Card.MASTERCARD);
mCardNumberEditText.setText("");
}
}
代码示例来源:origin: stripe/stripe-android
@Test
public void addJCBPrefix_callsBrandListener() {
for (String prefix : Card.PREFIXES_JCB) {
clearInvocations(mCardBrandChangeListener);
mCardNumberEditText.append(prefix);
verify(mCardBrandChangeListener, times(1)).onCardBrandChanged(Card.JCB);
mCardNumberEditText.setText("");
}
}
代码示例来源:origin: stripe/stripe-android
@Test
public void addDiscoverPrefix_callsBrandListener() {
for (String prefix : Card.PREFIXES_DISCOVER) {
clearInvocations(mCardBrandChangeListener);
mCardNumberEditText.append(prefix);
verify(mCardBrandChangeListener, times(1)).onCardBrandChanged(Card.DISCOVER);
mCardNumberEditText.setText("");
}
}
内容来源于网络,如有侵权,请联系作者删除!