@Test public void testFilterPreferences() throws Exception { NotificationFilterPreference filterPreference1 = mock(NotificationFilterPreference.class); NotificationFilterPreference filterPreference2 = mock(NotificationFilterPreference.class); when(testProvider.getFilterPreferences(testUser)).thenReturn(Sets.newSet(filterPreference1, filterPreference2)); Collection<NotificationFilterPreference> resultSet = mocker.getComponentUnderTest().getFilterPreferences(testUser); assertTrue(resultSet.contains(filterPreference1)); assertTrue(resultSet.contains(filterPreference2)); assertEquals(2, resultSet.size()); }
@Override public Collection<NotificationFilterPreference> getFilterPreferences(DocumentReference user) throws NotificationException { Set<NotificationFilterPreference> filterPreferences = new HashSet<>(); try { List<NotificationFilterPreferenceProvider> providers = componentManager.getInstanceList(NotificationFilterPreferenceProvider.class); for (NotificationFilterPreferenceProvider provider : providers) { filterPreferences.addAll(provider.getFilterPreferences(user)); } return filterPreferences; } catch (ComponentLookupException e) { throw new NotificationException(String.format("Unable to fetch a list of notification preference " + "providers with user [%s].", user)); } }
DefaultNotificationFilterPreferenceManager implements NotificationFilterPreferenceManager { @Override public Collection<NotificationFilterPreference> getFilterPreferences(DocumentReference user) throws NotificationException { Set<NotificationFilterPreference> filterPreferences = new HashSet<>(); try { List<NotificationFilterPreferenceProvider> providers = componentManager.getInstanceList(NotificationFilterPreferenceProvider.class); for (NotificationFilterPreferenceProvider provider : providers) { filterPreferences.addAll(provider.getFilterPreferences(user)); } return filterPreferences; } catch (ComponentLookupException e) { throw new NotificationException(String.format("Unable to fetch a list of notification preference " + "providers with user [%s].", user)); } } }
DefaultNotificationFilterPreferenceManager implements NotificationFilterPreferenceManager { @Override public Collection<NotificationFilterPreference> getFilterPreferences(DocumentReference user) throws NotificationException { Set<NotificationFilterPreference> filterPreferences = new HashSet<>(); try { List<NotificationFilterPreferenceProvider> providers = componentManager.getInstanceList(NotificationFilterPreferenceProvider.class); for (NotificationFilterPreferenceProvider provider : providers) { filterPreferences.addAll(provider.getFilterPreferences(user)); } return filterPreferences; } catch (ComponentLookupException e) { throw new NotificationException(String.format("Unable to fetch a list of notification preference " + "providers with user [%s].", user)); } }  }
DefaultNotificationFilterPreferenceManager implements NotificationFilterPreferenceManager { @Override public Collection<NotificationFilterPreference> getFilterPreferences(DocumentReference user) throws NotificationException { Set<NotificationFilterPreference> filterPreferences = new HashSet<>(); try { List<NotificationFilterPreferenceProvider> providers = componentManager.getInstanceList(NotificationFilterPreferenceProvider.class); for (NotificationFilterPreferenceProvider provider : providers) { filterPreferences.addAll(provider.getFilterPreferences(user)); } return filterPreferences; } catch (ComponentLookupException e) { throw new NotificationException(String.format("Unable to fetch a list of notification preference " + "providers with user [%s].", user)); } }  @Override Collection<NotificationFilterPreference> getFilterPreferences(DocumentReference user); @Override Stream<NotificationFilterPreference> getFilterPreferences(
            Collection<NotificationFilterPreference> filterPreferences, NotificationFilter filter); @Override Stream<NotificationFilterPreference> getFilterPreferences(
            Collection<NotificationFilterPreference> filterPreferences, NotificationFilter filter,
            NotificationFilterType filterType); @Override Stream<NotificationFilterPreference> getFilterPreferences(
            Collection<NotificationFilterPreference> filterPreferences, NotificationFilter filter,
            NotificationFilterType filterType, NotificationFormat format); @Override void saveFilterPreferences(DocumentReference user, Set<NotificationFilterPreference> filterPreferences); @Override void deleteFilterPreference(DocumentReference user, String filterPreferenceId); @Override void setFilterPreferenceEnabled(DocumentReference user, String filterPreferenceId, boolean enabled); @Override void setStartDateForUser(DocumentReference user, Date startDate); }
DefaultNotificationFilterPreferenceManager implements NotificationFilterPreferenceManager { @Override public Collection<NotificationFilterPreference> getFilterPreferences(DocumentReference user) throws NotificationException { Set<NotificationFilterPreference> filterPreferences = new HashSet<>(); try { List<NotificationFilterPreferenceProvider> providers = componentManager.getInstanceList(NotificationFilterPreferenceProvider.class); for (NotificationFilterPreferenceProvider provider : providers) { filterPreferences.addAll(provider.getFilterPreferences(user)); } return filterPreferences; } catch (ComponentLookupException e) { throw new NotificationException(String.format("Unable to fetch a list of notification preference " + "providers with user [%s].", user)); } }  @Override Collection<NotificationFilterPreference> getFilterPreferences(DocumentReference user); @Override Stream<NotificationFilterPreference> getFilterPreferences(
            Collection<NotificationFilterPreference> filterPreferences, NotificationFilter filter); @Override Stream<NotificationFilterPreference> getFilterPreferences(
            Collection<NotificationFilterPreference> filterPreferences, NotificationFilter filter,
            NotificationFilterType filterType); @Override Stream<NotificationFilterPreference> getFilterPreferences(
            Collection<NotificationFilterPreference> filterPreferences, NotificationFilter filter,
            NotificationFilterType filterType, NotificationFormat format); @Override void saveFilterPreferences(DocumentReference user, Set<NotificationFilterPreference> filterPreferences); @Override void deleteFilterPreference(DocumentReference user, String filterPreferenceId); @Override void setFilterPreferenceEnabled(DocumentReference user, String filterPreferenceId, boolean enabled); @Override void setStartDateForUser(DocumentReference user, Date startDate);  }