Package org.sonar.api.notifications

Examples of org.sonar.api.notifications.Notification


    template = new IssueChangesEmailTemplate(settings, userFinder);
  }

  @Test
  public void should_ignore_non_issue_changes() {
    Notification notification = new Notification("other");
    EmailMessage message = template.format(notification);
    assertThat(message).isNull();
  }
View Full Code Here


    assertThat(message).isNull();
  }

  @Test
  public void email_should_display_assignee_change() throws Exception {
    Notification notification = generateNotification()
      .setFieldValue("old.assignee", "simon")
      .setFieldValue("new.assignee", "louis");

    EmailMessage email = template.format(notification);
    assertThat(email.getMessageId()).isEqualTo("issue-changes/ABCDE");
View Full Code Here

    assertThat(email.getFrom()).isNull();
  }

  @Test
  public void email_should_display_plan_change() throws Exception {
    Notification notification = generateNotification()
      .setFieldValue("old.actionPlan", null)
      .setFieldValue("new.actionPlan", "ABC 1.0");

    EmailMessage email = template.format(notification);
    assertThat(email.getMessageId()).isEqualTo("issue-changes/ABCDE");
View Full Code Here

    assertThat(email.getFrom()).isNull();
  }

  @Test
  public void display_component_key_if_no_component_name() throws Exception {
    Notification notification = generateNotification()
      .setFieldValue("componentName", null);

    EmailMessage email = template.format(notification);
    assertThat(email.getMessageId()).isEqualTo("issue-changes/ABCDE");
    assertThat(email.getSubject()).isEqualTo("Struts, change on issue #ABCDE");
View Full Code Here

    assertThat(message).isEqualTo(expected);
  }

  @Test
  public void test_email_with_multiple_changes() throws Exception {
    Notification notification = generateNotification()
      .setFieldValue("comment", "How to fix it?")
      .setFieldValue("old.assignee", "simon")
      .setFieldValue("new.assignee", "louis")
      .setFieldValue("new.resolution", "FALSE-POSITIVE")
      .setFieldValue("new.status", "RESOLVED");
View Full Code Here

  public void notification_sender_should_be_the_author_of_change() {
    User user = mock(User.class);
    when(user.name()).thenReturn("Simon");
    when(userFinder.findByLogin("simon")).thenReturn(user);

    Notification notification = new Notification("issue-changes")
      .setFieldValue("projectName", "Struts")
      .setFieldValue("projectKey", "org.apache:struts")
      .setFieldValue("changeAuthor", "simon");

    EmailMessage message = template.format(notification);
View Full Code Here

    EmailMessage message = template.format(notification);
    assertThat(message.getFrom()).isEqualTo("Simon");
  }

  private Notification generateNotification() {
    Notification notification = new Notification("issue-changes")
      .setFieldValue("projectName", "Struts")
      .setFieldValue("projectKey", "org.apache:struts")
      .setFieldValue("componentName", "Action")
      .setFieldValue("componentKey", "org.apache.struts.Action")
      .setFieldValue("key", "ABCDE")
View Full Code Here

    TIME_PROFILER.start("Processing notifications queue");
    long start = now();
    long lastLog = start;
    long notifSentCount = 0;

    Notification notifToSend = manager.getFromQueue();
    while (notifToSend != null) {
      deliver(notifToSend);
      notifSentCount++;
      if (stopping) {
        break;
View Full Code Here

    template = new AlertsEmailTemplate(configuration);
  }

  @Test
  public void shouldNotFormatIfNotCorrectNotification() {
    Notification notification = new Notification("other-notif");
    EmailMessage message = template.format(notification);
    assertThat(message, nullValue());
  }
View Full Code Here

    assertThat(message, nullValue());
  }

  @Test
  public void shouldFormatAlertWithSeveralMessages() {
    Notification notification = createNotification("Orange (was Red)", "violations > 4, coverage < 75%", "WARN", "false");

    EmailMessage message = template.format(notification);
    assertThat(message.getMessageId(), is("alerts/45"));
    assertThat(message.getSubject(), is("Quality gate status changed on \"Foo\""));
    assertThat(message.getMessage(), is("" +
View Full Code Here

TOP

Related Classes of org.sonar.api.notifications.Notification

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.