Search in sources :

Example 1 with EmptyNode

use of org.xwiki.notifications.filters.expression.EmptyNode in project xwiki-platform by xwiki.

the class QueryGeneratorTest method generateQueryWithNoRelevantFilters.

@Test
public void generateQueryWithNoRelevantFilters() throws Exception {
    // Mocks
    NotificationFilter notificationFilter1 = mock(NotificationFilter.class);
    when(notificationFilterManager.getFilters(any(DocumentReference.class), any(NotificationPreference.class))).thenReturn(Collections.singleton(notificationFilter1));
    when(notificationFilter1.filterExpression(any(DocumentReference.class), any(NotificationPreference.class))).thenReturn(new EmptyNode());
    when(notificationFilter1.matchesPreference(any(NotificationPreference.class))).thenReturn(true);
    // Test
    ExpressionNode node = mocker.getComponentUnderTest().generateQueryExpression(new DocumentReference("xwiki", "XWiki", "UserA"), NotificationFormat.ALERT, null, startDate, Arrays.asList("event1", "event2"));
    assertEquals("(((DATE >= \"Thu Jan 01 01:00:00 CET 1970\" " + "AND (TYPE = \"create\" AND DATE >= \"Fri Jan 02 04:46:40 CET 1970\")) " + "AND NOT (ID IN (\"event1\", \"event2\"))) " + "AND HIDDEN <> true) " + "ORDER BY DATE DESC", node.toString());
}
Also used : NotificationPreference(org.xwiki.notifications.preferences.NotificationPreference) EmptyNode(org.xwiki.notifications.filters.expression.EmptyNode) ExpressionNode(org.xwiki.notifications.filters.expression.ExpressionNode) NotificationFilter(org.xwiki.notifications.filters.NotificationFilter) DocumentReference(org.xwiki.model.reference.DocumentReference) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)1 DocumentReference (org.xwiki.model.reference.DocumentReference)1 NotificationFilter (org.xwiki.notifications.filters.NotificationFilter)1 EmptyNode (org.xwiki.notifications.filters.expression.EmptyNode)1 ExpressionNode (org.xwiki.notifications.filters.expression.ExpressionNode)1 NotificationPreference (org.xwiki.notifications.preferences.NotificationPreference)1