use of org.sonar.server.issue.notification.IssuesChangesNotificationBuilder.Project in project sonarqube by SonarSource.
the class IssuesChangesNotificationBuilderTest method Project_not_equal.
@Test
@UseDataProvider("projectData")
public void Project_not_equal(Object object) {
Project project1 = new Project.Builder("uuid1").setKey("key1").setProjectName("name1").setBranchName("branch-name1").build();
assertThat(project1).isNotEqualTo(object);
}
use of org.sonar.server.issue.notification.IssuesChangesNotificationBuilder.Project in project sonarqube by SonarSource.
the class IssuesChangesNotificationBuilderTest method ChangedIssue_toString.
@Test
public void ChangedIssue_toString() {
ChangedIssue changedIssue = new ChangedIssue.Builder("key").setRule(newRule("repository", "key", RuleType.CODE_SMELL, "name")).setProject(new Project.Builder("uuid").setKey("key").setProjectName("name").setBranchName("branch-name").build()).setNewStatus("status").setNewResolution("resolution").setAssignee(new User("uuid", "login", "name")).build();
assertThat(changedIssue).hasToString("ChangedIssue{key='key', newStatus='status', newResolution='resolution', " + "assignee=User{uuid='uuid', login='login', name='name'}, " + "rule=Rule{key=repository:key, type=CODE_SMELL, name='name'}, " + "project=Project{uuid='uuid', key='key', projectName='name', branchName='branch-name'}}");
}
use of org.sonar.server.issue.notification.IssuesChangesNotificationBuilder.Project in project sonarqube by SonarSource.
the class IssuesChangesNotificationBuilderTest method Project_getters.
@Test
public void Project_getters() {
Project project1 = new Project.Builder("uuid").setKey("key").setProjectName("name").setBranchName("branch-name").build();
assertThat(project1.getKey()).isEqualTo("key");
assertThat(project1.getProjectName()).isEqualTo("name");
assertThat(project1.getUuid()).isEqualTo("uuid");
assertThat(project1.getBranchName()).hasValue("branch-name");
}
use of org.sonar.server.issue.notification.IssuesChangesNotificationBuilder.Project 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.Project in project sonarqube by SonarSource.
the class ChangesOnMyIssuesEmailTemplateTest method formats_returns_html_message_for_multiple_issues_of_same_rule_on_same_project_on_branch_when_analysis_change.
@Test
public void formats_returns_html_message_for_multiple_issues_of_same_rule_on_same_project_on_branch_when_analysis_change() {
String branchName = randomAlphabetic(19);
Project project = newBranch("1", branchName);
String ruleName = randomAlphabetic(8);
String host = randomAlphabetic(15);
Rule rule = newRule(ruleName, randomRuleTypeHotspotExcluded());
String status = randomValidStatus();
List<ChangedIssue> changedIssues = IntStream.range(0, 2 + new Random().nextInt(5)).mapToObj(i -> newChangedIssue("issue_" + i, status, project, rule)).collect(toList());
AnalysisChange analysisChange = newAnalysisChange();
when(emailSettings.getServerBaseURL()).thenReturn(host);
EmailMessage emailMessage = underTest.format(new ChangesOnMyIssuesNotification(analysisChange, ImmutableSet.copyOf(changedIssues)));
String expectedHref = host + "/project/issues?id=" + project.getKey() + "&branch=" + branchName + "&issues=" + changedIssues.stream().map(ChangedIssue::getKey).collect(joining("%2C"));
String expectedLinkText = "See all " + changedIssues.size() + " issues";
HtmlFragmentAssert.assertThat(emailMessage.getMessage()).hasParagraph().hasParagraph().hasParagraph().hasList("Rule " + ruleName + " - " + expectedLinkText).withLink(expectedLinkText, expectedHref).hasParagraph().hasParagraph().noMoreBlock();
}
Aggregations