@Test public void call_view_with_errors() { OperationResult result = new OperationResult(); result.addError(ValidationError.NAME); when(view.fillBill(any(Bill.class))).thenReturn(new Bill()); when(repository.save(any(Bill.class))).thenReturn(result); presenter.save(); verify(view, times(1)).showError(ValidationError.NAME); }
void save() { checkEditViewSet(); if (bill == null) bill = new Bill(); bill = editView.fillBill(bill); bill.setInitDate(initDate); bill.setEndDate(endDate); OperationResult result = repository.save(bill); if (result.isValid()) { editView.finishView(); } else { for (ValidationError validationError : result.getErrors()) editView.showError(validationError); } }