@Test void unwatchWhen2OppositeFilters() 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(watchedEntityReference.matchExactly(pref1)).thenReturn(true); pref1.setFilterType(NotificationFilterType.INCLUSIVE); pref1.setEnabled(true); pref1.setId("pref1"); DefaultNotificationFilterPreference pref2 = new DefaultNotificationFilterPreference(); pref2.setNotificationFormats(Sets.newSet(NotificationFormat.ALERT, NotificationFormat.EMAIL)); when(watchedEntityReference.matchExactly(pref2)).thenReturn(true); pref2.setFilterType(NotificationFilterType.EXCLUSIVE); pref2.setEnabled(true); pref2.setId("pref2"); when(notificationFilterPreferenceManager.getFilterPreferences(user)).thenReturn(Sets.newSet(pref1, pref2)); when(watchedEntityReference.isWatchedWithAllEventTypes(user)).thenReturn(true, false); watchedEntitiesManager.unwatchEntity(watchedEntityReference, user); verify(notificationFilterPreferenceManager).deleteFilterPreference(user, "pref1"); verify(watchedEntityReference, never()).createExclusiveFilterPreference(); verify(this.xwikiEventTypesEnabler, never()).ensureXWikiNotificationsAreEnabled(user); }
@Override public void unwatchEntity(WatchedEntityReference entity, DocumentReference user) throws NotificationException { handleEntity(entity, user, false); }
DefaultWatchedEntitiesManager implements WatchedEntitiesManager { @Override public void unwatchEntity(WatchedEntityReference entity, DocumentReference user) throws NotificationException { handleEntity(entity, user, false); } }
DefaultWatchedEntitiesManager implements WatchedEntitiesManager { @Override public void unwatchEntity(WatchedEntityReference entity, DocumentReference user) throws NotificationException { handleEntity(entity, user, false); }  }
DefaultWatchedEntitiesManager implements WatchedEntitiesManager { @Override public void unwatchEntity(WatchedEntityReference entity, DocumentReference user) throws NotificationException { handleEntity(entity, user, false); }  @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 unwatchEntity(WatchedEntityReference entity, DocumentReference user) throws NotificationException { handleEntity(entity, user, false); }  @Override void watchEntity(WatchedEntityReference entity, DocumentReference user); @Override void unwatchEntity(WatchedEntityReference entity, DocumentReference user); @Override Collection<String> getWatchedUsers(DocumentReference user);  }