Example #1
0
  /** Gets {@linkplain #getComment() the comment} fully marked up by {@link ChangeLogAnnotator}. */
  public String getCommentAnnotated() {
    MarkupText markup = new MarkupText(getComment());
    for (ChangeLogAnnotator a : ChangeLogAnnotator.all())
      a.annotate(getParent().build, this, markup);

    return markup.toString(false);
  }
 /** Mark up of URL should consider surrounding markers, if any. */
 public void test2() throws Exception {
   MarkupText m = new MarkupText("{abc='http://url/',def='ghi'}");
   new UrlAnnotator().newInstance(null).annotate(null, m);
   String html = m.toString(false);
   assertTrue(html.contains("<a href='http://url/'>http://url/</a>"));
   System.out.println(html);
 }
 @SuppressWarnings("unchecked")
 private String annotate(String text, ConsoleNote... notes) {
   Object context = new Object();
   MarkupText markupText = new MarkupText(text);
   for (ConsoleNote note : notes) {
     note.annotate(context, markupText, 0);
   }
   return markupText.toString(true);
 }
  @Test
  public void testNoWikiLinkToAnnotate() {
    AbstractBuild build = mock(AbstractBuild.class);
    AbstractProject<?, ?> project = mock(AbstractProject.class);
    when(project.getProperty(CodePlexProjectProperty.class))
        .thenReturn(new CodePlexProjectProperty("theproject"));
    when(build.getProject()).thenReturn(project);

    CodePlexChangeLogAnnotator annotator = new CodePlexChangeLogAnnotator();
    MarkupText markupText = new MarkupText("Ordinary commit message without wiki link.");
    annotator.annotate(build, null, markupText);
    assertEquals("Ordinary commit message without wiki link.", markupText.toString());
  }
  @Test
  public void assertWorkItemInBracketsIsAnnotated() {
    AbstractBuild build = mock(AbstractBuild.class);
    AbstractProject<?, ?> project = mock(AbstractProject.class);
    when(project.getProperty(CodePlexProjectProperty.class))
        .thenReturn(new CodePlexProjectProperty("theproject"));
    when(build.getProject()).thenReturn(project);

    CodePlexChangeLogAnnotator annotator = new CodePlexChangeLogAnnotator();
    MarkupText markupText = new MarkupText("Message with [workitem: 12]. Yes a link.");
    annotator.annotate(build, null, markupText);
    assertEquals(
        "Message with <a href='http://www.codeplex.com/theproject/WorkItem/View.aspx?WorkItemId=12'>[workitem: 12]</a>. Yes a link.",
        markupText.toString());
  }
  @Test
  public void assertWikiKeyWordIsAnnotated() {
    AbstractBuild build = mock(AbstractBuild.class);
    AbstractProject<?, ?> project = mock(AbstractProject.class);
    when(project.getProperty(CodePlexProjectProperty.class))
        .thenReturn(new CodePlexProjectProperty("theproject"));
    when(build.getProject()).thenReturn(project);

    CodePlexChangeLogAnnotator annotator = new CodePlexChangeLogAnnotator();
    MarkupText markupText = new MarkupText("Message with wiki:WikiLink. Yes a link.");
    annotator.annotate(build, null, markupText);
    assertEquals(
        "Message with <a href='http://www.codeplex.com/theproject/Wiki/View.aspx?title=WikiLink'>wiki:WikiLink</a>. Yes a link.",
        markupText.toString());
  }
Example #7
0
    /** Gets the text fully marked up by {@link ChangeLogAnnotator}. */
    public String getMsgAnnotated() {
      MarkupText markup = new MarkupText(getMsgEscaped());
      for (ChangeLogAnnotator a : ChangeLogAnnotator.all()) a.annotate(parent.build, this, markup);

      return markup.toString();
    }