ConsoleDetail implements ModelObject { @SuppressWarnings("unused") public String getSourceCode() { return sourceCode; } ConsoleDetail(final Run<?, ?> owner, final Stream<String> consoleLog, final int from, final int to); @Override String getDisplayName(); @SuppressWarnings("unused") // Called by jelly view to show the side panel Run<?, ?> getOwner(); @SuppressWarnings("unused") // Called by jelly view String getSourceCode();  }
@Test void shouldShowLinesOfConsoleLogStartAt10() { ConsoleDetail consoleDetail = new ConsoleDetail(mock(Run.class), createLines(1, 30), 11, 11); assertThat(consoleDetail.getSourceCode()).contains("<td >1</td>"); assertThat(consoleDetail.getSourceCode()).contains("<td >10</td>"); assertThat(consoleDetail.getSourceCode()).contains("#FCAF3E\">11</td>"); assertThat(consoleDetail.getSourceCode()).contains("<td >12</td>"); assertThat(consoleDetail.getSourceCode()).contains("<td >21</td>"); assertThat(consoleDetail.getSourceCode()).doesNotContain("<td >22</td>"); }
@Test void shouldShowLinesOfConsoleEndAtHighlighting() { ConsoleDetail consoleDetail = new ConsoleDetail(mock(Run.class), createLines(1, 10), 5, 10); assertThat(consoleDetail.getSourceCode()).contains("<td >1</td>"); assertThat(consoleDetail.getSourceCode()).contains("<td >4</td>"); assertThat(consoleDetail.getSourceCode()).contains("#FCAF3E\">5</td>"); assertThat(consoleDetail.getSourceCode()).contains("#FCAF3E\">10</td>"); assertThat(consoleDetail.getSourceCode()).doesNotContain("<td >11</td>"); }
@Test void shouldEscapeEntities() { try (Stream<String> lines = Stream.of("<b>CheckStyle</b> <script>execute</script>")) { ConsoleDetail consoleDetail = new ConsoleDetail(mock(Run.class), lines, 1, 2); assertThat(consoleDetail.getSourceCode()) .doesNotContain("<b>CheckStyle</b> <script>execute</script>") .contains("&lt;b&gt;CheckStyle&lt;/b&gt; &lt;script&gt;execute&lt;"); } }
@Test void shouldShowLinesOfConsoleLogStartAtBeginning() { ConsoleDetail consoleDetail = new ConsoleDetail(mock(Run.class), createLines(1, 20), 1, 2); assertThat(consoleDetail.getSourceCode()).contains("#FCAF3E\">1</td>"); assertThat(consoleDetail.getSourceCode()).contains("#FCAF3E\">2</td>"); assertThat(consoleDetail.getSourceCode()).contains("<td >3</td>"); assertThat(consoleDetail.getSourceCode()).contains("<td >12</td>"); assertThat(consoleDetail.getSourceCode()).doesNotContain("<td >13</td>"); }