NotificationCourseAccessManager implements CourseAccessManager { ICourse getCourseFromCacheOrLoad(RepositoryEntry courseRepositoryEntry) { ICourse course = repositoryEntryToCourseCache.get(courseRepositoryEntry.getResourceableId()); if (course == null) { OLATResourceable oLATResourceable = courseRepositoryEntry.getOlatResource(); if (oLATResourceable != null) { course = CourseFactory.loadCourse(oLATResourceable); repositoryEntryToCourseCache.put(courseRepositoryEntry.getResourceableId(), course); } } return course; } NotificationCourseAccessManager(); @Override void execute();  }
@Test public void getCourseFromCacheOrLoad_getExistingFromCache() { ICourse publicCourse = notificationCourseAccessManager.getCourseFromCacheOrLoad(okCourseMock); assertNotNull(publicCourse); }
@Test public void getCourseFromCacheOrLoad_getNotExisting() { RepositoryEntry notExistingRepositoryEntry = mock(RepositoryEntry.class); when(notExistingRepositoryEntry.getResourceableId()).thenReturn(new Long(100)); ICourse publicCourse = notificationCourseAccessManager.getCourseFromCacheOrLoad(notExistingRepositoryEntry); assertNull(publicCourse); }