@Test public void testTranslateGroupStreamPostCoord() { final List<Long> subscribers = new ArrayList<Long>(subscribersAll); subscribers.add(COORDINATOR2_ID); context.checking(new Expectations() { { oneOf(coordinatorsDAO).execute(GROUP_ID); will(returnValue(coordinators)); oneOf(subscribersAllDAO).execute(GROUP_ID); will(returnValue(subscribers)); } }); NotificationBatch results = sut.translate(new ActivityNotificationsRequest(null, COORDINATOR2_ID, GROUP_ID, ACTIVITY_ID)); context.assertIsSatisfied(); assertEquals(1, results.getRecipients().size()); TranslatorTestHelper.assertRecipients(results, NotificationType.POST_TO_FOLLOWED_STREAM, subscribers); PropertyMap<Object> props = results.getProperties(); assertEquals(5, props.size()); PropertyMapTestHelper.assertPlaceholder(props, "actor", PersonModelView.class, COORDINATOR2_ID); PropertyMapTestHelper.assertPlaceholder(props, "stream", DomainGroupModelView.class, GROUP_ID); PropertyMapTestHelper.assertAlias(props, "source", "stream"); PropertyMapTestHelper.assertPlaceholder(props, "activity", ActivityDTO.class, ACTIVITY_ID); PropertyMapTestHelper.assertValue(props, NotificationPropertyKeys.URL, "#activity/" + ACTIVITY_ID); }
public NotificationBatch translate(final ActivityNotificationsRequest inRequest) { boolean fromCoord = coordinatorDAO.execute(inRequest.getTargetEntityId()).contains(inRequest.getActorId()); DomainMapper<Long, List<Long>> subscriberDAO = fromCoord ? allSubscriberDAO : unrestrictedSubscriberDAO; List<Long> idsToNotify = subscriberDAO.execute(inRequest.getTargetEntityId()); idsToNotify.remove(inRequest.getActorId()); if (idsToNotify.isEmpty()) { return null; } NotificationBatch batch = new NotificationBatch(NotificationType.POST_TO_FOLLOWED_STREAM, idsToNotify); batch.setProperty(NotificationPropertyKeys.ACTOR, PersonModelView.class, inRequest.getActorId()); batch.setProperty("stream", DomainGroupModelView.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; }
PostGroupStreamTranslator implements NotificationTranslator<ActivityNotificationsRequest> { public NotificationBatch translate(final ActivityNotificationsRequest inRequest) { boolean fromCoord = coordinatorDAO.execute(inRequest.getTargetEntityId()).contains(inRequest.getActorId()); DomainMapper<Long, List<Long>> subscriberDAO = fromCoord ? allSubscriberDAO : unrestrictedSubscriberDAO; List<Long> idsToNotify = subscriberDAO.execute(inRequest.getTargetEntityId()); idsToNotify.remove(inRequest.getActorId()); if (idsToNotify.isEmpty()) { return null; } NotificationBatch batch = new NotificationBatch(NotificationType.POST_TO_FOLLOWED_STREAM, idsToNotify); batch.setProperty(NotificationPropertyKeys.ACTOR, PersonModelView.class, inRequest.getActorId()); batch.setProperty("stream", DomainGroupModelView.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; } }
PostGroupStreamTranslator implements NotificationTranslator<ActivityNotificationsRequest> { public NotificationBatch translate(final ActivityNotificationsRequest inRequest) { boolean fromCoord = coordinatorDAO.execute(inRequest.getTargetEntityId()).contains(inRequest.getActorId()); DomainMapper<Long, List<Long>> subscriberDAO = fromCoord ? allSubscriberDAO : unrestrictedSubscriberDAO; List<Long> idsToNotify = subscriberDAO.execute(inRequest.getTargetEntityId()); idsToNotify.remove(inRequest.getActorId()); if (idsToNotify.isEmpty()) { return null; } NotificationBatch batch = new NotificationBatch(NotificationType.POST_TO_FOLLOWED_STREAM, idsToNotify); batch.setProperty(NotificationPropertyKeys.ACTOR, PersonModelView.class, inRequest.getActorId()); batch.setProperty("stream", DomainGroupModelView.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; } PostGroupStreamTranslator(final DomainMapper<Long, List<Long>> inCoordinatorDAO,
            final DomainMapper<Long, List<Long>> inAllSubscriberDAO,
            final DomainMapper<Long, List<Long>> inUnrestrictedSubscriberDAO); }
PostGroupStreamTranslator implements NotificationTranslator<ActivityNotificationsRequest> { public NotificationBatch translate(final ActivityNotificationsRequest inRequest) { boolean fromCoord = coordinatorDAO.execute(inRequest.getTargetEntityId()).contains(inRequest.getActorId()); DomainMapper<Long, List<Long>> subscriberDAO = fromCoord ? allSubscriberDAO : unrestrictedSubscriberDAO; List<Long> idsToNotify = subscriberDAO.execute(inRequest.getTargetEntityId()); idsToNotify.remove(inRequest.getActorId()); if (idsToNotify.isEmpty()) { return null; } NotificationBatch batch = new NotificationBatch(NotificationType.POST_TO_FOLLOWED_STREAM, idsToNotify); batch.setProperty(NotificationPropertyKeys.ACTOR, PersonModelView.class, inRequest.getActorId()); batch.setProperty("stream", DomainGroupModelView.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; } PostGroupStreamTranslator(final DomainMapper<Long, List<Long>> inCoordinatorDAO,
            final DomainMapper<Long, List<Long>> inAllSubscriberDAO,
            final DomainMapper<Long, List<Long>> inUnrestrictedSubscriberDAO); NotificationBatch translate(final ActivityNotificationsRequest inRequest); }
PostGroupStreamTranslator implements NotificationTranslator<ActivityNotificationsRequest> { public NotificationBatch translate(final ActivityNotificationsRequest inRequest) { boolean fromCoord = coordinatorDAO.execute(inRequest.getTargetEntityId()).contains(inRequest.getActorId()); DomainMapper<Long, List<Long>> subscriberDAO = fromCoord ? allSubscriberDAO : unrestrictedSubscriberDAO; List<Long> idsToNotify = subscriberDAO.execute(inRequest.getTargetEntityId()); idsToNotify.remove(inRequest.getActorId()); if (idsToNotify.isEmpty()) { return null; } NotificationBatch batch = new NotificationBatch(NotificationType.POST_TO_FOLLOWED_STREAM, idsToNotify); batch.setProperty(NotificationPropertyKeys.ACTOR, PersonModelView.class, inRequest.getActorId()); batch.setProperty("stream", DomainGroupModelView.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; } PostGroupStreamTranslator(final DomainMapper<Long, List<Long>> inCoordinatorDAO,
            final DomainMapper<Long, List<Long>> inAllSubscriberDAO,
            final DomainMapper<Long, List<Long>> inUnrestrictedSubscriberDAO); NotificationBatch translate(final ActivityNotificationsRequest inRequest);  }