@Test
  public void should_remove_user_permission() {
    UserDto userDto = new UserDto().setId(1L).setLogin("user").setName("user");
    when(userDao.selectActiveUserByLogin("user")).thenReturn(userDto);
    when(permissionTemplateDao.selectByUuid(DEFAULT_KEY)).thenReturn(DEFAULT_TEMPLATE);

    underTest.removeUserPermission(DEFAULT_KEY, DEFAULT_PERMISSION, "user");

    verify(permissionTemplateDao, times(1)).deleteUserPermission(1L, 1L, DEFAULT_PERMISSION);
  }
  @Test
  public void should_validate_provided_user_login() {
    expected.expect(BadRequestException.class);
    expected.expectMessage("Unknown user:"******"unknown")).thenReturn(null);

    underTest.addUserPermission(DEFAULT_KEY, DEFAULT_PERMISSION, "unknown");
  }
Example #3
0
 private UserDto insertUser(String login) {
   return userDao.insert(session, new UserDto().setLogin(login).setName(login).setActive(true));
 }