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

bugfix: Support accountID for AssignIssue step for GDPR [JENKINS-61132] #113

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
Original file line number Diff line number Diff line change
Expand Up @@ -193,10 +193,15 @@ public ResponseData<Object> updateIssue(final String issueIdOrKey, final Object
}
}

public ResponseData<Void> assignIssue(final String issueIdorKey, final String userName) {
public ResponseData<Void> assignIssue(final String issueIdorKey, final String userName,
final String accountId) {
try {
Map input = Maps.newHashMap();
input.put("name", userName);
if (userName != null) {
input.put("name", userName);
} else {
input.put("accountId", accountId);
}
return parseResponse(
jiraEndPoints
.assignIssue(issueIdorKey, input)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,11 @@ protected ResponseData<Void> run() throws Exception {
ResponseData<Void> response = verifyInput();

if (response == null) {
final String userName = Util.fixEmpty(step.getUserName()) == null ? Util.fixEmpty(step.getAccountId()) : Util.fixEmpty(step.getUserName());
final String userName = Util.fixEmpty(step.getUserName());
final String accountId = Util.fixEmpty(step.getAccountId());
logger.println("JIRA: Site - " + siteName + " - Assigning issue: " + step.getIdOrKey()
+ " to: " + userName);
response = jiraService.assignIssue(step.getIdOrKey(), userName);
+ " to username: " + userName + " / accountId: " + accountId);
response = jiraService.assignIssue(step.getIdOrKey(), userName, accountId);
}

return logResponse(response);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public void setup() throws IOException, InterruptedException {
doNothing().when(printStreamMock).println();

final ResponseDataBuilder<Void> builder = ResponseData.builder();
when(jiraServiceMock.assignIssue(any(), any()))
when(jiraServiceMock.assignIssue(any(), any(), any()))
.thenReturn(builder.successful(true).code(200).message("Success").build());

when(contextMock.get(Run.class)).thenReturn(runMock);
Expand Down Expand Up @@ -99,7 +99,7 @@ public void testWithEmptyUserNameOrAccountIdThrowsAbortException() throws Except
stepExecution.run();

// Assert Test
verify(jiraServiceMock, times(1)).assignIssue("TEST-1", null);
verify(jiraServiceMock, times(1)).assignIssue("TEST-1", null, null);
assertThat(step.isFailOnError()).isEqualTo(true);
}

Expand All @@ -112,7 +112,7 @@ public void testSuccessfulUnassignIssue() throws Exception {
stepExecution.run();

// Assert Test
verify(jiraServiceMock, times(1)).assignIssue("TEST-1", null);
verify(jiraServiceMock, times(1)).assignIssue("TEST-1", null, null);
assertThat(step.isFailOnError()).isEqualTo(true);
}

Expand All @@ -125,7 +125,7 @@ public void testSuccessfulAssignIssue() throws Exception {
stepExecution.run();

// Assert Test
verify(jiraServiceMock, times(1)).assignIssue("TEST-1", "testUser");
verify(jiraServiceMock, times(1)).assignIssue("TEST-1", "testUser", null);
assertThat(step.isFailOnError()).isEqualTo(true);
}

Expand All @@ -138,7 +138,7 @@ public void testSuccessfulAssignIssueByAccountId() throws Exception {
stepExecution.run();

// Assert Test
verify(jiraServiceMock, times(1)).assignIssue("TEST-1", "testUser");
verify(jiraServiceMock, times(1)).assignIssue("TEST-1", null, "testUser");
assertThat(step.isFailOnError()).isEqualTo(true);
}
}