@Test public void shouldLoadContests_when_reloadTrue_and_rateLimitFalse() { codingCalendarViewModel.loadContests(true); Mockito.verify(codingCalendarRepository).fetchContests(true); Mockito.verify(repoListRateLimit).refreshRateLimiter(CodingCalendarViewModel.CONTEST_VIEW_MODEL); }
protected LiveData<Resource<List<Contest>>> loadContests(boolean reload) { if (reload || repoListRateLimit.shouldFetch(CONTEST_VIEW_MODEL)) { contests = codingCalendarRepository.fetchContests(reload); repoListRateLimit.refreshRateLimiter(CONTEST_VIEW_MODEL); } return contests; }
CodingCalendarViewModel extends ViewModel { protected LiveData<Resource<List<Contest>>> loadContests(boolean reload) { if (reload || repoListRateLimit.shouldFetch(CONTEST_VIEW_MODEL)) { contests = codingCalendarRepository.fetchContests(reload); repoListRateLimit.refreshRateLimiter(CONTEST_VIEW_MODEL); } return contests; } }
CodingCalendarViewModel extends ViewModel { protected LiveData<Resource<List<Contest>>> loadContests(boolean reload) { if (reload || repoListRateLimit.shouldFetch(CONTEST_VIEW_MODEL)) { contests = codingCalendarRepository.fetchContests(reload); repoListRateLimit.refreshRateLimiter(CONTEST_VIEW_MODEL); } return contests; } @Inject  CodingCalendarViewModel(CodingCalendarRepository codingCalendarRepository,
                                   RateLimiter<String> repoListRateLimit); }
CodingCalendarViewModel extends ViewModel { protected LiveData<Resource<List<Contest>>> loadContests(boolean reload) { if (reload || repoListRateLimit.shouldFetch(CONTEST_VIEW_MODEL)) { contests = codingCalendarRepository.fetchContests(reload); repoListRateLimit.refreshRateLimiter(CONTEST_VIEW_MODEL); } return contests; } @Inject  CodingCalendarViewModel(CodingCalendarRepository codingCalendarRepository,
                                   RateLimiter<String> repoListRateLimit); void openContestDetails(Long id); }
CodingCalendarViewModel extends ViewModel { protected LiveData<Resource<List<Contest>>> loadContests(boolean reload) { if (reload || repoListRateLimit.shouldFetch(CONTEST_VIEW_MODEL)) { contests = codingCalendarRepository.fetchContests(reload); repoListRateLimit.refreshRateLimiter(CONTEST_VIEW_MODEL); } return contests; } @Inject  CodingCalendarViewModel(CodingCalendarRepository codingCalendarRepository,
                                   RateLimiter<String> repoListRateLimit); void openContestDetails(Long id);  }