@Test public void getEventsThatHaveNoDescriptor() throws Exception { DocumentReference userA = new DocumentReference("xwiki", "XWiki", "UserA"); Event event1 = createMockedEvent("customThing", userA, userA, new Date(1510567729000L), "id1"); Event event2 = createMockedEvent("update", userA, userA, new Date(1510567729000L), "id2"); when(authorizationManager.hasAccess(eq(Right.VIEW), eq(userReference), any(DocumentReference.class))) .thenReturn(true); when(contextualAuthorizationManager.hasAccess(eq(Right.VIEW), any(DocumentReference.class))).thenReturn(true); when(eventStream.searchEvents(query)).thenReturn(Arrays.asList(event1, event2), Collections.emptyList()); when(recordableEventDescriptorHelper.hasDescriptor(eq("customThing"), eq(userA))).thenReturn(false); NotificationParameters parameters = new NotificationParameters(); parameters.user = userA; parameters.expectedCount = 5; parameters.format = NotificationFormat.ALERT; List<CompositeEvent> results = this.defaultParametrizedNotificationManager.getEvents(parameters); assertEquals(1, results.size()); assertEquals(event2, results.get(0).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);  }