Search in sources :

Example 1 with NotificationPreferenceManager

use of org.xwiki.notifications.preferences.NotificationPreferenceManager in project xwiki-platform by xwiki.

the class QueryGeneratorTest method setUp.

@Before
public void setUp() throws Exception {
    queryManager = mocker.getInstance(QueryManager.class);
    notificationPreferenceManager = mocker.getInstance(NotificationPreferenceManager.class);
    serializer = mocker.getInstance(EntityReferenceSerializer.TYPE_STRING);
    userPreferencesSource = mocker.getInstance(ConfigurationSource.class, "user");
    wikiDescriptorManager = mocker.getInstance(WikiDescriptorManager.class);
    notificationFilterManager = mocker.getInstance(NotificationFilterManager.class);
    startDate = new Date(10);
    query = mock(Query.class);
    when(queryManager.createQuery(anyString(), anyString())).thenReturn(query);
    pref1StartDate = new Date(100000000);
    NotificationPreference pref1 = mock(NotificationPreference.class);
    when(pref1.getProperties()).thenReturn(Collections.singletonMap(NotificationPreferenceProperty.EVENT_TYPE, "create"));
    when(pref1.getFormat()).thenReturn(NotificationFormat.ALERT);
    when(pref1.getStartDate()).thenReturn(pref1StartDate);
    when(pref1.isNotificationEnabled()).thenReturn(true);
    when(notificationPreferenceManager.getPreferences(userReference, true, NotificationFormat.ALERT)).thenReturn(Arrays.asList(pref1));
    NotificationFilterPreference fakeFilterPreference = mock(NotificationFilterPreference.class);
    when(fakeFilterPreference.isActive()).thenReturn(true);
    when(notificationFilterManager.getFilterPreferences(any(DocumentReference.class))).thenReturn(Sets.newSet(fakeFilterPreference));
    when(userPreferencesSource.getProperty("displayHiddenDocuments", 0)).thenReturn(0);
    when(wikiDescriptorManager.getMainWikiId()).thenReturn("xwiki");
}
Also used : NotificationFilterManager(org.xwiki.notifications.filters.NotificationFilterManager) NotificationPreference(org.xwiki.notifications.preferences.NotificationPreference) ConfigurationSource(org.xwiki.configuration.ConfigurationSource) NotificationPreferenceManager(org.xwiki.notifications.preferences.NotificationPreferenceManager) Query(org.xwiki.query.Query) WikiDescriptorManager(org.xwiki.wiki.descriptor.WikiDescriptorManager) QueryManager(org.xwiki.query.QueryManager) NotificationFilterPreference(org.xwiki.notifications.filters.NotificationFilterPreference) Date(java.util.Date) DocumentReference(org.xwiki.model.reference.DocumentReference) Before(org.junit.Before)

Example 2 with NotificationPreferenceManager

use of org.xwiki.notifications.preferences.NotificationPreferenceManager in project xwiki-platform by xwiki.

the class XWikiEventTypesEnablerTest method setUp.

@Before
public void setUp() throws Exception {
    notificationPreferenceManager = mocker.getInstance(NotificationPreferenceManager.class);
    documentAccessBridge = mocker.getInstance(DocumentAccessBridge.class);
    targetableNotificationPreferenceBuilderProvider = mock(Provider.class);
    when(targetableNotificationPreferenceBuilderProvider.get()).thenReturn(new DefaultTargetableNotificationPreferenceBuilder());
    mocker.registerComponent(new DefaultParameterizedType(null, Provider.class, TargetableNotificationPreferenceBuilder.class), targetableNotificationPreferenceBuilderProvider);
    when(documentAccessBridge.getCurrentUserReference()).thenReturn(currentUser);
}
Also used : NotificationPreferenceManager(org.xwiki.notifications.preferences.NotificationPreferenceManager) TargetableNotificationPreferenceBuilder(org.xwiki.notifications.preferences.TargetableNotificationPreferenceBuilder) DocumentAccessBridge(org.xwiki.bridge.DocumentAccessBridge) DefaultParameterizedType(org.xwiki.component.util.DefaultParameterizedType) Provider(javax.inject.Provider) Before(org.junit.Before)

Example 3 with NotificationPreferenceManager

use of org.xwiki.notifications.preferences.NotificationPreferenceManager in project xwiki-platform by xwiki.

the class DefaultNotificationManagerTest method setUp.

