@Test void testWithtZeroLengthSentence() throws RedPenException { Validator commaNumberValidator = ValidatorFactory.getInstance("CommaNumber"); String content = ""; Sentence str = new Sentence(content, 0); List<ValidationError> errors = new ArrayList<>(); commaNumberValidator.setErrorList(errors); commaNumberValidator.validate(str); assertNotNull(errors); assertEquals(0, errors.size()); }
@Override public void validate(Sentence sentence) { String content = sentence.getContent(); int commaCount = 0; int position = 0; while ((position = content.indexOf(this.comma)) != -1) { commaCount++; content = content.substring(position + 1, content.length()); } if (getMaxNum() < commaCount) { addLocalizedError(sentence, commaCount, getMaxNum()); } }
CommaNumberValidator extends Validator { @Override public void validate(Sentence sentence) { String content = sentence.getContent(); int commaCount = 0; int position = 0; while ((position = content.indexOf(this.comma)) != -1) { commaCount++; content = content.substring(position + 1, content.length()); } if (getMaxNum() < commaCount) { addLocalizedError(sentence, commaCount, getMaxNum()); } } }
CommaNumberValidator extends Validator { @Override public void validate(Sentence sentence) { String content = sentence.getContent(); int commaCount = 0; int position = 0; while ((position = content.indexOf(this.comma)) != -1) { commaCount++; content = content.substring(position + 1, content.length()); } if (getMaxNum() < commaCount) { addLocalizedError(sentence, commaCount, getMaxNum()); } } CommaNumberValidator(); }
CommaNumberValidator extends Validator { @Override public void validate(Sentence sentence) { String content = sentence.getContent(); int commaCount = 0; int position = 0; while ((position = content.indexOf(this.comma)) != -1) { commaCount++; content = content.substring(position + 1, content.length()); } if (getMaxNum() < commaCount) { addLocalizedError(sentence, commaCount, getMaxNum()); } } CommaNumberValidator(); @Override void validate(Sentence sentence); }
CommaNumberValidator extends Validator { @Override public void validate(Sentence sentence) { String content = sentence.getContent(); int commaCount = 0; int position = 0; while ((position = content.indexOf(this.comma)) != -1) { commaCount++; content = content.substring(position + 1, content.length()); } if (getMaxNum() < commaCount) { addLocalizedError(sentence, commaCount, getMaxNum()); } } CommaNumberValidator(); @Override void validate(Sentence sentence);  }