Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add possibility to assigned jira to user #8

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/main/java/org/sonar/plugins/jira/JiraConstants.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ public final class JiraConstants {

public static final String JIRA_ISSUE_COMPONENT_ID = "sonar.jira.issue.component.id";

public static final String JIRA_ASSIGNEE = "sonar.jira.issue.assigne";

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo in sonar property name? Should be sonar.jira.issue.assignee


private JiraConstants() {
}

Expand Down
10 changes: 10 additions & 0 deletions src/main/java/org/sonar/plugins/jira/reviews/JiraIssueCreator.java
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,15 @@
global = false,
project = true,
type = PropertyType.INTEGER
),
@Property(
key = JiraConstants.JIRA_ASSIGNEE,
defaultValue = "",
name = "Jira issues assignee",
description = "Which person to assign jira",
global = true,
project = true,
type = PropertyType.STRING
)
})
public class JiraIssueCreator implements ServerExtension {
Expand Down Expand Up @@ -210,6 +219,7 @@ protected RemoteIssue initRemoteIssue(Issue sonarIssue, Settings settings) {
issue.setPriority(sonarSeverityToJiraPriorityId(RulePriority.valueOf(sonarIssue.severity()), settings));
issue.setSummary(generateIssueSummary(sonarIssue));
issue.setDescription(generateIssueDescription(sonarIssue, settings));
issue.setAssignee(settings.getString(JiraConstants.JIRA_ASSIGNEE));
if (settings.hasKey(JiraConstants.JIRA_ISSUE_COMPONENT_ID)) {
String componentId = settings.getString(JiraConstants.JIRA_ISSUE_COMPONENT_ID);
RemoteComponent rc = new RemoteComponent();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,27 @@ public void shouldInitRemoteIssueWithTaskType() throws Exception {
assertThat(returnedIssue).isEqualTo(expectedIssue);
}

@Test
public void shouldInitRemoteIssueWithAssignee() throws Exception {
// Given that
settings.setProperty(JiraConstants.JIRA_ASSIGNEE, "JohnDoe");
RemoteIssue expectedIssue = new RemoteIssue();
expectedIssue.setProject("TEST");
expectedIssue.setType("3");
expectedIssue.setPriority("4");
expectedIssue.setSummary("SonarQube Issue #ABCD - Avoid cycle between java packages");
expectedIssue.setDescription("Issue detail:\n{quote}\nThe Cyclomatic Complexity of this method is 14 which is greater than 10 authorized.\n" +
"{quote}\n\n\nCheck it on SonarQube: http://my.sonar.com/issue/show/ABCD");
expectedIssue.setAssignee("JohnDoe");

// Verify
RemoteIssue returnedIssue = jiraIssueCreator.initRemoteIssue(sonarIssue, settings);

assertThat(returnedIssue.getSummary()).isEqualTo(expectedIssue.getSummary());
assertThat(returnedIssue.getDescription()).isEqualTo(expectedIssue.getDescription());
assertThat(returnedIssue).isEqualTo(expectedIssue);
}

@Test
public void shouldInitRemoteIssueWithComponent() throws Exception {
// Given that
Expand Down