-
Notifications
You must be signed in to change notification settings - Fork 654
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(jira): Add Jira issue transition to JiraNotificationService (#1080)
* feat(jira): Add Jira issue transition to JiraNotificationService `transitionContext` payload can be the full Jira transition REST API payload, however the transition ID will be looked up based on the transition name * feat(jira): Fixup and add ability to optionally send comment when transitioning issue
- Loading branch information
Showing
4 changed files
with
283 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
...ations/src/test/groovy/com/netflix/spinnaker/echo/jira/JiraNotificationServiceSpec.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package com.netflix.spinnaker.echo.jira | ||
|
||
import com.fasterxml.jackson.databind.ObjectMapper | ||
import com.netflix.spinnaker.echo.api.Notification | ||
import com.netflix.spinnaker.echo.jackson.EchoObjectMapper | ||
import com.netflix.spinnaker.kork.core.RetrySupport | ||
import spock.lang.Specification | ||
import spock.lang.Unroll | ||
|
||
|
||
class JiraNotificationServiceSpec extends Specification { | ||
|
||
def jiraService = Mock(JiraService) | ||
def retrySupport = new RetrySupport() | ||
def objectMapper = EchoObjectMapper.getInstance() | ||
JiraNotificationService service = new JiraNotificationService(jiraService, retrySupport, objectMapper) | ||
|
||
@Unroll | ||
void 'Handles Jira transition, calls comment if comment is set'() { | ||
given: | ||
def notification = new Notification( | ||
notificationType: "JIRA", | ||
source: new Notification.Source(user: "foo@example.com"), | ||
additionalContext: [ | ||
jiraIssue: "EXMPL-0000", | ||
comment: comment, | ||
transitionContext: [ | ||
transition: [ | ||
name: "Done" | ||
] | ||
] | ||
] | ||
) | ||
|
||
when: | ||
service.handle(notification) | ||
|
||
then: | ||
1 * jiraService.getIssueTransitions(_) >> new JiraService.IssueTransitions(transitions: [new JiraService.IssueTransitions.Transition(name: "Done", id: "4")]) | ||
1 * jiraService.transitionIssue(_, _) | ||
addCommentCall * jiraService.addComment(_, _) | ||
|
||
where: | ||
comment || addCommentCall | ||
null || 0 | ||
"testing 1234" || 1 | ||
} | ||
} |