@Test 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(); assertEquals(1, results.getRecipients().size()); TranslatorTestHelper.assertRecipients(results, NotificationType.FLAG_ACTIVITY, NON_ACTOR_ADMIN_IDS); 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); }
@Override public NotificationBatch translate(final ActivityNotificationsRequest inRequest) { ActivityDTO activity = activityDAO.execute(inRequest.getActivityId()); StreamEntityDTO stream = activity.getDestinationStream(); List<Long> adminIds = systemAdminsDAO.execute(null); adminIds.remove(inRequest.getActorId()); NotificationBatch batch = new NotificationBatch(NotificationType.FLAG_ACTIVITY, adminIds); batch.setProperty(NotificationPropertyKeys.ACTOR, PersonModelView.class, inRequest.getActorId()); batch.setProperty("activity", activity); batch.setProperty("stream", stream); batch.setPropertyAlias(NotificationPropertyKeys.SOURCE, "stream"); batch.setProperty(NotificationPropertyKeys.HIGH_PRIORITY, true); batch.setProperty(NotificationPropertyKeys.URL, UiUrlBuilder.relativeUrlForFlaggedActivity()); return batch; }
FlagTranslator implements NotificationTranslator<ActivityNotificationsRequest> { @Override public NotificationBatch translate(final ActivityNotificationsRequest inRequest) { ActivityDTO activity = activityDAO.execute(inRequest.getActivityId()); StreamEntityDTO stream = activity.getDestinationStream(); List<Long> adminIds = systemAdminsDAO.execute(null); adminIds.remove(inRequest.getActorId()); NotificationBatch batch = new NotificationBatch(NotificationType.FLAG_ACTIVITY, adminIds); batch.setProperty(NotificationPropertyKeys.ACTOR, PersonModelView.class, inRequest.getActorId()); batch.setProperty("activity", activity); batch.setProperty("stream", stream); batch.setPropertyAlias(NotificationPropertyKeys.SOURCE, "stream"); batch.setProperty(NotificationPropertyKeys.HIGH_PRIORITY, true); batch.setProperty(NotificationPropertyKeys.URL, UiUrlBuilder.relativeUrlForFlaggedActivity()); return batch; } }
FlagTranslator implements NotificationTranslator<ActivityNotificationsRequest> { @Override public NotificationBatch translate(final ActivityNotificationsRequest inRequest) { ActivityDTO activity = activityDAO.execute(inRequest.getActivityId()); StreamEntityDTO stream = activity.getDestinationStream(); List<Long> adminIds = systemAdminsDAO.execute(null); adminIds.remove(inRequest.getActorId()); NotificationBatch batch = new NotificationBatch(NotificationType.FLAG_ACTIVITY, adminIds); batch.setProperty(NotificationPropertyKeys.ACTOR, PersonModelView.class, inRequest.getActorId()); batch.setProperty("activity", activity); batch.setProperty("stream", stream); batch.setPropertyAlias(NotificationPropertyKeys.SOURCE, "stream"); batch.setProperty(NotificationPropertyKeys.HIGH_PRIORITY, true); batch.setProperty(NotificationPropertyKeys.URL, UiUrlBuilder.relativeUrlForFlaggedActivity()); return batch; } FlagTranslator(final DomainMapper<Long, ActivityDTO> inActivityDAO,
            final DomainMapper<Serializable, List<Long>> inSystemAdminsDAO); }
FlagTranslator implements NotificationTranslator<ActivityNotificationsRequest> { @Override public NotificationBatch translate(final ActivityNotificationsRequest inRequest) { ActivityDTO activity = activityDAO.execute(inRequest.getActivityId()); StreamEntityDTO stream = activity.getDestinationStream(); List<Long> adminIds = systemAdminsDAO.execute(null); adminIds.remove(inRequest.getActorId()); NotificationBatch batch = new NotificationBatch(NotificationType.FLAG_ACTIVITY, adminIds); batch.setProperty(NotificationPropertyKeys.ACTOR, PersonModelView.class, inRequest.getActorId()); batch.setProperty("activity", activity); batch.setProperty("stream", stream); batch.setPropertyAlias(NotificationPropertyKeys.SOURCE, "stream"); batch.setProperty(NotificationPropertyKeys.HIGH_PRIORITY, true); batch.setProperty(NotificationPropertyKeys.URL, UiUrlBuilder.relativeUrlForFlaggedActivity()); return batch; } FlagTranslator(final DomainMapper<Long, ActivityDTO> inActivityDAO,
            final DomainMapper<Serializable, List<Long>> inSystemAdminsDAO); @Override NotificationBatch translate(final ActivityNotificationsRequest inRequest); }
FlagTranslator implements NotificationTranslator<ActivityNotificationsRequest> { @Override public NotificationBatch translate(final ActivityNotificationsRequest inRequest) { ActivityDTO activity = activityDAO.execute(inRequest.getActivityId()); StreamEntityDTO stream = activity.getDestinationStream(); List<Long> adminIds = systemAdminsDAO.execute(null); adminIds.remove(inRequest.getActorId()); NotificationBatch batch = new NotificationBatch(NotificationType.FLAG_ACTIVITY, adminIds); batch.setProperty(NotificationPropertyKeys.ACTOR, PersonModelView.class, inRequest.getActorId()); batch.setProperty("activity", activity); batch.setProperty("stream", stream); batch.setPropertyAlias(NotificationPropertyKeys.SOURCE, "stream"); batch.setProperty(NotificationPropertyKeys.HIGH_PRIORITY, true); batch.setProperty(NotificationPropertyKeys.URL, UiUrlBuilder.relativeUrlForFlaggedActivity()); return batch; } FlagTranslator(final DomainMapper<Long, ActivityDTO> inActivityDAO,
            final DomainMapper<Serializable, List<Long>> inSystemAdminsDAO); @Override NotificationBatch translate(final ActivityNotificationsRequest inRequest);  }