Package org.eurekastreams.server.domain.stream

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


    public void testSingleDTONotLikedManyLikes()
    {
        final Long activityId = 2L;
        final Long personId = 1L;

        final ActivityDTO activity = new ActivityDTO();
        activity.setId(activityId);

        final PersonModelView user = new PersonModelView();
        user.setEntityId(personId);

        final List<ActivityDTO> activities = Arrays.asList(activity);

        final List<Long> likedActivityForUser = new LinkedList<Long>();
        likedActivityForUser.add(1L);
        likedActivityForUser.add(3L);
        likedActivityForUser.add(4L);

        final int numberOfLikes = 100;

        final List<Long> usersWhoLikedActivity = new LinkedList<Long>();
        for (int i = 0; i < numberOfLikes; i++)
        {
            usersWhoLikedActivity.add(new Long(i));
        }

        final List<PersonModelView> usersDTOs = new LinkedList<PersonModelView>();
        usersDTOs.add(new PersonModelView());
        usersDTOs.add(new PersonModelView());
        usersDTOs.add(new PersonModelView());
        usersDTOs.add(new PersonModelView());
        usersDTOs.add(new PersonModelView());
        usersDTOs.add(new PersonModelView());
        usersDTOs.add(new PersonModelView());
        usersDTOs.add(new PersonModelView());
        usersDTOs.add(new PersonModelView());
        usersDTOs.add(new PersonModelView());

        CONTEXT.checking(new Expectations()
        {
            {
                oneOf(getLikedActivityByUser).execute(Arrays.asList(personId));
                will(returnValue(Arrays.asList(likedActivityForUser)));

                oneOf(getPeopleWhoLikedActivity).execute(Arrays.asList(activityId));
                will(returnValue(Arrays.asList(usersWhoLikedActivity)));

                oneOf(peopleMapper).execute(usersWhoLikedActivity.subList(0, LIKER_LIMIT));
                will(returnValue(usersDTOs));
            }
        });

        sut.filter(activities, user);

        Assert.assertFalse(activity.isLiked());
        Assert.assertEquals(usersDTOs.size(), activity.getLikers().size());

        CONTEXT.assertIsSatisfied();
    }
