### Question:
Customer { public void setEmail(String email) { this.email = email; }  String getFirstName(); void setFirstName(String firstName); String getSecondName(); void setSecondName(String secondName); String getEmail(); void setEmail(String email);  }### Answer:
@Test public void givenBeanWithValidEmailConstraints_shouldValidate() { Customer customer = new Customer(); customer.setEmail("alex.theedom@example.com"); Set<ConstraintViolation<Customer>> constraintViolations = validator.validate(customer); assertThat(constraintViolations.size()).isEqualTo(0); }
@Test public void givenBeanWithInvalidEmailConstraints_shouldNotValidate() { Customer customer = new Customer(); customer.setEmail("alex.theedom@example.co.uk"); Set<ConstraintViolation<Customer>> constraintViolations = validator.validate(customer); assertThat(constraintViolations.size()).isEqualTo(1); }