コード例 #1
0
  @Test
  public void should_remove_group_from_templates() {
    GroupDto groupDto = new GroupDto().setId(1L).setName("group");
    when(groupDao.selectByName(session, "group")).thenReturn(groupDto);

    underTest.removeGroupFromTemplates("group");

    verify(permissionTemplateDao).deleteByGroup(eq(session), eq(1L));
  }
コード例 #2
0
  @Test
  public void should_remove_group_permission() {
    GroupDto groupDto = new GroupDto().setId(1L).setName("group");
    when(groupDao.selectByName(any(DbSession.class), eq("group"))).thenReturn(groupDto);
    when(permissionTemplateDao.selectByUuid(DEFAULT_KEY)).thenReturn(DEFAULT_TEMPLATE);

    underTest.removeGroupPermission(DEFAULT_KEY, DEFAULT_PERMISSION, "group");

    verify(permissionTemplateDao, times(1)).deleteGroupPermission(1L, 1L, DEFAULT_PERMISSION);
  }
コード例 #3
0
  @Test
  public void should_validate_provided_group_name() {
    expected.expect(BadRequestException.class);
    expected.expectMessage("Unknown group:");

    when(permissionTemplateDao.selectByUuid(DEFAULT_KEY)).thenReturn(DEFAULT_TEMPLATE);
    when(groupDao.selectByName(any(DbSession.class), eq("unknown"))).thenReturn(null);

    underTest.addGroupPermission(DEFAULT_KEY, DEFAULT_PERMISSION, "unknown");
  }
コード例 #4
0
 private GroupDto insertGroup(String groupName) {
   return groupDao.insert(
       session,
       new GroupDto().setName(groupName).setDescription(StringUtils.capitalize(groupName)));
 }