View Full Code Here


     * Test filtering without comments.
     */
    @Test
    public void testFilterNoComment()
    {
        final ActivityDTO activity = context.mock(ActivityDTO.class);
        PersonModelView user = new PersonModelView();

        context.checking(new Expectations()
        {
            {
View Full Code Here

     * Test filtering with comments.
     */
    @Test
    public void testFilterComments()
    {
        final ActivityDTO activity = context.mock(ActivityDTO.class);
        final CommentDTO firstComment = context.mock(CommentDTO.class, "firstComment");
        final CommentDTO lastComment = context.mock(CommentDTO.class, "lastComment");
       
        PersonModelView user = new PersonModelView();

View Full Code Here

    public void testTranslate()
    {
        StreamEntityDTO stream = new StreamEntityDTO();
        stream.setType(EntityType.PERSON);
        stream.setDestinationEntityId(4L);
        final ActivityDTO activity = new ActivityDTO();
        activity.setDestinationStream(stream);

        context.checking(new Expectations()
        {
            {
                allowing(activityDAO).execute(3L);
                will(returnValue(activity));
                allowing(systemAdminIdsMapper).execute(null);
                will(returnValue(new ArrayList<Long>(ADMIN_IDS)));
            }
        });

        NotificationBatch results = sut.translate(new ActivityNotificationsRequest(null, ACTOR_ID, 0L, 3L));

        context.assertIsSatisfied();

        // check recipients
        assertEquals(1, results.getRecipients().size());
        TranslatorTestHelper.assertRecipients(results, NotificationType.FLAG_ACTIVITY, NON_ACTOR_ADMIN_IDS);

        // check properties
        PropertyMap<Object> props = results.getProperties();
        assertEquals(6, props.size());
        PropertyMapTestHelper
                .assertPlaceholder(props, NotificationPropertyKeys.ACTOR, PersonModelView.class, ACTOR_ID);
        PropertyMapTestHelper.assertValue(props, "stream", activity.getDestinationStream());
        PropertyMapTestHelper.assertAlias(props, "source", "stream");
        PropertyMapTestHelper.assertValue(props, "activity", activity);
        PropertyMapTestHelper.assertValue(props, NotificationPropertyKeys.HIGH_PRIORITY, true);
        PropertyMapTestHelper.assertSetNonNull(props, NotificationPropertyKeys.URL);
    }
View Full Code Here

    public void testTranslateGroup()
    {
        StreamEntityDTO stream = new StreamEntityDTO();
        stream.setType(EntityType.GROUP);
        stream.setDestinationEntityId(4L);
        final ActivityDTO activity = new ActivityDTO();
        activity.setDestinationStream(stream);

        context.checking(new Expectations()
        {
            {
                allowing(activityDAO).execute(3L);
                will(returnValue(activity));
                allowing(systemAdminIdsMapper).execute(null);
                will(returnValue(new ArrayList<Long>(ADMIN_IDS)));
            }
        });

        NotificationBatch results = sut.translate(new ActivityNotificationsRequest(null, ACTOR_ID, 0L, 3L));

        context.assertIsSatisfied();

        // check recipients
        assertEquals(1, results.getRecipients().size());
        TranslatorTestHelper.assertRecipients(results, NotificationType.FLAG_ACTIVITY, NON_ACTOR_ADMIN_IDS);

        // check properties
        PropertyMap<Object> props = results.getProperties();
        assertEquals(6, props.size());
        PropertyMapTestHelper
                .assertPlaceholder(props, NotificationPropertyKeys.ACTOR, PersonModelView.class, ACTOR_ID);
        PropertyMapTestHelper.assertValue(props, "stream", activity.getDestinationStream());
        PropertyMapTestHelper.assertAlias(props, "source", "stream");
        PropertyMapTestHelper.assertValue(props, "activity", activity);
        PropertyMapTestHelper.assertValue(props, NotificationPropertyKeys.HIGH_PRIORITY, true);
        PropertyMapTestHelper.assertSetNonNull(props, NotificationPropertyKeys.URL);
    }
View Full Code Here

        destinationStream = new StreamEntityDTO();

        sut = new ShareVerbValidator(activityMapperMock, transMgr, groupMapperMock);

        testOriginalActivity = new ActivityDTO();
        testOriginalActivity.setVerb(ActivityVerb.SHARE);

        testOriginalActor = new StreamEntityDTO();
        testOriginalActor.setUniqueIdentifier(ORIGINAL_ACTOR_UNIQUE_ID);
View Full Code Here

     * Test the successful validation path.
     */
    @Test
    public void testValidate()
    {
        testActivity = new ActivityDTO();
        testActivity.setVerb(ActivityVerb.SHARE);

        testActivity.setOriginalActor(testOriginalActor);
        testActivity.setBaseObjectProperties(testBaseObjectProperties);
        testActivity.setBaseObjectType(BaseObjectType.BOOKMARK);
View Full Code Here

     * Test failure on Original Actor missing.
     */
    @Test
    public void testValidateOriginalActorMissing()
    {
        testActivity = new ActivityDTO();
        testActivity.setVerb(ActivityVerb.SHARE);

        testActivity.setOriginalActor(null);

        testActivity.setBaseObjectProperties(testBaseObjectProperties);
View Full Code Here

     * Test the failure on no activity results returned.
     */
    @Test
    public void testValidateEmptyActivityResults()
    {
        testActivity = new ActivityDTO();
        testActivity.setVerb(ActivityVerb.SHARE);

        testActivity.setOriginalActor(testOriginalActor);

        testActivity.setBaseObjectProperties(testBaseObjectProperties);
View Full Code Here

     * Test the failure multiple activities being returned.
     */
    @Test
    public void testFailureValidate()
    {
        testActivity = new ActivityDTO();
        testActivity.setVerb(ActivityVerb.SHARE);

        StreamEntityDTO mismatchedOriginalActor = new StreamEntityDTO();
        mismatchedOriginalActor.setUniqueIdentifier("something");
        testActivity.setOriginalActor(mismatchedOriginalActor);

        HashMap<String, String> mismatchedObjProperties = new HashMap<String, String>();
        mismatchedObjProperties.put("originalActivityId", FAIL_ORIGINAL_ACTIVITY_ID.toString());
        testActivity.setBaseObjectProperties(mismatchedObjProperties);
        testActivity.setBaseObjectType(BaseObjectType.NOTE);

        final List<Long> activityIds = new ArrayList<Long>();
        activityIds.add(FAIL_ORIGINAL_ACTIVITY_ID);

        // Expect two results to trigger an error.
        final List<ActivityDTO> matchingActivities = new ArrayList<ActivityDTO>();
        matchingActivities.add(new ActivityDTO());
        matchingActivities.add(new ActivityDTO());

        context.checking(new Expectations()
        {
            {
                oneOf(transMgr).getTransaction(transDef);
View Full Code Here

TOP

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

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.