use of org.sonar.api.notifications.Notification in project sonarqube by SonarSource.
the class NewIssuesEmailTemplateTest method do_not_add_footer_when_properties_missing.
@Test
public void do_not_add_footer_when_properties_missing() {
Notification notification = new Notification(NewIssuesNotification.TYPE).setFieldValue(RULE_TYPE + ".count", "32").setFieldValue("projectName", "Struts");
EmailMessage message = template.format(notification);
assertThat(message.getMessage()).doesNotContain("See it");
}
use of org.sonar.api.notifications.Notification in project sonarqube by SonarSource.
the class NewIssuesEmailTemplateTest method format_email_with_issue_on_branch.
@Test
public void format_email_with_issue_on_branch() {
Notification notification = newNotification(32).setFieldValue("branch", "feature1");
EmailMessage message = template.format(notification);
// TODO datetime to be completed when test is isolated from JVM timezone
assertThat(message.getMessage()).startsWith("Project: Struts\n" + "Branch: feature1\n" + "\n" + "32 new issues (new debt: 1d3h)\n" + "\n" + " Type\n" + " Bug: 1 Vulnerability: 10 Code Smell: 3\n" + "\n" + "More details at: http://nemo.sonarsource.org/project/issues?id=org.apache%3Astruts&branch=feature1&createdAt=2010-05-1");
}
use of org.sonar.api.notifications.Notification in project sonarqube by SonarSource.
the class MyNewIssuesEmailTemplateTest method format_email_with_all_fields_filled.
@Test
public void format_email_with_all_fields_filled() {
Notification notification = newNotification(32);
addTags(notification);
addRules(notification);
addComponents(notification);
EmailMessage message = underTest.format(notification);
// TODO datetime to be completed when test is isolated from JVM timezone
assertThat(message.getMessage()).startsWith("Project: Struts\n" + "\n" + "32 new issues (new debt: 1d3h)\n" + "\n" + " Type\n" + " Bug: 1 Vulnerability: 3 Code Smell: 0\n" + "\n" + " Rules\n" + " Rule the Universe (Clojure): 42\n" + " Rule the World (Java): 5\n" + "\n" + " Tags\n" + " oscar: 3\n" + " cesar: 10\n" + "\n" + " Most impacted files\n" + " /path/to/file: 3\n" + " /path/to/directory: 7\n" + "\n" + "More details at: http://nemo.sonarsource.org/project/issues?id=org.apache%3Astruts&assignees=lo.gin&createdAt=2010-05-18");
}
use of org.sonar.api.notifications.Notification in project sonarqube by SonarSource.
the class MyNewIssuesEmailTemplateTest method format_email_with_issue_on_branch.
@Test
public void format_email_with_issue_on_branch() {
Notification notification = newNotification(32).setFieldValue("projectVersion", "52.0").setFieldValue("branch", "feature1");
EmailMessage message = underTest.format(notification);
// TODO datetime to be completed when test is isolated from JVM timezone
assertThat(message.getMessage()).startsWith("Project: Struts\n" + "Branch: feature1\n" + "Version: 52.0\n" + "\n" + "32 new issues (new debt: 1d3h)\n" + "\n" + " Type\n" + " Bug: 1 Vulnerability: 3 Code Smell: 0\n" + "\n" + "More details at: http://nemo.sonarsource.org/project/issues?id=org.apache%3Astruts&assignees=lo.gin&branch=feature1&createdAt=2010-05-18");
}
use of org.sonar.api.notifications.Notification in project sonarqube by SonarSource.
the class QualityGateEventsStepTest method verify_branch_name_is_not_set_in_notification_when_main.
@Test
public void verify_branch_name_is_not_set_in_notification_when_main() {
analysisMetadataHolder.setBranch(new DefaultBranchImpl());
when(measureRepository.getRawMeasure(PROJECT_COMPONENT, alertStatusMetric)).thenReturn(of(Measure.newMeasureBuilder().setQualityGateStatus(OK_QUALITY_GATE_STATUS).createNoValue()));
when(measureRepository.getBaseMeasure(PROJECT_COMPONENT, alertStatusMetric)).thenReturn(of(Measure.newMeasureBuilder().setQualityGateStatus(new QualityGateStatus(ERROR)).createNoValue()));
underTest.execute(new TestComputationStepContext());
verify(notificationService).deliver(notificationArgumentCaptor.capture());
Notification notification = notificationArgumentCaptor.getValue();
assertThat(notification.getType()).isEqualTo("alerts");
assertThat(notification.getFieldValue("projectKey")).isEqualTo(PROJECT_COMPONENT.getKey());
assertThat(notification.getFieldValue("projectName")).isEqualTo(PROJECT_COMPONENT.getName());
assertThat(notification.getFieldValue("projectVersion")).isEqualTo(PROJECT_COMPONENT.getProjectAttributes().getProjectVersion());
assertThat(notification.getFieldValue("branch")).isNull();
reset(measureRepository, eventRepository, notificationService);
}
Aggregations