### Question:
OptionalExample { public void setText(String text) { this.text = Optional.of(text); }  Optional<String> getName(); void setName(String name); Optional<String> getText(); void setText(String text);  }### Answer:
@Test public void givenBeanWithOptionalStringExample_shouldNotValidate() { OptionalExample optionalExample = new OptionalExample(); optionalExample.setText(" "); Set<ConstraintViolation<OptionalExample>> constraintViolations = validator.validate(optionalExample); assertThat(constraintViolations.size()).isEqualTo(2); }