@Test public void givenListWithConstraints_shouldValidate() { Book book = new Book(); book.addChapterTitle("Chapter 1"); Set<ConstraintViolation<Book>> constraintViolations = validator.validate(book); assertThat(constraintViolations.size()).isEqualTo(0); }
public void addChapterTitle(String chapterTitle) { chapterTitles.add(chapterTitle); }
Book { public void addChapterTitle(String chapterTitle) { chapterTitles.add(chapterTitle); } }
Book { public void addChapterTitle(String chapterTitle) { chapterTitles.add(chapterTitle); }  }
Book { public void addChapterTitle(String chapterTitle) { chapterTitles.add(chapterTitle); }  List<String> getChapterTitles(); void addChapterTitle(String chapterTitle); Map<String, String> getAuthorChapter(); void addAuthorChapter(String author, String chapter); }
Book { public void addChapterTitle(String chapterTitle) { chapterTitles.add(chapterTitle); }  List<String> getChapterTitles(); void addChapterTitle(String chapterTitle); Map<String, String> getAuthorChapter(); void addAuthorChapter(String author, String chapter);  }