@Test public void getEventsUC6() throws Exception { DocumentReference doc1 = new DocumentReference("xwiki", "Main", "Bike"); DocumentReference doc2 = new DocumentReference("xwiki", "Main", "Guitar"); 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(true); when(contextualAuthorizationManager.hasAccess(Right.VIEW, doc2)).thenReturn(true); Event event1 = createMockedEvent(); when(event1.toString()).thenReturn("event1"); when(event1.getDocument()).thenReturn(doc1); when(event1.getType()).thenReturn("update"); when(event1.getGroupId()).thenReturn("g1"); Event event2 = createMockedEvent(); when(event2.toString()).thenReturn("event2"); when(event2.getDocument()).thenReturn(doc1); when(event2.getType()).thenReturn("update"); when(event2.getGroupId()).thenReturn("g2"); Event event3 = createMockedEvent(); when(event3.toString()).thenReturn("event3"); when(event3.getDocument()).thenReturn(doc1); when(event3.getType()).thenReturn("addComment"); when(event3.getGroupId()).thenReturn("g3"); Event event4 = createMockedEvent(); when(event4.toString()).thenReturn("event4"); when(event4.getDocument()).thenReturn(doc1); when(event4.getType()).thenReturn("update"); when(event4.getGroupId()).thenReturn("g3"); Event event5 = createMockedEvent(); when(event5.toString()).thenReturn("event5"); when(event5.getDocument()).thenReturn(doc1); when(event5.getType()).thenReturn("update"); when(event5.getGroupId()).thenReturn("g5"); Event event6 = createMockedEvent(); when(event6.toString()).thenReturn("event6"); when(event6.getDocument()).thenReturn(doc1); when(event6.getType()).thenReturn("addComment"); when(event6.getGroupId()).thenReturn("g5"); Event event7 = createMockedEvent(); when(event7.toString()).thenReturn("event7"); when(event7.getDocument()).thenReturn(doc2); when(event7.getType()).thenReturn("update"); when(event7.getGroupId()).thenReturn("g7"); Event event8 = createMockedEvent(); when(event8.toString()).thenReturn("event8"); when(event8.getDocument()).thenReturn(doc2); when(event8.getType()).thenReturn("addComment"); when(event8.getGroupId()).thenReturn("g7"); Event event9 = createMockedEvent(); when(event8.toString()).thenReturn("event9"); when(event9.getDocument()).thenReturn(doc1); when(event9.getType()).thenReturn("update"); when(event9.getGroupId()).thenReturn("g9"); Event event10 = createMockedEvent(); when(event8.toString()).thenReturn("event10"); when(event10.getDocument()).thenReturn(doc1); when(event10.getType()).thenReturn("addAnnotation"); when(event10.getGroupId()).thenReturn("g9"); Event event11 = createMockedEvent(); when(event8.toString()).thenReturn("event11"); when(event11.getDocument()).thenReturn(doc1); when(event11.getType()).thenReturn("update"); when(event11.getGroupId()).thenReturn("g11"); Event event12 = createMockedEvent(); when(event8.toString()).thenReturn("event12"); when(event12.getDocument()).thenReturn(doc1); when(event12.getType()).thenReturn("addAnnotation"); when(event12.getGroupId()).thenReturn("g11"); Event event13 = createMockedEvent(); when(event8.toString()).thenReturn("event11"); when(event13.getDocument()).thenReturn(doc1); when(event13.getType()).thenReturn("addAnnotation"); when(event13.getGroupId()).thenReturn("g13"); Event event14 = createMockedEvent(); when(event8.toString()).thenReturn("event12"); when(event14.getDocument()).thenReturn(doc1); when(event14.getType()).thenReturn("update"); when(event14.getGroupId()).thenReturn("g13"); when(eventStream.searchEvents(query)).thenReturn(Arrays.asList(event1, event2, event3, event4, event5, event6, event7, event8, event9, event10, event11, event12, event13, event14)); NotificationParameters parameters = new NotificationParameters(); parameters.user = new DocumentReference("xwiki", "XWiki", "UserA"); parameters.expectedCount = 50; List<CompositeEvent> results = this.defaultParametrizedNotificationManager.getEvents(parameters); assertEquals(4, results.size()); assertTrue(results.get(0).getEvents().contains(event1)); assertTrue(results.get(0).getEvents().contains(event2)); assertTrue(results.get(1).getEvents().contains(event3)); assertTrue(results.get(1).getEvents().contains(event4)); assertTrue(results.get(1).getEvents().contains(event5)); assertTrue(results.get(1).getEvents().contains(event6)); assertTrue(results.get(2).getEvents().contains(event7)); assertTrue(results.get(2).getEvents().contains(event8)); assertTrue(results.get(3).getEvents().contains(event9)); assertTrue(results.get(3).getEvents().contains(event10)); assertTrue(results.get(3).getEvents().contains(event11)); assertTrue(results.get(3).getEvents().contains(event12)); assertTrue(results.get(3).getEvents().contains(event13)); assertTrue(results.get(3).getEvents().contains(event14)); }
@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);  }