@Test void watchWhenNoFilterMatch() 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)); when(notificationFilterPreferenceManager.getFilterPreferences(user)).thenReturn(Sets.newSet(pref1)); when(watchedEntityReference.isWatchedWithAllEventTypes(user)).thenReturn(false); DefaultNotificationFilterPreference createdPref = mock(DefaultNotificationFilterPreference.class); when(watchedEntityReference.createInclusiveFilterPreference()).thenReturn(createdPref); when(watchedEntityReference.createExclusiveFilterPreference()).thenReturn(createdPref); when(createdPref.getId()).thenReturn("aabbccdd"); doAnswer(invocationOnMock -> { Set set = (Set) invocationOnMock.getArgument(1); DefaultNotificationFilterPreference prefToSave = (DefaultNotificationFilterPreference) set.toArray()[0]; assertEquals("aabbccdd", prefToSave.getId()); return null; }).when(notificationFilterPreferenceManager).saveFilterPreferences(eq(user), anySet()); watchedEntitiesManager.watchEntity(watchedEntityReference, user); verify(notificationFilterPreferenceManager).saveFilterPreferences(eq(user), anySet()); 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);  }