@Test public void getDefaultAutomaticWatchMode() throws Exception { assertEquals(AutomaticWatchMode.MAJOR, mocker.getComponentUnderTest().getDefaultAutomaticWatchMode(CURRENT_WIKI)); when(configurationSource.getProperty("xwiki.plugin.watchlist.automaticwatch")).thenReturn("new"); assertEquals(AutomaticWatchMode.NEW, mocker.getComponentUnderTest().getDefaultAutomaticWatchMode(CURRENT_WIKI)); when(configurationSource.getProperty("notifications.watchedEntities.autoWatch")).thenReturn("all"); assertEquals(AutomaticWatchMode.ALL, mocker.getComponentUnderTest().getDefaultAutomaticWatchMode(CURRENT_WIKI)); when(documentAccessBridge.getProperty( new DocumentReference("mainWiki", Arrays.asList("XWiki", "Notifications", "Code"), "NotificationAdministration"), new DocumentReference("mainWiki", Arrays.asList("XWiki", "Notifications", "Code"), "AutomaticWatchModeClass"), "automaticWatchMode")).thenReturn("NONE"); assertEquals(AutomaticWatchMode.NONE, mocker.getComponentUnderTest().getDefaultAutomaticWatchMode(CURRENT_WIKI)); when(documentAccessBridge.getProperty( new DocumentReference("wikiA", Arrays.asList("XWiki", "Notifications", "Code"), "NotificationAdministration"), new DocumentReference("wikiA", Arrays.asList("XWiki", "Notifications", "Code"), "AutomaticWatchModeClass"), "automaticWatchMode")).thenReturn("NEW"); assertEquals(AutomaticWatchMode.NEW, mocker.getComponentUnderTest().getDefaultAutomaticWatchMode(CURRENT_WIKI)); }
@Override public AutomaticWatchMode getDefaultAutomaticWatchMode(WikiReference wikiReference) { Object value = documentAccessBridge.getProperty(getAbsoluteConfigurationReference(wikiReference), getAbsoluteClassReference(wikiReference), AUTOMATIC_WATCH_MODE); if (value != null && StringUtils.isNotBlank((String) value)) { return AutomaticWatchMode.valueOf((String) value); } WikiReference mainWiki = new WikiReference(wikiDescriptorManager.getMainWikiId()); if (!wikiReference.equals(mainWiki)) { value = documentAccessBridge.getProperty(getAbsoluteConfigurationReference(mainWiki), getAbsoluteClassReference(mainWiki), AUTOMATIC_WATCH_MODE); if (value != null && StringUtils.isNotBlank((String) value)) { return AutomaticWatchMode.valueOf((String) value); } } return getAutomaticWatchMode(); }
DefaultWatchedEntitiesConfiguration implements WatchedEntitiesConfiguration { @Override public AutomaticWatchMode getDefaultAutomaticWatchMode(WikiReference wikiReference) { Object value = documentAccessBridge.getProperty(getAbsoluteConfigurationReference(wikiReference), getAbsoluteClassReference(wikiReference), AUTOMATIC_WATCH_MODE); if (value != null && StringUtils.isNotBlank((String) value)) { return AutomaticWatchMode.valueOf((String) value); } WikiReference mainWiki = new WikiReference(wikiDescriptorManager.getMainWikiId()); if (!wikiReference.equals(mainWiki)) { value = documentAccessBridge.getProperty(getAbsoluteConfigurationReference(mainWiki), getAbsoluteClassReference(mainWiki), AUTOMATIC_WATCH_MODE); if (value != null && StringUtils.isNotBlank((String) value)) { return AutomaticWatchMode.valueOf((String) value); } } return getAutomaticWatchMode(); } }
DefaultWatchedEntitiesConfiguration implements WatchedEntitiesConfiguration { @Override public AutomaticWatchMode getDefaultAutomaticWatchMode(WikiReference wikiReference) { Object value = documentAccessBridge.getProperty(getAbsoluteConfigurationReference(wikiReference), getAbsoluteClassReference(wikiReference), AUTOMATIC_WATCH_MODE); if (value != null && StringUtils.isNotBlank((String) value)) { return AutomaticWatchMode.valueOf((String) value); } WikiReference mainWiki = new WikiReference(wikiDescriptorManager.getMainWikiId()); if (!wikiReference.equals(mainWiki)) { value = documentAccessBridge.getProperty(getAbsoluteConfigurationReference(mainWiki), getAbsoluteClassReference(mainWiki), AUTOMATIC_WATCH_MODE); if (value != null && StringUtils.isNotBlank((String) value)) { return AutomaticWatchMode.valueOf((String) value); } } return getAutomaticWatchMode(); }  }
DefaultWatchedEntitiesConfiguration implements WatchedEntitiesConfiguration { @Override public AutomaticWatchMode getDefaultAutomaticWatchMode(WikiReference wikiReference) { Object value = documentAccessBridge.getProperty(getAbsoluteConfigurationReference(wikiReference), getAbsoluteClassReference(wikiReference), AUTOMATIC_WATCH_MODE); if (value != null && StringUtils.isNotBlank((String) value)) { return AutomaticWatchMode.valueOf((String) value); } WikiReference mainWiki = new WikiReference(wikiDescriptorManager.getMainWikiId()); if (!wikiReference.equals(mainWiki)) { value = documentAccessBridge.getProperty(getAbsoluteConfigurationReference(mainWiki), getAbsoluteClassReference(mainWiki), AUTOMATIC_WATCH_MODE); if (value != null && StringUtils.isNotBlank((String) value)) { return AutomaticWatchMode.valueOf((String) value); } } return getAutomaticWatchMode(); }  @Override boolean isEnabled(); @Override AutomaticWatchMode getAutomaticWatchMode(DocumentReference user); @Override AutomaticWatchMode getDefaultAutomaticWatchMode(WikiReference wikiReference); }
DefaultWatchedEntitiesConfiguration implements WatchedEntitiesConfiguration { @Override public AutomaticWatchMode getDefaultAutomaticWatchMode(WikiReference wikiReference) { Object value = documentAccessBridge.getProperty(getAbsoluteConfigurationReference(wikiReference), getAbsoluteClassReference(wikiReference), AUTOMATIC_WATCH_MODE); if (value != null && StringUtils.isNotBlank((String) value)) { return AutomaticWatchMode.valueOf((String) value); } WikiReference mainWiki = new WikiReference(wikiDescriptorManager.getMainWikiId()); if (!wikiReference.equals(mainWiki)) { value = documentAccessBridge.getProperty(getAbsoluteConfigurationReference(mainWiki), getAbsoluteClassReference(mainWiki), AUTOMATIC_WATCH_MODE); if (value != null && StringUtils.isNotBlank((String) value)) { return AutomaticWatchMode.valueOf((String) value); } } return getAutomaticWatchMode(); }  @Override boolean isEnabled(); @Override AutomaticWatchMode getAutomaticWatchMode(DocumentReference user); @Override AutomaticWatchMode getDefaultAutomaticWatchMode(WikiReference wikiReference);  }