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())
return "Generate Quality gate events";
}
- private String getMainBranchProjectKey() {
- return analysisMetadataHolder.getProject().getKey();
- }
}
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);
}
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());
.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());
return analysisMetadataHolder.getBranch().filter(b -> !b.isMain()).map(Branch::getName).orElse(null);
}
- private String getMainBranchProjectKey() {
- return analysisMetadataHolder.getProject().getKey();
- }
-
}
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();
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();
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);
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;
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()
@Rule
public AnalysisMetadataHolderRule analysisMetadataHolder = new AnalysisMetadataHolderRule()
- .setProject(new Project(PROJECT_UUID, PROJECT_KEY, PROJECT_NAME))
.setBranch(new DefaultBranchImpl())
.setAnalysisDate(new Date(ANALYSE_DATE));