@Test public void getEventsXWIKI14454() throws Exception { Event eventUpdate1 = createMockedEvent(); Event eventUpdate2 = createMockedEvent(); Event eventAddComment = createMockedEvent(); Event eventAddCommentUpdate = createMockedEvent(); DocumentReference doc = new DocumentReference("xwiki", "Main", "Bike"); when(eventUpdate1.getDocument()).thenReturn(doc); when(eventUpdate1.toString()).thenReturn("update1"); when(eventUpdate2.getDocument()).thenReturn(doc); when(eventUpdate2.toString()).thenReturn("update2"); when(eventAddComment.getDocument()).thenReturn(doc); when(eventAddComment.toString()).thenReturn("addComment"); when(eventAddCommentUpdate.getDocument()).thenReturn(doc); when(eventAddCommentUpdate.toString()).thenReturn("updateComment"); when(authorizationManager.hasAccess(Right.VIEW, userReference, doc)).thenReturn(true); when(contextualAuthorizationManager.hasAccess(Right.VIEW, doc)).thenReturn(true); when(eventUpdate1.getType()).thenReturn("update"); when(eventUpdate2.getType()).thenReturn("update"); when(eventAddComment.getType()).thenReturn("addComment"); when(eventAddCommentUpdate.getType()).thenReturn("update"); when(eventUpdate1.getGroupId()).thenReturn("g1"); when(eventUpdate2.getGroupId()).thenReturn("g2"); when(eventAddComment.getGroupId()).thenReturn("g3"); when(eventAddCommentUpdate.getGroupId()).thenReturn("g3"); when(eventStream.searchEvents(query)) .thenReturn(Arrays.asList(eventAddComment, eventAddCommentUpdate, eventUpdate2, eventUpdate1)); NotificationParameters parameters = new NotificationParameters(); parameters.user = new DocumentReference("xwiki", "XWiki", "UserA"); parameters.expectedCount = 5; List<CompositeEvent> results = this.defaultParametrizedNotificationManager.getEvents(parameters); assertEquals(2, results.size()); }
@Override public List<CompositeEvent> getEvents(NotificationParameters parameters) throws NotificationException { if (Boolean.TRUE.equals(parameters.onlyUnread) && !parameters.filters.contains(eventReadAlertFilter)) { parameters.filters.add(eventReadAlertFilter); } if (Boolean.TRUE.equals(parameters.onlyUnread) && !parameters.filters.contains(eventReadEmailFilter)) { parameters.filters.add(eventReadEmailFilter); } return getEvents(new ArrayList<>(), parameters); }
DefaultParametrizedNotificationManager implements ParametrizedNotificationManager { @Override public List<CompositeEvent> getEvents(NotificationParameters parameters) throws NotificationException { if (Boolean.TRUE.equals(parameters.onlyUnread) && !parameters.filters.contains(eventReadAlertFilter)) { parameters.filters.add(eventReadAlertFilter); } if (Boolean.TRUE.equals(parameters.onlyUnread) && !parameters.filters.contains(eventReadEmailFilter)) { parameters.filters.add(eventReadEmailFilter); } return getEvents(new ArrayList<>(), parameters); } }
DefaultParametrizedNotificationManager implements ParametrizedNotificationManager { @Override public List<CompositeEvent> getEvents(NotificationParameters parameters) throws NotificationException { if (Boolean.TRUE.equals(parameters.onlyUnread) && !parameters.filters.contains(eventReadAlertFilter)) { parameters.filters.add(eventReadAlertFilter); } if (Boolean.TRUE.equals(parameters.onlyUnread) && !parameters.filters.contains(eventReadEmailFilter)) { parameters.filters.add(eventReadEmailFilter); } return getEvents(new ArrayList<>(), parameters); }  }
DefaultParametrizedNotificationManager implements ParametrizedNotificationManager { @Override public List<CompositeEvent> getEvents(NotificationParameters parameters) throws NotificationException { if (Boolean.TRUE.equals(parameters.onlyUnread) && !parameters.filters.contains(eventReadAlertFilter)) { parameters.filters.add(eventReadAlertFilter); } if (Boolean.TRUE.equals(parameters.onlyUnread) && !parameters.filters.contains(eventReadEmailFilter)) { parameters.filters.add(eventReadEmailFilter); } return getEvents(new ArrayList<>(), parameters); }  @Override List<CompositeEvent> getEvents(NotificationParameters parameters); }
DefaultParametrizedNotificationManager implements ParametrizedNotificationManager { @Override public List<CompositeEvent> getEvents(NotificationParameters parameters) throws NotificationException { if (Boolean.TRUE.equals(parameters.onlyUnread) && !parameters.filters.contains(eventReadAlertFilter)) { parameters.filters.add(eventReadAlertFilter); } if (Boolean.TRUE.equals(parameters.onlyUnread) && !parameters.filters.contains(eventReadEmailFilter)) { parameters.filters.add(eventReadEmailFilter); } return getEvents(new ArrayList<>(), parameters); }  @Override List<CompositeEvent> getEvents(NotificationParameters parameters);  }