FileNameRenderer { public String renderAffectedFileLink(final Issue issue) { return createAffectedFileLink(issue).render(); } FileNameRenderer(final Run<?, ?> build); @VisibleForTesting  FileNameRenderer(final Run<?, ?> build, final BuildFolderFacade facade); String renderAffectedFileLink(final Issue issue); DomContent createAffectedFileLink(final Issue issue); DomContent createAffectedFileLink(final Issue issue, final String prefix); String getSourceCodeUrl(final Issue issue); String getFileNameAtLine(final Issue issue); String getFileName(final Issue issue);  }
@Test void shouldCreateFileNameAsLink() { FileNameRenderer renderer = createRenderer(true); Issue issue = new IssueBuilder().setFileName("/path/to/affected/file.txt").setLineStart(20).build(); assertThat(renderer.renderAffectedFileLink(issue)).matches("<a href=\"source\\.[0-9a-f-]+/#20\" data-toggle=\"tooltip\" data-placement=\"bottom\" title=\"/path/to/affected/file.txt\">file.txt:20</a>"); assertThat(renderer.renderAffectedFileLink(issue)).contains(issue.getId().toString()); }
@Test void shouldCreateLinkToConsoleLog() { FileNameRenderer renderer = createRenderer(false); Issue issue = new IssueBuilder().setFileName(ConsoleLogHandler.JENKINS_CONSOLE_LOG_FILE_NAME_ID).setLineStart(20).build(); assertThat(renderer.renderAffectedFileLink(issue)).matches("<a href=\"source\\.[0-9a-f-]+/#20\">Console Output:20</a>"); assertThat(renderer.renderAffectedFileLink(issue)).contains(issue.getId().toString()); }