Package org.jtalks.jcommune.model.entity

Examples of org.jtalks.jcommune.model.entity.JCUser


        assertReflectionEquals(user, result);
    }

    @Test
    public void testGetByUuidNotExist() {
        JCUser user = ObjectsFactory.getDefaultUser();
        session.save(user);

        JCUser result = dao.getByUuid("uuid");

        assertNull(result);
    }
View Full Code Here


        assertNull(result);
    }

    @Test
    public void testFetchByEMail() {
        JCUser user = ObjectsFactory.getDefaultUser();
        session.save(user);
        assertNotNull(dao.getByEmail(user.getEmail()));
    }
View Full Code Here

        assertNotNull(dao.getByEmail(user.getEmail()));
    }

    @Test
    public void testFetchNonActivatedAccounts() {
        JCUser activated = new JCUser("login", "email@mail.com", "password");
        activated.setEnabled(true);
        JCUser nonActivated = ObjectsFactory.getDefaultUser();
        session.save(activated);
        session.save(nonActivated);

        Collection<JCUser> users = dao.getNonActivatedUsers();
View Full Code Here

    }

    @Test
    public void getByUsernamesShouldReturnExistsInRepoUsers() {
        String firstExistsUsername = "Shogun";
        JCUser firstExistsUser = givenJCUserWithUsernameStoredInDb(firstExistsUsername);
        Set<String> existsUsernames = new HashSet<>(asList(firstExistsUsername));

        List<JCUser> foundByUsernames = dao.getByUsernames(existsUsernames);

        assertTrue(foundByUsernames.size() == existsUsernames.size(), "It should return all users by their names.");
        assertTrue(foundByUsernames.contains(firstExistsUser), firstExistsUser.getUsername() + "should be found by his name.");
    }
View Full Code Here

        assertTrue(foundByUsernames.contains(firstExistsUser), firstExistsUser.getUsername() + "should be found by his name.");
    }

    @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);
View Full Code Here

        assertEquals(dao.getUsernames(usernamePattern, resultCount).size(), 1);
    }

    private JCUser givenJCUserWithUsernameStoredInDb(String username) {
        JCUser expected = new JCUser(username, username + "@mail.com", username + "pass");
        session.save(expected);
        session.clear();
        return expected;
    }
View Full Code Here

        session.clear();
        return expected;
    }

    private JCUser createUserWithMail(String username, String email, boolean enabled) {
        JCUser user = new JCUser(username, email, username + "pass");
        user.setEnabled(enabled);
        session.persist(user);
        return user;
    }
View Full Code Here

        SimplePage simplePage = new SimplePage();
        simplePage.setName("Title");
        simplePage.setContent("Content");
        simplePage.setPathName(pagePathName);

        JCUser userCreator = userService.getCurrentUser();
        simplePageService.createPage(simplePage, userCreator);
        SimplePageDto simplePageDto = new SimplePageDto(simplePage);

        return new ModelAndView("simplePageEditor")
                .addObject(PAGE_DTO, simplePageDto);
View Full Code Here

    public void renderAvatar(
            HttpServletRequest request,
            HttpServletResponse response,
            @PathVariable Long id)
            throws NotFoundException, IOException {
        JCUser user = userService.get(id);

        Date ifModifiedDate = getIfModifiedSineDate(request.getHeader(IF_MODIFIED_SINCE_HEADER));
        if (!user.getAvatarLastModificationTime().isAfter(ifModifiedDate.getTime())) {
            response.setStatus(HttpServletResponse.SC_NOT_MODIFIED);
        } else {
            byte[] avatar = user.getAvatar();
            response.setContentType("image/jpeg");
            response.setContentLength(avatar.length);
            response.getOutputStream().write(avatar);
        }

        Date avatarLastModificationDate = new Date(
                user.getAvatarLastModificationTime().getMillis());
        setupAvatarHeaders(response, avatarLastModificationDate);
    }
View Full Code Here

    @BeforeMethod
    public void setUp() throws Exception {
        breadcrumbBuilder = new BreadcrumbBuilder();

        JCUser user = new JCUser("user", "mail@mail.com", "password");

        section = new Section("Section Name");
        section.setId(ID);

        branch = new Branch("Branch Name", "Branch description");
View Full Code Here

TOP

Related Classes of org.jtalks.jcommune.model.entity.JCUser

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.