@Test void testChangeLimit() throws RedPenException { Document document = Document.builder() .addSection(4) .addSectionHeader("Abstract") .addParagraph() .build(); Configuration config = Configuration.builder() .addValidatorConfig(new ValidatorConfiguration("EmptySection").addProperty("limit", "3")) .build(); Validator validator = ValidatorFactory.getInstance(config.getValidatorConfigs().get(0), config); List<ValidationError> errors = new ArrayList<>(); validator.setErrorList(errors); validator.validate(document.getSection(0)); assertEquals(0, errors.size()); }
@Override public void validate(Section section) { if (0 == section.getLevel() || section.getLevel() >= sectionLevelLimit) { return; } Sentence header = section.getJoinedHeaderContents(); if (section.getNumberOfParagraphs() == 0) { addLocalizedError(header, header.getContent()); } else { for (Paragraph p : section.getParagraphs()) { if (p.getNumberOfSentences() == 0) { addLocalizedError(header, header.getContent()); break; } } } }
EmptySectionValidator extends Validator { @Override public void validate(Section section) { if (0 == section.getLevel() || section.getLevel() >= sectionLevelLimit) { return; } Sentence header = section.getJoinedHeaderContents(); if (section.getNumberOfParagraphs() == 0) { addLocalizedError(header, header.getContent()); } else { for (Paragraph p : section.getParagraphs()) { if (p.getNumberOfSentences() == 0) { addLocalizedError(header, header.getContent()); break; } } } } }
EmptySectionValidator extends Validator { @Override public void validate(Section section) { if (0 == section.getLevel() || section.getLevel() >= sectionLevelLimit) { return; } Sentence header = section.getJoinedHeaderContents(); if (section.getNumberOfParagraphs() == 0) { addLocalizedError(header, header.getContent()); } else { for (Paragraph p : section.getParagraphs()) { if (p.getNumberOfSentences() == 0) { addLocalizedError(header, header.getContent()); break; } } } }  }
EmptySectionValidator extends Validator { @Override public void validate(Section section) { if (0 == section.getLevel() || section.getLevel() >= sectionLevelLimit) { return; } Sentence header = section.getJoinedHeaderContents(); if (section.getNumberOfParagraphs() == 0) { addLocalizedError(header, header.getContent()); } else { for (Paragraph p : section.getParagraphs()) { if (p.getNumberOfSentences() == 0) { addLocalizedError(header, header.getContent()); break; } } } }  @Override void validate(Section section); }
EmptySectionValidator extends Validator { @Override public void validate(Section section) { if (0 == section.getLevel() || section.getLevel() >= sectionLevelLimit) { return; } Sentence header = section.getJoinedHeaderContents(); if (section.getNumberOfParagraphs() == 0) { addLocalizedError(header, header.getContent()); } else { for (Paragraph p : section.getParagraphs()) { if (p.getNumberOfSentences() == 0) { addLocalizedError(header, header.getContent()); break; } } } }  @Override void validate(Section section);  }