-
Notifications
You must be signed in to change notification settings - Fork 57
/
benten-mock.feature
172 lines (149 loc) · 6.04 KB
/
benten-mock.feature
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
Feature: benten mock
Background:
* def stories = {}
* def users = {}
* def delay = function(){ java.lang.Thread.sleep(1000) }
* def nextId = call read('increment.js')
Scenario: pathMatches('/rest/api/2/search') && methodIs('get')
* eval jql = requestParams.jql
* def assignee = undefined
* eval
"""
var regex = /assignee=\s*(.*?)\s*ORDER BY updated DESC/g;
assignee = regex.exec(jql);
"""
* def response = {}
* def issues = []
* eval userStories = stories
* def fun = function(){ var filteredIssues = {} ; filteredIssues.issues = []; for(key in stories){ if(stories[key] != undefined && stories[key].fields != undefined && stories[key].fields.assignee!=undefined )if(stories[key].fields.assignee.name == assignee[1]){filteredIssues.issues.push(stories[key])}} return filteredIssues;}
* eval filteredIssues = fun()
* print filteredIssues
* def response = filteredIssues
* def afterScenario = delay
Scenario: pathMatches('/rest/api/2/issue/{id}/transitions') && methodIs('get')
* def responseStatus = 200
* def response = read('transitions.json')
* def afterScenario = delay
Scenario: methodIs('post') && pathMatches('/rest/api/2/issue/{id}/transitions')
* eval key = pathParams.id
* def story = stories[key]
* def transition = request.transition
* eval
"""
if(story)
{
if(transition){
story.fields.status.name = transition.to.name;
}
}
"""
* def responseStatus = story ? 204 : 404
* def response = story ? "" : {"errorMessages":["Issue Does Not Exist"],"errors":{}}
* def afterScenario = delay
Scenario: pathMatches('/rest/api/2/issue/{id}/comment') && methodIs('post')
* eval key = pathParams.id
* def story = stories[key]
* def comment = request
* eval
"""
if(story)
{
if(!story.fields.comment)
{
story.fields.comment = {}
story.fields.comment.comments = [];
}
story.fields.comment.comments.push(comment);
}
"""
* def responseStatus = story ? 201 : 404
* def response = story ? "" : {"errorMessages":["Issue Does Not Exist"],"errors":{}}
* def afterScenario = delay
Scenario: pathMatches('/rest/api/2/issue/{id}') && methodIs('put')
* print hello
* def responseStatus = 204
* eval key = pathParams.id
* def story = stories[key]
* eval
"""
if(story) {
if(request.fields.assignee) {
story.fields.assignee = request.fields.assignee;
story.fields.assignee.displayName = request.fields.assignee.name;
}
if(request.fields.reporter){
story.fields.reporter = request.fields.reporter;
story.fields.reporter.displayName = request.fields.reporter.name;
}
}
"""
* print story
* def responseStatus = story ? 204 : 404
* def response = story ? story : {"errorMessages":["Issue Does Not Exist"],"errors":{}}
* def afterScenario = delay
Scenario: pathMatches('/rest/api/2/issue/createmeta') && methodIs('get')
* def response = read('create-metadata-response.json')
* eval response.projects[0].key = requestParams.projectKeys[0]
* def afterScenario = delay
Scenario: pathMatches('/rest/api/2/issue/{id}') && methodIs('get')
* eval key = pathParams.id
* def story = stories[key]
* print story
* def responseStatus = story ? 200 : 404
* def response = story ? story : {"errorMessages":["Issue Does Not Exist"],"errors":{}}
* def afterScenario = delay
Scenario: pathMatches('/rest/api/2/issue') && methodIs('post')
* eval key = request.fields.project.key+'-'+nextId()
* def story = { key : '#(key)',fields : { priority : {name : 'P2:MEDIUM'}, status : {name : 'New'}, issuetype : '#(request.fields.issuetype)', description: '#(request.fields.description)', summary : '#(request.fields.summary)'}}
* eval stories[key] = story
* print stories
* def response = story
* def responseStatus = 201
* def afterScenario = delay
Scenario: pathMatches('/rest/api/2/issue/{id}/worklog') && methodIs('post')
* eval key = pathParams.id
* print 'here' + key
* def story = stories[key]
* def worklog = request
* print 'here' + story
* eval
"""
if(story) {
if(!story.fields.worklog){
story.fields.worklog = {};
story.fields.worklog.worklogs= [];
}
story.fields.worklog.worklogs.push(worklog);
}
"""
* def responseStatus = story ? 201 : 404
* def response = story ? story : {"errorMessages":["Issue Does Not Exist"],"errors":{}}
* def afterScenario = delay
Scenario: pathMatches('/rest/agile/1.0/sprint/{id}/issue')
* def response = read('sprint-issues-get-response.json')
* def afterScenario = delay
Scenario: pathMatches('/rest/agile/1.0/board')
* def response = read('board-get-response.json')
* def afterScenario = delay
Scenario: pathMatches('/rest/greenhopper/1.0/sprintquery/{id}')
* def response = read('sprint-by-boardid.json')
* def afterScenario = delay
Scenario: pathMatches('/rest/greenhopper/1.0/rapid/charts/sprintreport')
* def response = read('get-sprint-report.json')
* def afterScenario = delay
Scenario: pathMatches('/job/{name}/api/json')
* print requestHeaders
* def response = read('job-by-name.json')
Scenario: pathMatches('/api/json')
* def response = read('all-jobs.json')
Scenario: pathMatches('/job/{name}/build/api/json') && methodIs('post')
* def responseStatus = 200
* def response = read('job-by-name.json')
* def responseHeaders = {}
* set responseHeaders.Location = 'https://localhost:8001/queue/item/445/'
Scenario: pathMatches('/job/{name}/{buildnumber}/api/json') && methodIs('get')
* def responseStatus = 200
* def response = read('job-by-build.json')
Scenario:
* print request
* def response = {}