Browse Source

Update issue notification link

tags/4.5-RC1
Julien Lancelot 10 years ago
parent
commit
e529bfafb0

+ 3
- 1
plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/issue/notification/IssueChangesEmailTemplate.java View File

@@ -92,7 +92,9 @@ public class IssueChangesEmailTemplate extends EmailTemplate {

private void appendFooter(StringBuilder sb, Notification notification) {
String issueKey = notification.getFieldValue("key");
sb.append("See it in SonarQube: ").append(settings.getServerBaseURL()).append("/issue/show/").append(issueKey).append(NEW_LINE);
String componentKey = notification.getFieldValue("componentKey");
sb.append("See it in SonarQube: ").append(settings.getServerBaseURL()).append("/component/index#component=").append(componentKey)
.append("&currentIssue=").append(issueKey).append(NEW_LINE);
}

private void appendLine(StringBuilder sb, @Nullable String line) {

+ 20
- 1
plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/issue/notification/IssueChangesEmailTemplateTest.java View File

@@ -99,6 +99,24 @@ public class IssueChangesEmailTemplateTest {
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");

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');
assertThat(message).isEqualTo(expected);
}

@Test
public void test_email_with_multiple_changes() throws Exception {
Notification notification = generateNotification()
@@ -139,7 +157,8 @@ public class IssueChangesEmailTemplateTest {
Notification notification = new Notification("issue-changes")
.setFieldValue("projectName", "Struts")
.setFieldValue("projectKey", "org.apache:struts")
.setFieldValue("componentName", "org.apache.struts.Action")
.setFieldValue("componentName", "Action")
.setFieldValue("componentKey", "org.apache.struts.Action")
.setFieldValue("key", "ABCDE")
.setFieldValue("ruleName", "Avoid Cycles")
.setFieldValue("message", "Has 3 cycles");

+ 6
- 0
plugins/sonar-core-plugin/src/test/resources/org/sonar/plugins/core/issue/notification/IssueChangesEmailTemplateTest/display_component_key_if_no_component_name.txt View File

@@ -0,0 +1,6 @@
org.apache.struts.Action
Rule: Avoid Cycles
Message: Has 3 cycles


See it in SonarQube: http://nemo.sonarsource.org/component/index#component=org.apache.struts.Action&currentIssue=ABCDE

+ 2
- 2
plugins/sonar-core-plugin/src/test/resources/org/sonar/plugins/core/issue/notification/IssueChangesEmailTemplateTest/email_with_action_plan_change.txt View File

@@ -1,7 +1,7 @@
org.apache.struts.Action
Action
Rule: Avoid Cycles
Message: Has 3 cycles

Action Plan changed to ABC 1.0

See it in SonarQube: http://nemo.sonarsource.org/issue/show/ABCDE
See it in SonarQube: http://nemo.sonarsource.org/component/index#component=org.apache.struts.Action&currentIssue=ABCDE

+ 2
- 2
plugins/sonar-core-plugin/src/test/resources/org/sonar/plugins/core/issue/notification/IssueChangesEmailTemplateTest/email_with_assignee_change.txt View File

@@ -1,7 +1,7 @@
org.apache.struts.Action
Action
Rule: Avoid Cycles
Message: Has 3 cycles

Assignee changed to louis

See it in SonarQube: http://nemo.sonarsource.org/issue/show/ABCDE
See it in SonarQube: http://nemo.sonarsource.org/component/index#component=org.apache.struts.Action&currentIssue=ABCDE

+ 2
- 2
plugins/sonar-core-plugin/src/test/resources/org/sonar/plugins/core/issue/notification/IssueChangesEmailTemplateTest/email_with_multiple_changes.txt View File

@@ -1,4 +1,4 @@
org.apache.struts.Action
Action
Rule: Avoid Cycles
Message: Has 3 cycles

@@ -7,4 +7,4 @@ Assignee changed to louis
Resolution: FALSE-POSITIVE
Status: RESOLVED

See it in SonarQube: http://nemo.sonarsource.org/issue/show/ABCDE
See it in SonarQube: http://nemo.sonarsource.org/component/index#component=org.apache.struts.Action&currentIssue=ABCDE

Loading…
Cancel
Save