@Test public void getEvents1Update2Events() throws Exception { Event event1 = createMockedEvent(); when(event1.toString()).thenReturn("event1"); Event event2 = createMockedEvent(); when(event1.toString()).thenReturn("event2"); Event event3 = createMockedEvent(); when(event1.toString()).thenReturn("event3"); DocumentReference doc = new DocumentReference("xwiki", "Main", "Bike"); when(event1.getDocument()).thenReturn(doc); when(event2.getDocument()).thenReturn(doc); when(event3.getDocument()).thenReturn(doc); when(authorizationManager.hasAccess(Right.VIEW, userReference, doc)).thenReturn(true); when(contextualAuthorizationManager.hasAccess(Right.VIEW, doc)).thenReturn(true); when(event1.getType()).thenReturn("update"); when(event2.getType()).thenReturn("addComment"); when(event3.getType()).thenReturn("addAnnotation"); when(event1.getGroupId()).thenReturn("g1"); when(event2.getGroupId()).thenReturn("g1"); when(event3.getGroupId()).thenReturn("g1"); when(eventStream.searchEvents(query)).thenReturn(Arrays.asList(event1, event2, event3)); NotificationParameters parameters = new NotificationParameters(); parameters.user = new DocumentReference("xwiki", "XWiki", "UserA"); parameters.expectedCount = 50; List<CompositeEvent> results = this.defaultParametrizedNotificationManager.getEvents(parameters); assertEquals(1, results.size()); assertTrue(results.get(0).getEvents().contains(event1)); assertTrue(results.get(0).getEvents().contains(event2)); assertTrue(results.get(0).getEvents().contains(event3)); }
@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);  }