@Test public void testTransform() { RequestTransformer sut = new SetCurrentUserNotificationPreferencesTransformer(notifierTypes, categories); ActionContext ctx = TestContextCreator.createPrincipalActionContext( (Serializable) Arrays.asList(dto1, dto2, dto3), null, PERSON_ID); SetUserNotificationFilterPreferencesRequest result = (SetUserNotificationFilterPreferencesRequest) sut .transform(ctx); assertEquals(PERSON_ID, result.getPersonId()); Collection<NotificationFilterPreferenceDTO> list = result.getPrefList(); assertEquals(1, list.size()); NotificationFilterPreferenceDTO dto = list.iterator().next(); assertEquals("EMAIL", dto.getNotifierType()); assertEquals("COMMENT", dto.getNotificationCategory()); }
@Override public Serializable transform(final ActionContext inActionContext) { long userId = ((PrincipalActionContext) inActionContext).getPrincipal().getId(); Collection<NotificationFilterPreferenceDTO> list = new ArrayList<NotificationFilterPreferenceDTO>(); for (NotificationFilterPreferenceDTO dto : (Collection<NotificationFilterPreferenceDTO>) inActionContext .getParams()) { if (categories.contains(dto.getNotificationCategory()) && notifierTypes.containsKey(dto.getNotifierType())) { list.add(dto); } } return new SetUserNotificationFilterPreferencesRequest(userId, list); }
SetCurrentUserNotificationPreferencesTransformer implements RequestTransformer { @Override public Serializable transform(final ActionContext inActionContext) { long userId = ((PrincipalActionContext) inActionContext).getPrincipal().getId(); Collection<NotificationFilterPreferenceDTO> list = new ArrayList<NotificationFilterPreferenceDTO>(); for (NotificationFilterPreferenceDTO dto : (Collection<NotificationFilterPreferenceDTO>) inActionContext .getParams()) { if (categories.contains(dto.getNotificationCategory()) && notifierTypes.containsKey(dto.getNotifierType())) { list.add(dto); } } return new SetUserNotificationFilterPreferencesRequest(userId, list); } }
SetCurrentUserNotificationPreferencesTransformer implements RequestTransformer { @Override public Serializable transform(final ActionContext inActionContext) { long userId = ((PrincipalActionContext) inActionContext).getPrincipal().getId(); Collection<NotificationFilterPreferenceDTO> list = new ArrayList<NotificationFilterPreferenceDTO>(); for (NotificationFilterPreferenceDTO dto : (Collection<NotificationFilterPreferenceDTO>) inActionContext .getParams()) { if (categories.contains(dto.getNotificationCategory()) && notifierTypes.containsKey(dto.getNotifierType())) { list.add(dto); } } return new SetUserNotificationFilterPreferencesRequest(userId, list); } SetCurrentUserNotificationPreferencesTransformer(final Map<String, String> inNotifierTypes,
            final Set<String> inCategories); }
SetCurrentUserNotificationPreferencesTransformer implements RequestTransformer { @Override public Serializable transform(final ActionContext inActionContext) { long userId = ((PrincipalActionContext) inActionContext).getPrincipal().getId(); Collection<NotificationFilterPreferenceDTO> list = new ArrayList<NotificationFilterPreferenceDTO>(); for (NotificationFilterPreferenceDTO dto : (Collection<NotificationFilterPreferenceDTO>) inActionContext .getParams()) { if (categories.contains(dto.getNotificationCategory()) && notifierTypes.containsKey(dto.getNotifierType())) { list.add(dto); } } return new SetUserNotificationFilterPreferencesRequest(userId, list); } SetCurrentUserNotificationPreferencesTransformer(final Map<String, String> inNotifierTypes,
            final Set<String> inCategories); @Override Serializable transform(final ActionContext inActionContext); }
SetCurrentUserNotificationPreferencesTransformer implements RequestTransformer { @Override public Serializable transform(final ActionContext inActionContext) { long userId = ((PrincipalActionContext) inActionContext).getPrincipal().getId(); Collection<NotificationFilterPreferenceDTO> list = new ArrayList<NotificationFilterPreferenceDTO>(); for (NotificationFilterPreferenceDTO dto : (Collection<NotificationFilterPreferenceDTO>) inActionContext .getParams()) { if (categories.contains(dto.getNotificationCategory()) && notifierTypes.containsKey(dto.getNotifierType())) { list.add(dto); } } return new SetUserNotificationFilterPreferencesRequest(userId, list); } SetCurrentUserNotificationPreferencesTransformer(final Map<String, String> inNotifierTypes,
            final Set<String> inCategories); @Override Serializable transform(final ActionContext inActionContext);  }