@Test void shouldCreateSourceWithoutLineNumber() { SourcePrinter printer = new SourcePrinter(); IssueBuilder builder = new IssueBuilder(); Issue issue = builder.build(); Document document = Jsoup.parse(printer.render(asStream("format-java.txt"), issue, NO_DESCRIPTION, ICON_URL)); String expectedFile = toString("format-java.txt"); assertThat(document.text()).isEqualToIgnoringWhitespace(expectedFile); Elements pre = document.getElementsByTag("pre"); assertThat(pre.text()).isEqualToIgnoringWhitespace(expectedFile); }
public String render(final Stream<String> lines, final Issue issue, final String description, final String iconUrl) { try (LookaheadStream stream = new LookaheadStream(lines)) { int start = issue.getLineStart(); int end = issue.getLineEnd(); StringBuilder before = readBlockUntilLine(stream, start - 1); StringBuilder marked = readBlockUntilLine(stream, end); StringBuilder after = readBlockUntilLine(stream, Integer.MAX_VALUE); String language = selectLanguageClass(issue); String code = asCode(before, language, "line-numbers") + asCode(marked, language, "highlight") + createInfoPanel(issue, description, iconUrl) + asCode(after, language); return pre().with(new UnescapedText(code)).renderFormatted(); } }
SourcePrinter { public String render(final Stream<String> lines, final Issue issue, final String description, final String iconUrl) { try (LookaheadStream stream = new LookaheadStream(lines)) { int start = issue.getLineStart(); int end = issue.getLineEnd(); StringBuilder before = readBlockUntilLine(stream, start - 1); StringBuilder marked = readBlockUntilLine(stream, end); StringBuilder after = readBlockUntilLine(stream, Integer.MAX_VALUE); String language = selectLanguageClass(issue); String code = asCode(before, language, "line-numbers") + asCode(marked, language, "highlight") + createInfoPanel(issue, description, iconUrl) + asCode(after, language); return pre().with(new UnescapedText(code)).renderFormatted(); } } }
SourcePrinter { public String render(final Stream<String> lines, final Issue issue, final String description, final String iconUrl) { try (LookaheadStream stream = new LookaheadStream(lines)) { int start = issue.getLineStart(); int end = issue.getLineEnd(); StringBuilder before = readBlockUntilLine(stream, start - 1); StringBuilder marked = readBlockUntilLine(stream, end); StringBuilder after = readBlockUntilLine(stream, Integer.MAX_VALUE); String language = selectLanguageClass(issue); String code = asCode(before, language, "line-numbers") + asCode(marked, language, "highlight") + createInfoPanel(issue, description, iconUrl) + asCode(after, language); return pre().with(new UnescapedText(code)).renderFormatted(); } } SourcePrinter(); @VisibleForTesting  SourcePrinter(final JenkinsFacade jenkinsFacade); }
SourcePrinter { public String render(final Stream<String> lines, final Issue issue, final String description, final String iconUrl) { try (LookaheadStream stream = new LookaheadStream(lines)) { int start = issue.getLineStart(); int end = issue.getLineEnd(); StringBuilder before = readBlockUntilLine(stream, start - 1); StringBuilder marked = readBlockUntilLine(stream, end); StringBuilder after = readBlockUntilLine(stream, Integer.MAX_VALUE); String language = selectLanguageClass(issue); String code = asCode(before, language, "line-numbers") + asCode(marked, language, "highlight") + createInfoPanel(issue, description, iconUrl) + asCode(after, language); return pre().with(new UnescapedText(code)).renderFormatted(); } } SourcePrinter(); @VisibleForTesting  SourcePrinter(final JenkinsFacade jenkinsFacade); String render(final Stream<String> lines, final Issue issue, final String description,
            final String iconUrl); }
SourcePrinter { public String render(final Stream<String> lines, final Issue issue, final String description, final String iconUrl) { try (LookaheadStream stream = new LookaheadStream(lines)) { int start = issue.getLineStart(); int end = issue.getLineEnd(); StringBuilder before = readBlockUntilLine(stream, start - 1); StringBuilder marked = readBlockUntilLine(stream, end); StringBuilder after = readBlockUntilLine(stream, Integer.MAX_VALUE); String language = selectLanguageClass(issue); String code = asCode(before, language, "line-numbers") + asCode(marked, language, "highlight") + createInfoPanel(issue, description, iconUrl) + asCode(after, language); return pre().with(new UnescapedText(code)).renderFormatted(); } } SourcePrinter(); @VisibleForTesting  SourcePrinter(final JenkinsFacade jenkinsFacade); String render(final Stream<String> lines, final Issue issue, final String description,
            final String iconUrl);  }