### Question:
FindCustomer implements BusinessOperation<String> { @Override public String perform() throws BusinessException { if (!this.errors.isEmpty()) { throw this.errors.pop(); } return this.customerId; } FindCustomer(String customerId, BusinessException... errors); @Override String perform();  }### Answer:
@Test public void oneException() { assertThrows(BusinessException.class, () -> { new FindCustomer("123", new BusinessException("test")).perform(); }); }
@Test public void noExceptions() throws Exception { assertThat(new FindCustomer("123").perform(), is("123")); }
@Test public void resultAfterExceptions() throws Exception { final var op = new FindCustomer( "123", new CustomerNotFoundException("not found"), new DatabaseNotAvailableException("not available") ); try { op.perform(); } catch (CustomerNotFoundException e) { } try { op.perform(); } catch (DatabaseNotAvailableException e) { } assertThat(op.perform(), is("123")); }
@Test public void noExceptions() throws Exception { assertThat( new FindCustomer("123").perform(), is("123") ); }
@Test public void oneException() throws Exception { assertThrows(BusinessException.class, () -> { new FindCustomer("123", new BusinessException("test")).perform(); }); }
@Test public void resultAfterExceptions() throws Exception { final BusinessOperation<String> op = new FindCustomer( "123", new CustomerNotFoundException("not found"), new DatabaseNotAvailableException("not available") ); try { op.perform(); } catch (CustomerNotFoundException e) { } try { op.perform(); } catch (DatabaseNotAvailableException e) { } assertThat( op.perform(), is("123") ); }