@Test public void testTranslateOwnPersonalStreamPost() { context.checking(new Expectations() { { allowing(followersDAO).execute(ACTOR_ID); will(returnValue(new ArrayList<Long>())); } }); NotificationBatch results = sut.translate(new ActivityNotificationsRequest(null, ACTOR_ID, ACTOR_ID, ACTIVITY_ID)); assertNull(results); }
@Override public NotificationBatch translate(final ActivityNotificationsRequest inRequest) { List<Long> followerIdsToNotify = followersDAO.execute(inRequest.getTargetEntityId()); followerIdsToNotify.remove(inRequest.getActorId()); followerIdsToNotify.remove(inRequest.getTargetEntityId()); NotificationBatch batch = new NotificationBatch(); if (inRequest.getActorId() != inRequest.getTargetEntityId()) { batch.setRecipient(NotificationType.POST_TO_PERSONAL_STREAM, inRequest.getTargetEntityId()); } if (!followerIdsToNotify.isEmpty()) { batch.getRecipients().put(NotificationType.POST_TO_FOLLOWED_STREAM, followerIdsToNotify); } if (batch.getRecipients().isEmpty()) { return null; } batch.setProperty(NotificationPropertyKeys.ACTOR, PersonModelView.class, inRequest.getActorId()); batch.setProperty("stream", PersonModelView.class, inRequest.getTargetEntityId()); batch.setProperty("activity", ActivityDTO.class, inRequest.getActivityId()); batch.setPropertyAlias(NotificationPropertyKeys.SOURCE, "stream"); batch.setProperty(NotificationPropertyKeys.URL, UiUrlBuilder.relativeUrlForActivity(inRequest.getActivityId())); return batch; }
PostPersonStreamTranslator implements NotificationTranslator<ActivityNotificationsRequest> { @Override public NotificationBatch translate(final ActivityNotificationsRequest inRequest) { List<Long> followerIdsToNotify = followersDAO.execute(inRequest.getTargetEntityId()); followerIdsToNotify.remove(inRequest.getActorId()); followerIdsToNotify.remove(inRequest.getTargetEntityId()); NotificationBatch batch = new NotificationBatch(); if (inRequest.getActorId() != inRequest.getTargetEntityId()) { batch.setRecipient(NotificationType.POST_TO_PERSONAL_STREAM, inRequest.getTargetEntityId()); } if (!followerIdsToNotify.isEmpty()) { batch.getRecipients().put(NotificationType.POST_TO_FOLLOWED_STREAM, followerIdsToNotify); } if (batch.getRecipients().isEmpty()) { return null; } batch.setProperty(NotificationPropertyKeys.ACTOR, PersonModelView.class, inRequest.getActorId()); batch.setProperty("stream", PersonModelView.class, inRequest.getTargetEntityId()); batch.setProperty("activity", ActivityDTO.class, inRequest.getActivityId()); batch.setPropertyAlias(NotificationPropertyKeys.SOURCE, "stream"); batch.setProperty(NotificationPropertyKeys.URL, UiUrlBuilder.relativeUrlForActivity(inRequest.getActivityId())); return batch; } }
PostPersonStreamTranslator implements NotificationTranslator<ActivityNotificationsRequest> { @Override public NotificationBatch translate(final ActivityNotificationsRequest inRequest) { List<Long> followerIdsToNotify = followersDAO.execute(inRequest.getTargetEntityId()); followerIdsToNotify.remove(inRequest.getActorId()); followerIdsToNotify.remove(inRequest.getTargetEntityId()); NotificationBatch batch = new NotificationBatch(); if (inRequest.getActorId() != inRequest.getTargetEntityId()) { batch.setRecipient(NotificationType.POST_TO_PERSONAL_STREAM, inRequest.getTargetEntityId()); } if (!followerIdsToNotify.isEmpty()) { batch.getRecipients().put(NotificationType.POST_TO_FOLLOWED_STREAM, followerIdsToNotify); } if (batch.getRecipients().isEmpty()) { return null; } batch.setProperty(NotificationPropertyKeys.ACTOR, PersonModelView.class, inRequest.getActorId()); batch.setProperty("stream", PersonModelView.class, inRequest.getTargetEntityId()); batch.setProperty("activity", ActivityDTO.class, inRequest.getActivityId()); batch.setPropertyAlias(NotificationPropertyKeys.SOURCE, "stream"); batch.setProperty(NotificationPropertyKeys.URL, UiUrlBuilder.relativeUrlForActivity(inRequest.getActivityId())); return batch; } PostPersonStreamTranslator(final DomainMapper<Long, List<Long>> inFollowersDAO); }
PostPersonStreamTranslator implements NotificationTranslator<ActivityNotificationsRequest> { @Override public NotificationBatch translate(final ActivityNotificationsRequest inRequest) { List<Long> followerIdsToNotify = followersDAO.execute(inRequest.getTargetEntityId()); followerIdsToNotify.remove(inRequest.getActorId()); followerIdsToNotify.remove(inRequest.getTargetEntityId()); NotificationBatch batch = new NotificationBatch(); if (inRequest.getActorId() != inRequest.getTargetEntityId()) { batch.setRecipient(NotificationType.POST_TO_PERSONAL_STREAM, inRequest.getTargetEntityId()); } if (!followerIdsToNotify.isEmpty()) { batch.getRecipients().put(NotificationType.POST_TO_FOLLOWED_STREAM, followerIdsToNotify); } if (batch.getRecipients().isEmpty()) { return null; } batch.setProperty(NotificationPropertyKeys.ACTOR, PersonModelView.class, inRequest.getActorId()); batch.setProperty("stream", PersonModelView.class, inRequest.getTargetEntityId()); batch.setProperty("activity", ActivityDTO.class, inRequest.getActivityId()); batch.setPropertyAlias(NotificationPropertyKeys.SOURCE, "stream"); batch.setProperty(NotificationPropertyKeys.URL, UiUrlBuilder.relativeUrlForActivity(inRequest.getActivityId())); return batch; } PostPersonStreamTranslator(final DomainMapper<Long, List<Long>> inFollowersDAO); @Override NotificationBatch translate(final ActivityNotificationsRequest inRequest); }
PostPersonStreamTranslator implements NotificationTranslator<ActivityNotificationsRequest> { @Override public NotificationBatch translate(final ActivityNotificationsRequest inRequest) { List<Long> followerIdsToNotify = followersDAO.execute(inRequest.getTargetEntityId()); followerIdsToNotify.remove(inRequest.getActorId()); followerIdsToNotify.remove(inRequest.getTargetEntityId()); NotificationBatch batch = new NotificationBatch(); if (inRequest.getActorId() != inRequest.getTargetEntityId()) { batch.setRecipient(NotificationType.POST_TO_PERSONAL_STREAM, inRequest.getTargetEntityId()); } if (!followerIdsToNotify.isEmpty()) { batch.getRecipients().put(NotificationType.POST_TO_FOLLOWED_STREAM, followerIdsToNotify); } if (batch.getRecipients().isEmpty()) { return null; } batch.setProperty(NotificationPropertyKeys.ACTOR, PersonModelView.class, inRequest.getActorId()); batch.setProperty("stream", PersonModelView.class, inRequest.getTargetEntityId()); batch.setProperty("activity", ActivityDTO.class, inRequest.getActivityId()); batch.setPropertyAlias(NotificationPropertyKeys.SOURCE, "stream"); batch.setProperty(NotificationPropertyKeys.URL, UiUrlBuilder.relativeUrlForActivity(inRequest.getActivityId())); return batch; } PostPersonStreamTranslator(final DomainMapper<Long, List<Long>> inFollowersDAO); @Override NotificationBatch translate(final ActivityNotificationsRequest inRequest);  }