@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") ); }
@Override public String perform() throws BusinessException { if (!this.errors.isEmpty()) { throw this.errors.pop(); } return this.customerId; }
FindCustomer implements BusinessOperation<String> { @Override public String perform() throws BusinessException { if (!this.errors.isEmpty()) { throw this.errors.pop(); } return this.customerId; } }
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); }
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(); }
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();  }