Examples of EmailMessage


Examples of org.sonar.plugins.emailnotifications.api.EmailMessage

  public void shouldNotAddFooterIfMissingProperties() {
    Notification notification = new Notification("new-issues")
      .setFieldValue("count", "32")
      .setFieldValue("projectName", "Struts");

    EmailMessage message = template.format(notification);
    assertThat(message.getMessage()).doesNotContain("See it");
  }
View Full Code Here

Examples of org.sonar.plugins.emailnotifications.api.EmailMessage

  }

  @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

Examples of org.sonar.plugins.emailnotifications.api.EmailMessage

  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");
    assertThat(email.getSubject()).isEqualTo("Struts, change on issue #ABCDE");

    String message = email.getMessage();
    String expected = Resources.toString(Resources.getResource(
        "org/sonar/plugins/core/issue/notification/IssueChangesEmailTemplateTest/email_with_assignee_change.txt"),
      Charsets.UTF_8
    );
    expected = StringUtils.remove(expected, '\r');
    assertThat(message).isEqualTo(expected);
    assertThat(email.getFrom()).isNull();
  }
View Full Code Here

Examples of org.sonar.plugins.emailnotifications.api.EmailMessage

  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");
    assertThat(email.getSubject()).isEqualTo("Struts, change on issue #ABCDE");

    String message = email.getMessage();
    String expected = Resources.toString(Resources.getResource(
        "org/sonar/plugins/core/issue/notification/IssueChangesEmailTemplateTest/email_with_action_plan_change.txt"),
      Charsets.UTF_8
    );
    expected = StringUtils.remove(expected, '\r');
    assertThat(message).isEqualTo(expected);
    assertThat(email.getFrom()).isNull();
  }
View Full Code Here

Examples of org.sonar.plugins.emailnotifications.api.EmailMessage

  @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");

    String message = email.getMessage();
    String expected = Resources.toString(Resources.getResource(
        "org/sonar/plugins/core/issue/notification/IssueChangesEmailTemplateTest/display_component_key_if_no_component_name.txt"),
      Charsets.UTF_8
    );
    expected = StringUtils.remove(expected, '\r');
View Full Code Here

Examples of org.sonar.plugins.emailnotifications.api.EmailMessage

      .setFieldValue("old.assignee", "simon")
      .setFieldValue("new.assignee", "louis")
      .setFieldValue("new.resolution", "FALSE-POSITIVE")
      .setFieldValue("new.status", "RESOLVED");

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

    String message = email.getMessage();
    String expected = Resources.toString(Resources.getResource(
      "org/sonar/plugins/core/issue/notification/IssueChangesEmailTemplateTest/email_with_multiple_changes.txt"), Charsets.UTF_8);
    expected = StringUtils.remove(expected, '\r');
    assertThat(message).isEqualTo(expected);
    assertThat(email.getFrom()).isNull();
  }
View Full Code Here

Examples of org.sonar.plugins.emailnotifications.api.EmailMessage

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

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

Examples of org.sonar.plugins.emailnotifications.api.EmailMessage

    // Generate text
    String subject = generateSubject(projectName, alertLevel, isNewAlert);
    String messageBody = generateMessageBody(projectName, projectKey, alertName, alertText, isNewAlert);

    // And finally return the email that will be sent
    return new EmailMessage()
        .setMessageId("alerts/" + projectId)
        .setSubject(subject)
        .setMessage(messageBody);
  }
View Full Code Here

Examples of org.sonar.plugins.emailnotifications.api.EmailMessage

    User user = userFinder.findByLogin(username);
    if (StringUtils.isBlank(user.getEmail())) {
      LOG.debug("Email not defined for user: " + username);
      return;
    }
    EmailMessage emailMessage = format(notification);
    if (emailMessage != null) {
      emailMessage.setTo(user.getEmail());
      deliver(emailMessage);
    }
  }
View Full Code Here

Examples of org.sonar.plugins.emailnotifications.api.EmailMessage

    }
  }

  private EmailMessage format(Notification notification) {
    for (EmailTemplate template : templates) {
      EmailMessage email = template.format(notification);
      if (email != null) {
        return email;
      }
    }
    LOG.warn("Email template not found for notification: {}", notification);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.