@Test public void shouldReplaceViewModelSuppliedInMalariaProgramViewModelList() throws InvocationTargetException, NoSuchMethodException, LMISException, IllegalAccessException { initializeImplementationReportViewModels(); ImplementationReportViewModel implementationReportViewModel = getImplementationViewModel(ImplementationReportType.US); List<ImplementationReportViewModel> implementationReportViewModels = malariaDataReportFormPresenter.regenerateImplementationModels(implementationReportViewModel); assertThat(implementationReportViewModels.size(), is(numberOfMalariaReportRows)); assertThat(implementationReportViewModels.get(2).getExistingStock6x1(), is(implementationReportViewModel.getExistingStock6x1() + apeImplementationReportViewModel.getExistingStock6x1())); assertThat(implementationReportViewModels.get(2).getCurrentTreatment6x3(), is(implementationReportViewModel.getCurrentTreatment6x3() + apeImplementationReportViewModel.getCurrentTreatment6x3())); }
public List<ImplementationReportViewModel> regenerateImplementationModels(ImplementationReportViewModel updatedViewModel) { int indexOfUpdatedModel = getIndexOfModel(updatedViewModel); viewModels.remove(indexOfUpdatedModel); viewModels.add(indexOfUpdatedModel, updatedViewModel); viewModels.remove(viewModels.size() - 1); viewModels.add(generateTotalViewModel(viewModels.get(0), viewModels.get(1))); return viewModels; }
MalariaDataReportFormPresenter extends BaseReportPresenter { public List<ImplementationReportViewModel> regenerateImplementationModels(ImplementationReportViewModel updatedViewModel) { int indexOfUpdatedModel = getIndexOfModel(updatedViewModel); viewModels.remove(indexOfUpdatedModel); viewModels.add(indexOfUpdatedModel, updatedViewModel); viewModels.remove(viewModels.size() - 1); viewModels.add(generateTotalViewModel(viewModels.get(0), viewModels.get(1))); return viewModels; } }
MalariaDataReportFormPresenter extends BaseReportPresenter { public List<ImplementationReportViewModel> regenerateImplementationModels(ImplementationReportViewModel updatedViewModel) { int indexOfUpdatedModel = getIndexOfModel(updatedViewModel); viewModels.remove(indexOfUpdatedModel); viewModels.add(indexOfUpdatedModel, updatedViewModel); viewModels.remove(viewModels.size() - 1); viewModels.add(generateTotalViewModel(viewModels.get(0), viewModels.get(1))); return viewModels; } MalariaDataReportFormPresenter(); }
MalariaDataReportFormPresenter extends BaseReportPresenter { public List<ImplementationReportViewModel> regenerateImplementationModels(ImplementationReportViewModel updatedViewModel) { int indexOfUpdatedModel = getIndexOfModel(updatedViewModel); viewModels.remove(indexOfUpdatedModel); viewModels.add(indexOfUpdatedModel, updatedViewModel); viewModels.remove(viewModels.size() - 1); viewModels.add(generateTotalViewModel(viewModels.get(0), viewModels.get(1))); return viewModels; } MalariaDataReportFormPresenter(); @Override void attachView(BaseView v); Observable<List<ImplementationReportViewModel>> getImplementationViewModelsForCurrentMalariaProgram(final Period period); MalariaProgram getMalariaProgram(); List<ImplementationReportViewModel> regenerateImplementationModels(ImplementationReportViewModel updatedViewModel); Observable<MalariaProgram> onSaveForm(final ViaReportStatus status, final String sign); @Override void deleteDraft(); @Override boolean isDraft(); boolean isSubmittedForApproval(); }
MalariaDataReportFormPresenter extends BaseReportPresenter { public List<ImplementationReportViewModel> regenerateImplementationModels(ImplementationReportViewModel updatedViewModel) { int indexOfUpdatedModel = getIndexOfModel(updatedViewModel); viewModels.remove(indexOfUpdatedModel); viewModels.add(indexOfUpdatedModel, updatedViewModel); viewModels.remove(viewModels.size() - 1); viewModels.add(generateTotalViewModel(viewModels.get(0), viewModels.get(1))); return viewModels; } MalariaDataReportFormPresenter(); @Override void attachView(BaseView v); Observable<List<ImplementationReportViewModel>> getImplementationViewModelsForCurrentMalariaProgram(final Period period); MalariaProgram getMalariaProgram(); List<ImplementationReportViewModel> regenerateImplementationModels(ImplementationReportViewModel updatedViewModel); Observable<MalariaProgram> onSaveForm(final ViaReportStatus status, final String sign); @Override void deleteDraft(); @Override boolean isDraft(); boolean isSubmittedForApproval(); static final int INVALID_INDEX; }