Java Code Examples for org.mockito.Mockito#doReturn()

The following examples show how to use org.mockito.Mockito#doReturn() . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
static <V> Stubber futureReturns(V value) {
  ListenableFuture<V> ret = Futures.immediateFuture(value);
  return Mockito.doReturn(ret);
}
 
Example 2
static Stubber futureThrows(Throwable t) {
  ListenableFuture<?> ret = Futures.immediateFailedFuture(t);
  return Mockito.doReturn(ret);
}
 
Example 3
static <V> Stubber futureReturns(V value) {
  ListenableFuture<V> ret = Futures.immediateFuture(value);
  return Mockito.doReturn(ret);
}
 
Example 4
static Stubber futureThrows(Throwable t) {
  ListenableFuture<?> ret = Futures.immediateFailedFuture(t);
  return Mockito.doReturn(ret);
}
 
Example 5
Source Project: mockito-java8   File: WithMockito.java    License: Apache License 2.0 4 votes vote down vote up
/**
 * Delegates call to {@link Mockito#doReturn(Object)}.
 */
default Stubber doReturn(Object toBeReturned) {
    return Mockito.doReturn(toBeReturned);
}
 
Example 6
Source Project: mockito-java8   File: WithMockito.java    License: Apache License 2.0 4 votes vote down vote up
/**
 * Delegates call to {@link Mockito#doReturn(Object, Object...)}.
 */
default Stubber doReturn(Object toBeReturned, Object... toBeReturnedNext) {
    return Mockito.doReturn(toBeReturned, toBeReturnedNext);
}
 
Example 7
Source Project: dexmaker   File: ExtendedMockito.java    License: Apache License 2.0 2 votes vote down vote up
/**
 * Same as {@link Mockito#doReturn(Object)} but adds the ability to stub static method calls
 * via {@link StaticCapableStubber#when(MockedMethod)} and
 * {@link StaticCapableStubber#when(MockedVoidMethod)}.
 */
public static StaticCapableStubber doReturn(Object toBeReturned) {
    return new StaticCapableStubber(Mockito.doReturn(toBeReturned));
}
 
Example 8
Source Project: dexmaker   File: ExtendedMockito.java    License: Apache License 2.0 2 votes vote down vote up
/**
 * Same as {@link Mockito#doReturn(Object, Object...)} but adds the ability to stub static
 * method calls via {@link StaticCapableStubber#when(MockedMethod)} and
 * {@link StaticCapableStubber#when(MockedVoidMethod)}.
 */
public static StaticCapableStubber doReturn(Object toBeReturned, Object... toBeReturnedNext) {
    return new StaticCapableStubber(Mockito.doReturn(toBeReturned, toBeReturnedNext));
}