Ejemplo n.º 1
0
 /** 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);
 }
Ejemplo n.º 2
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);
  }
Ejemplo n.º 3
0
 @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());
  }
 /**
  * Format the given time-stamp and add it to the mark-up text.
  *
  * @param text the mark-up text
  * @param timestamp the time-stamp to format
  */
 public void markup(MarkupText text, Timestamp timestamp) {
   String timestampString = formatTimestamp.apply(timestamp);
   // Wrap the time-stamp in a span element, which is used to detect the
   // time-stamp when inspecting the page with Javascript.
   String markup = "<span class=\"timestamp\">" + timestampString + "</span>";
   // Add as end tag, which will be inserted prior to tags added by other
   // console notes (e.g. AntTargetNote).
   text.addMarkup(0, 0, "", markup);
 }
 @Override
 public ConsoleAnnotator annotate(Object context, MarkupText text, int charPos) {
   if (text.getText().contains("ERROR"))
     text.addMarkup(0, text.length(), "<span style=\"font-weight: bold; color:red\">", "</span>");
   if (text.getText().contains("INFO"))
     text.addMarkup(0, text.length(), "<span style=\"color:#993300\">", "</span>");
   return null;
 }
Ejemplo n.º 9
0
 @Override
 public ConsoleAnnotator annotate(Object context, MarkupText text, int charPos) {
   text.addMarkup(0, text.length(), "<span class=error-inline>", "</span>");
   return null;
 }
Ejemplo n.º 10
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();
    }