IncidentListPresenter extends RecordListPresenter { @Override public int calculateDisplayedIndex() { List<Incident> incidents = incidentService.getAll(); return incidents.isEmpty() ? HAVE_NO_RESULT : HAVE_RESULT_LIST; } @Inject  IncidentListPresenter(IncidentService incidentService, IncidentFormService
            incidentFormService, RecordService recordService); @Override boolean isFormReady(); @Override List<Long> getRecordsByFilter(SpinnerState spinnerState); @Override List<Long> getSyncedRecords(); @Override int getSyncedRecordsCount(); @Override int calculateDisplayedIndex();  }
@Test public void should_return_displayed_index() throws Exception { when(incidentService.getAll()).thenReturn(Collections.EMPTY_LIST); int index = incidentListPresenter.calculateDisplayedIndex(); assertThat("Should return 1 when incidents is empty", index, is(1)); }
@Test public void should_return_zero_when_incident_list_exits() throws Exception { List<Incident> incidents = Arrays.asList(new Incident()); when(incidentService.getAll()).thenReturn(incidents); assertThat("Should return 0 when incident exits", incidentListPresenter.calculateDisplayedIndex(), is(0)); verify(incidentService, times(1)).getAll(); }