### Question:
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);  }### Answer:
@Test public void shouldLoadContests_when_reloadFalse_and_rateLimitFalse() { Mockito.when(repoListRateLimit.shouldFetch(CodingCalendarViewModel.CONTEST_VIEW_MODEL)) .thenReturn(false); codingCalendarViewModel.loadContests(false); Mockito.verify(codingCalendarRepository, Mockito.never()).fetchContests(Mockito.anyBoolean()); Mockito.verify(repoListRateLimit, Mockito.never()).refreshRateLimiter(CodingCalendarViewModel.CONTEST_VIEW_MODEL); }
@Test public void shouldLoadContests_when_reloadTrue_and_rateLimitFalse() { codingCalendarViewModel.loadContests(true); Mockito.verify(codingCalendarRepository).fetchContests(true); Mockito.verify(repoListRateLimit).refreshRateLimiter(CodingCalendarViewModel.CONTEST_VIEW_MODEL); }
@Test public void shouldLoadContests_when_reloadFalse_and_rateLimitTrue() { Mockito.when(repoListRateLimit.shouldFetch(CodingCalendarViewModel.CONTEST_VIEW_MODEL)) .thenReturn(true); codingCalendarViewModel.loadContests(false); Mockito.verify(codingCalendarRepository).fetchContests(false); Mockito.verify(repoListRateLimit).refreshRateLimiter(CodingCalendarViewModel.CONTEST_VIEW_MODEL); }