@Test public void testTranslate() { final long coord1id = 1001L; final long coord2id = 1002L; final String groupName = "The Name of My Group"; final long groupId = 2000L; final long orgId = 3000L; final long actorId = 4000L; final List<Long> admins = new ArrayList<Long>(); admins.add(coord1id); admins.add(coord2id); final DomainGroup group = new DomainGroup(); group.setName(groupName); final DomainMapper<Serializable, List<Long>> systemAdminIdsMapper = context.mock(DomainMapper.class, "SystemAdminIdsMapper"); final FindByIdMapper<DomainGroup> groupMapper = context.mock(FindByIdMapper.class); final FindByIdRequest mapperRequest = new FindByIdRequest("DomainGroup", groupId); context.checking(new Expectations() { { allowing(groupMapper).execute(with(equalInternally(mapperRequest))); will(returnValue(group)); oneOf(systemAdminIdsMapper).execute(null); will(returnValue(admins)); } }); NotificationTranslator<TargetEntityNotificationsRequest> sut = new RequestNewGroupTranslator(groupMapper, systemAdminIdsMapper); NotificationBatch results = sut.translate(new TargetEntityNotificationsRequest(null, actorId, groupId)); context.assertIsSatisfied(); assertEquals(1, results.getRecipients().size()); TranslatorTestHelper.assertRecipients(results, NotificationType.REQUEST_NEW_GROUP, admins); PropertyMap<Object> props = results.getProperties(); assertEquals(5, props.size()); PropertyMapTestHelper.assertPlaceholder(props, "actor", PersonModelView.class, actorId); PropertyMapTestHelper.assertValue(props, "group", group); PropertyMapTestHelper.assertValue(props, NotificationPropertyKeys.HIGH_PRIORITY, true); PropertyMapTestHelper.assertAlias(props, NotificationPropertyKeys.SOURCE, "group"); PropertyMapTestHelper.assertSetNonNull(props, NotificationPropertyKeys.URL); }
@Override public NotificationBatch translate(final TargetEntityNotificationsRequest inRequest) { DomainGroup group = groupDAO.execute(new FindByIdRequest("DomainGroup", inRequest.getTargetEntityId())); List<Long> admins = systemAdminIdsDAO.execute(null); NotificationBatch batch = new NotificationBatch(NotificationType.REQUEST_NEW_GROUP, admins); batch.setProperty(NotificationPropertyKeys.ACTOR, PersonModelView.class, inRequest.getActorId()); batch.setProperty("group", group); batch.setPropertyAlias(NotificationPropertyKeys.SOURCE, "group"); batch.setProperty(NotificationPropertyKeys.HIGH_PRIORITY, true); batch.setProperty(NotificationPropertyKeys.URL, UiUrlBuilder.relativeUrlForPendingGroupRequest()); return batch; }
RequestNewGroupTranslator implements NotificationTranslator<TargetEntityNotificationsRequest> { @Override public NotificationBatch translate(final TargetEntityNotificationsRequest inRequest) { DomainGroup group = groupDAO.execute(new FindByIdRequest("DomainGroup", inRequest.getTargetEntityId())); List<Long> admins = systemAdminIdsDAO.execute(null); NotificationBatch batch = new NotificationBatch(NotificationType.REQUEST_NEW_GROUP, admins); batch.setProperty(NotificationPropertyKeys.ACTOR, PersonModelView.class, inRequest.getActorId()); batch.setProperty("group", group); batch.setPropertyAlias(NotificationPropertyKeys.SOURCE, "group"); batch.setProperty(NotificationPropertyKeys.HIGH_PRIORITY, true); batch.setProperty(NotificationPropertyKeys.URL, UiUrlBuilder.relativeUrlForPendingGroupRequest()); return batch; } }
RequestNewGroupTranslator implements NotificationTranslator<TargetEntityNotificationsRequest> { @Override public NotificationBatch translate(final TargetEntityNotificationsRequest inRequest) { DomainGroup group = groupDAO.execute(new FindByIdRequest("DomainGroup", inRequest.getTargetEntityId())); List<Long> admins = systemAdminIdsDAO.execute(null); NotificationBatch batch = new NotificationBatch(NotificationType.REQUEST_NEW_GROUP, admins); batch.setProperty(NotificationPropertyKeys.ACTOR, PersonModelView.class, inRequest.getActorId()); batch.setProperty("group", group); batch.setPropertyAlias(NotificationPropertyKeys.SOURCE, "group"); batch.setProperty(NotificationPropertyKeys.HIGH_PRIORITY, true); batch.setProperty(NotificationPropertyKeys.URL, UiUrlBuilder.relativeUrlForPendingGroupRequest()); return batch; } RequestNewGroupTranslator(final FindByIdMapper<DomainGroup> inGroupDAO,
            final DomainMapper<Serializable, List<Long>> inSystemAdminIdsDAO); }
RequestNewGroupTranslator implements NotificationTranslator<TargetEntityNotificationsRequest> { @Override public NotificationBatch translate(final TargetEntityNotificationsRequest inRequest) { DomainGroup group = groupDAO.execute(new FindByIdRequest("DomainGroup", inRequest.getTargetEntityId())); List<Long> admins = systemAdminIdsDAO.execute(null); NotificationBatch batch = new NotificationBatch(NotificationType.REQUEST_NEW_GROUP, admins); batch.setProperty(NotificationPropertyKeys.ACTOR, PersonModelView.class, inRequest.getActorId()); batch.setProperty("group", group); batch.setPropertyAlias(NotificationPropertyKeys.SOURCE, "group"); batch.setProperty(NotificationPropertyKeys.HIGH_PRIORITY, true); batch.setProperty(NotificationPropertyKeys.URL, UiUrlBuilder.relativeUrlForPendingGroupRequest()); return batch; } RequestNewGroupTranslator(final FindByIdMapper<DomainGroup> inGroupDAO,
            final DomainMapper<Serializable, List<Long>> inSystemAdminIdsDAO); @Override NotificationBatch translate(final TargetEntityNotificationsRequest inRequest); }
RequestNewGroupTranslator implements NotificationTranslator<TargetEntityNotificationsRequest> { @Override public NotificationBatch translate(final TargetEntityNotificationsRequest inRequest) { DomainGroup group = groupDAO.execute(new FindByIdRequest("DomainGroup", inRequest.getTargetEntityId())); List<Long> admins = systemAdminIdsDAO.execute(null); NotificationBatch batch = new NotificationBatch(NotificationType.REQUEST_NEW_GROUP, admins); batch.setProperty(NotificationPropertyKeys.ACTOR, PersonModelView.class, inRequest.getActorId()); batch.setProperty("group", group); batch.setPropertyAlias(NotificationPropertyKeys.SOURCE, "group"); batch.setProperty(NotificationPropertyKeys.HIGH_PRIORITY, true); batch.setProperty(NotificationPropertyKeys.URL, UiUrlBuilder.relativeUrlForPendingGroupRequest()); return batch; } RequestNewGroupTranslator(final FindByIdMapper<DomainGroup> inGroupDAO,
            final DomainMapper<Serializable, List<Long>> inSystemAdminIdsDAO); @Override NotificationBatch translate(final TargetEntityNotificationsRequest inRequest);  }