use of org.sonar.server.issue.notification.IssuesChangesNotificationBuilder.UserChange in project sonarqube by SonarSource.
the class IssuesChangesNotificationBuilderTest method UserChange_not_equal.
@Test
@UseDataProvider("userData")
public void UserChange_not_equal(Object object) {
long now = System2.INSTANCE.now();
String uuid_1 = "uuid-1";
String login_1 = "login-1";
String name_1 = "name-1";
UserChange userChange1 = new UserChange(now, new User(uuid_1, login_1, name_1));
assertThat(userChange1).isNotEqualTo(object);
}
use of org.sonar.server.issue.notification.IssuesChangesNotificationBuilder.UserChange in project sonarqube by SonarSource.
the class IssuesChangesNotificationBuilderTest method UserChange_isAuthorLogin.
@Test
public void UserChange_isAuthorLogin() {
long now = System2.INSTANCE.now();
String uuid = "uuid-1";
String login = "login-1";
String name = "name-1";
UserChange userChange = new UserChange(now, new User(uuid, login, name));
assertThat(userChange.isAuthorLogin("other-login")).isFalse();
assertThat(userChange.isAuthorLogin("login-1")).isTrue();
}
use of org.sonar.server.issue.notification.IssuesChangesNotificationBuilder.UserChange in project sonarqube by SonarSource.
the class IssuesChangesNotificationBuilderTest method UserChange_equals.
@Test
public void UserChange_equals() {
long now = System2.INSTANCE.now();
String uuid_1 = "uuid-1";
String login_1 = "login-1";
String name_1 = "name-1";
UserChange userChange1 = new UserChange(now, new User(uuid_1, login_1, name_1));
UserChange userChange2 = new UserChange(now, new User(uuid_1, login_1, name_1));
assertThat(userChange1).isEqualTo(userChange2).isEqualTo(userChange1);
}
use of org.sonar.server.issue.notification.IssuesChangesNotificationBuilder.UserChange in project sonarqube by SonarSource.
the class ChangesOnMyIssuesEmailTemplateTest method formats_returns_html_message_for_multiple_issues_of_same_rule_on_same_project_on_master_when_user_change.
@Test
public void formats_returns_html_message_for_multiple_issues_of_same_rule_on_same_project_on_master_when_user_change() {
Project project = newProject("1");
String ruleName = randomAlphabetic(8);
String host = randomAlphabetic(15);
Rule rule = newRule(ruleName, randomRuleTypeHotspotExcluded());
List<ChangedIssue> changedIssues = IntStream.range(0, 2 + new Random().nextInt(5)).mapToObj(i -> newChangedIssue("issue_" + i, randomValidStatus(), project, rule)).collect(toList());
UserChange userChange = newUserChange();
when(emailSettings.getServerBaseURL()).thenReturn(host);
EmailMessage emailMessage = underTest.format(new ChangesOnMyIssuesNotification(userChange, ImmutableSet.copyOf(changedIssues)));
String expectedHref = host + "/project/issues?id=" + project.getKey() + "&issues=" + changedIssues.stream().map(ChangedIssue::getKey).collect(joining("%2C"));
String expectedLinkText = "See all " + changedIssues.size() + " issues";
HtmlFragmentAssert.assertThat(emailMessage.getMessage()).hasParagraph().hasParagraph().hasParagraph(project.getProjectName()).hasList("Rule " + ruleName + " - " + expectedLinkText).withLink(expectedLinkText, expectedHref).hasParagraph().hasParagraph().noMoreBlock();
}
use of org.sonar.server.issue.notification.IssuesChangesNotificationBuilder.UserChange in project sonarqube by SonarSource.
the class FpOrWontFixEmailTemplate method format.
@Override
@CheckForNull
public EmailMessage format(Notification notif) {
if (!(notif instanceof FPOrWontFixNotification)) {
return null;
}
FPOrWontFixNotification notification = (FPOrWontFixNotification) notif;
EmailMessage emailMessage = new EmailMessage().setMessageId(getMessageId(notification.getResolution())).setSubject(buildSubject(notification)).setHtmlMessage(buildMessage(notification));
if (notification.getChange() instanceof UserChange) {
User user = ((UserChange) notification.getChange()).getUser();
emailMessage.setFrom(user.getName().orElse(user.getLogin()));
}
return emailMessage;
}
Aggregations