AcademyRepository implements AcademyDataSource { @Override public LiveData<List<CourseEntity>> getBookmarkedCourses() { return localDataSource.getBookmarkedCourses(); } private  AcademyRepository(@NonNull RemoteDataSource remoteDataSource, @NonNull LocalDataSource localDataSource, AppExecutors appExecutors); static AcademyRepository getInstance(RemoteDataSource remoteData, LocalDataSource localDataSource, AppExecutors appExecutors); @Override LiveData<Resource<List<CourseEntity>>> getAllCourses(); @Override LiveData<List<CourseEntity>> getBookmarkedCourses(); @Override LiveData<Resource<CourseWithModule>> getCourseWithModules(final String courseId); @Override LiveData<Resource<List<ModuleEntity>>> getAllModulesByCourse(String courseId); @Override LiveData<Resource<ModuleEntity>> getContent(String moduleId); @Override void setCourseBookmark(CourseEntity course, boolean state); @Override void setReadModule(ModuleEntity module);  }
@Test public void getBookmarkedCourses() { doAnswer(invocation -> { ((RemoteDataSource.LoadCoursesCallback) invocation.getArguments()[0]) .onAllCoursesReceived(courseResponses); return null; }).when(remote).getAllCourses(any(RemoteDataSource.LoadCoursesCallback.class)); List<CourseEntity> courseEntities = LiveDataTestUtil.getValue(academyRepository.getBookmarkedCourses()); verify(remote).getAllCourses(any(RemoteDataSource.LoadCoursesCallback.class)); assertNotNull(courseEntities); assertEquals(courseResponses.size(), courseEntities.size()); }