@Test
  public void shouldChangeUserPasswordWhenAsked() {
    User updatedUser = new User();
    updatedUser.setUserName(user.getUserName());
    updatedUser.setPasswordHash("newpass");
    when(userMapper.findByUsername(user.getUserName())).thenReturn(updatedUser);

    boolean ret = userService.password(user, "newpass");
    verify(userMapper).update(user);
    assertEquals(userService.getByUsername(user.getUserName()).getPasswordHash(), "newpass");
    assertEquals(ret, true);
  }
  @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 shouldReturnAllUsersWhithRoleWhenInvoked() {
    List<User> users = new ArrayList<User>();
    users.add(user);

    when(userMapper.findAllUsers()).thenReturn(users);
    when(userRoleMapper.get(user.getId())).thenReturn(userRole);

    Map<User, String> result = userService.getAllUsersWithRole();
    Map<User, String> expect = new HashMap<User, String>();
    expect.put(user, userRole.getRoleName());
    assertEquals(result, expect);
    verify(userMapper).findAllUsers();
    verify(userRoleMapper).get(user.getId());
  }