@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()); }
@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 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 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(); }
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); }
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);  }