@Test public void testTranslateFollowGroup() { final List<Long> coordinators = Arrays.asList(COORDINATOR1_ID, COORDINATOR2_ID); context.checking(new Expectations() { { oneOf(coordinatorDAO).execute(GROUP_FOLLOWED_ID); will(returnValue(coordinators)); allowing(idToUniqueIdDAO).execute(ACTOR_ID); will(returnValue("somebody")); } }); NotificationBatch results = sut.translate(new TargetEntityNotificationsRequest(null, ACTOR_ID, GROUP_FOLLOWED_ID)); context.assertIsSatisfied(); assertEquals(1, results.getRecipients().size()); TranslatorTestHelper .assertRecipients(results, NotificationType.FOLLOW_GROUP, COORDINATOR1_ID, COORDINATOR2_ID); PropertyMap<Object> props = results.getProperties(); assertEquals(4, props.size()); PropertyMapTestHelper.assertPlaceholder(props, "actor", PersonModelView.class, ACTOR_ID); PropertyMapTestHelper.assertPlaceholder(props, "stream", DomainGroupModelView.class, GROUP_FOLLOWED_ID); PropertyMapTestHelper.assertAlias(props, "source", "stream"); PropertyMapTestHelper.assertValue(props, NotificationPropertyKeys.URL, "#activity/person/somebody"); }
@Override public NotificationBatch translate(final TargetEntityNotificationsRequest inRequest) { List<Long> coordinatorIds = coordinatorDAO.execute(inRequest.getTargetEntityId()); if (coordinatorIds.contains(inRequest.getActorId())) { return null; } NotificationBatch batch = new NotificationBatch(NotificationType.FOLLOW_GROUP, coordinatorIds); batch.setProperty(NotificationPropertyKeys.ACTOR, PersonModelView.class, inRequest.getActorId()); batch.setProperty("stream", DomainGroupModelView.class, inRequest.getTargetEntityId()); batch.setPropertyAlias(NotificationPropertyKeys.SOURCE, "stream"); batch.setProperty(NotificationPropertyKeys.URL, UiUrlBuilder.relativeUrlForEntity(EntityType.PERSON, idToUniqueIdDAO.execute(inRequest.getActorId()))); return batch; }
FollowGroupTranslator implements NotificationTranslator<TargetEntityNotificationsRequest> { @Override public NotificationBatch translate(final TargetEntityNotificationsRequest inRequest) { List<Long> coordinatorIds = coordinatorDAO.execute(inRequest.getTargetEntityId()); if (coordinatorIds.contains(inRequest.getActorId())) { return null; } NotificationBatch batch = new NotificationBatch(NotificationType.FOLLOW_GROUP, coordinatorIds); batch.setProperty(NotificationPropertyKeys.ACTOR, PersonModelView.class, inRequest.getActorId()); batch.setProperty("stream", DomainGroupModelView.class, inRequest.getTargetEntityId()); batch.setPropertyAlias(NotificationPropertyKeys.SOURCE, "stream"); batch.setProperty(NotificationPropertyKeys.URL, UiUrlBuilder.relativeUrlForEntity(EntityType.PERSON, idToUniqueIdDAO.execute(inRequest.getActorId()))); return batch; } }
FollowGroupTranslator implements NotificationTranslator<TargetEntityNotificationsRequest> { @Override public NotificationBatch translate(final TargetEntityNotificationsRequest inRequest) { List<Long> coordinatorIds = coordinatorDAO.execute(inRequest.getTargetEntityId()); if (coordinatorIds.contains(inRequest.getActorId())) { return null; } NotificationBatch batch = new NotificationBatch(NotificationType.FOLLOW_GROUP, coordinatorIds); batch.setProperty(NotificationPropertyKeys.ACTOR, PersonModelView.class, inRequest.getActorId()); batch.setProperty("stream", DomainGroupModelView.class, inRequest.getTargetEntityId()); batch.setPropertyAlias(NotificationPropertyKeys.SOURCE, "stream"); batch.setProperty(NotificationPropertyKeys.URL, UiUrlBuilder.relativeUrlForEntity(EntityType.PERSON, idToUniqueIdDAO.execute(inRequest.getActorId()))); return batch; } FollowGroupTranslator(final DomainMapper<Long, List<Long>> inCoordinatorDAO,
            final DomainMapper<Long, String> inIdToUniqueIdDAO); }
FollowGroupTranslator implements NotificationTranslator<TargetEntityNotificationsRequest> { @Override public NotificationBatch translate(final TargetEntityNotificationsRequest inRequest) { List<Long> coordinatorIds = coordinatorDAO.execute(inRequest.getTargetEntityId()); if (coordinatorIds.contains(inRequest.getActorId())) { return null; } NotificationBatch batch = new NotificationBatch(NotificationType.FOLLOW_GROUP, coordinatorIds); batch.setProperty(NotificationPropertyKeys.ACTOR, PersonModelView.class, inRequest.getActorId()); batch.setProperty("stream", DomainGroupModelView.class, inRequest.getTargetEntityId()); batch.setPropertyAlias(NotificationPropertyKeys.SOURCE, "stream"); batch.setProperty(NotificationPropertyKeys.URL, UiUrlBuilder.relativeUrlForEntity(EntityType.PERSON, idToUniqueIdDAO.execute(inRequest.getActorId()))); return batch; } FollowGroupTranslator(final DomainMapper<Long, List<Long>> inCoordinatorDAO,
            final DomainMapper<Long, String> inIdToUniqueIdDAO); @Override NotificationBatch translate(final TargetEntityNotificationsRequest inRequest); }
FollowGroupTranslator implements NotificationTranslator<TargetEntityNotificationsRequest> { @Override public NotificationBatch translate(final TargetEntityNotificationsRequest inRequest) { List<Long> coordinatorIds = coordinatorDAO.execute(inRequest.getTargetEntityId()); if (coordinatorIds.contains(inRequest.getActorId())) { return null; } NotificationBatch batch = new NotificationBatch(NotificationType.FOLLOW_GROUP, coordinatorIds); batch.setProperty(NotificationPropertyKeys.ACTOR, PersonModelView.class, inRequest.getActorId()); batch.setProperty("stream", DomainGroupModelView.class, inRequest.getTargetEntityId()); batch.setPropertyAlias(NotificationPropertyKeys.SOURCE, "stream"); batch.setProperty(NotificationPropertyKeys.URL, UiUrlBuilder.relativeUrlForEntity(EntityType.PERSON, idToUniqueIdDAO.execute(inRequest.getActorId()))); return batch; } FollowGroupTranslator(final DomainMapper<Long, List<Long>> inCoordinatorDAO,
            final DomainMapper<Long, String> inIdToUniqueIdDAO); @Override NotificationBatch translate(final TargetEntityNotificationsRequest inRequest);  }