Skip to content

Commit

Permalink
chore: Add E2E tests for Jira add comment sink Kamelet
Browse files Browse the repository at this point in the history
  • Loading branch information
christophd committed Jun 4, 2024
1 parent 06d6447 commit 88798a4
Show file tree
Hide file tree
Showing 6 changed files with 169 additions and 0 deletions.
23 changes: 23 additions & 0 deletions test/jira/jira-add-comment-response.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"self": "yaks:resolveURL('jira-service')/rest/api/latest/issue/${jira.issue.id}/comment/${jira.issue.comment.id}",
"id": "${jira.issue.comment.id}",
"author": {
"self": "yaks:resolveURL('jira-service')/rest/api/latest/user?username=yaks",
"name": "yaks",
"displayName": "YAKS User",
"active": false
},
"body": "${jira.issue.comment}",
"updateAuthor": {
"self": "yaks:resolveURL('jira-service')/rest/api/latest/user?username=yaks",
"name": "yaks",
"displayName": "YAKS User",
"active": false
},
"created": "yaks:currentDate(yyyy-MM-dd'T'HH:mm:ss.SZ)",
"updated": "yaks:currentDate(yyyy-MM-dd'T'HH:mm:ss.SZ)",
"visibility": {
"type": "role",
"value": "Users"
}
}
36 changes: 36 additions & 0 deletions test/jira/jira-add-comment-sink-pipe.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
apiVersion: camel.apache.org/v1
kind: Pipe
metadata:
name: jira-add-comment-sink-pipe
spec:
source:
ref:
kind: Kamelet
apiVersion: camel.apache.org/v1
name: timer-source
properties:
period: ${timer.source.period}
message: '${jira.issue.comment}'
steps:
- ref:
kind: Kamelet
apiVersion: camel.apache.org/v1
name: insert-header-action
properties:
name: issueKey
value: ${jira.issue.key}
- ref:
kind: Kamelet
apiVersion: camel.apache.org/v1
name: log-action
properties:
showHeaders: true
sink:
ref:
kind: Kamelet
apiVersion: camel.apache.org/v1
name: jira-add-comment-sink
properties:
jiraUrl: yaks:resolveURL('jira-service')
username: ${jira.username}
password: ${jira.password}
56 changes: 56 additions & 0 deletions test/jira/jira-add-comment-sink.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
Feature: Jira Kamelet - Sink

Background:
Given variables
| timer.source.period | 10000 |
| jira.project.key | CAMEL |
| jira.project.id | 10001 |
| jira.issue.id | 10001 |
| jira.issue.key | CAMEL-10001 |
| jira.issue.summary | New bug, citrus:randomString(10) |
| jira.issue.assignee | Superman |
| jira.issue.type | Bug |
| jira.issue.description | Sample bug |
| jira.issue.comment | New comment, citrus:randomString(10) |
| jira.issue.comment.id | 10001 |
| jira.username | yaks |
| jira.password | secr3t |
Given HTTP server timeout is 120000 ms
Given HTTP server "jira-service"

Scenario: Create Http server
Given create Kubernetes service jira-service

Scenario: Verify Jira events
# Create binding
Given load Pipe jira-add-comment-sink-pipe.yaml
# Verify get issue request
Given expect HTTP request header: Authorization="Basic citrus:encodeBase64(${jira.username}:${jira.password})"
When receive GET /rest/api/latest/issue/${jira.issue.key}
Then HTTP response header: Content-Type="application/json"
And HTTP response body: yaks:readFile('jira-get-issue-response.json')
Then send HTTP 200 OK
# Verify add comment request
Given expect HTTP request header: Authorization="Basic citrus:encodeBase64(${jira.username}:${jira.password})"
When receive GET /rest/api/latest/serverInfo
Then HTTP response body: yaks:readFile('jira-server-info.json')
Then send HTTP 200 OK
# Verify add comment request
Given expect HTTP request header: Authorization="Basic citrus:encodeBase64(${jira.username}:${jira.password})"
Then expect HTTP request body
"""
{
"body": "${jira.issue.comment}"
}
"""
When receive POST /rest/api/latest/issue/${jira.issue.key}/comment
Then HTTP response body: yaks:readFile('jira-add-comment-response.json')
Then send HTTP 200 OK
# Verify event
And Camel K integration jira-add-comment-sink-pipe should print ${jira.issue.comment}

Scenario: Remove resources
# Remove Camel K binding
Given delete Pipe jira-add-comment-sink-pipe
Given delete Kubernetes service jira-service
And stop server component jira-service
35 changes: 35 additions & 0 deletions test/jira/jira-get-issue-response.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"expand": "schema,names",
"id": "${jira.issue.id}",
"key": "${jira.issue.key}",
"self": "yaks:resolveURL('jira-service')/rest/api/latest/issue/${jira.issue.key}",
"transitions": "yaks:resolveURL('jira-service')/rest/api/latest/issue/${jira.issue.key}/transitions",
"names": {},
"schema": {},
"fields": {
"project": {
"self": "yaks:resolveURL('jira-service')/rest/api/latest/project/${jira.project.id}",
"id": "${jira.project.id}",
"key": "CAMEL"
},
"summary": "${jira.issue.summary}",
"custom": "${jira.issue.key}",
"issuetype": {
"self": "yaks:resolveURL('jira-service')/rest/api/latest/issuetype/3",
"id": "3",
"description": "A task that needs to be done.",
"iconUrl": "yaks:resolveURL('jira-service')/images/icons/task.gif",
"name": "Task",
"subtask": false
},
"created": "yaks:currentDate(yyyy-MM-dd'T'HH:mm:ss.SZ)",
"updated": "yaks:currentDate(yyyy-MM-dd'T'HH:mm:ss.SZ)",
"status": {
"self": "yaks:resolveURL('jira-service')/rest/api/latest/status/1",
"id": 1,
"description": "Open task.",
"iconUrl": "yaks:resolveURL('jira-service')/images/icons/status_1.gif",
"name": "Open"
}
}
}
15 changes: 15 additions & 0 deletions test/jira/jira-server-info.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"baseUrl": "yaks:resolveURL('jira-service')",
"version": "5.0.0",
"versionNumbers": [
5,
0,
0
],
"buildNumber": 581,
"buildDate": "yaks:currentDate(yyyy-MM-dd'T'HH:mm:ss.SZ)",
"serverTime": "yaks:currentDate(yyyy-MM-dd'T'HH:mm:ss.SZ)",
"scmInfo": "yaks:randomString(40, LOWERCASE)",
"buildPartnerName": "YAKS Co.",
"serverTitle": "Test Jira Server"
}
4 changes: 4 additions & 0 deletions test/jira/yaks-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ config:
- jira-credentials.properties
- jira-source-pipe.yaml
- jira-add-issue-sink-pipe.yaml
- jira-add-comment-sink-pipe.yaml
- jira-server-info.json
- jira-add-comment-response.json
- jira-get-issue-response.json
- jira-create-issue-request.json
- jira-create-issue-response.json
- jira-issue-types.json
Expand Down

0 comments on commit 88798a4

Please sign in to comment.