@Test public void testTranslateFollowPerson() { NotificationTranslator<TargetEntityNotificationsRequest> sut = new FollowPersonTranslator(idToUniqueIdDAO); context.checking(new Expectations() { { allowing(idToUniqueIdDAO).execute(ACTOR_ID); will(returnValue("somebody")); } }); NotificationBatch results = sut.translate(new TargetEntityNotificationsRequest(null, ACTOR_ID, FOLLOWED_ID)); assertEquals(1, results.getRecipients().size()); TranslatorTestHelper.assertRecipients(results, NotificationType.FOLLOW_PERSON, FOLLOWED_ID); PropertyMap<Object> props = results.getProperties(); assertEquals(4, props.size()); PropertyMapTestHelper.assertPlaceholder(props, "actor", PersonModelView.class, ACTOR_ID); PropertyMapTestHelper.assertPlaceholder(props, "stream", PersonModelView.class, FOLLOWED_ID); PropertyMapTestHelper.assertAlias(props, "source", "stream"); PropertyMapTestHelper.assertValue(props, NotificationPropertyKeys.URL, "#activity/person/somebody"); }
@Override public NotificationBatch translate(final TargetEntityNotificationsRequest inRequest) { NotificationBatch batch = new NotificationBatch(NotificationType.FOLLOW_PERSON, inRequest.getTargetEntityId()); batch.setProperty(NotificationPropertyKeys.ACTOR, PersonModelView.class, inRequest.getActorId()); batch.setProperty("stream", PersonModelView.class, inRequest.getTargetEntityId()); batch.setPropertyAlias(NotificationPropertyKeys.SOURCE, "stream"); batch.setProperty(NotificationPropertyKeys.URL, UiUrlBuilder.relativeUrlForEntity(EntityType.PERSON, idToUniqueIdDAO.execute(inRequest.getActorId()))); return batch; }
FollowPersonTranslator implements NotificationTranslator<TargetEntityNotificationsRequest> { @Override public NotificationBatch translate(final TargetEntityNotificationsRequest inRequest) { NotificationBatch batch = new NotificationBatch(NotificationType.FOLLOW_PERSON, inRequest.getTargetEntityId()); batch.setProperty(NotificationPropertyKeys.ACTOR, PersonModelView.class, inRequest.getActorId()); batch.setProperty("stream", PersonModelView.class, inRequest.getTargetEntityId()); batch.setPropertyAlias(NotificationPropertyKeys.SOURCE, "stream"); batch.setProperty(NotificationPropertyKeys.URL, UiUrlBuilder.relativeUrlForEntity(EntityType.PERSON, idToUniqueIdDAO.execute(inRequest.getActorId()))); return batch; } }
FollowPersonTranslator implements NotificationTranslator<TargetEntityNotificationsRequest> { @Override public NotificationBatch translate(final TargetEntityNotificationsRequest inRequest) { NotificationBatch batch = new NotificationBatch(NotificationType.FOLLOW_PERSON, inRequest.getTargetEntityId()); batch.setProperty(NotificationPropertyKeys.ACTOR, PersonModelView.class, inRequest.getActorId()); batch.setProperty("stream", PersonModelView.class, inRequest.getTargetEntityId()); batch.setPropertyAlias(NotificationPropertyKeys.SOURCE, "stream"); batch.setProperty(NotificationPropertyKeys.URL, UiUrlBuilder.relativeUrlForEntity(EntityType.PERSON, idToUniqueIdDAO.execute(inRequest.getActorId()))); return batch; } FollowPersonTranslator(final DomainMapper<Long, String> inIdToUniqueIdDAO); }
FollowPersonTranslator implements NotificationTranslator<TargetEntityNotificationsRequest> { @Override public NotificationBatch translate(final TargetEntityNotificationsRequest inRequest) { NotificationBatch batch = new NotificationBatch(NotificationType.FOLLOW_PERSON, inRequest.getTargetEntityId()); batch.setProperty(NotificationPropertyKeys.ACTOR, PersonModelView.class, inRequest.getActorId()); batch.setProperty("stream", PersonModelView.class, inRequest.getTargetEntityId()); batch.setPropertyAlias(NotificationPropertyKeys.SOURCE, "stream"); batch.setProperty(NotificationPropertyKeys.URL, UiUrlBuilder.relativeUrlForEntity(EntityType.PERSON, idToUniqueIdDAO.execute(inRequest.getActorId()))); return batch; } FollowPersonTranslator(final DomainMapper<Long, String> inIdToUniqueIdDAO); @Override NotificationBatch translate(final TargetEntityNotificationsRequest inRequest); }
FollowPersonTranslator implements NotificationTranslator<TargetEntityNotificationsRequest> { @Override public NotificationBatch translate(final TargetEntityNotificationsRequest inRequest) { NotificationBatch batch = new NotificationBatch(NotificationType.FOLLOW_PERSON, inRequest.getTargetEntityId()); batch.setProperty(NotificationPropertyKeys.ACTOR, PersonModelView.class, inRequest.getActorId()); batch.setProperty("stream", PersonModelView.class, inRequest.getTargetEntityId()); batch.setPropertyAlias(NotificationPropertyKeys.SOURCE, "stream"); batch.setProperty(NotificationPropertyKeys.URL, UiUrlBuilder.relativeUrlForEntity(EntityType.PERSON, idToUniqueIdDAO.execute(inRequest.getActorId()))); return batch; } FollowPersonTranslator(final DomainMapper<Long, String> inIdToUniqueIdDAO); @Override NotificationBatch translate(final TargetEntityNotificationsRequest inRequest);  }