@Test public void givenBeanWithOptionalStringExample_shouldNotValidate() { OptionalExample optionalExample = new OptionalExample(); optionalExample.setText(" "); Set<ConstraintViolation<OptionalExample>> constraintViolations = validator.validate(optionalExample); assertThat(constraintViolations.size()).isEqualTo(2); }
public void setText(String text) { this.text = Optional.of(text); }
OptionalExample { public void setText(String text) { this.text = Optional.of(text); } }
OptionalExample { public void setText(String text) { this.text = Optional.of(text); }  }
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); }
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);  }