@Test public void testTranslateShared() { context.checking(new Expectations() { { allowing(author).getType(); will(returnValue(EntityType.PERSON)); allowing(activity).getOriginalActor(); will(returnValue(originalAuthor)); allowing(originalAuthor).getType(); will(returnValue(EntityType.PERSON)); } }); NotificationBatch results = sut.translate(new ActivityNotificationsRequest(null, 1L, 0L, ACTIVITY_ID)); context.assertIsSatisfied(); assertEquals(1, results.getRecipients().size()); TranslatorTestHelper.assertRecipients(results, NotificationType.LIKE_ACTIVITY, AUTHOR_ID, ORIGINAL_AUTHOR_ID); PropertyMap<Object> props = results.getProperties(); assertEquals(5, props.size()); PropertyMapTestHelper.assertPlaceholder(props, "actor", PersonModelView.class, 1L); PropertyMapTestHelper.assertValue(props, "stream", activity.getDestinationStream()); PropertyMapTestHelper.assertValue(props, "activity", activity); PropertyMapTestHelper.assertAlias(props, NotificationPropertyKeys.SOURCE, "stream"); PropertyMapTestHelper.assertValue(props, NotificationPropertyKeys.URL, "#activity/" + ACTIVITY_ID); }
@Override public NotificationBatch translate(final ActivityNotificationsRequest inRequest) { ActivityDTO activity = activityDAO.execute(inRequest.getActivityId()); Collection<Long> recipients = new HashSet<Long>(); addAuthorIfAppropriate(activity.getActor(), inRequest.getActorId(), recipients); addAuthorIfAppropriate(activity.getOriginalActor(), inRequest.getActorId(), recipients); if (recipients.isEmpty()) { return null; } NotificationBatch batch = new NotificationBatch(NotificationType.LIKE_ACTIVITY, recipients); batch.setProperty(NotificationPropertyKeys.ACTOR, PersonModelView.class, inRequest.getActorId()); batch.setProperty("stream", activity.getDestinationStream()); batch.setProperty("activity", activity); batch.setPropertyAlias(NotificationPropertyKeys.SOURCE, "stream"); batch.setProperty(NotificationPropertyKeys.URL, UiUrlBuilder.relativeUrlForActivity(inRequest.getActivityId())); return batch; }
LikeTranslator implements NotificationTranslator<ActivityNotificationsRequest> { @Override public NotificationBatch translate(final ActivityNotificationsRequest inRequest) { ActivityDTO activity = activityDAO.execute(inRequest.getActivityId()); Collection<Long> recipients = new HashSet<Long>(); addAuthorIfAppropriate(activity.getActor(), inRequest.getActorId(), recipients); addAuthorIfAppropriate(activity.getOriginalActor(), inRequest.getActorId(), recipients); if (recipients.isEmpty()) { return null; } NotificationBatch batch = new NotificationBatch(NotificationType.LIKE_ACTIVITY, recipients); batch.setProperty(NotificationPropertyKeys.ACTOR, PersonModelView.class, inRequest.getActorId()); batch.setProperty("stream", activity.getDestinationStream()); batch.setProperty("activity", activity); batch.setPropertyAlias(NotificationPropertyKeys.SOURCE, "stream"); batch.setProperty(NotificationPropertyKeys.URL, UiUrlBuilder.relativeUrlForActivity(inRequest.getActivityId())); return batch; } }
LikeTranslator implements NotificationTranslator<ActivityNotificationsRequest> { @Override public NotificationBatch translate(final ActivityNotificationsRequest inRequest) { ActivityDTO activity = activityDAO.execute(inRequest.getActivityId()); Collection<Long> recipients = new HashSet<Long>(); addAuthorIfAppropriate(activity.getActor(), inRequest.getActorId(), recipients); addAuthorIfAppropriate(activity.getOriginalActor(), inRequest.getActorId(), recipients); if (recipients.isEmpty()) { return null; } NotificationBatch batch = new NotificationBatch(NotificationType.LIKE_ACTIVITY, recipients); batch.setProperty(NotificationPropertyKeys.ACTOR, PersonModelView.class, inRequest.getActorId()); batch.setProperty("stream", activity.getDestinationStream()); batch.setProperty("activity", activity); batch.setPropertyAlias(NotificationPropertyKeys.SOURCE, "stream"); batch.setProperty(NotificationPropertyKeys.URL, UiUrlBuilder.relativeUrlForActivity(inRequest.getActivityId())); return batch; } LikeTranslator(final DomainMapper<Long, ActivityDTO> inActivityDAO); }
LikeTranslator implements NotificationTranslator<ActivityNotificationsRequest> { @Override public NotificationBatch translate(final ActivityNotificationsRequest inRequest) { ActivityDTO activity = activityDAO.execute(inRequest.getActivityId()); Collection<Long> recipients = new HashSet<Long>(); addAuthorIfAppropriate(activity.getActor(), inRequest.getActorId(), recipients); addAuthorIfAppropriate(activity.getOriginalActor(), inRequest.getActorId(), recipients); if (recipients.isEmpty()) { return null; } NotificationBatch batch = new NotificationBatch(NotificationType.LIKE_ACTIVITY, recipients); batch.setProperty(NotificationPropertyKeys.ACTOR, PersonModelView.class, inRequest.getActorId()); batch.setProperty("stream", activity.getDestinationStream()); batch.setProperty("activity", activity); batch.setPropertyAlias(NotificationPropertyKeys.SOURCE, "stream"); batch.setProperty(NotificationPropertyKeys.URL, UiUrlBuilder.relativeUrlForActivity(inRequest.getActivityId())); return batch; } LikeTranslator(final DomainMapper<Long, ActivityDTO> inActivityDAO); @Override NotificationBatch translate(final ActivityNotificationsRequest inRequest); }
LikeTranslator implements NotificationTranslator<ActivityNotificationsRequest> { @Override public NotificationBatch translate(final ActivityNotificationsRequest inRequest) { ActivityDTO activity = activityDAO.execute(inRequest.getActivityId()); Collection<Long> recipients = new HashSet<Long>(); addAuthorIfAppropriate(activity.getActor(), inRequest.getActorId(), recipients); addAuthorIfAppropriate(activity.getOriginalActor(), inRequest.getActorId(), recipients); if (recipients.isEmpty()) { return null; } NotificationBatch batch = new NotificationBatch(NotificationType.LIKE_ACTIVITY, recipients); batch.setProperty(NotificationPropertyKeys.ACTOR, PersonModelView.class, inRequest.getActorId()); batch.setProperty("stream", activity.getDestinationStream()); batch.setProperty("activity", activity); batch.setPropertyAlias(NotificationPropertyKeys.SOURCE, "stream"); batch.setProperty(NotificationPropertyKeys.URL, UiUrlBuilder.relativeUrlForActivity(inRequest.getActivityId())); return batch; } LikeTranslator(final DomainMapper<Long, ActivityDTO> inActivityDAO); @Override NotificationBatch translate(final ActivityNotificationsRequest inRequest);  }