CaseListPresenter extends RecordListPresenter { @Override public List<Long> getRecordsByFilter(SpinnerState spinnerState) { switch (spinnerState) { case AGE_ASC: return caseService.getAllOrderByAgeASC(); case AGE_DES: return caseService.getAllOrderByAgeDES(); case REG_DATE_ASC: return caseService.getAllOrderByDateASC(); case REG_DATE_DES: return caseService.getAllOrderByDateDES(); default: return new ArrayList<>(); } } @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_records_by_age_ASC_filter() throws Exception { SpinnerState spinnerState = SpinnerState.AGE_ASC; List<Long> expected = new ArrayList<>(); when(caseService.getAllOrderByAgeASC()).thenReturn(expected); List<Long> actual = caseListPresenter.getRecordsByFilter(spinnerState); assertThat("Should return records by age ASC filter when SpinnerState is AGE_ASC", actual, is(expected)); }
@Test public void should_return_records_by_age_DES_filter() throws Exception { SpinnerState spinnerState = SpinnerState.AGE_DES; List<Long> expected = new ArrayList<>(); when(caseService.getAllOrderByAgeDES()).thenReturn(expected); List<Long> actual = caseListPresenter.getRecordsByFilter(spinnerState); assertThat("Should return records by age DES filter when SpinnerState is AGE_DES", actual, is(expected)); }
@Test public void should_return_records_by_registration_date_DES_filter() throws Exception { SpinnerState spinnerState = SpinnerState.REG_DATE_DES; List<Long> expected = new ArrayList<>(); when(caseService.getAllOrderByDateDES()).thenReturn(expected); List<Long> actual = caseListPresenter.getRecordsByFilter(spinnerState); assertThat("Should return records by registrarion date DES filter when SpinnerState is AGE_DES", actual, is(expected)); }
@Test public void should_return_records_by_registration_date_ASC_filter() throws Exception { SpinnerState spinnerState = SpinnerState.REG_DATE_ASC; List<Long> expected = new ArrayList<>(); when(caseService.getAllOrderByDateASC()).thenReturn(expected); List<Long> actual = caseListPresenter.getRecordsByFilter(spinnerState); assertThat("Should return records by registrarion date ASC filter when SpinnerState is AGE_DES", actual, is(expected)); }