@Test void testWithSeveralFilterPreferences() throws Exception { WatchedEntityReference watchedEntityReference = mock(WatchedEntityReference.class); DocumentReference user = new DocumentReference("xwiki", "XWiki", "User"); DefaultNotificationFilterPreference pref1 = new DefaultNotificationFilterPreference(); pref1.setNotificationFormats(Sets.newSet(NotificationFormat.ALERT, NotificationFormat.EMAIL)); DefaultNotificationFilterPreference pref2 = new DefaultNotificationFilterPreference(); pref2.setEventTypes(Sets.newSet("update")); pref2.setNotificationFormats(Sets.newSet(NotificationFormat.ALERT, NotificationFormat.EMAIL)); when(watchedEntityReference.matchExactly(pref2)).thenReturn(true); DefaultNotificationFilterPreference pref3 = new DefaultNotificationFilterPreference(); pref3.setNotificationFormats(Sets.newSet(NotificationFormat.ALERT)); when(watchedEntityReference.matchExactly(pref3)).thenReturn(true); DefaultNotificationFilterPreference pref4 = new DefaultNotificationFilterPreference(); pref4.setNotificationFormats(Sets.newSet(NotificationFormat.ALERT, NotificationFormat.EMAIL)); when(watchedEntityReference.matchExactly(pref4)).thenReturn(true); pref4.setFilterType(NotificationFilterType.INCLUSIVE); pref4.setEnabled(false); pref4.setId("pref4"); when(notificationFilterPreferenceManager.getFilterPreferences(user)) .thenReturn(Sets.newSet(pref1, pref2, pref3, pref4)); when(watchedEntityReference.isWatchedWithAllEventTypes(user)).thenReturn(false, true); watchedEntitiesManager.watchEntity(watchedEntityReference, user); verify(watchedEntityReference, never()).matchExactly(pref2); verify(watchedEntityReference, never()).matchExactly(pref3); verify(notificationFilterPreferenceManager).setFilterPreferenceEnabled(user, "pref4", true); verify(watchedEntityReference, never()).createInclusiveFilterPreference(); verify(this.xwikiEventTypesEnabler).ensureXWikiNotificationsAreEnabled(user); }
@Override public void watchEntity(WatchedEntityReference entity, DocumentReference user) throws NotificationException { handleEntity(entity, user, true); }
DefaultWatchedEntitiesManager implements WatchedEntitiesManager { @Override public void watchEntity(WatchedEntityReference entity, DocumentReference user) throws NotificationException { handleEntity(entity, user, true); } }
DefaultWatchedEntitiesManager implements WatchedEntitiesManager { @Override public void watchEntity(WatchedEntityReference entity, DocumentReference user) throws NotificationException { handleEntity(entity, user, true); }  }
DefaultWatchedEntitiesManager implements WatchedEntitiesManager { @Override public void watchEntity(WatchedEntityReference entity, DocumentReference user) throws NotificationException { handleEntity(entity, user, true); }  @Override void watchEntity(WatchedEntityReference entity, DocumentReference user); @Override void unwatchEntity(WatchedEntityReference entity, DocumentReference user); @Override Collection<String> getWatchedUsers(DocumentReference user); }
DefaultWatchedEntitiesManager implements WatchedEntitiesManager { @Override public void watchEntity(WatchedEntityReference entity, DocumentReference user) throws NotificationException { handleEntity(entity, user, true); }  @Override void watchEntity(WatchedEntityReference entity, DocumentReference user); @Override void unwatchEntity(WatchedEntityReference entity, DocumentReference user); @Override Collection<String> getWatchedUsers(DocumentReference user);  }