コード例 #1
0
  @Test
  public void save_gets_data_from_screen_and_save_to_repository() {
    when(view.fillBill(any(Bill.class))).thenReturn(new Bill());
    when(repository.save(any(Bill.class))).thenReturn(new OperationResult());

    presenter.save();

    verify(view, times(1)).fillBill(any(Bill.class));
    verify(repository, times(1)).save(any(Bill.class));
    verify(view, times(1)).finishView();
  }
コード例 #2
0
  @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);
  }