@Test public void shouldReturnTrueWhenUserDisabledSuccess() { user.setEnabled(true); User disabledUser = new User(); disabledUser.setEnabled(false); disabledUser.setUserName("user"); when(userMapper.findByUsername("user")).thenReturn(disabledUser); assertTrue(userService.disable(user)); verify(userMapper).update(user); assertFalse(userService.getByUsername("user").isEnabled()); }
@Test public void shouldReturnFalseWhenUserDisabledFailed() { user.setEnabled(false); assertFalse("should return false when given null user", userService.disable(null)); assertFalse("should return false when given disabled user", userService.disable(user)); verify(userMapper, never()).update(user); }