Java 类org.mockito.internal.stubbing.answers.DoesNothing 实例源码

项目:springmock    文件:MockitoDoubleConfigurationParserTest.java   
@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)));
}
项目:android-buruberi    文件:Testing.java   
public static OperationTimeout createMockOperationTimeout() {
    return mock(OperationTimeout.class, new DoesNothing());
}
项目:cassandra-maven-plugin    文件:CqlExecCassandraMojoPowerMockTest.java   
private ArgumentCaptor<ThriftApiOperation> mockThriftExecution() {
    return mockThriftExecutionWith(new DoesNothing());
}
项目:astor    文件:VoidMethodStubbableImpl.java   
public VoidMethodStubbable<T> toReturn() {
    invocationContainerImpl.addAnswerForVoidMethod(new DoesNothing());
    return this;
}
项目:astor    文件:StubberImpl.java   
public Stubber doNothing() {
    answers.add(new DoesNothing());
    return this;
}
项目:astor    文件:VoidMethodStubbableImpl.java   
public VoidMethodStubbable<T> toReturn() {
    invocationContainerImpl.addAnswerForVoidMethod(new DoesNothing());
    return this;
}
项目:powermock    文件:PowerMockito.java   
/**
 * Use doNothing() for setting void methods to do nothing. <b>Beware that
 * void methods on mocks do nothing by default!</b> However, there are rare
 * situations when doNothing() comes handy:
 * <p>
 * 1. Stubbing consecutive calls on a void method:
 *
 * <pre>
 * doNothing().doThrow(new RuntimeException()).when(mock).someVoidMethod();
 *
 * //does nothing the first time:
 * mock.someVoidMethod();
 *
 * //throws RuntimeException the next time:
 * mock.someVoidMethod();
 * </pre>
 *
 * 2. When you spy real objects and you want the void method to do nothing:
 *
 * <pre>
 * List list = new LinkedList();
 * List spy = spy(list);
 *
 * //let's make clear() do nothing
 * doNothing().when(spy).clear();
 *
 * spy.add(&quot;one&quot;);
 *
 * //clear() does nothing, so the list still contains &quot;one&quot;
 * spy.clear();
 * </pre>
 * <p>
 * See examples in javadoc for {@link Mockito} class
 *
 * @return stubber - to select a method for stubbing
 */
public static PowerMockitoStubber doNothing() {
    return POWERMOCKITO_CORE.doAnswer(new DoesNothing());
}
项目:astor    文件:Mockito.java   
/**
 * Use doNothing() for setting void methods to do nothing. <b>Beware that void methods on mocks do nothing by default!</b> 
 * However, there are rare situations when doNothing() comes handy:  
 * <p>
 * 1. Stubbing consecutive calls on a void method:
 * <pre>
 *   doNothing().
 *   doThrow(new RuntimeException())
 *   .when(mock).someVoidMethod();
 *   
 *   //does nothing the first time:
 *   mock.someVoidMethod();
 *   
 *   //throws RuntimeException the next time:
 *   mock.someVoidMethod();
 * </pre>
 * 
 * 2. When you spy real objects and you want the void method to do nothing:
 * <pre>
 *   List list = new LinkedList();
 *   List spy = spy(list);
 *   
 *   //let's make clear() do nothing
 *   doNothing().when(spy).clear();
 *   
 *   spy.add("one");
 *   
 *   //clear() does nothing, so the list still contains "one"
 *   spy.clear();
 * </pre>
 * <p>
 * See examples in javadoc for {@link Mockito} class
 *   
 * @return stubber - to select a method for stubbing
 */
public static Stubber doNothing() {
    return MOCKITO_CORE.doAnswer(new DoesNothing());
}