@Test public void getCoursesAccesibleForIdentity() { assertTrue(contextsOfSubscriber1.size() == 4); Map<Long, RepositoryEntry> contextIdToRepositoryEntryMap = notificationCourseAccessManager.getCoursesAccesibleForIdentity(contextsOfSubscriber1); assertEquals("only one course is accessible for this identity", 1, contextIdToRepositoryEntryMap.size()); }
Map<Long, RepositoryEntry> getCoursesAccesibleForIdentity(List<NotificationSubscriptionContext> notificationCourseAccessTOs) { Set<Long> contextIdSet = new HashSet<Long>(); Map<Long, RepositoryEntry> onlyAccessibleCourses = new HashMap<Long, RepositoryEntry>(); for (NotificationSubscriptionContext notificationCourseAccessTO : notificationCourseAccessTOs) { if (!contextIdSet.contains(notificationCourseAccessTO.getContextId())) { RepositoryEntry repositoryEntry = isCourseAccesibleForIdentity(notificationCourseAccessTO); contextIdSet.add(notificationCourseAccessTO.getContextId()); if (repositoryEntry != null) { onlyAccessibleCourses.put(notificationCourseAccessTO.getContextId(), repositoryEntry); } } } return onlyAccessibleCourses; }
NotificationCourseAccessManager implements CourseAccessManager { Map<Long, RepositoryEntry> getCoursesAccesibleForIdentity(List<NotificationSubscriptionContext> notificationCourseAccessTOs) { Set<Long> contextIdSet = new HashSet<Long>(); Map<Long, RepositoryEntry> onlyAccessibleCourses = new HashMap<Long, RepositoryEntry>(); for (NotificationSubscriptionContext notificationCourseAccessTO : notificationCourseAccessTOs) { if (!contextIdSet.contains(notificationCourseAccessTO.getContextId())) { RepositoryEntry repositoryEntry = isCourseAccesibleForIdentity(notificationCourseAccessTO); contextIdSet.add(notificationCourseAccessTO.getContextId()); if (repositoryEntry != null) { onlyAccessibleCourses.put(notificationCourseAccessTO.getContextId(), repositoryEntry); } } } return onlyAccessibleCourses; } }
NotificationCourseAccessManager implements CourseAccessManager { Map<Long, RepositoryEntry> getCoursesAccesibleForIdentity(List<NotificationSubscriptionContext> notificationCourseAccessTOs) { Set<Long> contextIdSet = new HashSet<Long>(); Map<Long, RepositoryEntry> onlyAccessibleCourses = new HashMap<Long, RepositoryEntry>(); for (NotificationSubscriptionContext notificationCourseAccessTO : notificationCourseAccessTOs) { if (!contextIdSet.contains(notificationCourseAccessTO.getContextId())) { RepositoryEntry repositoryEntry = isCourseAccesibleForIdentity(notificationCourseAccessTO); contextIdSet.add(notificationCourseAccessTO.getContextId()); if (repositoryEntry != null) { onlyAccessibleCourses.put(notificationCourseAccessTO.getContextId(), repositoryEntry); } } } return onlyAccessibleCourses; } NotificationCourseAccessManager(); }
NotificationCourseAccessManager implements CourseAccessManager { Map<Long, RepositoryEntry> getCoursesAccesibleForIdentity(List<NotificationSubscriptionContext> notificationCourseAccessTOs) { Set<Long> contextIdSet = new HashSet<Long>(); Map<Long, RepositoryEntry> onlyAccessibleCourses = new HashMap<Long, RepositoryEntry>(); for (NotificationSubscriptionContext notificationCourseAccessTO : notificationCourseAccessTOs) { if (!contextIdSet.contains(notificationCourseAccessTO.getContextId())) { RepositoryEntry repositoryEntry = isCourseAccesibleForIdentity(notificationCourseAccessTO); contextIdSet.add(notificationCourseAccessTO.getContextId()); if (repositoryEntry != null) { onlyAccessibleCourses.put(notificationCourseAccessTO.getContextId(), repositoryEntry); } } } return onlyAccessibleCourses; } NotificationCourseAccessManager(); @Override void execute(); }
NotificationCourseAccessManager implements CourseAccessManager { Map<Long, RepositoryEntry> getCoursesAccesibleForIdentity(List<NotificationSubscriptionContext> notificationCourseAccessTOs) { Set<Long> contextIdSet = new HashSet<Long>(); Map<Long, RepositoryEntry> onlyAccessibleCourses = new HashMap<Long, RepositoryEntry>(); for (NotificationSubscriptionContext notificationCourseAccessTO : notificationCourseAccessTOs) { if (!contextIdSet.contains(notificationCourseAccessTO.getContextId())) { RepositoryEntry repositoryEntry = isCourseAccesibleForIdentity(notificationCourseAccessTO); contextIdSet.add(notificationCourseAccessTO.getContextId()); if (repositoryEntry != null) { onlyAccessibleCourses.put(notificationCourseAccessTO.getContextId(), repositoryEntry); } } } return onlyAccessibleCourses; } NotificationCourseAccessManager(); @Override void execute();  }