@Test void testConvertValidationErrorChangingErrorLevel() throws RedPenException { Configuration config = Configuration.builder() .addValidatorConfig(new ValidatorConfiguration("SentenceLength").setLevel(ValidatorConfiguration.LEVEL.INFO)).build(); Validator validator = ValidatorFactory.getInstance(config.getValidatorConfigs().get(0), config); Sentence sentence = new Sentence("This is a long long long long long long long long long long long long" + " long long long long long long long long long long long long long long long long long long long long sentence", 0); List<ValidationError> errors = new ArrayList<>(); validator.setErrorList(errors); validator.validate(sentence); Document document = new cc.redpen.model.Document.DocumentBuilder(new WhiteSpaceTokenizer()).build(); List<ValidationError> validationErrors = Arrays.asList(errors.get(0)); String resultString = formatter.format(document, validationErrors); assertTrue(resultString.indexOf("ValidationInfo[SentenceLength]") > 0 ); }
@Override public void format(PrintWriter pw, Map<Document, List<ValidationError>> docErrorsMap) throws RedPenException, IOException { BufferedWriter writer = new BufferedWriter(new PrintWriter(pw)); for (Document document : docErrorsMap.keySet()) { List<ValidationError> errors = docErrorsMap.get(document); for (ValidationError error : errors) { writer.write(formatError(document, error)); } } try { writer.flush(); } catch (IOException e) { LOG.error("failed to flush", e); } }
PlainFormatter extends Formatter { @Override public void format(PrintWriter pw, Map<Document, List<ValidationError>> docErrorsMap) throws RedPenException, IOException { BufferedWriter writer = new BufferedWriter(new PrintWriter(pw)); for (Document document : docErrorsMap.keySet()) { List<ValidationError> errors = docErrorsMap.get(document); for (ValidationError error : errors) { writer.write(formatError(document, error)); } } try { writer.flush(); } catch (IOException e) { LOG.error("failed to flush", e); } } }
PlainFormatter extends Formatter { @Override public void format(PrintWriter pw, Map<Document, List<ValidationError>> docErrorsMap) throws RedPenException, IOException { BufferedWriter writer = new BufferedWriter(new PrintWriter(pw)); for (Document document : docErrorsMap.keySet()) { List<ValidationError> errors = docErrorsMap.get(document); for (ValidationError error : errors) { writer.write(formatError(document, error)); } } try { writer.flush(); } catch (IOException e) { LOG.error("failed to flush", e); } }  }
PlainFormatter extends Formatter { @Override public void format(PrintWriter pw, Map<Document, List<ValidationError>> docErrorsMap) throws RedPenException, IOException { BufferedWriter writer = new BufferedWriter(new PrintWriter(pw)); for (Document document : docErrorsMap.keySet()) { List<ValidationError> errors = docErrorsMap.get(document); for (ValidationError error : errors) { writer.write(formatError(document, error)); } } try { writer.flush(); } catch (IOException e) { LOG.error("failed to flush", e); } }  @Override void format(PrintWriter pw, Map<Document, List<ValidationError>> docErrorsMap); @Override String formatError(Document document, ValidationError error); }
PlainFormatter extends Formatter { @Override public void format(PrintWriter pw, Map<Document, List<ValidationError>> docErrorsMap) throws RedPenException, IOException { BufferedWriter writer = new BufferedWriter(new PrintWriter(pw)); for (Document document : docErrorsMap.keySet()) { List<ValidationError> errors = docErrorsMap.get(document); for (ValidationError error : errors) { writer.write(formatError(document, error)); } } try { writer.flush(); } catch (IOException e) { LOG.error("failed to flush", e); } }  @Override void format(PrintWriter pw, Map<Document, List<ValidationError>> docErrorsMap); @Override String formatError(Document document, ValidationError error);  }