@Test public void getNotificationPreferencesWithAdditionalParameters() throws Exception { DocumentReference user = new DocumentReference("xwiki", "test", "user"); mockPreferenceProviders(user); List<NotificationPreference> preferences = mocker.getComponentUnderTest().getPreferences(user, true, NotificationFormat.ALERT); assertEquals(1, preferences.size()); assertTrue(preferences.contains(mockPreference11)); preferences = mocker.getComponentUnderTest().getPreferences(user, false, NotificationFormat.ALERT); assertEquals(1, preferences.size()); assertTrue(preferences.contains(mockPreference21)); preferences = mocker.getComponentUnderTest().getPreferences(user, true, NotificationFormat.EMAIL); assertEquals(0, preferences.size()); preferences = mocker.getComponentUnderTest().getPreferences(user, false, NotificationFormat.EMAIL); assertEquals(2, preferences.size()); assertTrue(preferences.contains(mockPreference22)); assertTrue(preferences.contains(mockPreference23)); }
@Override public List<NotificationPreference> getPreferences(DocumentReference user, boolean isEnabled, NotificationFormat format) throws NotificationException { List<NotificationPreference> preferences = getAllPreferences(user); Iterator<NotificationPreference> it = preferences.iterator(); while (it.hasNext()) { NotificationPreference preference = it.next(); if (preference.isNotificationEnabled() != isEnabled || !preference.getFormat().equals(format)) { it.remove(); } } return preferences; }
DefaultNotificationPreferenceManager implements NotificationPreferenceManager { @Override public List<NotificationPreference> getPreferences(DocumentReference user, boolean isEnabled, NotificationFormat format) throws NotificationException { List<NotificationPreference> preferences = getAllPreferences(user); Iterator<NotificationPreference> it = preferences.iterator(); while (it.hasNext()) { NotificationPreference preference = it.next(); if (preference.isNotificationEnabled() != isEnabled || !preference.getFormat().equals(format)) { it.remove(); } } return preferences; } }
DefaultNotificationPreferenceManager implements NotificationPreferenceManager { @Override public List<NotificationPreference> getPreferences(DocumentReference user, boolean isEnabled, NotificationFormat format) throws NotificationException { List<NotificationPreference> preferences = getAllPreferences(user); Iterator<NotificationPreference> it = preferences.iterator(); while (it.hasNext()) { NotificationPreference preference = it.next(); if (preference.isNotificationEnabled() != isEnabled || !preference.getFormat().equals(format)) { it.remove(); } } return preferences; }  }
DefaultNotificationPreferenceManager implements NotificationPreferenceManager { @Override public List<NotificationPreference> getPreferences(DocumentReference user, boolean isEnabled, NotificationFormat format) throws NotificationException { List<NotificationPreference> preferences = getAllPreferences(user); Iterator<NotificationPreference> it = preferences.iterator(); while (it.hasNext()) { NotificationPreference preference = it.next(); if (preference.isNotificationEnabled() != isEnabled || !preference.getFormat().equals(format)) { it.remove(); } } return preferences; }  @Override List<NotificationPreference> getAllPreferences(DocumentReference user); @Override List<NotificationPreference> getAllPreferences(WikiReference wiki); @Override List<NotificationPreference> getPreferences(DocumentReference user, boolean isEnabled,
            NotificationFormat format); @Override void setStartDateForUser(DocumentReference user, Date startDate); @Override void savePreferences(List<NotificationPreference> preferences); }
DefaultNotificationPreferenceManager implements NotificationPreferenceManager { @Override public List<NotificationPreference> getPreferences(DocumentReference user, boolean isEnabled, NotificationFormat format) throws NotificationException { List<NotificationPreference> preferences = getAllPreferences(user); Iterator<NotificationPreference> it = preferences.iterator(); while (it.hasNext()) { NotificationPreference preference = it.next(); if (preference.isNotificationEnabled() != isEnabled || !preference.getFormat().equals(format)) { it.remove(); } } return preferences; }  @Override List<NotificationPreference> getAllPreferences(DocumentReference user); @Override List<NotificationPreference> getAllPreferences(WikiReference wiki); @Override List<NotificationPreference> getPreferences(DocumentReference user, boolean isEnabled,
            NotificationFormat format); @Override void setStartDateForUser(DocumentReference user, Date startDate); @Override void savePreferences(List<NotificationPreference> preferences);  }