### Question:
Person { public void setCars(List<String> cars) { this.cars = cars; }  String getFirstName(); void setFirstName(String firstName); String getSecondName(); void setSecondName(String secondName); String getEmail(); void setEmail(String email); List<String> getCars(); void setCars(List<String> cars);  }### Answer:
@Test public void givenBeanWithEmptyElementInCollection_shouldValidate() { Person person = new Person(); person.setCars(new ArrayList<String>() { { add(null); } }); Set<ConstraintViolation<Person>> constraintViolations = validator.validateProperty(person, "cars"); assertThat(constraintViolations.size()).isEqualTo(1); }
@Test public void givenBeanWithEmptyElementInCollection_shouldNotValidate() { Person person = new Person(); person.setCars(new ArrayList<String>() { { add(null); } }); Set<ConstraintViolation<Person>> constraintViolations = validator.validateProperty(person, "cars"); assertThat(constraintViolations.size()).isEqualTo(1); }