/**
* Creates email message for notification "alerts".
- *
+ *
* @since 3.5
*/
public class AlertsEmailTemplate extends EmailTemplate {
if (Metric.Level.OK.toString().equals(alertLevel)) {
subjectBuilder.append("\"").append(projectName).append("\" is back to green");
} else if (isNewAlert) {
- subjectBuilder.append("New alert on \"").append(projectName).append("\"");
+ subjectBuilder.append("New quality gate threshold reached on \"").append(projectName).append("\"");
} else {
- subjectBuilder.append("Alert level changed on \"").append(projectName).append("\"");
+ subjectBuilder.append("Quality gate status changed on \"").append(projectName).append("\"");
}
return subjectBuilder.toString();
}
private String generateMessageBody(String projectName, String projectKey, String alertName, String alertText, boolean isNewAlert) {
StringBuilder messageBody = new StringBuilder();
messageBody.append("Project: ").append(projectName).append("\n");
- messageBody.append("Alert level: ").append(alertName).append("\n\n");
+ messageBody.append("Quality gate status: ").append(alertName).append("\n\n");
String[] alerts = StringUtils.split(alertText, ",");
if (alerts.length > 0) {
if (isNewAlert) {
- messageBody.append("New alert");
+ messageBody.append("New quality gate threshold");
} else {
- messageBody.append("Alert");
+ messageBody.append("Quality gate threshold");
}
if (alerts.length == 1) {
messageBody.append(": ").append(alerts[0].trim()).append("\n");
*/
package org.sonar.plugins.emailnotifications.templates.alerts;
-import org.sonar.plugins.emailnotifications.templates.alerts.AlertsEmailTemplate;
-
import org.junit.Before;
import org.junit.Test;
import org.sonar.api.config.EmailSettings;
EmailMessage message = template.format(notification);
assertThat(message.getMessageId(), is("alerts/45"));
- assertThat(message.getSubject(), is("Alert level changed on \"Foo\""));
+ assertThat(message.getSubject(), is("Quality gate status changed on \"Foo\""));
assertThat(message.getMessage(), is("" +
"Project: Foo\n" +
- "Alert level: Orange (was Red)\n" +
+ "Quality gate status: Orange (was Red)\n" +
"\n" +
- "Alerts:\n" +
+ "Quality gate thresholds:\n" +
" - violations > 4\n" +
" - coverage < 75%\n" +
"\n" +
EmailMessage message = template.format(notification);
assertThat(message.getMessageId(), is("alerts/45"));
- assertThat(message.getSubject(), is("New alert on \"Foo\""));
+ assertThat(message.getSubject(), is("New quality gate threshold reached on \"Foo\""));
assertThat(message.getMessage(), is("" +
"Project: Foo\n" +
- "Alert level: Orange (was Red)\n" +
+ "Quality gate status: Orange (was Red)\n" +
"\n" +
- "New alerts:\n" +
+ "New quality gate thresholds:\n" +
" - violations > 4\n" +
" - coverage < 75%\n" +
"\n" +
EmailMessage message = template.format(notification);
assertThat(message.getMessageId(), is("alerts/45"));
- assertThat(message.getSubject(), is("New alert on \"Foo\""));
+ assertThat(message.getSubject(), is("New quality gate threshold reached on \"Foo\""));
assertThat(message.getMessage(), is("" +
"Project: Foo\n" +
- "Alert level: Orange (was Red)\n" +
+ "Quality gate status: Orange (was Red)\n" +
"\n" +
- "New alert: violations > 4\n" +
+ "New quality gate threshold: violations > 4\n" +
"\n" +
"See it in SonarQube: http://nemo.sonarsource.org/dashboard/index/org.sonar.foo:foo"));
}
assertThat(message.getSubject(), is("\"Foo\" is back to green"));
assertThat(message.getMessage(), is("" +
"Project: Foo\n" +
- "Alert level: Green (was Red)\n" +
+ "Quality gate status: Green (was Red)\n" +
"\n" +
"\n" +
"See it in SonarQube: http://nemo.sonarsource.org/dashboard/index/org.sonar.foo:foo"));