示例#1
0
  @Test
  public void testFetchData() {
    // result from server is a list with at least one film -> give this film list to tableView
    when(filmDataModel.getAppliedFilter()).thenReturn(demoFilterWithResult);
    tablePresenter.fetchData();
    // 1st called from constructor (no results info), 2nd called when rpc starts loading (loading
    // info),3rd the result from the rpc
    verify(tableView, times(3)).setTable(Matchers.anyListOf(Film.class));

    // result from server is empty list -> tableView receives pseudo film list with information
    when(filmDataModel.getAppliedFilter()).thenReturn(demoFilterWithoutResult);
    tablePresenter.fetchData();
    // 1st called from constructor (no results info), 2nd the result of the empty rpc
    verify(tableView, times(2))
        .setTable(Matchers.eq(tablePresenter.createPseudoFilmList("No Search Results Found")));
  }