@Test public void testTranslateApproved() { NotificationTranslator<GroupMembershipResponseNotificationsRequest> sut = new GroupMembershipResponseTranslator( NotificationType.REQUEST_GROUP_ACCESS_APPROVED, idToUniqueIdDAO); context.checking(new Expectations() { { allowing(idToUniqueIdDAO).execute(GROUP_ID); will(returnValue("somegroup")); } }); NotificationBatch results = sut.translate(new GroupMembershipResponseNotificationsRequest( RequestType.REQUEST_GROUP_ACCESS_APPROVED, ACTOR_ID, GROUP_ID, REQUESTOR_ID)); assertEquals(1, results.getRecipients().size()); TranslatorTestHelper.assertRecipients(results, NotificationType.REQUEST_GROUP_ACCESS_APPROVED, REQUESTOR_ID); PropertyMap<Object> props = results.getProperties(); assertEquals(4, props.size()); PropertyMapTestHelper.assertPlaceholder(props, "group", DomainGroupModelView.class, GROUP_ID); PropertyMapTestHelper.assertAlias(props, NotificationPropertyKeys.ACTOR, "group"); PropertyMapTestHelper.assertAlias(props, NotificationPropertyKeys.SOURCE, "group"); PropertyMapTestHelper.assertValue(props, NotificationPropertyKeys.URL, "#activity/group/somegroup"); }
@Override public NotificationBatch translate(final GroupMembershipResponseNotificationsRequest inRequest) { NotificationBatch batch = new NotificationBatch(type, inRequest.getRequestorId()); batch.setProperty("group", DomainGroupModelView.class, inRequest.getTargetEntityId()); batch.setPropertyAlias(NotificationPropertyKeys.ACTOR, "group"); batch.setPropertyAlias(NotificationPropertyKeys.SOURCE, "group"); if (inRequest.getType() == RequestType.REQUEST_GROUP_ACCESS_APPROVED) { batch.setProperty( NotificationPropertyKeys.URL, UiUrlBuilder.relativeUrlForEntity(EntityType.GROUP, idToUniqueIdDAO.execute(inRequest.getTargetEntityId()))); } return batch; }
GroupMembershipResponseTranslator implements
        NotificationTranslator<GroupMembershipResponseNotificationsRequest> { @Override public NotificationBatch translate(final GroupMembershipResponseNotificationsRequest inRequest) { NotificationBatch batch = new NotificationBatch(type, inRequest.getRequestorId()); batch.setProperty("group", DomainGroupModelView.class, inRequest.getTargetEntityId()); batch.setPropertyAlias(NotificationPropertyKeys.ACTOR, "group"); batch.setPropertyAlias(NotificationPropertyKeys.SOURCE, "group"); if (inRequest.getType() == RequestType.REQUEST_GROUP_ACCESS_APPROVED) { batch.setProperty( NotificationPropertyKeys.URL, UiUrlBuilder.relativeUrlForEntity(EntityType.GROUP, idToUniqueIdDAO.execute(inRequest.getTargetEntityId()))); } return batch; } }
GroupMembershipResponseTranslator implements
        NotificationTranslator<GroupMembershipResponseNotificationsRequest> { @Override public NotificationBatch translate(final GroupMembershipResponseNotificationsRequest inRequest) { NotificationBatch batch = new NotificationBatch(type, inRequest.getRequestorId()); batch.setProperty("group", DomainGroupModelView.class, inRequest.getTargetEntityId()); batch.setPropertyAlias(NotificationPropertyKeys.ACTOR, "group"); batch.setPropertyAlias(NotificationPropertyKeys.SOURCE, "group"); if (inRequest.getType() == RequestType.REQUEST_GROUP_ACCESS_APPROVED) { batch.setProperty( NotificationPropertyKeys.URL, UiUrlBuilder.relativeUrlForEntity(EntityType.GROUP, idToUniqueIdDAO.execute(inRequest.getTargetEntityId()))); } return batch; } GroupMembershipResponseTranslator(final NotificationType inType,
            final DomainMapper<Long, String> inIdToUniqueIdDAO); }
GroupMembershipResponseTranslator implements
        NotificationTranslator<GroupMembershipResponseNotificationsRequest> { @Override public NotificationBatch translate(final GroupMembershipResponseNotificationsRequest inRequest) { NotificationBatch batch = new NotificationBatch(type, inRequest.getRequestorId()); batch.setProperty("group", DomainGroupModelView.class, inRequest.getTargetEntityId()); batch.setPropertyAlias(NotificationPropertyKeys.ACTOR, "group"); batch.setPropertyAlias(NotificationPropertyKeys.SOURCE, "group"); if (inRequest.getType() == RequestType.REQUEST_GROUP_ACCESS_APPROVED) { batch.setProperty( NotificationPropertyKeys.URL, UiUrlBuilder.relativeUrlForEntity(EntityType.GROUP, idToUniqueIdDAO.execute(inRequest.getTargetEntityId()))); } return batch; } GroupMembershipResponseTranslator(final NotificationType inType,
            final DomainMapper<Long, String> inIdToUniqueIdDAO); @Override NotificationBatch translate(final GroupMembershipResponseNotificationsRequest inRequest); }
GroupMembershipResponseTranslator implements
        NotificationTranslator<GroupMembershipResponseNotificationsRequest> { @Override public NotificationBatch translate(final GroupMembershipResponseNotificationsRequest inRequest) { NotificationBatch batch = new NotificationBatch(type, inRequest.getRequestorId()); batch.setProperty("group", DomainGroupModelView.class, inRequest.getTargetEntityId()); batch.setPropertyAlias(NotificationPropertyKeys.ACTOR, "group"); batch.setPropertyAlias(NotificationPropertyKeys.SOURCE, "group"); if (inRequest.getType() == RequestType.REQUEST_GROUP_ACCESS_APPROVED) { batch.setProperty( NotificationPropertyKeys.URL, UiUrlBuilder.relativeUrlForEntity(EntityType.GROUP, idToUniqueIdDAO.execute(inRequest.getTargetEntityId()))); } return batch; } GroupMembershipResponseTranslator(final NotificationType inType,
            final DomainMapper<Long, String> inIdToUniqueIdDAO); @Override NotificationBatch translate(final GroupMembershipResponseNotificationsRequest inRequest);  }