### Question:
RepeatedConstraint { public void setText(String text) { this.text = text; }  String getText(); void setText(String text);  }### Answer:
@Test public void givenBeanWithValidDomain_shouldValidate() { RepeatedConstraint repeatedConstraint = new RepeatedConstraint(); repeatedConstraint.setText("www.readlearncode.com"); Set<ConstraintViolation<RepeatedConstraint>> constraintViolations = validator.validate(repeatedConstraint); assertThat(constraintViolations.size()).isEqualTo(0); }
@Test public void givenBeanWithInValidDomain_shouldNotValidate() { RepeatedConstraint repeatedConstraint = new RepeatedConstraint(); repeatedConstraint.setText("www.readlearncode.net"); Set<ConstraintViolation<RepeatedConstraint>> constraintViolations = validator.validate(repeatedConstraint); assertThat(constraintViolations.size()).isEqualTo(1); }