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

The following examples show how to use org.mockito.Mockito#doReturn() . 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
Source File: TestQuorumJournalManagerUnit.java    From hadoop with Apache License 2.0 4 votes vote down vote up
static <V> Stubber futureReturns(V value) {
  ListenableFuture<V> ret = Futures.immediateFuture(value);
  return Mockito.doReturn(ret);
}
 
Example 2
Source File: TestQuorumJournalManagerUnit.java    From hadoop with Apache License 2.0 4 votes vote down vote up
static Stubber futureThrows(Throwable t) {
  ListenableFuture<?> ret = Futures.immediateFailedFuture(t);
  return Mockito.doReturn(ret);
}
 
Example 3
Source File: TestQuorumJournalManagerUnit.java    From big-c with Apache License 2.0 4 votes vote down vote up
static <V> Stubber futureReturns(V value) {
  ListenableFuture<V> ret = Futures.immediateFuture(value);
  return Mockito.doReturn(ret);
}
 
Example 4
Source File: TestQuorumJournalManagerUnit.java    From big-c with Apache License 2.0 4 votes vote down vote up
static Stubber futureThrows(Throwable t) {
  ListenableFuture<?> ret = Futures.immediateFailedFuture(t);
  return Mockito.doReturn(ret);
}
 
Example 5
Source File: WithMockito.java    From mockito-java8 with 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 File: WithMockito.java    From mockito-java8 with 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 File: ExtendedMockito.java    From dexmaker with 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 File: ExtendedMockito.java    From dexmaker with 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));
}