コード例 #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);
  }
コード例 #3
0
  @Test(expected = BillNotFoundException.class)
  public void load_empty_bill_throws_not_found_exception() {
    when(repository.find(UUID)).thenReturn(null);

    presenter.loadBill(UUID);
  }
コード例 #4
0
 @Before
 public void setUp() throws Exception {
   initMocks(this);
   presenter = new BillPresenter(repository);
   presenter.attachView(view);
 }