CustomerValidator { public void validate(Customer customer) { if (StringUtils.isBlank(customer.getName())) { throw new IllegalArgumentException("Missing customer name"); } validateAddress(customer.getAddress()); }  void validate(Customer customer);  }
@Test public void validCustomer_ok() { validator.validate(aValidCustomer().build()); }
@Test(expected = IllegalArgumentException.class) public void customerWithoutName_fails() { validator.validate(aValidCustomer().withName(null).build()); }
@Test(expected = IllegalArgumentException.class) public void customerWithoutAddress_fails() { validator.validate(aValidCustomer().withAddress((Address)null).build()); }
@Test public void customerWithoutAddressCity_fails() { expectedException.expectMessage("address city"); validator.validate(aValidCustomer().withAddress(aValidAddress().withCity("")).build()); }