@Test public void getModules() { MutableLiveData<List<ModuleEntity>> module = new MutableLiveData<>(); module.setValue(dummyModules); when(academyRepository.getAllModulesByCourse(courseId)).thenReturn(module); List<ModuleEntity> moduleEntities = viewModel.getModules().getValue(); verify(academyRepository).getAllModulesByCourse(courseId); assertNotNull(moduleEntities); assertEquals(7, moduleEntities.size()); viewModel.getModules().observeForever(modulesObserver); verify(modulesObserver).onChanged(dummyModules); }
public LiveData<List<ModuleEntity>> getModules() { return academyRepository.getAllModulesByCourse(courseId); }
DetailCourseViewModel extends ViewModel { public LiveData<List<ModuleEntity>> getModules() { return academyRepository.getAllModulesByCourse(courseId); } }
DetailCourseViewModel extends ViewModel { public LiveData<List<ModuleEntity>> getModules() { return academyRepository.getAllModulesByCourse(courseId); } DetailCourseViewModel(AcademyRepository mAcademyRepository); }
DetailCourseViewModel extends ViewModel { public LiveData<List<ModuleEntity>> getModules() { return academyRepository.getAllModulesByCourse(courseId); } DetailCourseViewModel(AcademyRepository mAcademyRepository); void setSelectedCourse(String courseId); LiveData<CourseEntity> getCourse(); LiveData<List<ModuleEntity>> getModules(); }
DetailCourseViewModel extends ViewModel { public LiveData<List<ModuleEntity>> getModules() { return academyRepository.getAllModulesByCourse(courseId); } DetailCourseViewModel(AcademyRepository mAcademyRepository); void setSelectedCourse(String courseId); LiveData<CourseEntity> getCourse(); LiveData<List<ModuleEntity>> getModules();  }