@Test
 public void highlight_syntax_with_html_from_component_on_given_lines() throws Exception {
   assertThat(
           sourceDecorator.getDecoratedSourceAsHtml(
               "org.apache.struts:struts:Dispatcher", null, 2))
       .hasSize(2);
   assertThat(
           sourceDecorator.getDecoratedSourceAsHtml(
               "org.apache.struts:struts:Dispatcher", 2, null))
       .hasSize(5);
   assertThat(
           sourceDecorator.getDecoratedSourceAsHtml("org.apache.struts:struts:Dispatcher", 1, 2))
       .hasSize(2);
 }
  @Test
  public void should_not_query_sources_if_no_snapshot_data() throws Exception {
    SnapshotSourceDao snapshotSourceDao = mock(SnapshotSourceDao.class);
    SnapshotDataDao snapshotDataDao = mock(SnapshotDataDao.class);

    HtmlSourceDecorator sourceDecorator =
        new HtmlSourceDecorator(mock(MyBatis.class), snapshotSourceDao, snapshotDataDao);

    sourceDecorator.getDecoratedSourceAsHtml(14L);

    verify(snapshotDataDao, times(1))
        .selectSnapshotData(14L, Lists.newArrayList("highlight_syntax", "symbol"));
    verify(snapshotSourceDao, times(0)).selectSnapshotSource(14L);
  }
  @Test
  public void should_not_query_sources_if_no_snapshot_data_from_component() throws Exception {
    SnapshotSourceDao snapshotSourceDao = mock(SnapshotSourceDao.class);
    SnapshotDataDao snapshotDataDao = mock(SnapshotDataDao.class);

    HtmlSourceDecorator sourceDecorator =
        new HtmlSourceDecorator(mock(MyBatis.class), snapshotSourceDao, snapshotDataDao);

    sourceDecorator.getDecoratedSourceAsHtml(
        "org.apache.struts:struts:DebuggingInterceptor", null, null);

    verify(snapshotDataDao, times(1))
        .selectSnapshotDataByComponentKey(
            eq("org.apache.struts:struts:DebuggingInterceptor"),
            eq(Lists.newArrayList("highlight_syntax", "symbol")),
            any(SqlSession.class));
    verify(snapshotSourceDao, times(0))
        .selectSnapshotSourceByComponentKey(
            eq("org.apache.struts:struts:DebuggingInterceptor"), any(SqlSession.class));
  }
  @Test
  public void mark_symbols_with_html() throws Exception {
    List<String> decoratedSource = sourceDecorator.getDecoratedSourceAsHtml(12L);

    assertThat(decoratedSource)
        .containsExactly(
            "/*",
            " * Header",
            " */",
            "",
            "public class <span class=\"sym-31 sym\">HelloWorld</span> {",
            "}");
  }
  @Test
  public void highlight_syntax_with_html() throws Exception {
    List<String> decoratedSource = sourceDecorator.getDecoratedSourceAsHtml(11L);

    assertThat(decoratedSource)
        .containsExactly(
            "<span class=\"cppd\">/*</span>",
            "<span class=\"cppd\"> * Header</span>",
            "<span class=\"cppd\"> */</span>",
            "",
            "<span class=\"k\">public </span><span class=\"k\">class </span>HelloWorld {",
            "}");
  }
  @Test
  public void highlight_syntax_with_html_from_component() throws Exception {
    List<String> decoratedSource =
        sourceDecorator.getDecoratedSourceAsHtml("org.apache.struts:struts:Dispatcher", null, null);

    assertThat(decoratedSource)
        .containsExactly(
            "<span class=\"cppd\">/*</span>",
            "<span class=\"cppd\"> * Header</span>",
            "<span class=\"cppd\"> */</span>",
            "",
            "<span class=\"k\">public </span><span class=\"k\">class </span>HelloWorld {",
            "}");
  }
  @Test
  public void mark_symbols_with_html_from_component() throws Exception {
    List<String> decoratedSource =
        sourceDecorator.getDecoratedSourceAsHtml(
            "org.apache.struts:struts:VelocityManager", null, null);

    assertThat(decoratedSource)
        .containsExactly(
            "/*",
            " * Header",
            " */",
            "",
            "public class <span class=\"sym-31 sym\">HelloWorld</span> {",
            "}");
  }
  @Test
  public void decorate_source_with_multiple_decoration_strategies() throws Exception {
    List<String> decoratedSource = sourceDecorator.getDecoratedSourceAsHtml(13L);

    assertThat(decoratedSource)
        .containsExactly(
            "<span class=\"cppd\">/*</span>",
            "<span class=\"cppd\"> * Header</span>",
            "<span class=\"cppd\"> */</span>",
            "",
            "<span class=\"k\">public </span><span class=\"k\">class </span><span class=\"sym-31 sym\">HelloWorld</span> {",
            "  <span class=\"k\">public</span> <span class=\"k\">void</span> <span class=\"sym-58 sym\">foo</span>() {",
            "  }",
            "  <span class=\"k\">public</span> <span class=\"k\">void</span> <span class=\"sym-84 sym\">bar</span>() {",
            "    <span class=\"sym-58 sym\">foo</span>();",
            "  }",
            "}");
  }
  @Test
  public void decorate_source_with_multiple_decoration_strategies_from_component()
      throws Exception {
    List<String> decoratedSource =
        sourceDecorator.getDecoratedSourceAsHtml(
            "org.apache.struts:struts:DebuggingInterceptor", null, null);

    assertThat(decoratedSource)
        .containsExactly(
            "<span class=\"cppd\">/*</span>",
            "<span class=\"cppd\"> * Header</span>",
            "<span class=\"cppd\"> */</span>",
            "",
            "<span class=\"k\">public </span><span class=\"k\">class </span><span class=\"sym-31 sym\">HelloWorld</span> {",
            "  <span class=\"k\">public</span> <span class=\"k\">void</span> <span class=\"sym-58 sym\">foo</span>() {",
            "  }",
            "  <span class=\"k\">public</span> <span class=\"k\">void</span> <span class=\"sym-84 sym\">bar</span>() {",
            "    <span class=\"sym-58 sym\">foo</span>();",
            "  }",
            "}");
  }