Package org.eurekastreams.server.domain.stream

Examples of org.eurekastreams.server.domain.stream.Comment


    public CommentDTO execute(final InsertActivityCommentRequest inRequest)
    {
        final Activity activity = (Activity) getHibernateSession().load(Activity.class, inRequest.getActivityId());
       
        // create comment and persist to DB.
        Comment comment = new Comment((Person) getHibernateSession().load(Person.class, inRequest.getUserId()),
                activity,
                inRequest.getContent().trim());
       
        getEntityManager().persist(comment);
       
        CommentDTO commentDTO = new CommentDTO();
        commentDTO.setActivityId(inRequest.getActivityId());
        commentDTO.setAuthorId(inRequest.getUserId());
        commentDTO.setId(comment.getId());
        commentDTO.setTimeSent(comment.getTimeSent());
        commentDTO.setBody(inRequest.getContent());
       
        //fully popluate and cache the commentDTO
        commentDTOPopulator.execute(commentDTO, getCache());
       
View Full Code Here


        // flush and clear entityManager before query the DB.
        getEntityManager().flush();
        getEntityManager().clear();

        // Query comment from DB to assert that record was inserted in.
        Comment comment = (Comment) getEntityManager().createQuery("FROM Comment where id = :commentId").setParameter(
                "commentId", newCommentId).getSingleResult();

        // verify correct values were inserted into DB.
        assertNotNull(comment);
        assertEquals(smithersId, comment.getAuthor().getId());
        assertEquals(activityId, comment.getTarget().getId());
        assertEquals(is1000, comment.getBody());

        // Get the activity DTO and assert is was updated correctly by sut.
        activityDTO = activityMapper.execute(activityIds).get(0);
        assertEquals(activityId, activityDTO.getId());
        assertEquals(4, activityDTO.getCommentCount());
View Full Code Here

    @Test
    public void testExecute()
    {
        // set up activity with two comments posted same day, quickest comment is 10 min
        Activity a1 = (Activity) getEntityManager().createQuery("FROM Activity WHERE id = 6789").getSingleResult();
        Comment a1c1 = (Comment) getEntityManager().createQuery("FROM Comment WHERE id = 1").getSingleResult();
        Comment a1c2 = (Comment) getEntityManager().createQuery("FROM Comment WHERE id = 2").getSingleResult();

        a1.setPostedTime(new Date(year, 4, 1, 7, 0, 0));
        a1c1.setTimeSent(new Date(year, 4, 1, 7, 2, 0));
        a1c2.setTimeSent(new Date(year, 4, 1, 7, 4, 0));

        // set up another activity with two comments post same day, quickest comment is 20 min.
        Activity a2 = (Activity) getEntityManager().createQuery("FROM Activity WHERE id = 6790").getSingleResult();
        Comment a2c1 = (Comment) getEntityManager().createQuery("FROM Comment WHERE id = 5").getSingleResult();
        Comment a2c2 = (Comment) getEntityManager().createQuery("FROM Comment WHERE id = 6").getSingleResult();

        a2.setPostedTime(new Date(year, 4, 1, 8, 0, 0));
        a2c1.setTimeSent(new Date(year, 4, 1, 8, 6, 0));
        a2c2.setTimeSent(new Date(year, 4, 1, 8, 8, 0));

        getEntityManager().flush();
        getEntityManager().clear();

        // execute mapper assert avg response time is 15 min.
View Full Code Here

    @Test
    public void testExecuteDifferentDays()
    {
        // set up activity with two comments posted same day, quickest comment is 10 min
        Activity a1 = (Activity) getEntityManager().createQuery("FROM Activity WHERE id = 6789").getSingleResult();
        Comment a1c1 = (Comment) getEntityManager().createQuery("FROM Comment WHERE id = 1").getSingleResult();
        Comment a1c2 = (Comment) getEntityManager().createQuery("FROM Comment WHERE id = 2").getSingleResult();

        a1.setPostedTime(new Date(year, 4, 1, 7, 0, 0));
        a1c1.setTimeSent(new Date(year, 4, 1, 7, 2, 0));
        a1c2.setTimeSent(new Date(year, 4, 1, 7, 4, 0));

        // set up another activity with two comments post different day, quickest comment is 20 min.
        Activity a2 = (Activity) getEntityManager().createQuery("FROM Activity WHERE id = 6790").getSingleResult();
        Comment a2c1 = (Comment) getEntityManager().createQuery("FROM Comment WHERE id = 5").getSingleResult();
        Comment a2c2 = (Comment) getEntityManager().createQuery("FROM Comment WHERE id = 6").getSingleResult();

        a2.setPostedTime(new Date(year, 4, 2, 8, 0, 0));
        a2c1.setTimeSent(new Date(year, 4, 2, 8, 6, 0));
        a2c2.setTimeSent(new Date(year, 4, 2, 8, 8, 0));

        getEntityManager().flush();
        getEntityManager().clear();

        // execute mapper assert avg response time is 15 min.
View Full Code Here

     */
    @Test
    public void testExecuteActivityDayOld()
    {
        Activity a1 = (Activity) getEntityManager().createQuery("FROM Activity WHERE id = 6789").getSingleResult();
        Comment a1c1 = (Comment) getEntityManager().createQuery("FROM Comment WHERE id = 1").getSingleResult();
        Comment a1c2 = (Comment) getEntityManager().createQuery("FROM Comment WHERE id = 2").getSingleResult();

        a1.setPostedTime(new Date(year, 4, 1, 7, 0, 0));
        a1c1.setTimeSent(new Date(year, 4, 2, 7, 2, 0));
        a1c2.setTimeSent(new Date(year, 4, 2, 7, 4, 0));

        getEntityManager().flush();
        getEntityManager().clear();

        Assert.assertEquals(0, (long) sut.execute(new Date(year, 4, 2)));
View Full Code Here

     */
    @Before
    public void setup()
    {
        Activity act;
        Comment comment;
        Date april4th = new Date(april4th2011);

        sut = new GetDailyMessageCountDbMapper();
        sut.setEntityManager(getEntityManager());

        final long actId1 = 6789L;
        act = getEntityManager().find(Activity.class, actId1);
        act.setPostedTime(april4th);
        act.setAppType(EntityType.APPLICATION);
        getEntityManager().persist(act);

        final long actId2 = 6790L;
        act = getEntityManager().find(Activity.class, actId2);
        act.setPostedTime(april4th);
        act.setAppType(null);
        getEntityManager().persist(act);

        // an activity not by a person - this should be ignored
        final long actId3 = 6791L;
        act = getEntityManager().find(Activity.class, actId3);
        act.setAppType(EntityType.PLUGIN);
        act.setPostedTime(april4th);
        getEntityManager().persist(act);

        // an activity not by a person - this should be ignored
        final long actId4 = 6793L;
        act = getEntityManager().find(Activity.class, actId4);
        act.setAppType(EntityType.PLUGIN);
        act.setPostedTime(april4th);
        getEntityManager().persist(act);

        final long commentId = 9;
        comment = getEntityManager().find(Comment.class, commentId);
        comment.setTimeSent(april4th);
        getEntityManager().persist(comment);

        getEntityManager().flush();
    }
View Full Code Here

TOP

Related Classes of org.eurekastreams.server.domain.stream.Comment

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.