@Test public void getCourse() { MutableLiveData<CourseEntity> course = new MutableLiveData<>(); course.setValue(dummyCourse); when(academyRepository.getCourseWithModules(courseId)).thenReturn(course); CourseEntity courseEntity = viewModel.getCourse().getValue(); verify(academyRepository).getCourseWithModules(courseId); assertNotNull(courseEntity); assertEquals(dummyCourse.getCourseId(), courseEntity.getCourseId()); assertEquals(dummyCourse.getDeadline(), courseEntity.getDeadline()); assertEquals(dummyCourse.getDescription(), courseEntity.getDescription()); assertEquals(dummyCourse.getImagePath(), courseEntity.getImagePath()); assertEquals(dummyCourse.getTitle(), courseEntity.getTitle()); viewModel.getCourse().observeForever(courseObserver); verify(courseObserver).onChanged(dummyCourse); }
public String getCourseId() { return courseId.getValue(); }
DetailCourseViewModel extends ViewModel { public String getCourseId() { return courseId.getValue(); } }
DetailCourseViewModel extends ViewModel { public String getCourseId() { return courseId.getValue(); } DetailCourseViewModel(AcademyRepository mAcademyRepository); }
DetailCourseViewModel extends ViewModel { public String getCourseId() { return courseId.getValue(); } DetailCourseViewModel(AcademyRepository mAcademyRepository); String getCourseId(); void setCourseId(String courseId); }
DetailCourseViewModel extends ViewModel { public String getCourseId() { return courseId.getValue(); } DetailCourseViewModel(AcademyRepository mAcademyRepository); String getCourseId(); void setCourseId(String courseId); public LiveData<Resource<CourseWithModule>> courseModule; }