Package org.jtalks.common.model.entity

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


    }

    @Test
    public void addingValidUserToValidGroupShouldSucceed() {
        JCUser user = givenJCUserWithUsernameStoredInDb("test-user");
        Group group = PersistedObjectsFactory.group("test-group");
        user.addGroup(group);
        dao.saveOrUpdate(user);
        flushAndClearSession(session);

        Group selected = groupDao.get(group.getId());
        assertEquals(selected.getUsers().size(), 1);
        assertReflectionEquals(selected.getUsers().get(0), user);
    }
View Full Code Here


    @VisibleForTesting
    static Group copyUserGroup(Group group, JCUser user) {
        if (group == null) {
            throw new IllegalArgumentException("User group should not be null");
        }
        Group copy = new Group(group.getName(), group.getDescription());
        copy.setId(group.getId());
        copy.setUuid(group.getUuid());
        copy.getUsers().add(user);
        return copy;
    }
View Full Code Here

        user.setLastName("lastname");
        user.setBanReason("spam");
        user.setRole("ROLE_USER");
        user.setAvatar(new byte[]{1, 2, 3});
        user.setVersion(1L);
        Group group = new Group("users");
        group.getUsers().add(user);
        user.setGroups(Arrays.asList(group));
        user.setSalt("salt");
        user.setPostCount(1);
        user.setLanguage(Language.ENGLISH);
        user.setPageSize(15);
View Full Code Here

        assertSame(copy.getOwner(), newOwner);
    }

    @Test
    public void copyUserGroupShouldCopyCorrectlyIfOnlyRequiredFieldsFilled() {
        Group group = new Group("name");
        JCUser user =  new JCUser("username", "email@mail.com", "pass");
        Group copy = JCUser.copyUserGroup(group, user);

        assertNotSame(group, copy);
        assertUserGroupEqualsIgnoreUsers(copy, group);
        assertEquals(copy.getUsers().size(), 1);
        assertSame(copy.getUsers().get(0), user);
    }
View Full Code Here

        assertSame(copy.getUsers().get(0), user);
    }

    @Test
    public void copyUserGroupShouldCopyCorrectlyIfAllFieldsFilled() {
        Group group = new Group("name", "description");
        group.setId(1);
        group.setUuid("uuid");
        List<User> users = Arrays.asList(new User("username", "email@mail.com", "pass"),
                new User("username1", "email1@mail.com", "pass1"));
        group.setUsers(users);
        JCUser newUser =  new JCUser("username", "email@mail.com", "pass");

        Group copy = JCUser.copyUserGroup(group, newUser);

        assertNotSame(copy, group);
        assertUserGroupEqualsIgnoreUsers(copy, group);
        assertEquals(copy.getUsers().size(), 1);
        assertSame(copy.getUsers().get(0), newUser);
    }
View Full Code Here

    void testCreatePage() throws EntityExistsException {
        SimplePage simplePage = new SimplePage(NAME, CONTENT, PATH_NAME);
        JCUser user = new JCUser("username", "email", "password");

        when(dao.isExist(PATH_NAME)).thenReturn(false);
        when(groupDao.getGroupByName(AdministrationGroup.ADMIN.getName())).thenReturn(new Group());

        SimplePage actualSimplePage = simplePageService.createPage(simplePage, user);

        assertEquals(actualSimplePage.getName(), NAME);
        assertEquals(actualSimplePage.getContent(), CONTENT);
View Full Code Here

    @Test
    public void activateAccountShouldEnableUser() throws Exception {
        JCUser user = new JCUser(USERNAME, EMAIL, PASSWORD);
        when(userDao.getByUuid(user.getUuid())).thenReturn(user);
        when(groupDao.getGroupByName(AdministrationGroup.USER.getName())).thenReturn(new Group());

        userService.activateAccount(user.getUuid());
        assertTrue(user.isEnabled());
    }
View Full Code Here

    @Test
    public void activateAccountShouldAddUserToRegisteredUsersGroup() throws Exception {
        JCUser user = new JCUser(USERNAME, EMAIL, PASSWORD);
        when(userDao.getByUuid(user.getUuid())).thenReturn(user);
        Group registeredUsersGroup = new Group();
        when(groupDao.getGroupByName(AdministrationGroup.USER.getName())).thenReturn(registeredUsersGroup);

        userService.activateAccount(user.getUuid());
        assertTrue(user.getGroups().contains(registeredUsersGroup));
    }
View Full Code Here

    @Test(expectedExceptions = UserTriesActivatingAccountAgainException.class)
    public void testActivateAccountAlreadyEnabled() throws NotFoundException, UserTriesActivatingAccountAgainException {
        JCUser user = new JCUser(USERNAME, EMAIL, PASSWORD);
        user.setEnabled(true);
        when(userDao.getByUuid(user.getUuid())).thenReturn(user);
        Group group = new Group();
        when(groupDao.getGroupByName(AdministrationGroup.USER.getName())).thenReturn(group);

        userService.activateAccount(user.getUuid());

        assertTrue(user.isEnabled());
        verify(groupDao, never()).saveOrUpdate(any(Group.class));
        assertFalse(group.getUsers().contains(user));
    }
View Full Code Here

        }


        this.getDao().saveOrUpdate(simplePage);

        Group group = groupDao.getGroupByName(AdministrationGroup.ADMIN.getName());
        securityService.createAclBuilder().grant(GeneralPermission.WRITE).to(group).on(simplePage).flush();

        logger.info("SimplePage registered: {}", simplePage.getName());
        return simplePage;
    }
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.