diff options
author | Julien Lancelot <julien.lancelot@sonarsource.com> | 2016-12-13 17:59:25 +0100 |
---|---|---|
committer | Julien Lancelot <julien.lancelot@sonarsource.com> | 2016-12-14 14:03:49 +0100 |
commit | 0f6beee827a54bb53f9a2f4c5f56fa0006cacf34 (patch) | |
tree | 45095c564b6b340466ec877fcf7ae9fd9db1e493 /it | |
parent | d7524698cf5f99f438a72e403b3b169e88634778 (diff) | |
download | sonarqube-0f6beee827a54bb53f9a2f4c5f56fa0006cacf34.tar.gz sonarqube-0f6beee827a54bb53f9a2f4c5f56fa0006cacf34.zip |
SONAR-7728 Add IT checking changelog of file move contains file names
Diffstat (limited to 'it')
-rw-r--r-- | it/it-tests/src/test/java/it/issue/IssueChangelogTest.java | 51 |
1 files changed, 35 insertions, 16 deletions
diff --git a/it/it-tests/src/test/java/it/issue/IssueChangelogTest.java b/it/it-tests/src/test/java/it/issue/IssueChangelogTest.java index 75a0c78d6be..f9b9067b49e 100644 --- a/it/it-tests/src/test/java/it/issue/IssueChangelogTest.java +++ b/it/it-tests/src/test/java/it/issue/IssueChangelogTest.java @@ -19,39 +19,37 @@ */ package it.issue; +import com.sonar.orchestrator.locator.FileLocation; import java.util.List; import org.junit.Before; -import org.junit.Rule; import org.junit.Test; import org.sonar.wsclient.issue.Issue; import org.sonarqube.ws.Issues; import org.sonarqube.ws.Issues.ChangelogWsResponse.Changelog; -import util.ProjectAnalysis; -import util.ProjectAnalysisRule; +import org.sonarqube.ws.client.WsClient; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.tuple; import static util.ItUtils.newAdminWsClient; +import static util.ItUtils.runProjectAnalysis; public class IssueChangelogTest extends AbstractIssueTest { - @Rule - public final ProjectAnalysisRule projectAnalysisRule = ProjectAnalysisRule.from(ORCHESTRATOR); - - Issue issue; - ProjectAnalysis xooSampleAnalysis; + private static WsClient adminClient; @Before - public void resetData() { - xooSampleAnalysis = projectAnalysisRule - .newProjectAnalysis(projectAnalysisRule.registerProject("shared/xoo-sample")) - .withQualityProfile(projectAnalysisRule.registerProfile("/issue/IssueChangelogTest/one-issue-per-line-profile.xml")); - xooSampleAnalysis.run(); - issue = searchRandomIssue(); + public void prepareData() { + ORCHESTRATOR.resetData(); + ORCHESTRATOR.getServer().restoreProfile(FileLocation.ofClasspath("/issue/IssueChangelogTest/one-issue-per-line-profile.xml")); + ORCHESTRATOR.getServer().provisionProject("sample", "sample"); + ORCHESTRATOR.getServer().associateProjectToQualityProfile("sample", "xoo", "one-issue-per-line"); + adminClient = newAdminWsClient(ORCHESTRATOR); } @Test public void update_changelog_when_assigning_issue_by_user() throws Exception { + runProjectAnalysis(ORCHESTRATOR, "shared/xoo-sample"); + Issue issue = searchRandomIssue(); assertIssueHasNoChange(issue.key()); adminIssueClient().assign(issue.key(), "admin"); @@ -68,11 +66,13 @@ public class IssueChangelogTest extends AbstractIssueTest { @Test public void update_changelog_when_reopening_unresolved_issue_by_scan() throws Exception { + runProjectAnalysis(ORCHESTRATOR, "shared/xoo-sample"); + Issue issue = searchRandomIssue(); assertIssueHasNoChange(issue.key()); // re analyse the project after resolving an issue in order to reopen it adminIssueClient().doTransition(issue.key(), "resolve"); - xooSampleAnalysis.run(); + runProjectAnalysis(ORCHESTRATOR, "shared/xoo-sample"); List<Changelog> changes = changelog(issue.key()).getChangelogList(); assertThat(changes).hasSize(2); @@ -94,12 +94,31 @@ public class IssueChangelogTest extends AbstractIssueTest { .containsOnly(tuple("resolution", "", ""), tuple("status", "RESOLVED", "REOPENED")); } + @Test + public void display_file_name_in_changelog_during_file_move() { + // version 1 + runProjectAnalysis(ORCHESTRATOR, "issue/xoo-tracking-v1"); + + // version 2 + runProjectAnalysis(ORCHESTRATOR, "issue/xoo-tracking-v3"); + + Issue issue = searchRandomIssue(); + List<Changelog> changes = changelog(issue.key()).getChangelogList(); + assertThat(changes).hasSize(1); + Changelog change = changes.get(0); + assertThat(change.hasUser()).isFalse(); + assertThat(change.getCreationDate()).isNotNull(); + assertThat(change.getDiffsList()) + .extracting(Changelog.Diff::getKey, Changelog.Diff::getOldValue, Changelog.Diff::getNewValue) + .containsOnly(tuple("file", "src/main/xoo/sample/Sample.xoo", "src/main/xoo/sample/Sample2.xoo")); + } + private void assertIssueHasNoChange(String issueKey) { assertThat(changelog(issueKey).getChangelogList()).isEmpty(); } private static Issues.ChangelogWsResponse changelog(String issueKey) { - return newAdminWsClient(ORCHESTRATOR).issues().changelog(issueKey); + return adminClient.issues().changelog(issueKey); } } |