aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/computation/task/projectanalysis/step/QualityGateEventsStep.java5
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/computation/task/projectanalysis/step/SendIssueNotificationsStep.java10
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/step/QualityGateEventsStepTest.java6
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/step/SendIssueNotificationsStepTest.java29
4 files changed, 20 insertions, 30 deletions
diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/task/projectanalysis/step/QualityGateEventsStep.java b/server/sonar-server/src/main/java/org/sonar/server/computation/task/projectanalysis/step/QualityGateEventsStep.java
index 64310f4b8f6..8897c682e25 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/computation/task/projectanalysis/step/QualityGateEventsStep.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/computation/task/projectanalysis/step/QualityGateEventsStep.java
@@ -126,7 +126,7 @@ public class QualityGateEventsStep implements ComputationStep {
Notification notification = new Notification("alerts")
.setDefaultMessage(String.format("Alert on %s: %s", project.getName(), label))
.setFieldValue("projectName", project.getName())
- .setFieldValue("projectKey", getMainBranchProjectKey())
+ .setFieldValue("projectKey", project.getPublicKey())
.setFieldValue("projectUuid", project.getUuid())
.setFieldValue("alertName", label)
.setFieldValue("alertText", rawStatus.getText())
@@ -145,7 +145,4 @@ public class QualityGateEventsStep implements ComputationStep {
return "Generate Quality gate events";
}
- private String getMainBranchProjectKey() {
- return analysisMetadataHolder.getProject().getKey();
- }
}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/task/projectanalysis/step/SendIssueNotificationsStep.java b/server/sonar-server/src/main/java/org/sonar/server/computation/task/projectanalysis/step/SendIssueNotificationsStep.java
index fbfb35060ee..95e83be4a24 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/computation/task/projectanalysis/step/SendIssueNotificationsStep.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/computation/task/projectanalysis/step/SendIssueNotificationsStep.java
@@ -106,7 +106,7 @@ public class SendIssueNotificationsStep implements ComputationStep {
IssueChangeNotification changeNotification = new IssueChangeNotification();
changeNotification.setRuleName(rules.getByKey(issue.ruleKey()).getName());
changeNotification.setIssue(issue);
- changeNotification.setProject(getMainBranchProjectKey(), project.getName(), getBranchName());
+ changeNotification.setProject(project.getPublicKey(), project.getName(), getBranchName());
service.deliver(changeNotification);
}
@@ -114,7 +114,7 @@ public class SendIssueNotificationsStep implements ComputationStep {
NewIssuesStatistics.Stats globalStatistics = statistics.globalStatistics();
NewIssuesNotification notification = newIssuesNotificationFactory
.newNewIssuesNotication()
- .setProject(getMainBranchProjectKey(), project.getUuid(), project.getName(), getBranchName())
+ .setProject(project.getPublicKey(), project.getUuid(), project.getName(), getBranchName())
.setAnalysisDate(new Date(analysisDate))
.setStatistics(project.getName(), globalStatistics)
.setDebt(globalStatistics.debt());
@@ -130,7 +130,7 @@ public class SendIssueNotificationsStep implements ComputationStep {
.newMyNewIssuesNotification()
.setAssignee(assignee);
myNewIssuesNotification
- .setProject(getMainBranchProjectKey(), project.getUuid(), project.getName(), getBranchName())
+ .setProject(project.getPublicKey(), project.getUuid(), project.getName(), getBranchName())
.setAnalysisDate(new Date(analysisDate))
.setStatistics(project.getName(), assigneeStatistics)
.setDebt(assigneeStatistics.debt());
@@ -148,8 +148,4 @@ public class SendIssueNotificationsStep implements ComputationStep {
return analysisMetadataHolder.getBranch().filter(b -> !b.isMain()).map(Branch::getName).orElse(null);
}
- private String getMainBranchProjectKey() {
- return analysisMetadataHolder.getProject().getKey();
- }
-
}
diff --git a/server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/step/QualityGateEventsStepTest.java b/server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/step/QualityGateEventsStepTest.java
index 76dcf82762e..72033929cd9 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/step/QualityGateEventsStepTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/step/QualityGateEventsStepTest.java
@@ -187,7 +187,7 @@ public class QualityGateEventsStepTest {
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("projectKey")).isEqualTo(PROJECT_COMPONENT.getPublicKey());
assertThat(notification.getFieldValue("projectUuid")).isEqualTo(PROJECT_COMPONENT.getUuid());
assertThat(notification.getFieldValue("projectName")).isEqualTo(PROJECT_COMPONENT.getName());
assertThat(notification.getFieldValue("branch")).isNull();
@@ -239,7 +239,7 @@ public class QualityGateEventsStepTest {
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("projectKey")).isEqualTo(PROJECT_COMPONENT.getPublicKey());
assertThat(notification.getFieldValue("projectUuid")).isEqualTo(PROJECT_COMPONENT.getUuid());
assertThat(notification.getFieldValue("projectName")).isEqualTo(PROJECT_COMPONENT.getName());
assertThat(notification.getFieldValue("branch")).isNull();
@@ -263,7 +263,7 @@ public class QualityGateEventsStepTest {
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("projectKey")).isEqualTo(PROJECT_COMPONENT.getPublicKey());
assertThat(notification.getFieldValue("projectUuid")).isEqualTo(PROJECT_COMPONENT.getUuid());
assertThat(notification.getFieldValue("projectName")).isEqualTo(PROJECT_COMPONENT.getName());
assertThat(notification.getFieldValue("branch")).isEqualTo(branchName);
diff --git a/server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/step/SendIssueNotificationsStepTest.java b/server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/step/SendIssueNotificationsStepTest.java
index 9db49085e2f..6b3115688c0 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/step/SendIssueNotificationsStepTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/step/SendIssueNotificationsStepTest.java
@@ -30,11 +30,10 @@ import org.sonar.api.utils.Duration;
import org.sonar.api.utils.System2;
import org.sonar.core.issue.DefaultIssue;
import org.sonar.server.computation.task.projectanalysis.analysis.AnalysisMetadataHolderRule;
-import org.sonar.server.computation.task.projectanalysis.analysis.Project;
-import org.sonar.server.computation.task.projectanalysis.component.DefaultBranchImpl;
-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.Component.Type;
+import org.sonar.server.computation.task.projectanalysis.component.DefaultBranchImpl;
+import org.sonar.server.computation.task.projectanalysis.component.TreeRootHolderRule;
import org.sonar.server.computation.task.projectanalysis.issue.IssueCache;
import org.sonar.server.computation.task.projectanalysis.issue.RuleRepository;
import org.sonar.server.computation.task.step.ComputationStep;
@@ -57,22 +56,21 @@ import static org.sonar.server.computation.task.projectanalysis.component.Report
public class SendIssueNotificationsStepTest extends BaseStepTest {
- static final String PROJECT_UUID = "PROJECT_UUID";
- static final String PROJECT_KEY = "PROJECT_KEY";
- static final String PROJECT_NAME = "PROJECT_NAME";
+ private static final String PROJECT_UUID = "PROJECT_UUID";
+ private static final String PROJECT_KEY = "PROJECT_KEY";
+ private static final String PROJECT_NAME = "PROJECT_NAME";
- static final String BRANCH_COMPONENT_UUID = "BRANCH_UUID";
- static final String BRANCH_COMPONENT_KEY = "BRANCH_KEY";
- static final String BRANCH_COMPONENT_NAME = "BRANCH_NAME";
- static final String BRANCH_NAME = "feature";
+ private static final String BRANCH_COMPONENT_UUID = "BRANCH_UUID";
+ private static final String BRANCH_COMPONENT_NAME = "BRANCH_NAME";
+ private static final String BRANCH_NAME = "feature";
- static final long ANALYSE_DATE = 123L;
+ private static final long ANALYSE_DATE = 123L;
- static final Duration ISSUE_DURATION = Duration.create(100L);
- static final String ISSUE_ASSIGNEE = "John";
+ private static final Duration ISSUE_DURATION = Duration.create(100L);
+ private static final String ISSUE_ASSIGNEE = "John";
- static final Component PROJECT = builder(Type.PROJECT, 1).setUuid(PROJECT_UUID).setKey(PROJECT_KEY).setName(PROJECT_NAME).build();
- static final Component BRANCH = builder(Type.PROJECT, 2).setUuid(BRANCH_COMPONENT_UUID).setKey(BRANCH_COMPONENT_KEY).setName(BRANCH_COMPONENT_NAME).build();
+ private static final Component PROJECT = builder(Type.PROJECT, 1).setUuid(PROJECT_UUID).setPublicKey(PROJECT_KEY).setName(PROJECT_NAME).build();
+ private static final Component BRANCH = builder(Type.PROJECT, 2).setUuid(BRANCH_COMPONENT_UUID).setPublicKey(PROJECT_KEY).setName(BRANCH_COMPONENT_NAME).build();
@Rule
public TreeRootHolderRule treeRootHolder = new TreeRootHolderRule()
@@ -80,7 +78,6 @@ public class SendIssueNotificationsStepTest extends BaseStepTest {
@Rule
public AnalysisMetadataHolderRule analysisMetadataHolder = new AnalysisMetadataHolderRule()
- .setProject(new Project(PROJECT_UUID, PROJECT_KEY, PROJECT_NAME))
.setBranch(new DefaultBranchImpl())
.setAnalysisDate(new Date(ANALYSE_DATE));