@Test public void testPerformActionWithMultipleRows() throws Exception { context.checking(new Expectations() { { oneOf(mapper).execute(PERSON_ID); will(returnValue(Arrays.asList(dto1, dto2, dto3))); } }); PrincipalActionContext ctx = TestContextCreator.createPrincipalActionContext(null, null, PERSON_ID); GetUserNotificationFilterPreferencesResponse result = (GetUserNotificationFilterPreferencesResponse) sut .execute(ctx); context.assertIsSatisfied(); assertEquals(1, result.getPreferences().size()); assertEquals(dto1, result.getPreferences().iterator().next()); assertEquals(2, result.getNotifierTypes().size()); }
@Override public Serializable execute(final PrincipalActionContext inActionContext) throws ExecutionException { long userId = inActionContext.getPrincipal().getId(); List<NotificationFilterPreferenceDTO> list = new ArrayList<NotificationFilterPreferenceDTO>(); for (NotificationFilterPreferenceDTO dto : mapper.execute(userId)) { if (notifierTypes.containsKey(dto.getNotifierType()) && categories.contains(dto.getNotificationCategory())) { list.add(dto); } } return new GetUserNotificationFilterPreferencesResponse(list, notifierTypes); }
GetUserNotificationFilterPreferencesExecution implements ExecutionStrategy<PrincipalActionContext> { @Override public Serializable execute(final PrincipalActionContext inActionContext) throws ExecutionException { long userId = inActionContext.getPrincipal().getId(); List<NotificationFilterPreferenceDTO> list = new ArrayList<NotificationFilterPreferenceDTO>(); for (NotificationFilterPreferenceDTO dto : mapper.execute(userId)) { if (notifierTypes.containsKey(dto.getNotifierType()) && categories.contains(dto.getNotificationCategory())) { list.add(dto); } } return new GetUserNotificationFilterPreferencesResponse(list, notifierTypes); } }
GetUserNotificationFilterPreferencesExecution implements ExecutionStrategy<PrincipalActionContext> { @Override public Serializable execute(final PrincipalActionContext inActionContext) throws ExecutionException { long userId = inActionContext.getPrincipal().getId(); List<NotificationFilterPreferenceDTO> list = new ArrayList<NotificationFilterPreferenceDTO>(); for (NotificationFilterPreferenceDTO dto : mapper.execute(userId)) { if (notifierTypes.containsKey(dto.getNotifierType()) && categories.contains(dto.getNotificationCategory())) { list.add(dto); } } return new GetUserNotificationFilterPreferencesResponse(list, notifierTypes); } GetUserNotificationFilterPreferencesExecution(
            final DomainMapper<Long, Collection<NotificationFilterPreferenceDTO>> inMapper,
            final Map<String, String> inNotifierTypes, final Set<String> inNotificationCategories); }
GetUserNotificationFilterPreferencesExecution implements ExecutionStrategy<PrincipalActionContext> { @Override public Serializable execute(final PrincipalActionContext inActionContext) throws ExecutionException { long userId = inActionContext.getPrincipal().getId(); List<NotificationFilterPreferenceDTO> list = new ArrayList<NotificationFilterPreferenceDTO>(); for (NotificationFilterPreferenceDTO dto : mapper.execute(userId)) { if (notifierTypes.containsKey(dto.getNotifierType()) && categories.contains(dto.getNotificationCategory())) { list.add(dto); } } return new GetUserNotificationFilterPreferencesResponse(list, notifierTypes); } GetUserNotificationFilterPreferencesExecution(
            final DomainMapper<Long, Collection<NotificationFilterPreferenceDTO>> inMapper,
            final Map<String, String> inNotifierTypes, final Set<String> inNotificationCategories); @Override Serializable execute(final PrincipalActionContext inActionContext); }
GetUserNotificationFilterPreferencesExecution implements ExecutionStrategy<PrincipalActionContext> { @Override public Serializable execute(final PrincipalActionContext inActionContext) throws ExecutionException { long userId = inActionContext.getPrincipal().getId(); List<NotificationFilterPreferenceDTO> list = new ArrayList<NotificationFilterPreferenceDTO>(); for (NotificationFilterPreferenceDTO dto : mapper.execute(userId)) { if (notifierTypes.containsKey(dto.getNotifierType()) && categories.contains(dto.getNotificationCategory())) { list.add(dto); } } return new GetUserNotificationFilterPreferencesResponse(list, notifierTypes); } GetUserNotificationFilterPreferencesExecution(
            final DomainMapper<Long, Collection<NotificationFilterPreferenceDTO>> inMapper,
            final Map<String, String> inNotifierTypes, final Set<String> inNotificationCategories); @Override Serializable execute(final PrincipalActionContext inActionContext);  }