@Before
public void setUp() throws Exception {
    eventStream = mocker.getInstance(EventStream.class);
    queryGenerator = mocker.getInstance(QueryGenerator.class);
    documentAccessBridge = mocker.getInstance(DocumentAccessBridge.class);
    documentReferenceResolver = mocker.getInstance(DocumentReferenceResolver.TYPE_STRING);
    notificationPreferenceManager = mocker.getInstance(NotificationPreferenceManager.class);
    authorizationManager = mocker.getInstance(AuthorizationManager.class);
    startDate = new Date(10);
    when(documentReferenceResolver.resolve("xwiki:XWiki.UserA")).thenReturn(userReference);
    query = mock(Query.class);
    when(queryGenerator.generateQuery(any(DocumentReference.class), any(NotificationFormat.class), nullable(Date.class), nullable(Date.class), nullable(List.class))).thenReturn(query);
    NotificationPreference pref1 = mock(NotificationPreference.class);
    when(pref1.getProperties()).thenReturn(Collections.singletonMap(NotificationPreferenceProperty.EVENT_TYPE, "create"));
    when(pref1.isNotificationEnabled()).thenReturn(true);
    when(notificationPreferenceManager.getAllPreferences(userReference)).thenReturn(Arrays.asList(pref1));
}
Also used : NotificationPreference(org.xwiki.notifications.preferences.NotificationPreference) NotificationPreferenceManager(org.xwiki.notifications.preferences.NotificationPreferenceManager) Query(org.xwiki.query.Query) EventStream(org.xwiki.eventstream.EventStream) NotificationFormat(org.xwiki.notifications.NotificationFormat) DocumentAccessBridge(org.xwiki.bridge.DocumentAccessBridge) ComponentList(org.xwiki.test.annotation.ComponentList) List(java.util.List) AuthorizationManager(org.xwiki.security.authorization.AuthorizationManager) Date(java.util.Date) DocumentReference(org.xwiki.model.reference.DocumentReference) Before(org.junit.Before)

Example 4 with NotificationPreferenceManager

use of org.xwiki.notifications.preferences.NotificationPreferenceManager in project xwiki-platform by xwiki.

the class NotificationPreferenceScriptServiceTest method setUp.

@Before
public void setUp() throws Exception {
    notificationPreferenceManager = mocker.getInstance(NotificationPreferenceManager.class);
    documentAccessBridge = mocker.getInstance(DocumentAccessBridge.class);
    authorizationManager = mocker.getInstance(ContextualAuthorizationManager.class);
    targetableNotificationPreferenceBuilderProvider = mock(Provider.class);
    when(targetableNotificationPreferenceBuilderProvider.get()).thenReturn(new DefaultTargetableNotificationPreferenceBuilder());
    mocker.registerComponent(new DefaultParameterizedType(null, Provider.class, TargetableNotificationPreferenceBuilder.class), targetableNotificationPreferenceBuilderProvider);
}
Also used : ContextualAuthorizationManager(org.xwiki.security.authorization.ContextualAuthorizationManager) NotificationPreferenceManager(org.xwiki.notifications.preferences.NotificationPreferenceManager) DefaultTargetableNotificationPreferenceBuilder(org.xwiki.notifications.preferences.internal.DefaultTargetableNotificationPreferenceBuilder) DefaultTargetableNotificationPreferenceBuilder(org.xwiki.notifications.preferences.internal.DefaultTargetableNotificationPreferenceBuilder) TargetableNotificationPreferenceBuilder(org.xwiki.notifications.preferences.TargetableNotificationPreferenceBuilder) DocumentAccessBridge(org.xwiki.bridge.DocumentAccessBridge) DefaultParameterizedType(org.xwiki.component.util.DefaultParameterizedType) Provider(javax.inject.Provider) Before(org.junit.Before)

Aggregations

Before (org.junit.Before)4 NotificationPreferenceManager (org.xwiki.notifications.preferences.NotificationPreferenceManager)4 DocumentAccessBridge (org.xwiki.bridge.DocumentAccessBridge)3 Date (java.util.Date)2 Provider (javax.inject.Provider)2 DefaultParameterizedType (org.xwiki.component.util.DefaultParameterizedType)2 DocumentReference (org.xwiki.model.reference.DocumentReference)2 NotificationPreference (org.xwiki.notifications.preferences.NotificationPreference)2 TargetableNotificationPreferenceBuilder (org.xwiki.notifications.preferences.TargetableNotificationPreferenceBuilder)2 Query (org.xwiki.query.Query)2 List (java.util.List)1 ConfigurationSource (org.xwiki.configuration.ConfigurationSource)1 EventStream (org.xwiki.eventstream.EventStream)1 NotificationFormat (org.xwiki.notifications.NotificationFormat)1 NotificationFilterManager (org.xwiki.notifications.filters.NotificationFilterManager)1 NotificationFilterPreference (org.xwiki.notifications.filters.NotificationFilterPreference)1 DefaultTargetableNotificationPreferenceBuilder (org.xwiki.notifications.preferences.internal.DefaultTargetableNotificationPreferenceBuilder)1 QueryManager (org.xwiki.query.QueryManager)1 AuthorizationManager (org.xwiki.security.authorization.AuthorizationManager)1 ContextualAuthorizationManager (org.xwiki.security.authorization.ContextualAuthorizationManager)1