aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJulien Lancelot <julien.lancelot@sonarsource.com>2017-08-30 16:59:30 +0200
committerJanos Gyerik <janos.gyerik@sonarsource.com>2017-09-12 11:34:55 +0200
commitd75d2ff0e82714871bfe28cf5e6ae736e7dd30ce (patch)
treeccce80f2c6d6be00dd74e8c44c26bad0f4573dff
parented5f97afc84310a2f8b5585ba5b92ab38414966e (diff)
downloadsonarqube-d75d2ff0e82714871bfe28cf5e6ae736e7dd30ce.tar.gz
sonarqube-d75d2ff0e82714871bfe28cf5e6ae736e7dd30ce.zip
SONAR-9616 Issue#componentKey should be the public key
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/computation/task/projectanalysis/issue/MovedIssueVisitor.java2
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/computation/task/projectanalysis/issue/TrackerRawInputFactory.java4
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/component/ReportComponent.java10
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/issue/MovedIssueVisitorTest.java8
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/issue/TrackerRawInputFactoryTest.java11
5 files changed, 23 insertions, 12 deletions
diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/task/projectanalysis/issue/MovedIssueVisitor.java b/server/sonar-server/src/main/java/org/sonar/server/computation/task/projectanalysis/issue/MovedIssueVisitor.java
index 38328b7ff15..efafe43e941 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/computation/task/projectanalysis/issue/MovedIssueVisitor.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/computation/task/projectanalysis/issue/MovedIssueVisitor.java
@@ -59,7 +59,7 @@ public class MovedIssueVisitor extends IssueVisitor {
// changes the issue's component uuid, add a change and set issue as changed to enforce it is persisted to DB
issueUpdater.setIssueMoved(issue, component.getUuid(), IssueChangeContext.createUser(new Date(analysisMetadataHolder.getAnalysisDate()), null));
// other fields (such as module, modulePath, componentKey) are read-only and set/reset for consistency only
- issue.setComponentKey(component.getKey());
+ issue.setComponentKey(component.getPublicKey());
issue.setModuleUuid(null);
issue.setModuleUuidPath(null);
}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/task/projectanalysis/issue/TrackerRawInputFactory.java b/server/sonar-server/src/main/java/org/sonar/server/computation/task/projectanalysis/issue/TrackerRawInputFactory.java
index 9de67f6b610..f113a73a86b 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/computation/task/projectanalysis/issue/TrackerRawInputFactory.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/computation/task/projectanalysis/issue/TrackerRawInputFactory.java
@@ -161,9 +161,9 @@ public class TrackerRawInputFactory {
issue.setResolution(null);
issue.setStatus(Issue.STATUS_OPEN);
issue.setComponentUuid(component.getUuid());
- issue.setComponentKey(component.getKey());
+ issue.setComponentKey(component.getPublicKey());
issue.setProjectUuid(treeRootHolder.getRoot().getUuid());
- issue.setProjectKey(treeRootHolder.getRoot().getKey());
+ issue.setProjectKey(treeRootHolder.getRoot().getPublicKey());
return issue;
}
diff --git a/server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/component/ReportComponent.java b/server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/component/ReportComponent.java
index e3baec1c188..3ebeabcc647 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/component/ReportComponent.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/component/ReportComponent.java
@@ -37,7 +37,13 @@ public class ReportComponent implements Component {
private static final FileAttributes DEFAULT_FILE_ATTRIBUTES = new FileAttributes(false, null, 1);
- public static final Component DUMB_PROJECT = builder(Type.PROJECT, 1).setKey("PROJECT_KEY").setUuid("PROJECT_UUID").setName("Project Name").setVersion("1.0-SNAPSHOT").build();
+ public static final Component DUMB_PROJECT = builder(Type.PROJECT, 1)
+ .setKey("PROJECT_KEY")
+ .setPublicKey("PUBLIC_PROJECT_KEY")
+ .setUuid("PROJECT_UUID")
+ .setName("Project Name")
+ .setVersion("1.0-SNAPSHOT")
+ .build();
private final Type type;
private final Status status;
@@ -170,7 +176,7 @@ public class ReportComponent implements Component {
}
public static Builder builder(Type type, int ref) {
- return new Builder(type, ref).setKey("key_" + ref).setUuid("uuid_" + ref);
+ return new Builder(type, ref).setKey("key_" + ref).setPublicKey("public_" + ref).setUuid("uuid_" + ref);
}
public static final class Builder {
diff --git a/server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/issue/MovedIssueVisitorTest.java b/server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/issue/MovedIssueVisitorTest.java
index 568fb90b02b..9328e9d7359 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/issue/MovedIssueVisitorTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/issue/MovedIssueVisitorTest.java
@@ -45,7 +45,11 @@ import static org.mockito.Mockito.when;
public class MovedIssueVisitorTest {
private static final long ANALYSIS_DATE = 894521;
private static final String FILE_UUID = "file uuid";
- private static final Component FILE = ReportComponent.builder(Component.Type.FILE, 1).setUuid(FILE_UUID).build();
+ private static final Component FILE = ReportComponent.builder(Component.Type.FILE, 1)
+ .setKey("key_1")
+ .setPublicKey("public_key_1")
+ .setUuid(FILE_UUID)
+ .build();
@org.junit.Rule
public ExpectedException expectedException = ExpectedException.none();
@@ -115,7 +119,7 @@ public class MovedIssueVisitorTest {
underTest.onIssue(FILE, issue);
verify(issue).setComponentUuid(FILE.getUuid());
- verify(issue).setComponentKey(FILE.getKey());
+ verify(issue).setComponentKey(FILE.getPublicKey());
verify(issue).setModuleUuid(null);
verify(issue).setModuleUuidPath(null);
verify(issue).setChanged(true);
diff --git a/server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/issue/TrackerRawInputFactoryTest.java b/server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/issue/TrackerRawInputFactoryTest.java
index 0133505adb2..dabb0922fa5 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/issue/TrackerRawInputFactoryTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/issue/TrackerRawInputFactoryTest.java
@@ -32,9 +32,9 @@ import org.sonar.scanner.protocol.Constants;
import org.sonar.scanner.protocol.output.ScannerReport;
import org.sonar.scanner.protocol.output.ScannerReport.TextRange;
import org.sonar.server.computation.task.projectanalysis.batch.BatchReportReaderRule;
-import org.sonar.server.computation.task.projectanalysis.component.TreeRootHolderRule;
import org.sonar.server.computation.task.projectanalysis.component.Component;
import org.sonar.server.computation.task.projectanalysis.component.ReportComponent;
+import org.sonar.server.computation.task.projectanalysis.component.TreeRootHolderRule;
import org.sonar.server.computation.task.projectanalysis.issue.commonrule.CommonRuleEngine;
import org.sonar.server.computation.task.projectanalysis.issue.filter.IssueFilter;
import org.sonar.server.computation.task.projectanalysis.source.SourceLinesRepositoryRule;
@@ -49,10 +49,10 @@ import static org.mockito.Mockito.when;
public class TrackerRawInputFactoryTest {
- static int FILE_REF = 2;
+ private static int FILE_REF = 2;
- static ReportComponent PROJECT = ReportComponent.builder(Component.Type.PROJECT, 1).setKey("PROJECT_KEY_2").setUuid("PROJECT_UUID_1").build();
- static ReportComponent FILE = ReportComponent.builder(Component.Type.FILE, FILE_REF).setKey("FILE_KEY_2").setUuid("FILE_UUID_2").build();
+ private static ReportComponent PROJECT = ReportComponent.builder(Component.Type.PROJECT, 1).build();
+ private static ReportComponent FILE = ReportComponent.builder(Component.Type.FILE, FILE_REF).build();
@Rule
public TreeRootHolderRule treeRootHolder = new TreeRootHolderRule().setRoot(PROJECT);
@@ -190,7 +190,8 @@ public class TrackerRawInputFactoryTest {
}
private void assertInitializedIssue(DefaultIssue issue) {
- assertThat(issue.componentKey()).isEqualTo(FILE.getKey());
+ assertThat(issue.projectKey()).isEqualTo(PROJECT.getPublicKey());
+ assertThat(issue.componentKey()).isEqualTo(FILE.getPublicKey());
assertThat(issue.componentUuid()).isEqualTo(FILE.getUuid());
assertThat(issue.resolution()).isNull();
assertThat(issue.status()).isEqualTo(Issue.STATUS_OPEN);