@Test public void testTranslate() { final long groupId = 50L; NotificationTranslator<TargetEntityNotificationsRequest> sut = new PendingGroupApprovedTranslator(groupMapper, groupCoordinatorMapper); final DomainGroupModelView group = context.mock(DomainGroupModelView.class); context.checking(new Expectations() { { allowing(groupMapper).execute(groupId); will(returnValue(group)); allowing(groupCoordinatorMapper).execute(groupId); will(returnValue(Arrays.asList(4L, 2L))); allowing(group).getUniqueId(); will(returnValue("somegroup")); } }); NotificationBatch results = sut.translate(new TargetEntityNotificationsRequest( RequestType.REQUEST_NEW_GROUP_APPROVED, 0L, groupId)); context.assertIsSatisfied(); assertEquals(1, results.getRecipients().size()); TranslatorTestHelper.assertRecipients(results, NotificationType.REQUEST_NEW_GROUP_APPROVED, 2L, 4L); PropertyMap<Object> props = results.getProperties(); assertEquals(3, props.size()); PropertyMapTestHelper.assertValue(props, "group", group); PropertyMapTestHelper.assertValue(props, NotificationPropertyKeys.HIGH_PRIORITY, true); PropertyMapTestHelper.assertValue(props, NotificationPropertyKeys.URL, "#activity/group/somegroup"); }
@Override public NotificationBatch translate(final TargetEntityNotificationsRequest inRequest) { DomainGroupModelView group = groupDAO.execute(inRequest.getTargetEntityId()); Collection<Long> recipientIds = groupCoordinatorDAO.execute(inRequest.getTargetEntityId()); NotificationBatch batch = new NotificationBatch(NotificationType.REQUEST_NEW_GROUP_APPROVED, recipientIds); batch.setProperty("group", group); batch.setProperty(NotificationPropertyKeys.HIGH_PRIORITY, true); batch.setProperty(NotificationPropertyKeys.URL, UiUrlBuilder.relativeUrlForEntity(EntityType.GROUP, group.getUniqueId())); return batch; }
PendingGroupApprovedTranslator implements NotificationTranslator<TargetEntityNotificationsRequest> { @Override public NotificationBatch translate(final TargetEntityNotificationsRequest inRequest) { DomainGroupModelView group = groupDAO.execute(inRequest.getTargetEntityId()); Collection<Long> recipientIds = groupCoordinatorDAO.execute(inRequest.getTargetEntityId()); NotificationBatch batch = new NotificationBatch(NotificationType.REQUEST_NEW_GROUP_APPROVED, recipientIds); batch.setProperty("group", group); batch.setProperty(NotificationPropertyKeys.HIGH_PRIORITY, true); batch.setProperty(NotificationPropertyKeys.URL, UiUrlBuilder.relativeUrlForEntity(EntityType.GROUP, group.getUniqueId())); return batch; } }
PendingGroupApprovedTranslator implements NotificationTranslator<TargetEntityNotificationsRequest> { @Override public NotificationBatch translate(final TargetEntityNotificationsRequest inRequest) { DomainGroupModelView group = groupDAO.execute(inRequest.getTargetEntityId()); Collection<Long> recipientIds = groupCoordinatorDAO.execute(inRequest.getTargetEntityId()); NotificationBatch batch = new NotificationBatch(NotificationType.REQUEST_NEW_GROUP_APPROVED, recipientIds); batch.setProperty("group", group); batch.setProperty(NotificationPropertyKeys.HIGH_PRIORITY, true); batch.setProperty(NotificationPropertyKeys.URL, UiUrlBuilder.relativeUrlForEntity(EntityType.GROUP, group.getUniqueId())); return batch; } PendingGroupApprovedTranslator(final DomainMapper<Long, DomainGroupModelView> inGroupDAO,
            final DomainMapper<Long, List<Long>> inGroupCoordinatorDAO); }
PendingGroupApprovedTranslator implements NotificationTranslator<TargetEntityNotificationsRequest> { @Override public NotificationBatch translate(final TargetEntityNotificationsRequest inRequest) { DomainGroupModelView group = groupDAO.execute(inRequest.getTargetEntityId()); Collection<Long> recipientIds = groupCoordinatorDAO.execute(inRequest.getTargetEntityId()); NotificationBatch batch = new NotificationBatch(NotificationType.REQUEST_NEW_GROUP_APPROVED, recipientIds); batch.setProperty("group", group); batch.setProperty(NotificationPropertyKeys.HIGH_PRIORITY, true); batch.setProperty(NotificationPropertyKeys.URL, UiUrlBuilder.relativeUrlForEntity(EntityType.GROUP, group.getUniqueId())); return batch; } PendingGroupApprovedTranslator(final DomainMapper<Long, DomainGroupModelView> inGroupDAO,
            final DomainMapper<Long, List<Long>> inGroupCoordinatorDAO); @Override NotificationBatch translate(final TargetEntityNotificationsRequest inRequest); }
PendingGroupApprovedTranslator implements NotificationTranslator<TargetEntityNotificationsRequest> { @Override public NotificationBatch translate(final TargetEntityNotificationsRequest inRequest) { DomainGroupModelView group = groupDAO.execute(inRequest.getTargetEntityId()); Collection<Long> recipientIds = groupCoordinatorDAO.execute(inRequest.getTargetEntityId()); NotificationBatch batch = new NotificationBatch(NotificationType.REQUEST_NEW_GROUP_APPROVED, recipientIds); batch.setProperty("group", group); batch.setProperty(NotificationPropertyKeys.HIGH_PRIORITY, true); batch.setProperty(NotificationPropertyKeys.URL, UiUrlBuilder.relativeUrlForEntity(EntityType.GROUP, group.getUniqueId())); return batch; } PendingGroupApprovedTranslator(final DomainMapper<Long, DomainGroupModelView> inGroupDAO,
            final DomainMapper<Long, List<Long>> inGroupCoordinatorDAO); @Override NotificationBatch translate(final TargetEntityNotificationsRequest inRequest);  }