Package org.jtalks.jcommune.model.entity

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


    }

    @Test
    public void testMarkAsReadTopicsToUser() {
        List<Topic> topics = PersistedObjectsFactory.createAndSaveTopicListWithPosts(10);
        JCUser user = PersistedObjectsFactory.getDefaultUser();

        //records of posts in topics
        Map<Long, DateTime> listCountPostsToTopics = markAllTopicsASRead(topics, user);
        //records in database about read topic
        Map<Long, DateTime> actualCountPostsToTopics = getActualListCountPostsToTopics(topics, user);
View Full Code Here


    }

    @Test
    public void testDeleteMarksTopicsToUser() {
        List<Topic> topics = PersistedObjectsFactory.createAndSaveTopicListWithPosts(10);
        JCUser user = PersistedObjectsFactory.getDefaultUser();
        SQLQuery deletedEntities = (SQLQuery) session.getNamedQuery("deleteAllMarksReadToUser");
        deletedEntities
                .addSynchronizedEntityClass(LastReadPost.class)
                .setParameter("user", user.getId())
                .setParameter("branch", topics.get(0).getBranch().getId())
                .setCacheable(false)
                .executeUpdate();

        List<LastReadPost> lastReadPostList = lastReadPostDao.getLastReadPosts(user, topics);
View Full Code Here

        assertEquals(resultOfGetTopics, actualCountOfPosts);
    }

    @Test
    public void testMarkAllReadToUserInTwoBranches() {
        JCUser user = PersistedObjectsFactory.getDefaultUser();
        List<Topic> topicsOfFirstBranch = PersistedObjectsFactory.createAndSaveTopicListWithPosts(10);
        List<Topic> topicsOfSecondBranch = PersistedObjectsFactory.createAndSaveTopicListWithPosts(10);
        //records of posts in topics
        Map<Long, DateTime> listCountPostsToTopicsInFBranch = new HashMap<Long, DateTime>();
        Map<Long, DateTime> listCountPostsToTopicsInSBranch = new HashMap<Long, DateTime>();
View Full Code Here

    }

    @Test
    public void getLastReadPostsForUserInTopicsShouldReturnThem() {
        int topicsSize = 10;
        JCUser user = PersistedObjectsFactory.getDefaultUser();
        List<Topic> userTopics = PersistedObjectsFactory.createAndSaveTopicListWithPosts(topicsSize);
        markAllTopicsASRead(userTopics, user);

        List<LastReadPost> lastReadPosts = lastReadPostDao.getLastReadPosts(user, userTopics);
View Full Code Here

    }

    @Test
    public void getLastReadPostsForUserShouldReturnEmptyListForEmptyListOfTopics() {
        List<Topic> userTopics = Collections.emptyList();
        JCUser user = new JCUser("user", "user@gmail.com", "password");

        List<LastReadPost> lastReadPosts = lastReadPostDao.getLastReadPosts(user, userTopics);

        assertTrue(lastReadPosts.isEmpty(), "For passed empty list of topics it should return empty list.");
View Full Code Here

    }

    @Test
    public void deleteLastReadPostsShouldDeleteAllRecodrsForGivenUser() {
        List<Topic> topics = PersistedObjectsFactory.createAndSaveTopicListWithPosts(10);
        JCUser user = PersistedObjectsFactory.getDefaultUser();
        markAllTopicsASRead(topics, user);

        lastReadPostDao.deleteLastReadPostsFor(user);

        @SuppressWarnings("unchecked")
View Full Code Here

    }

    @Test
    public void notifyNewlyMentionedUsersShouldNotNotifyNotAgreedWithNotificationsUsers() {
        Post mentioningPost = getPost(1L, "[user]Shogun[/user]");
        JCUser mentionedUser = getJCUser("Shogun", false);
        when(userDao.getByUsernames(asSet("Shogun"))).thenReturn(asList(mentionedUser));

        List<JCUser> usersToNotify = MentionedUsers.parse(mentioningPost).getNewUsersToNotify(userDao);

        assertEquals(mentioningPost.getPostContent(), "[user]Shogun[/user]",
View Full Code Here

        verify(postDao, never()).saveOrUpdate(mentioningPost);
    }

    @Test
    public void notifyNewlyMentionedUsersShouldNotSendIfUserIsSubscriberOfTopic() {
        JCUser mentionedUser = getJCUser("Shogun", true);
        Post mentioningPost = getPost(1L, "[user]Shogun[/user]");
        mentioningPost.getTopic().setSubscribers(asSet(mentionedUser));
        when(userDao.getByUsernames(asSet("Shogun"))).thenReturn(asList(mentionedUser));

        List<JCUser> usersToNotify = MentionedUsers.parse(mentioningPost).getNewUsersToNotify(userDao);
View Full Code Here

        assertEquals(usersToNotify.size(), 0);
        verify(postDao, never()).saveOrUpdate(mentioningPost);
    }

    private JCUser getJCUser(String name, boolean isMentioningEnabled) {
        JCUser user = new JCUser(name, "email@gmail.com", "password");
        user.setMentioningNotificationsEnabled(isMentioningEnabled);
        return user;
    }
View Full Code Here

    public static <T> Set<T> asSet(T... values) {
        return new HashSet<>(Arrays.asList(values));
    }

    private JCUser getUser(String username, long userId) {
        JCUser user = new JCUser(username, "sshogunn@gmail.com", "shogun password");
        user.setId(userId);
        return user;
    }
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.