CaseListPresenter extends RecordListPresenter { @Override public int calculateDisplayedIndex() { List<Case> cases = caseService.getAll(); return cases.isEmpty() ? HAVE_NO_RESULT : HAVE_RESULT_LIST; } @Inject  CaseListPresenter(CaseService caseService, CaseFormService caseFormService, RecordService recordService); @Override boolean isFormReady(); @Override List<Long> getRecordsByFilter(SpinnerState spinnerState); @Override List<Long> getSyncedRecords(); @Override int calculateDisplayedIndex(); @Override int getSyncedRecordsCount();  }
@Test public void should_return_displayed_index_when_case_is_empty() throws Exception { when(caseService.getAll()).thenReturn(Collections.EMPTY_LIST); int index = caseListPresenter.calculateDisplayedIndex(); assertThat("Should return 1 when cases is empty", index, is(1)); }
@Test public void should_return_zero_index_when_case_exits() throws Exception { List<Case> cases = Arrays.asList(new Case()); when(caseService.getAll()).thenReturn(cases); assertThat("Should return 0 when case exits", caseListPresenter.calculateDisplayedIndex(), is(0)); }