@Test void testInvalid() { Document document = Document.builder() .addSection(1) .addSectionHeader("Chapter 1") .addSection(3) .addSectionHeader("Section 1.1.1") .build(); List<ValidationError> errors = new ArrayList<>(); validator.setErrorList(errors); validator.validate(document); assertEquals(1, errors.size()); }
@Override public void validate(Document document) { int seen = 0; for (Section s: document) { final int current = s.getLevel(); if (seen > 0) { if (current <= seen) { seen = current; } else { if (current == seen + 1) { seen = current; } else { addLocalizedError(s.getJoinedHeaderContents(), s.getJoinedHeaderContents().getContent(), current, seen + 1); } } } else { seen = current; } } }
GappedSectionValidator extends Validator { @Override public void validate(Document document) { int seen = 0; for (Section s: document) { final int current = s.getLevel(); if (seen > 0) { if (current <= seen) { seen = current; } else { if (current == seen + 1) { seen = current; } else { addLocalizedError(s.getJoinedHeaderContents(), s.getJoinedHeaderContents().getContent(), current, seen + 1); } } } else { seen = current; } } } }
GappedSectionValidator extends Validator { @Override public void validate(Document document) { int seen = 0; for (Section s: document) { final int current = s.getLevel(); if (seen > 0) { if (current <= seen) { seen = current; } else { if (current == seen + 1) { seen = current; } else { addLocalizedError(s.getJoinedHeaderContents(), s.getJoinedHeaderContents().getContent(), current, seen + 1); } } } else { seen = current; } } }  }
GappedSectionValidator extends Validator { @Override public void validate(Document document) { int seen = 0; for (Section s: document) { final int current = s.getLevel(); if (seen > 0) { if (current <= seen) { seen = current; } else { if (current == seen + 1) { seen = current; } else { addLocalizedError(s.getJoinedHeaderContents(), s.getJoinedHeaderContents().getContent(), current, seen + 1); } } } else { seen = current; } } }  @Override void validate(Document document); }
GappedSectionValidator extends Validator { @Override public void validate(Document document) { int seen = 0; for (Section s: document) { final int current = s.getLevel(); if (seen > 0) { if (current <= seen) { seen = current; } else { if (current == seen + 1) { seen = current; } else { addLocalizedError(s.getJoinedHeaderContents(), s.getJoinedHeaderContents().getContent(), current, seen + 1); } } } else { seen = current; } } }  @Override void validate(Document document);  }