Java 类org.mockito.stubbing.DeprecatedOngoingStubbing 实例源码

项目:teiid    文件:TestExecutionReuse.java   
@Before public void setup() throws DataNotAvailableException, TranslatorException {
    execution = Mockito.mock(FakeReusableExecution.class);
    ec = null;
    DeprecatedOngoingStubbing stubbing = Mockito.stub(execution.next()).toReturn((List) Arrays.asList((Object)null)).toReturn(null);
    for (int i = 1; i < EXEC_COUNT; i++) {
        stubbing.toReturn(Arrays.asList((Object)null)).toReturn(null);
    }
    Mockito.doAnswer(new Answer<Void>() {
        @Override
        public Void answer(InvocationOnMock invocation) throws Throwable {
            synchronized (TestExecutionReuse.class) {
                isDisposed = true;
                TestExecutionReuse.class.notify();
            }
            return null;
        }
    }).when(execution).dispose();
}
项目:securemock    文件:Mockito.java   
public static <T> DeprecatedOngoingStubbing<T> stub(final T methodCall) {
    return AccessController.doPrivileged(new PrivilegedAction<DeprecatedOngoingStubbing<T>>() {
        @Override
        public DeprecatedOngoingStubbing<T> run() {
            return org.mockito.Mockito.stub(methodCall);
        }
    });
}
项目:astor    文件:MockitoCore.java   
public <T> DeprecatedOngoingStubbing<T> stub(T methodCall) {
    mockingProgress.stubbingStarted();
    return (DeprecatedOngoingStubbing) stub();
}
项目:astor    文件:OngoingStubbingImpl.java   
public DeprecatedOngoingStubbing<T> toAnswer(Answer<?> answer) {
    invocationContainerImpl.addAnswer(answer);
    return new ConsecutiveStubbing<T>(invocationContainerImpl);
}
项目:astor    文件:ConsecutiveStubbing.java   
public DeprecatedOngoingStubbing<T> toAnswer(Answer<?> answer) {
    invocationContainerImpl.addConsecutiveAnswer(answer);
    return this;
}
项目:astor    文件:BaseStubbing.java   
public DeprecatedOngoingStubbing<T> toReturn(T value) {
    return toAnswer(new Returns(value));
}
项目:astor    文件:BaseStubbing.java   
public DeprecatedOngoingStubbing<T> toThrow(Throwable throwable) {
    return toAnswer(new ThrowsException(throwable));
}
项目:astor    文件:MockitoCore.java   
public <T> DeprecatedOngoingStubbing<T> stub(T methodCall) {
    mockingProgress.stubbingStarted();
    return (DeprecatedOngoingStubbing) stub();
}
项目:astor    文件:OngoingStubbingImpl.java   
public DeprecatedOngoingStubbing<T> toAnswer(Answer<?> answer) {
    invocationContainerImpl.addAnswer(answer);
    return new ConsecutiveStubbing<T>(invocationContainerImpl);
}
项目:astor    文件:ConsecutiveStubbing.java   
public DeprecatedOngoingStubbing<T> toAnswer(Answer<?> answer) {
    invocationContainerImpl.addConsecutiveAnswer(answer);
    return this;
}
项目:astor    文件:BaseStubbing.java   
public DeprecatedOngoingStubbing<T> toReturn(T value) {
    return toAnswer(new Returns(value));
}
项目:astor    文件:BaseStubbing.java   
public DeprecatedOngoingStubbing<T> toThrow(Throwable throwable) {
    return toAnswer(new ThrowsException(throwable));
}
项目:interface-it    文件:MockitoMixinWithSupertype.java   
/**
 * Delegate call to public static <T> org.mockito.stubbing.DeprecatedOngoingStubbing<T> org.mockito.Mockito.stub(T)
 * {@link org.mockito.Mockito#stub(java.lang.Object)}
 */
default <T> DeprecatedOngoingStubbing<T> stub(T methodCall) {
    return Mockito.stub(methodCall);
}
项目:interface-it    文件:Mockito.java   
/**
 * Delegate call to public static <T> org.mockito.stubbing.DeprecatedOngoingStubbing<T> org.mockito.Mockito.stub(T)
 * {@link org.mockito.Mockito#stub(java.lang.Object)}
 */
default <T> DeprecatedOngoingStubbing<T> stub(T methodCall) {
    return org.mockito.Mockito.stub(methodCall);
}
项目:astor    文件:Mockito.java   
/**
 * Stubs a method call with return value or an exception. E.g:
 *
 * <pre>
 * stub(mock.someMethod()).toReturn(10);
 *
 * //you can use flexible argument matchers, e.g:
 * stub(mock.someMethod(<b>anyString()</b>)).toReturn(10);
 *
 * //setting exception to be thrown:
 * stub(mock.someMethod("some arg")).toThrow(new RuntimeException());
 *
 * //you can stub with different behavior for consecutive method calls.
 * //Last stubbing (e.g: toReturn("foo")) determines the behavior for further consecutive calls.
 * stub(mock.someMethod("some arg"))
 *  .toThrow(new RuntimeException())
 *  .toReturn("foo");
 * </pre>
 * <p>
 * Some users find stub() confusing therefore {@link Mockito#when(Object)} is recommended over stub()
 * <pre>
 *   //Instead of:
 *   stub(mock.count()).toReturn(10);
 * 
 *   //You can do:
 *   when(mock.count()).thenReturn(10);
 * </pre> 
 * For stubbing void methods with throwables see: {@link Mockito#doThrow(Throwable)}
 * <p>
 * Stubbing can be overridden: for example common stubbing can go to fixture
 * setup but the test methods can override it.
 * Please note that overridding stubbing is a potential code smell that points out too much stubbing.
 * <p>
 * Once stubbed, the method will always return stubbed value regardless
 * of how many times it is called.
 * <p>
 * Last stubbing is more important - when you stubbed the same method with
 * the same arguments many times.
 * <p>
 * Although it is possible to verify a stubbed invocation, usually <b>it's just redundant</b>.
 * Let's say you've stubbed foo.bar(). 
 * If your code cares what foo.bar() returns then something else breaks(often before even verify() gets executed).
 * If your code doesn't care what get(0) returns then it should not be stubbed. 
 * Not convinced? See <a href="http://monkeyisland.pl/2008/04/26/asking-and-telling">here</a>. 
 * 
 * @param methodCall
 *            method call
 * @return DeprecatedOngoingStubbing object to set stubbed value/exception
 */
public static <T> DeprecatedOngoingStubbing<T> stub(T methodCall) {
    return MOCKITO_CORE.stub(methodCall);
}