@Test public void testTranslate() { final List<Long> coordinators = new ArrayList<Long>(); coordinators.add(COORDINATOR1_ID); coordinators.add(COORDINATOR3_ID); context.checking(new Expectations() { { oneOf(coordinatorsDAO).execute(GROUP_ID); will(returnValue(coordinators)); allowing(idToUniqueIdDAO).execute(GROUP_ID); will(returnValue("somegroup")); } }); NotificationBatch results = sut.translate(new TargetEntityNotificationsRequest(null, ACTOR_ID, GROUP_ID)); context.assertIsSatisfied(); assertEquals(1, results.getRecipients().size()); TranslatorTestHelper.assertRecipients(results, NotificationType.REQUEST_GROUP_ACCESS, COORDINATOR1_ID, COORDINATOR3_ID); PropertyMap<Object> props = results.getProperties(); assertEquals(5, props.size()); PropertyMapTestHelper.assertPlaceholder(props, "actor", PersonModelView.class, ACTOR_ID); PropertyMapTestHelper.assertPlaceholder(props, "group", DomainGroupModelView.class, GROUP_ID); 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) { List<Long> coordinatorIds = coordinatorDAO.execute(inRequest.getTargetEntityId()); NotificationBatch batch = new NotificationBatch(NotificationType.REQUEST_GROUP_ACCESS, coordinatorIds); batch.setProperty(NotificationPropertyKeys.ACTOR, PersonModelView.class, inRequest.getActorId()); batch.setProperty("group", DomainGroupModelView.class, inRequest.getTargetEntityId()); batch.setPropertyAlias(NotificationPropertyKeys.SOURCE, "group"); batch.setProperty(NotificationPropertyKeys.HIGH_PRIORITY, true); batch.setProperty(NotificationPropertyKeys.URL, UiUrlBuilder.relativeUrlForGroupAccessRequest(idToUniqueIdDAO.execute(inRequest.getTargetEntityId()))); return batch; }
RequestGroupAccessTranslator implements NotificationTranslator<TargetEntityNotificationsRequest> { @Override public NotificationBatch translate(final TargetEntityNotificationsRequest inRequest) { List<Long> coordinatorIds = coordinatorDAO.execute(inRequest.getTargetEntityId()); NotificationBatch batch = new NotificationBatch(NotificationType.REQUEST_GROUP_ACCESS, coordinatorIds); batch.setProperty(NotificationPropertyKeys.ACTOR, PersonModelView.class, inRequest.getActorId()); batch.setProperty("group", DomainGroupModelView.class, inRequest.getTargetEntityId()); batch.setPropertyAlias(NotificationPropertyKeys.SOURCE, "group"); batch.setProperty(NotificationPropertyKeys.HIGH_PRIORITY, true); batch.setProperty(NotificationPropertyKeys.URL, UiUrlBuilder.relativeUrlForGroupAccessRequest(idToUniqueIdDAO.execute(inRequest.getTargetEntityId()))); return batch; } }
RequestGroupAccessTranslator implements NotificationTranslator<TargetEntityNotificationsRequest> { @Override public NotificationBatch translate(final TargetEntityNotificationsRequest inRequest) { List<Long> coordinatorIds = coordinatorDAO.execute(inRequest.getTargetEntityId()); NotificationBatch batch = new NotificationBatch(NotificationType.REQUEST_GROUP_ACCESS, coordinatorIds); batch.setProperty(NotificationPropertyKeys.ACTOR, PersonModelView.class, inRequest.getActorId()); batch.setProperty("group", DomainGroupModelView.class, inRequest.getTargetEntityId()); batch.setPropertyAlias(NotificationPropertyKeys.SOURCE, "group"); batch.setProperty(NotificationPropertyKeys.HIGH_PRIORITY, true); batch.setProperty(NotificationPropertyKeys.URL, UiUrlBuilder.relativeUrlForGroupAccessRequest(idToUniqueIdDAO.execute(inRequest.getTargetEntityId()))); return batch; } RequestGroupAccessTranslator(final DomainMapper<Long, List<Long>> inCoordinatorDAO,
            final DomainMapper<Long, String> inIdToUniqueIdDAO); }
RequestGroupAccessTranslator implements NotificationTranslator<TargetEntityNotificationsRequest> { @Override public NotificationBatch translate(final TargetEntityNotificationsRequest inRequest) { List<Long> coordinatorIds = coordinatorDAO.execute(inRequest.getTargetEntityId()); NotificationBatch batch = new NotificationBatch(NotificationType.REQUEST_GROUP_ACCESS, coordinatorIds); batch.setProperty(NotificationPropertyKeys.ACTOR, PersonModelView.class, inRequest.getActorId()); batch.setProperty("group", DomainGroupModelView.class, inRequest.getTargetEntityId()); batch.setPropertyAlias(NotificationPropertyKeys.SOURCE, "group"); batch.setProperty(NotificationPropertyKeys.HIGH_PRIORITY, true); batch.setProperty(NotificationPropertyKeys.URL, UiUrlBuilder.relativeUrlForGroupAccessRequest(idToUniqueIdDAO.execute(inRequest.getTargetEntityId()))); return batch; } RequestGroupAccessTranslator(final DomainMapper<Long, List<Long>> inCoordinatorDAO,
            final DomainMapper<Long, String> inIdToUniqueIdDAO); @Override NotificationBatch translate(final TargetEntityNotificationsRequest inRequest); }
RequestGroupAccessTranslator implements NotificationTranslator<TargetEntityNotificationsRequest> { @Override public NotificationBatch translate(final TargetEntityNotificationsRequest inRequest) { List<Long> coordinatorIds = coordinatorDAO.execute(inRequest.getTargetEntityId()); NotificationBatch batch = new NotificationBatch(NotificationType.REQUEST_GROUP_ACCESS, coordinatorIds); batch.setProperty(NotificationPropertyKeys.ACTOR, PersonModelView.class, inRequest.getActorId()); batch.setProperty("group", DomainGroupModelView.class, inRequest.getTargetEntityId()); batch.setPropertyAlias(NotificationPropertyKeys.SOURCE, "group"); batch.setProperty(NotificationPropertyKeys.HIGH_PRIORITY, true); batch.setProperty(NotificationPropertyKeys.URL, UiUrlBuilder.relativeUrlForGroupAccessRequest(idToUniqueIdDAO.execute(inRequest.getTargetEntityId()))); return batch; } RequestGroupAccessTranslator(final DomainMapper<Long, List<Long>> inCoordinatorDAO,
            final DomainMapper<Long, String> inIdToUniqueIdDAO); @Override NotificationBatch translate(final TargetEntityNotificationsRequest inRequest);  }