Package org.jtalks.common.model.entity

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


        }
        if (authInfo.containsKey("enabled")) {
            user.setEnabled(Boolean.parseBoolean(authInfo.get("enabled")));
        }
        if (user.isEnabled() && user.getGroups().isEmpty()) {
            Group group = groupDao.getGroupByName(AdministrationGroup.USER.getName());
            user.addGroup(group);
        }
        getDao().saveOrUpdate(user);
        return user;
    }
View Full Code Here


    @Test
    public void getPermissionGroupsShouldReturnAllowedPermissionGroupsWhenBranchExist() throws Exception {
        long branchId = 42;
        BranchPermission permission = BranchPermission.CLOSE_TOPICS;
        GroupsPermissions expectedPermissions = new GroupsPermissions();
        expectedPermissions.addAllowed(permission, new Group("1"));

        Branch expectedBranch = new Branch("name", "description");
        when(branchDao.isExist(branchId)).thenReturn(true);
        when(branchDao.get(branchId)).thenReturn(expectedBranch);
        doReturn(expectedPermissions).when(permissionService).getPermissionsFor(expectedBranch);
View Full Code Here

    @Test
    public void getPermissionGroupsShouldReturnRestrictedPermissionGroupsWhenBranchExist() throws Exception {
        long branchId = 42;
        BranchPermission permission = BranchPermission.CLOSE_TOPICS;
        GroupsPermissions expectedPermissions = new GroupsPermissions();
        expectedPermissions.addRestricted(permission, new Group("1"));

        Branch expectedBranch = new Branch("name", "description");
        when(branchDao.isExist(branchId)).thenReturn(true);
        when(branchDao.get(branchId)).thenReturn(expectedBranch);
        doReturn(expectedPermissions).when(permissionService).getPermissionsFor(expectedBranch);
View Full Code Here

        String email = "email@email.em";
        LoginUserDto loginUserDto = createDefaultLoginUserDto();
        JCUser oldUser = prepareOldUser(loginUserDto.getUserName());
        Map<String, String> authInfo = createAuthInfo(oldUser.getUsername(), email);
        authInfo.put("enabled", "true");
        Group group = new Group(AdministrationGroup.USER.getName());
        when(groupDao.getGroupByName(AdministrationGroup.USER.getName())).thenReturn(group);
        when(userDao.getByUsername(oldUser.getUsername())).thenReturn(oldUser);
        when(encryptionService.encryptPassword(loginUserDto.getPassword())).thenReturn(passwordHash);
        UsernamePasswordAuthenticationToken expectedToken = mock(UsernamePasswordAuthenticationToken.class);
        when(securityFacade.getContext()).thenReturn(securityContext);
View Full Code Here

        String password = "password";
        String passwordHash = "5f4dcc3b5aa765d61d8327deb882cf99";
        String email = "email@email.em";
        LoginUserDto loginUserDto = createDefaultLoginUserDto();
        Map<String, String> authInfo = createAuthInfo(username, email);
        Group group = new Group(AdministrationGroup.USER.getName());
        User commonUser = new User(username, email, password, null);
        commonUser.getGroups().add(group);
        when(groupDao.getGroupByName(group.getName())).thenReturn(group);
        when(userDao.getByUsername(username)).thenReturn(null);
        when(userDao.getCommonUserByUsername(username)).thenReturn(commonUser);
        when(encryptionService.encryptPassword(password)).thenReturn(passwordHash);
        prepareAuth();
        preparePlugin(username, passwordHash, authInfo);
View Full Code Here

        Branch branch = new Branch(title, description);
        branch.setSection(section);
        section.addOrUpdateBranch(branch);
        sectionDao.saveOrUpdate(section);
        //add default permission to view topics (for group Registered users)
        Group registeredUsersGroup = groupDao.getGroupByName(AdministrationGroup.USER.getName());
        Collection<Group> groups = Arrays.asList(registeredUsersGroup);
        PermissionChanges permissionChanges = new PermissionChanges(BranchPermission.VIEW_TOPICS, groups,
                Collections.<Group>emptyList());
        permissionService.changeGrants(branch, permissionChanges);
    }
View Full Code Here

        PersistedObjectsFactory.setSession(session);
    }

    @Test
    public void testSave() {
        Group group = ObjectsFactory.getRandomGroup();

        saveAndEvict(group);
        Group savedGroup = (Group) session.get(Group.class, group.getId());

        assertReflectionEquals(group, savedGroup);
    }
View Full Code Here

        assertReflectionEquals(group, savedGroup);
    }

    @Test
    public void testSaveIdGeneration() {
        Group group = ObjectsFactory.getRandomGroup();
        long initialId = 0;
        group.setId(initialId);

        saveAndEvict(group);

        assertNotSame(group.getId(), initialId, "ID is not created");
    }
View Full Code Here

        assertNotSame(group.getId(), initialId, "ID is not created");
    }

    @Test
    public void testGetById() {
        Group group = ObjectsFactory.getRandomGroup();

        saveAndEvict(group);

        Group actual = groupDao.get(group.getId());
        assertReflectionEquals(actual, group);
    }
View Full Code Here

    }


    @Test
    public void testGetAll() {
        Group group0 = ObjectsFactory.getRandomGroup();
        saveAndEvict(group0);

        Group group1 = ObjectsFactory.getRandomGroup();
        saveAndEvict(group1);

        List<Group> actual = groupDao.getAll();
        assertEquals(actual.size(), 2);
        assertReflectionEquals(actual.get(0), group0);
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.