@Test void testConvertValidationErrorWithoutFileName() { List<ValidationError> errors = new ArrayList<>(); setErrorList(errors); addLocalizedError(new Sentence("This is a sentence", 0)); 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); assertEquals("0: ValidationError[PlainFormatterTest], plain test error at line: This is a sentence\n", resultString); }
@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);  }