Mocker { public T mock() { return mock(0); } Mocker(Class<T> clazz);  Mocker(Mocker<T> mocker); Mocker<T> when(Func1<T, R> when); Mocker<T> when(Func2<T, Integer, R> when); Mocker<T> thenReturn(Func1<T, R> thenReturn); Mocker<T> thenReturn(Func2<T, Integer, R> thenReturn); static Mocker<V> of(Class<V> clazz); T mock(); T mock(int i); @SuppressWarnings("unchecked") static V mock(Class<V> clazz); static Mocker<V> mocker(Class<V> clazz); Mocker<T> then(Action1<T> then); Mocker<T> then(Action2<T, Integer> then); Mocker<T> lift(); Mocker<T> safeLift(); Mocker<T> lift(Mocker<T> mocker); List<T> asList(); List<T> asList(int many); Mocker<T> times(int times); Mocker<T> atLeast(int atLeast); Mocker<T> atMost(int atMost); Mocker<T> never(); Mocker<T> atLeastOnce(); Mocker<T> verify(Action1<T> verify); Mocker<T> verify(Action2<T, Integer> verify); T never(Action1<T> verify); T times(Action1<T> verify, int i); final Class<T> clazz; public Func1<T, ?> when; public Func1<T, ?> thenReturn; public Func2<T, Integer, ?> when2; public Func2<T, Integer, ?> thenReturn2; public Action1<T> verify; public Action2<T, Integer> verify2; public Action1<T> then; public Action2<T, Integer> then2; public Mocker<T> mocker; public T that; public VerificationMode verification; }
@Test public void testMock() { List mock = mock(List.class); when(mock.size()).thenReturn(3); assertThat(mock.size()).isEqualTo(3); }