@Test public void testExecute() { final Map<String, String> notifierTypes = new LinkedHashMap<String, String>(); notifierTypes.put("EMAIL", ""); notifierTypes.put("INAPP", ""); sut = new DisableNotificationCategoryExecution(mapper, notifierTypes); final AnonymousClassInterceptor<SetUserNotificationFilterPreferencesRequest> rqstInt = new AnonymousClassInterceptor<SetUserNotificationFilterPreferencesRequest>(); context.checking(new Expectations() { { oneOf(mapper).execute(with(any(SetUserNotificationFilterPreferencesRequest.class))); will(rqstInt); } }); PrincipalActionContext ctx = TestContextCreator.createPrincipalActionContext("FOLLOW", null, 8L); sut.execute(ctx); context.assertIsSatisfied(); SetUserNotificationFilterPreferencesRequest rqst = rqstInt.getObject(); assertEquals(8L, rqst.getPersonId()); List<NotificationFilterPreferenceDTO> list = (List<NotificationFilterPreferenceDTO>) rqst.getPrefList(); assertEquals(2, list.size()); assertTrue(Matchers.hasItem(equalInternally(new NotificationFilterPreferenceDTO(8L, "EMAIL", "FOLLOW"))) .matches(list) || Matchers.hasItem(equalInternally(new NotificationFilterPreferenceDTO("EMAIL", "FOLLOW"))).matches( list)); assertTrue(Matchers.hasItem(equalInternally(new NotificationFilterPreferenceDTO(8L, "INAPP", "FOLLOW"))) .matches(list) || Matchers.hasItem(equalInternally(new NotificationFilterPreferenceDTO("INAPP", "FOLLOW"))).matches( list)); }
@Override public Serializable execute(final PrincipalActionContext inActionContext) { String category = (String) inActionContext.getParams(); long userId = inActionContext.getPrincipal().getId(); List<NotificationFilterPreferenceDTO> dtos = new ArrayList<NotificationFilterPreferenceDTO>(); for (String notifier : notifierTypes.keySet()) { dtos.add(new NotificationFilterPreferenceDTO(notifier, category)); } prefsMapper.execute(new SetUserNotificationFilterPreferencesRequest(userId, dtos)); return null; }
DisableNotificationCategoryExecution implements ExecutionStrategy<PrincipalActionContext> { @Override public Serializable execute(final PrincipalActionContext inActionContext) { String category = (String) inActionContext.getParams(); long userId = inActionContext.getPrincipal().getId(); List<NotificationFilterPreferenceDTO> dtos = new ArrayList<NotificationFilterPreferenceDTO>(); for (String notifier : notifierTypes.keySet()) { dtos.add(new NotificationFilterPreferenceDTO(notifier, category)); } prefsMapper.execute(new SetUserNotificationFilterPreferencesRequest(userId, dtos)); return null; } }
DisableNotificationCategoryExecution implements ExecutionStrategy<PrincipalActionContext> { @Override public Serializable execute(final PrincipalActionContext inActionContext) { String category = (String) inActionContext.getParams(); long userId = inActionContext.getPrincipal().getId(); List<NotificationFilterPreferenceDTO> dtos = new ArrayList<NotificationFilterPreferenceDTO>(); for (String notifier : notifierTypes.keySet()) { dtos.add(new NotificationFilterPreferenceDTO(notifier, category)); } prefsMapper.execute(new SetUserNotificationFilterPreferencesRequest(userId, dtos)); return null; } DisableNotificationCategoryExecution(
            final DomainMapper<SetUserNotificationFilterPreferencesRequest, Void> inPrefsMapper,
            final Map<String, String> inNotifierTypes); }
DisableNotificationCategoryExecution implements ExecutionStrategy<PrincipalActionContext> { @Override public Serializable execute(final PrincipalActionContext inActionContext) { String category = (String) inActionContext.getParams(); long userId = inActionContext.getPrincipal().getId(); List<NotificationFilterPreferenceDTO> dtos = new ArrayList<NotificationFilterPreferenceDTO>(); for (String notifier : notifierTypes.keySet()) { dtos.add(new NotificationFilterPreferenceDTO(notifier, category)); } prefsMapper.execute(new SetUserNotificationFilterPreferencesRequest(userId, dtos)); return null; } DisableNotificationCategoryExecution(
            final DomainMapper<SetUserNotificationFilterPreferencesRequest, Void> inPrefsMapper,
            final Map<String, String> inNotifierTypes); @Override Serializable execute(final PrincipalActionContext inActionContext); }
DisableNotificationCategoryExecution implements ExecutionStrategy<PrincipalActionContext> { @Override public Serializable execute(final PrincipalActionContext inActionContext) { String category = (String) inActionContext.getParams(); long userId = inActionContext.getPrincipal().getId(); List<NotificationFilterPreferenceDTO> dtos = new ArrayList<NotificationFilterPreferenceDTO>(); for (String notifier : notifierTypes.keySet()) { dtos.add(new NotificationFilterPreferenceDTO(notifier, category)); } prefsMapper.execute(new SetUserNotificationFilterPreferencesRequest(userId, dtos)); return null; } DisableNotificationCategoryExecution(
            final DomainMapper<SetUserNotificationFilterPreferencesRequest, Void> inPrefsMapper,
            final Map<String, String> inNotifierTypes); @Override Serializable execute(final PrincipalActionContext inActionContext);  }