@Test void testConvertValidationErrorWithoutFileName() throws RedPenException { List<ValidationError> errors = new ArrayList<>(); setErrorList(errors); addLocalizedError(new Sentence("text", 0)); XMLFormatter formatter = new XMLFormatter(); List<ValidationError> validationErrors = Arrays.asList(errors.get(0)); String resultString = formatter.format(new cc.redpen.model.Document.DocumentBuilder(new WhiteSpaceTokenizer()).build(), validationErrors); Document document = extractDocument(resultString); assertEquals(1, document.getElementsByTagName("error").getLength()); assertEquals(1, document.getElementsByTagName("message").getLength()); assertEquals("Fatal Error", document.getElementsByTagName("message").item(0).getTextContent()); assertEquals(0, document.getElementsByTagName("file").getLength()); assertEquals(1, document.getElementsByTagName("lineNum").getLength()); assertEquals(1, document.getElementsByTagName("level").getLength()); assertEquals(1, document.getElementsByTagName("validator").getLength()); assertEquals("Error", document.getElementsByTagName("level").item(0).getTextContent()); assertEquals("0", document.getElementsByTagName("lineNum").item(0).getTextContent()); assertEquals(this.getClass().getSimpleName(), document.getElementsByTagName("validator").item(0).getTextContent()); }
@Override public void format(PrintWriter pw, Map<cc.redpen.model.Document, List<ValidationError>> docErrorsMap) throws RedPenException, IOException { BufferedWriter writer = new BufferedWriter(new PrintWriter(pw)); writer.write("<validation-result>\n"); for (cc.redpen.model.Document document : docErrorsMap.keySet()) { List<ValidationError> errors = docErrorsMap.get(document); for (ValidationError error : errors) { writer.write(formatError(document, error)); } } writer.write("</validation-result>"); writer.flush(); }
XMLFormatter extends Formatter { @Override public void format(PrintWriter pw, Map<cc.redpen.model.Document, List<ValidationError>> docErrorsMap) throws RedPenException, IOException { BufferedWriter writer = new BufferedWriter(new PrintWriter(pw)); writer.write("<validation-result>\n"); for (cc.redpen.model.Document document : docErrorsMap.keySet()) { List<ValidationError> errors = docErrorsMap.get(document); for (ValidationError error : errors) { writer.write(formatError(document, error)); } } writer.write("</validation-result>"); writer.flush(); } }
XMLFormatter extends Formatter { @Override public void format(PrintWriter pw, Map<cc.redpen.model.Document, List<ValidationError>> docErrorsMap) throws RedPenException, IOException { BufferedWriter writer = new BufferedWriter(new PrintWriter(pw)); writer.write("<validation-result>\n"); for (cc.redpen.model.Document document : docErrorsMap.keySet()) { List<ValidationError> errors = docErrorsMap.get(document); for (ValidationError error : errors) { writer.write(formatError(document, error)); } } writer.write("</validation-result>"); writer.flush(); } XMLFormatter(); }
XMLFormatter extends Formatter { @Override public void format(PrintWriter pw, Map<cc.redpen.model.Document, List<ValidationError>> docErrorsMap) throws RedPenException, IOException { BufferedWriter writer = new BufferedWriter(new PrintWriter(pw)); writer.write("<validation-result>\n"); for (cc.redpen.model.Document document : docErrorsMap.keySet()) { List<ValidationError> errors = docErrorsMap.get(document); for (ValidationError error : errors) { writer.write(formatError(document, error)); } } writer.write("</validation-result>"); writer.flush(); } XMLFormatter(); @Override void format(PrintWriter pw, Map<cc.redpen.model.Document, List<ValidationError>> docErrorsMap); @Override String formatError(cc.redpen.model.Document document, ValidationError error); }
XMLFormatter extends Formatter { @Override public void format(PrintWriter pw, Map<cc.redpen.model.Document, List<ValidationError>> docErrorsMap) throws RedPenException, IOException { BufferedWriter writer = new BufferedWriter(new PrintWriter(pw)); writer.write("<validation-result>\n"); for (cc.redpen.model.Document document : docErrorsMap.keySet()) { List<ValidationError> errors = docErrorsMap.get(document); for (ValidationError error : errors) { writer.write(formatError(document, error)); } } writer.write("</validation-result>"); writer.flush(); } XMLFormatter(); @Override void format(PrintWriter pw, Map<cc.redpen.model.Document, List<ValidationError>> docErrorsMap); @Override String formatError(cc.redpen.model.Document document, ValidationError error);  }