NotificationCourseAccessManager implements CourseAccessManager { Set<Long> removeInvalidContexts(List<Long> subscriberIds) { log.debug("removeInvalidContexts started"); Set<Long> unaccessibleCourseIds = new HashSet<Long>(); for (Long subscriberId : subscriberIds) { List<NotificationSubscriptionContext> notificationCourseAccessTOs = notificationLearnServiceImpl.getNotificationSubscriptionContexts(subscriberId); Set<Long> subscribedCourseIds = getSubscribedCourseIds(notificationCourseAccessTOs); addUnaccessibleCourseIds(subscribedCourseIds, unaccessibleCourseIds); notificationLearnServiceImpl.removePublishers(unaccessibleCourseIds); } log.debug("removeInvalidContexts finished"); return unaccessibleCourseIds; } NotificationCourseAccessManager(); @Override void execute();  }
@Test public void removeInvalidContexts_4_InvalidContextsFound() { Set<Long> invalidContextsIds = notificationCourseAccessManager.removeInvalidContexts(subscriberIds); assertEquals(4, invalidContextsIds.size()); assertTrue(invalidContextsIds.contains(contextId_privateCourse1)); assertFalse(invalidContextsIds.contains(contextId_ok)); }
@Test public void removeInvalidContexts_5_InvalidContextsFound() { when(okCourseMock.getAccess()).thenReturn(RepositoryEntry.ACC_OWNERS_AUTHORS); Set<Long> invalidContextsIds = notificationCourseAccessManager.removeInvalidContexts(subscriberIds); assertEquals(5, invalidContextsIds.size()); assertTrue(invalidContextsIds.contains(contextId_privateCourse1)); assertTrue(invalidContextsIds.contains(contextId_ok)); }
@Test public void removeInvalidContexts_2_InvalidContextsFound() { subscriberIds.remove(subscriberId1); Set<Long> invalidContextsIds = notificationCourseAccessManager.removeInvalidContexts(subscriberIds); assertEquals(2, invalidContextsIds.size()); assertTrue(invalidContextsIds.contains(contextId_privateCourse1)); assertFalse(invalidContextsIds.contains(contextId_ok)); }