@Test public void shouldGenerate1CanNotDoInventoryViewModelsWhenThereIsNoMissedRnrAndThereIsNoHistoricalRnrAndItIs17May() throws Exception { Program program = new ProgramBuilder().setProgramCode("VIA").build(); presenter.setViewProgram(Constants.Program.VIA_PROGRAM); presenter.setProgramCode(program.getProgramCode()); LMISTestApp.getInstance().setCurrentTimeMillis(new DateTime(DateUtil.parseString("2016-05-17", DateUtil.DB_DATE_FORMAT)).getMillis()); when(rnrFormRepository.list()).thenReturn(new ArrayList<RnRForm>()); when(requisitionPeriodService.generateNextPeriod(program.getProgramCode(), null)).thenReturn(periodAplToMay); List<RnRFormViewModel> rnRFormViewModels = presenter.buildFormListViewModels(); assertThat(rnRFormViewModels.size()).isEqualTo(1); assertThat(rnRFormViewModels.get(0).getType()).isEqualTo(RnRFormViewModel.TYPE_CANNOT_DO_MONTHLY_INVENTORY); assertThat(rnRFormViewModels.get(0).getPeriodEndMonth()).isEqualTo(periodAplToMay.getEnd()); }
@NonNull protected List<RnRFormViewModel> buildFormListViewModels() throws LMISException { List<RnRFormViewModel> rnRFormViewModels = new ArrayList<>(); ReportTypeForm typeForm = reportTypeFormRepository.queryByCode(viewProgram.getReportType()); List<RnRForm> rnRForms = repository.listInclude(RnRForm.Emergency.Yes, programCode, typeForm); generateRnrViewModelByRnrFormsInDB(rnRFormViewModels, rnRForms); if (typeForm.active) { generateViewModelsByCurrentDate(rnRFormViewModels, typeForm); } populateSyncErrorsOnViewModels(rnRFormViewModels); Collections.sort(rnRFormViewModels, (lhs, rhs) -> rhs.getPeriodEndMonth().compareTo(lhs.getPeriodEndMonth())); generateInactiveFormListViewModels(rnRFormViewModels, typeForm); return rnRFormViewModels; }
RnRFormListPresenter extends Presenter { @NonNull protected List<RnRFormViewModel> buildFormListViewModels() throws LMISException { List<RnRFormViewModel> rnRFormViewModels = new ArrayList<>(); ReportTypeForm typeForm = reportTypeFormRepository.queryByCode(viewProgram.getReportType()); List<RnRForm> rnRForms = repository.listInclude(RnRForm.Emergency.Yes, programCode, typeForm); generateRnrViewModelByRnrFormsInDB(rnRFormViewModels, rnRForms); if (typeForm.active) { generateViewModelsByCurrentDate(rnRFormViewModels, typeForm); } populateSyncErrorsOnViewModels(rnRFormViewModels); Collections.sort(rnRFormViewModels, (lhs, rhs) -> rhs.getPeriodEndMonth().compareTo(lhs.getPeriodEndMonth())); generateInactiveFormListViewModels(rnRFormViewModels, typeForm); return rnRFormViewModels; } }
RnRFormListPresenter extends Presenter { @NonNull protected List<RnRFormViewModel> buildFormListViewModels() throws LMISException { List<RnRFormViewModel> rnRFormViewModels = new ArrayList<>(); ReportTypeForm typeForm = reportTypeFormRepository.queryByCode(viewProgram.getReportType()); List<RnRForm> rnRForms = repository.listInclude(RnRForm.Emergency.Yes, programCode, typeForm); generateRnrViewModelByRnrFormsInDB(rnRFormViewModels, rnRForms); if (typeForm.active) { generateViewModelsByCurrentDate(rnRFormViewModels, typeForm); } populateSyncErrorsOnViewModels(rnRFormViewModels); Collections.sort(rnRFormViewModels, (lhs, rhs) -> rhs.getPeriodEndMonth().compareTo(lhs.getPeriodEndMonth())); generateInactiveFormListViewModels(rnRFormViewModels, typeForm); return rnRFormViewModels; }  }
RnRFormListPresenter extends Presenter { @NonNull protected List<RnRFormViewModel> buildFormListViewModels() throws LMISException { List<RnRFormViewModel> rnRFormViewModels = new ArrayList<>(); ReportTypeForm typeForm = reportTypeFormRepository.queryByCode(viewProgram.getReportType()); List<RnRForm> rnRForms = repository.listInclude(RnRForm.Emergency.Yes, programCode, typeForm); generateRnrViewModelByRnrFormsInDB(rnRFormViewModels, rnRForms); if (typeForm.active) { generateViewModelsByCurrentDate(rnRFormViewModels, typeForm); } populateSyncErrorsOnViewModels(rnRFormViewModels); Collections.sort(rnRFormViewModels, (lhs, rhs) -> rhs.getPeriodEndMonth().compareTo(lhs.getPeriodEndMonth())); generateInactiveFormListViewModels(rnRFormViewModels, typeForm); return rnRFormViewModels; }  @Override void attachView(BaseView v); Observable<List<RnRFormViewModel>> loadRnRFormList(); void deleteRnRForm(RnRForm form); Observable<Boolean> hasMissedPeriod(); }
RnRFormListPresenter extends Presenter { @NonNull protected List<RnRFormViewModel> buildFormListViewModels() throws LMISException { List<RnRFormViewModel> rnRFormViewModels = new ArrayList<>(); ReportTypeForm typeForm = reportTypeFormRepository.queryByCode(viewProgram.getReportType()); List<RnRForm> rnRForms = repository.listInclude(RnRForm.Emergency.Yes, programCode, typeForm); generateRnrViewModelByRnrFormsInDB(rnRFormViewModels, rnRForms); if (typeForm.active) { generateViewModelsByCurrentDate(rnRFormViewModels, typeForm); } populateSyncErrorsOnViewModels(rnRFormViewModels); Collections.sort(rnRFormViewModels, (lhs, rhs) -> rhs.getPeriodEndMonth().compareTo(lhs.getPeriodEndMonth())); generateInactiveFormListViewModels(rnRFormViewModels, typeForm); return rnRFormViewModels; }  @Override void attachView(BaseView v); Observable<List<RnRFormViewModel>> loadRnRFormList(); void deleteRnRForm(RnRForm form); Observable<Boolean> hasMissedPeriod();  }