### Question:
SectionLengthValidator extends Validator { @Override public void validate(Section section) { int sectionCharNumber = 0; for (Paragraph currentParagraph : section.getParagraphs()) { for (Sentence sentence : currentParagraph.getSentences()) { sectionCharNumber += sentence.getContent().length(); } } if (sectionCharNumber > getInt("max_num")) { addLocalizedError(section.getJoinedHeaderContents(), sectionCharNumber, getInt("max_num")); } } SectionLengthValidator(); @Override void validate(Section section);  }### Answer:
@Test void testSectionLength() { Section section = new Section(0, "header"); Paragraph paragraph = new Paragraph(); paragraph.appendSentence("it like a piece of a cake.", 0); section.appendParagraph(paragraph); List<ValidationError> errors = new ArrayList<>(); validator.setErrorList(errors); validator.validate(section); assertEquals(1, errors.size()); }
@Test void testWithSectionWithoutHeader() { Section section = new Section(0); Paragraph paragraph = new Paragraph(); paragraph.appendSentence("it like a piece of a cake.", 0); section.appendParagraph(paragraph); List<ValidationError> errors = new ArrayList<>(); validator.setErrorList(errors); validator.validate(section); assertEquals(1, errors.size()); }