Package org.eurekastreams.server.domain.stream

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


     * Tests with type not an app.
     */
    @Test
    public void testTypeNotApp()
    {
        Activity activity = new Activity();
        activity.setAppId(9L);
        activity.setAppType(EntityType.PERSON);

        Assert.assertEquals("0", sut.objectToString(activity));
    }
View Full Code Here


     * Tests with null id.
     */
    @Test
    public void testIdNull()
    {
        Activity activity = new Activity();
        activity.setAppId(null);
        activity.setAppType(EntityType.APPLICATION);

        Assert.assertEquals("0", sut.objectToString(activity));
    }
View Full Code Here

     * Tests with null type.
     */
    @Test
    public void testTypeNull()
    {
        Activity activity = new Activity();
        activity.setAppId(5L);

        Assert.assertEquals("0", sut.objectToString(activity));
    }
View Full Code Here

     * Tests for an app.
     */
    @Test
    public void testForApp()
    {
        Activity activity = new Activity();
        activity.setAppId(5L);
        activity.setAppType(EntityType.APPLICATION);

        Assert.assertEquals(ActivitySourceClassBridge.APPLICATION_PREFIX + Long.toString(5L), sut
                .objectToString(activity));
    }
View Full Code Here

     * Tests for a plugin.
     */
    @Test
    public void testForPlugin()
    {
        Activity activity = new Activity();
        activity.setAppId(7L);
        activity.setAppType(EntityType.PLUGIN);

        Assert.assertEquals(ActivitySourceClassBridge.PLUGIN_PREFIX + Long.toString(7L), sut.objectToString(activity));
    }
View Full Code Here

     * Test the SUT.
     */
    @Test
    public void test()
    {
        final Activity activity = CONTEXT.mock(Activity.class);

        CONTEXT.checking(new Expectations()
        {
            {
                oneOf(interstingnessStrategMocky).computeInterestingness(activity);
View Full Code Here

     * Test adding a like.
     */
    @Test
    public void testAddLike()
    {
        final Activity activityEntity = context.mock(Activity.class);
        final SetActivityLikeRequest currentRequest = new SetActivityLikeRequest(1L, LikeActionType.ADD_LIKE);

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

     * Test removing a like.
     */
    @Test
    public void testRemoveLike()
    {
        final Activity activityEntity = context.mock(Activity.class);
        final SetActivityLikeRequest currentRequest = new SetActivityLikeRequest(1L, LikeActionType.REMOVE_LIKE);

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

    public Serializable execute(final TaskHandlerActionContext<PrincipalActionContext> inActionContext)
    {
        ActivityDTO inActivityDTO = ((PostActivityRequest) inActionContext.getActionContext().getParams())
                .getActivityDTO();
        ActivityDTO persistedActivityDTO;
        Activity newActivity = convertDTOToActivity(inActivityDTO, inActionContext.getUserActionRequests());
        List<UserActionRequest> queueRequests = new ArrayList<UserActionRequest>();

        String actorAccountName = inActionContext.getActionContext().getPrincipal().getAccountId();

        newActivity.setPostedTime(new Date());
        newActivity.setActorId(actorAccountName);
        newActivity.setActorType(EntityType.PERSON);

        long actorId = 0;
        long destinationId = 0;
        EntityType destinationType;

        // Persist to long term storage.
        insertMapper.execute(new PersistenceRequest<Activity>(newActivity));
        insertMapper.flush();

        // Force the cache to load the activityDTO in from the db.
        List<ActivityDTO> activityResults = activitiesMapper.execute(Arrays.asList(newActivity.getId()));
        persistedActivityDTO = activityResults.get(0);
        actorId = persistedActivityDTO.getActor().getId();
        destinationId = persistedActivityDTO.getDestinationStream().getDestinationEntityId();
        destinationType = persistedActivityDTO.getDestinationStream().getType();
View Full Code Here

     * @return - Activity object populated with the values from the ActivityDTO passed in.
     */
    private Activity convertDTOToActivity(final ActivityDTO inActivityDTO,
            final List<UserActionRequest> inUserActionRequestList)
    {
        Activity currentActivity = new Activity();
        currentActivity.setAnnotation(inActivityDTO.getAnnotation());
        // This will only occur in the Share verb scenario.

        if (inActivityDTO.getBaseObjectProperties().containsKey("originalActivityId")
                && (inActivityDTO.getBaseObjectProperties().get("originalActivityId") != null))
        {
            try
            {
                currentActivity.setOriginalActivityId(new Long(inActivityDTO.getBaseObjectProperties().get(
                        "originalActivityId")));
            }
            catch (NumberFormatException nex)
            {
                logger.error("Error occurred parsing original activity id: "
                        + inActivityDTO.getBaseObjectProperties().get("originalActivityId"), nex);
            }
        }

        if (inActivityDTO.getBaseObjectProperties().containsKey("targetUrl")
                && inActivityDTO.getBaseObjectProperties().get("targetUrl") != null)
        {
            String url = inActivityDTO.getBaseObjectProperties().get("targetUrl");
            if (url != null)
            {
                // has a link to share
                logger.info("New activity shares link with url: " + url);

                SharedResource sr = findOrInsertSharedResourceMapper.execute(new SharedResourceRequest(url, null));
                if (sr != null)
                {
                    logger.info("Found shared resource - id: " + sr.getId());
                    currentActivity.setSharedLink(sr);

                    String cacheKey = CacheKeys.SHARED_RESOURCE_BY_UNIQUE_KEY
                            + sharedResourceCacheKeySuffixTransformer.transform(url);

                    // delete the cache immediately
                    logger.debug("Immediately deleting cache key while in transaction '" + cacheKey
                            + "', then queuing it up for post-transaction cleanup to avoid race.");
                    cache.delete(cacheKey);

                    // queue up a cache delete for after this transaction is
                    // closed - to prevent race condition
                    inUserActionRequestList.add(new UserActionRequest("deleteCacheKeysAction", null,
                            (Serializable) Collections.singleton(cacheKey)));
                }
            }
        }

        currentActivity.setBaseObject(inActivityDTO.getBaseObjectProperties());
        currentActivity.setBaseObjectType(inActivityDTO.getBaseObjectType());
        currentActivity.setLocation(inActivityDTO.getLocation());
        currentActivity.setMood(inActivityDTO.getMood());
        if (inActivityDTO.getOriginalActor() != null)
        {
            currentActivity.setOriginalActorId(inActivityDTO.getOriginalActor().getUniqueIdentifier());
            currentActivity.setOriginalActorType(inActivityDTO.getOriginalActor().getType());
        }
        currentActivity.setRecipientStreamScope(recipientRetriever.getStreamScope(inActivityDTO));
        currentActivity.setVerb(inActivityDTO.getVerb());
        currentActivity.setIsDestinationStreamPublic(recipientRetriever.isDestinationStreamPublic(inActivityDTO));

        currentActivity.setAppId(inActivityDTO.getAppId());
        currentActivity.setAppName(inActivityDTO.getAppName());
        currentActivity.setAppSource(inActivityDTO.getAppSource());
        currentActivity.setAppType(inActivityDTO.getAppType());
        currentActivity.setShowInStream(inActivityDTO.getShowInStream());

        return currentActivity;
    }
View Full Code Here

TOP

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

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.