UserServiceImpl implements UserService { public boolean isUserEverLoginSuccessfully() { return userDao.countUser() > 0; } UserServiceImpl(UserDao userDao); boolean isUserEverLoginSuccessfully(); static final String TAG; }
@Test public void should_be_truthy_when_user_ever_login_successfully() { when(userDao.countUser()).thenReturn(1L); assertThat(userService.isUserEverLoginSuccessfully(), is(true)); }
@Test public void should_be_false_when_user_never_login_successfully() { when(userDao.countUser()).thenReturn(0L); assertThat(userService.isUserEverLoginSuccessfully(), is(false)); }