Package org.jtalks.common.model.entity

Examples of org.jtalks.common.model.entity.Group


        Component component = setupComponentMock();

        BranchPermission targetPermission = BranchPermission.CREATE_POSTS;
        BranchPermissionDto dto = createBranchPermissionDto(targetPermission);

        List<Group> selectedGroupList = Arrays.asList(new Group("1"), new Group("2"), new Group("3"));
        when(branchService.getPermissionGroupsFor(component.getId(), dto.getBranchId(), dto.isAllowed(), targetPermission))
                .thenReturn(selectedGroupList);

        List<Group> allGroupList = Arrays.asList(new Group("4"), new Group("5"), new Group("6"));
        when(permissionManager.getAllGroupsWithoutExcluded(selectedGroupList, targetPermission)).thenReturn(allGroupList);
        when(permissionManager.findBranchPermissionByMask(targetPermission.getMask())).thenReturn(targetPermission);

        JsonResponse jsonResponse = administrationController.getGroupsForBranchPermission(dto);
View Full Code Here


    private List<GroupAce> groupAces;
    private List<JtalksPermission> permissions;

    @Deprecated
    public static Group randomGroup(long id) {
        Group group = new Group(RandomStringUtils.randomAlphanumeric(15), RandomStringUtils.randomAlphanumeric(20));
        group.setId(id);
        return group;
    }
View Full Code Here

                grant(eq(sids), eq(listFromArray(changes.getPermission())), eq(branch));
    }

    @Test
    public void getAllGroupsWithoutExcludedShouldReturnAllGroupsWhenExcludedListIsEmpty() {
        List<Group> allGroups = Arrays.asList(new Group("1"), new Group("2"));
        when(groupDao.getAll()).thenReturn(allGroups);

        List<Group> result = manager.getAllGroupsWithoutExcluded(Collections.EMPTY_LIST, BranchPermission.CLOSE_TOPICS);

        assertEquals(allGroups, result);
View Full Code Here

        assertEquals(allGroups, result);
    }

    @Test
    public void getAllGroupsWithoutExcludedShouldReturnAllGroupsWithoutExcluded() {
        Group excludedGroup = new Group("1");
        List<Group> allGroups = new ArrayList<>(Arrays.asList(excludedGroup, new Group("2")));
        when(groupDao.getAll()).thenReturn(allGroups);

        List<Group> result = manager.getAllGroupsWithoutExcluded(Arrays.asList(excludedGroup), BranchPermission.CLOSE_TOPICS);

        assertEquals(result.size(), 1);
View Full Code Here

        assertEquals(result.get(0), allGroups.get(0));
    }

    @Test
    public void getAllGroupsWithoutExcludedShouldReturnListWithAnonymousGroupWhenItNotExcludedAndRequestedViewTopicPermission() {
        Group excludedGroup = new Group("1");
        List<Group> allGroups = new ArrayList<>(Arrays.asList(excludedGroup, new Group("2")));
        when(groupDao.getAll()).thenReturn(allGroups);

        List<Group> result = manager.getAllGroupsWithoutExcluded(Arrays.asList(excludedGroup), BranchPermission.VIEW_TOPICS);
        assertTrue(result.contains(AnonymousGroup.ANONYMOUS_GROUP));
    }
View Full Code Here

        assertTrue(result.contains(AnonymousGroup.ANONYMOUS_GROUP));
    }

    @Test
    public void getGroupsByIdsShouldReturnAllGroupsWhichIdIsSpecified() {
        List<Group> groups = Arrays.asList(new Group("group1"), new Group("group2"));
        List<Long> ids = Arrays.asList(1L, 2L);

        when(groupDao.getGroupsByIds(ids)).thenReturn(groups);

        List<Group> result = manager.getGroupsByIds(ids);
View Full Code Here

        assertTrue(result.isEmpty());
    }

    @Test
    public void getGroupsByIdsShouldReturnListWithAnonymousGroupWhenListOfIdsContainsZeroValue() {
        List<Group> groups = new ArrayList<>(Arrays.asList(new Group("group1")));
        List<Long> ids = Arrays.asList(0L, 1L);

        when(groupDao.getGroupsByIds(ids)).thenReturn(groups);

        List<Group> result = manager.getGroupsByIds(ids);
View Full Code Here

    }

    @DataProvider
    public Object[][] accessChanges() {
        PermissionChanges accessChanges = new PermissionChanges(BranchPermission.CLOSE_TOPICS);
        accessChanges.addNewlyAddedGroups(newArrayList(new Group("new1"), new Group("new2")));
        accessChanges.addRemovedGroups(newArrayList(new Group("removed1"), new Group("removed2")));
        return new Object[][]{{accessChanges}};
    }
View Full Code Here

        long lastGroupId = 1;

        for (int i = 0; i < permissions.length; i++) {
            for (int j = 0, count = RandomUtils.nextInt(20) + 10; j < count; j++) {
                Group group = randomGroup(lastGroupId++);
                groups.add(group);

                this.permissions.add(permissions[i]);
                groupAces.add(buildGroupAce(entity, permissions[i], (i % 2 == 1), acl,
                        new UserGroupSid(group.getId())));
            }
            AccessControlEntry controlEntry = mock(AccessControlEntry.class);
            when(controlEntry.getPermission()).thenReturn(permissions[i]);
            when(controlEntry.getSid()).thenReturn(UserSid.createAnonymous());
            when(controlEntry.isGranting()).thenReturn((i % 2 == 1));
View Full Code Here

            LOGGER.info("Could not activate user with UUID[{}] because it doesn't exist. Either it was removed from DB "
                    + "because too much time passed between registration and activation, or there is an error in link"
                    + ", might be possible the user searches for vulnerabilities in the forum.", uuid);
            throw new NotFoundException();
        } else if (!user.isEnabled()) {
            Group group = groupDao.getGroupByName(AdministrationGroup.USER.getName());
            user.addGroup(group);
            user.setEnabled(true);
            this.getDao().saveOrUpdate(user);
            LOGGER.info("User [{}] successfully activated", user.getUsername());
        } else {
View Full Code Here

TOP

Related Classes of org.jtalks.common.model.entity.Group

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.