@Test public void getEventsWith2Queries() throws Exception { Event event1 = createMockedEvent(); Event event2 = createMockedEvent(); Event event3 = createMockedEvent(); Event event4 = createMockedEvent(); Event event5 = createMockedEvent(); Event event6 = createMockedEvent(); DocumentReference doc1 = new DocumentReference("xwiki", "Main", "WebHome"); when(event1.getDocument()).thenReturn(doc1); DocumentReference doc2 = new DocumentReference("xwiki", "PrivateSpace", "WebHome"); when(event2.getDocument()).thenReturn(doc2); when(event3.getDocument()).thenReturn(doc2); when(event4.getDocument()).thenReturn(doc2); when(authorizationManager.hasAccess(Right.VIEW, userReference, doc1)).thenReturn(true); when(contextualAuthorizationManager.hasAccess(Right.VIEW, doc1)).thenReturn(true); when(authorizationManager.hasAccess(Right.VIEW, userReference, doc2)).thenReturn(false); when(event1.getType()).thenReturn("type1"); when(event2.getType()).thenReturn("type2"); when(event3.getType()).thenReturn("type3"); when(event4.getType()).thenReturn("type4"); when(event5.getType()).thenReturn("type5"); when(event6.getType()).thenReturn("type6"); when(eventStream.searchEvents(query)).thenReturn(Arrays.asList(event1, event2, event3, event4), Arrays.asList(event5, event6)); NotificationParameters parameters = new NotificationParameters(); parameters.user = new DocumentReference("xwiki", "XWiki", "UserA"); parameters.expectedCount = 2; List<CompositeEvent> results = this.defaultParametrizedNotificationManager.getEvents(parameters); assertEquals(2, results.size()); assertEquals(event1, results.get(0).getEvents().get(0)); assertEquals(event5, results.get(1).getEvents().get(0)); }
@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);  }