jirarest2 0.0.9 → 0.0.10
Sign up to get free protection for your applications and to get access to all the features.
- data.tar.gz.sig +0 -0
- data/History.txt +10 -0
- data/Manifest.txt +4 -0
- data/README.txt +2 -0
- data/bin/jira_comment +156 -0
- data/bin/jira_create_issue +0 -4
- data/lib/jirarest2.rb +2 -1
- data/lib/jirarest2/connect.rb +19 -11
- data/lib/jirarest2/exceptions.rb +6 -2
- data/lib/jirarest2/services.rb +12 -3
- data/lib/jirarest2/services/comment.rb +118 -0
- data/test/data/get-comments.txt +5 -0
- data/test/data/issuespec.txt +1 -10
- data/test/test_comment.rb +88 -0
- data/test/test_connect.rb +0 -4
- data/test/test_result.rb +3 -1
- data/test/test_watcher.rb +1 -1
- metadata +8 -2
- metadata.gz.sig +0 -0
data.tar.gz.sig
CHANGED
Binary file
|
data/History.txt
CHANGED
@@ -1,3 +1,13 @@
|
|
1
|
+
=== 0.0.10 / 2012-08-02
|
2
|
+
|
3
|
+
* 1 major enhancement:
|
4
|
+
|
5
|
+
* Added exceptions for return code 400 and 400 in the main executer
|
6
|
+
|
7
|
+
* 1 minor enhancements:
|
8
|
+
|
9
|
+
* Added jira_comment to work with comments. It's not very nice to errors and there might be some work with. This fixes #12
|
10
|
+
|
1
11
|
=== 0.0.9 / 2012-07-27
|
2
12
|
|
3
13
|
* 1 major enhancement:
|
data/Manifest.txt
CHANGED
@@ -5,6 +5,7 @@ Manifest.txt
|
|
5
5
|
README.txt
|
6
6
|
Rakefile
|
7
7
|
bin/create_issue.rb
|
8
|
+
bin/jira_comment
|
8
9
|
bin/jira_create_issue
|
9
10
|
bin/jira_create_issue.rb
|
10
11
|
bin/jira_watcher
|
@@ -17,16 +18,19 @@ lib/jirarest2/issue.rb
|
|
17
18
|
lib/jirarest2/madbitconfig.rb
|
18
19
|
lib/jirarest2/result.rb
|
19
20
|
lib/jirarest2/services.rb
|
21
|
+
lib/jirarest2/services/comment.rb
|
20
22
|
lib/jirarest2/services/issuelink.rb
|
21
23
|
lib/jirarest2/services/issuelinktype.rb
|
22
24
|
lib/jirarest2/services/watcher.rb
|
23
25
|
lib/jirarest2bin.rb
|
26
|
+
test/data/get-comments.txt
|
24
27
|
test/data/issuespec.txt
|
25
28
|
test/data/test.config.data
|
26
29
|
test/data/test.json
|
27
30
|
test/data/test.nojson
|
28
31
|
test/data/test.nojson1
|
29
32
|
test/data/ticket.json
|
33
|
+
test/test_comment.rb
|
30
34
|
test/test_connect.rb
|
31
35
|
test/test_credentials.rb
|
32
36
|
test/test_issue.rb
|
data/README.txt
CHANGED
@@ -22,11 +22,13 @@ There are scripts to create new issues with watchers and link those to existing
|
|
22
22
|
* Still in the alpha stages. The classes are still pretty volatile.
|
23
23
|
* jira_create_issue allows you to create new issues with watchers and link those to existing issues
|
24
24
|
* jira_watcher allows you to manipulate watchers on existing issues
|
25
|
+
* jira_comment allows you to add read and update comments. (The latter only if you know the right comment id)
|
25
26
|
|
26
27
|
== SYNOPSIS:
|
27
28
|
|
28
29
|
jira_create_issue -h
|
29
30
|
jira_watcher -h
|
31
|
+
jira_comment -h
|
30
32
|
|
31
33
|
== REQUIREMENTS:
|
32
34
|
|
data/bin/jira_comment
ADDED
@@ -0,0 +1,156 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
# Copyright (C) 2012 Cyril Bitterich
|
4
|
+
#
|
5
|
+
# This program is free software: you can redistribute it and/or modify
|
6
|
+
# it under the terms of the GNU General Public License as published by
|
7
|
+
# the Free Software Foundation, either version 3 of the License, or
|
8
|
+
# (at your option) any later version.
|
9
|
+
#
|
10
|
+
# This program is distributed in the hope that it will be useful,
|
11
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13
|
+
# GNU General Public License for more details.
|
14
|
+
#
|
15
|
+
# You should have received a copy of the GNU General Public License
|
16
|
+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
17
|
+
|
18
|
+
|
19
|
+
require "jirarest2bin"
|
20
|
+
require "pp"
|
21
|
+
|
22
|
+
# Check for the minimum ruby version we need
|
23
|
+
Jirarest2Bin::check_ruby_version
|
24
|
+
|
25
|
+
class ParseOptions
|
26
|
+
|
27
|
+
=begin
|
28
|
+
Parse the command line parameters
|
29
|
+
@return [Array] returns two hashes. The first one contains the options for the issue, the second one for the execution of the script
|
30
|
+
=end
|
31
|
+
def self.parse(args)
|
32
|
+
issueopts = OpenStruct.new
|
33
|
+
scriptopts = OpenStruct.new
|
34
|
+
scriptopts.configfile = "~/.jiraconfig"
|
35
|
+
scriptopts.ofs = "\n"
|
36
|
+
|
37
|
+
|
38
|
+
opts = OptionParser.new do |opts|
|
39
|
+
opts.banner = "Usage: #{__FILE__} [options]"
|
40
|
+
scriptopts = Jirarest2Bin::defaultoptions(opts,scriptopts)
|
41
|
+
|
42
|
+
opts.on("-i", "--issue ISSUE,ISSUE,...", Array, "Issues to work on") do |i|
|
43
|
+
issueopts.issues = i
|
44
|
+
end
|
45
|
+
|
46
|
+
opts.on("-d", "--id COMMENTID", "ID number of the comment (for remove and set/update)") do |i|
|
47
|
+
issueopts.commentid = i
|
48
|
+
end
|
49
|
+
|
50
|
+
opts.on("-t", "--text TEXT", "Text for the comment to add/update") do |w|
|
51
|
+
issueopts.text = w
|
52
|
+
end
|
53
|
+
|
54
|
+
opts.on("-c", "--command [command]",[:add,:remove,:view,:get,:set,:update], "What to do with the comment(s) on the issues (add, remove,set)") do |c|
|
55
|
+
c = :set if c == :update
|
56
|
+
c = :get if c == :view
|
57
|
+
scriptopts.command = c
|
58
|
+
end
|
59
|
+
|
60
|
+
opts.on("-O", "--field-seperator CHAR", "Output field separator. Set this if you want the output to be formatted in one line for example.") do |ofs|
|
61
|
+
scriptopts.ofs = ofs
|
62
|
+
end
|
63
|
+
|
64
|
+
opts.on("-v", "--verbose", "Tell what I did in great detail") do |v|
|
65
|
+
scriptopts.verbose = v
|
66
|
+
end
|
67
|
+
end # OptionParser.new
|
68
|
+
|
69
|
+
opts.parse!(args)
|
70
|
+
return issueopts, scriptopts
|
71
|
+
|
72
|
+
end #parse
|
73
|
+
end # class
|
74
|
+
|
75
|
+
@issueopts, @scriptopts = ParseOptions.parse(ARGV)
|
76
|
+
|
77
|
+
# Print the issues to STDOUT
|
78
|
+
# We use the instance-varable @scriptopts.ofs here
|
79
|
+
# @param [String] issue The Key of the Issue these comments belong to
|
80
|
+
# @param [Array(CommentElement)] results An Array of CommentElement
|
81
|
+
def print_results(issue,results)
|
82
|
+
output = Array.new
|
83
|
+
if results.size == 0 then
|
84
|
+
output << "There are no comments for #{issue}."
|
85
|
+
else
|
86
|
+
output << "Comment(s) for #{issue}:"
|
87
|
+
end
|
88
|
+
results.each { |result|
|
89
|
+
output << result.text
|
90
|
+
output << "Created on #{result.cdate.to_s}"
|
91
|
+
output << "Last written by: #{result.author} on #{result.mdate.to_s}"
|
92
|
+
}
|
93
|
+
puts output.join(@scriptopts.ofs)
|
94
|
+
|
95
|
+
end
|
96
|
+
|
97
|
+
# Calls the issues and get the comments of each issue in return.
|
98
|
+
# @param [Array] issues An Array containing the issuekeys
|
99
|
+
# @param [Fixnum] id Identidication number of the comment to view
|
100
|
+
def view_comments(issues,id = nil)
|
101
|
+
connection = Jirarest2Bin::get_connection(@scriptopts,@connection)
|
102
|
+
result = Array.new
|
103
|
+
if id.nil? then
|
104
|
+
issues.each { |issue|
|
105
|
+
connectedissue = Comment.new(connection,issue)
|
106
|
+
result << connectedissue.get
|
107
|
+
print_results(issue,result.flatten.compact)
|
108
|
+
}
|
109
|
+
else
|
110
|
+
connectedissue = Comment.new(connection,issues[0],id)
|
111
|
+
result << connectedissue.get
|
112
|
+
print_results(issues,result.flatten.compact)
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
116
|
+
# Calls the issues and runs the needed work on it with the given users by opening the connection to the server, looking for the issue identified by the key and executing the string
|
117
|
+
# @param [Array] issues Issues to work with
|
118
|
+
# @param [Array] text Text to work with
|
119
|
+
# @param [String] method Kind of work to be done
|
120
|
+
# @param [Fixnum] id Identifier of the comment
|
121
|
+
def work(issues,text,method,id = nil)
|
122
|
+
connection = Jirarest2Bin::get_connection(@scriptopts,@connection)
|
123
|
+
issues.each{ |issue|
|
124
|
+
connectedissue = Comment.new(connection, issue, id)
|
125
|
+
connectedissue.send method, text
|
126
|
+
if @scriptopts.verbose then
|
127
|
+
if id.nil? then
|
128
|
+
puts "Used #{method} on issue #{issue}"
|
129
|
+
else
|
130
|
+
puts "Used #{method} on the comment #{id} on issue #{issue}"
|
131
|
+
end
|
132
|
+
end
|
133
|
+
}
|
134
|
+
end
|
135
|
+
|
136
|
+
if @scriptopts.writeconf then
|
137
|
+
Jirarest2Bin::write_configfile(@scriptopts)
|
138
|
+
end
|
139
|
+
|
140
|
+
Jirarest2Bin::required_argument("issue") if @issueopts.issues.nil?
|
141
|
+
case @scriptopts.command
|
142
|
+
when :add
|
143
|
+
Jirarest2Bin::required_argument("text") if @issueopts.text.nil?
|
144
|
+
work(@issueopts.issues,@issueopts.text,"add")
|
145
|
+
when :remove
|
146
|
+
Jirarest2Bin::required_argument("id") if @issueopts.commentid.nil?
|
147
|
+
work(@issueopts.issues,"","delete",@issueopts.commentid)
|
148
|
+
when :set
|
149
|
+
Jirarest2Bin::required_argument("id") if @issueopts.commentid.nil?
|
150
|
+
Jirarest2Bin::required_argument("text") if @issueopts.text.nil?
|
151
|
+
work(@issueopts.issues,@issueopts.text,"update",@issueopts.commentid)
|
152
|
+
when :get
|
153
|
+
view_comments(@issueopts.issues, @issueopts.commentid)
|
154
|
+
else
|
155
|
+
puts "Don't know what to do. Please set -c"
|
156
|
+
end
|
data/bin/jira_create_issue
CHANGED
@@ -199,13 +199,9 @@ def get_jsondata_from_file
|
|
199
199
|
content = Hash.new
|
200
200
|
if data["metadata"] then # We have metadata and content
|
201
201
|
content = data["content"]
|
202
|
-
pp "metadata"
|
203
202
|
@issueopts.project = data["metadata"]["project"] if data["metadata"]["project"]
|
204
203
|
@issueopts.issue = data["metadata"]["issue"] if data["metadata"]["issue"]
|
205
|
-
pp data["metadata"]["watcher"].class
|
206
|
-
pp data["metadata"]["watcher"]
|
207
204
|
@issueopts.watchers = data["metadata"]["watcher"] if data["metadata"]["watcher"]
|
208
|
-
pp data["metadata"]["link"]
|
209
205
|
@scriptopts.linkdestkey, @scriptopts.linktype = data["metadata"]["link"].flatten if data["metadata"]["link"]
|
210
206
|
else # We have the simple format that carries only the content
|
211
207
|
content = data
|
data/lib/jirarest2.rb
CHANGED
@@ -17,7 +17,7 @@
|
|
17
17
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
18
18
|
#
|
19
19
|
|
20
|
-
VERSION = "0.0.
|
20
|
+
VERSION = "0.0.10"
|
21
21
|
|
22
22
|
require_relative "jirarest2/connect"
|
23
23
|
require_relative "jirarest2/issue"
|
@@ -26,3 +26,4 @@ require_relative "jirarest2/exceptions"
|
|
26
26
|
require_relative "jirarest2/services/watcher"
|
27
27
|
require_relative "jirarest2/services"
|
28
28
|
require_relative "jirarest2/services/issuelink"
|
29
|
+
require_relative "jirarest2/services/comment"
|
data/lib/jirarest2/connect.rb
CHANGED
@@ -44,9 +44,8 @@ class Connect
|
|
44
44
|
def execute(operation,uritail,data)
|
45
45
|
uri = nil
|
46
46
|
uri = URI(@CONNECTURL+uritail)
|
47
|
-
|
48
47
|
if data != "" then
|
49
|
-
if operation
|
48
|
+
if ! (operation == "Post" || operation == "Put") then # POST carries the payload in the body that's why we have to wait
|
50
49
|
uri.query = URI.encode_www_form(data)
|
51
50
|
end
|
52
51
|
end
|
@@ -57,27 +56,33 @@ class Connect
|
|
57
56
|
req["Content-Type"] = "application/json;charset=UTF-8"
|
58
57
|
|
59
58
|
if data != "" then
|
60
|
-
if operation == "Post" then # POST
|
59
|
+
if (operation == "Post" || operation == "Put") then # POST and PUT carry the payload in the body
|
61
60
|
@payload = data.to_json
|
62
61
|
req.body = @payload
|
63
62
|
end
|
64
63
|
end
|
65
64
|
|
65
|
+
|
66
66
|
# Ask the server
|
67
67
|
result = Net::HTTP.start(uri.host, uri.port) {|http|
|
68
68
|
http.request(req)
|
69
69
|
}
|
70
|
+
|
70
71
|
# deal with output
|
71
72
|
case result
|
72
|
-
when Net::
|
73
|
+
when Net::HTTPBadRequest # 400
|
74
|
+
raise Jirarest2::BadRequestError, result.body
|
75
|
+
when Net::HTTPUnauthorized # 401 No login-credentials oder wrong ones.
|
73
76
|
raise Jirarest2::AuthentificationError, result.body
|
74
|
-
when Net::HTTPForbidden #
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
77
|
+
when Net::HTTPForbidden # 403
|
78
|
+
if result.get_fields("x-authentication-denied-reason")[0] =~ /.*login-url=(.*)/ then #Captcha-Time
|
79
|
+
raise Jirarest2::AuthentificationCaptchaError, $1
|
80
|
+
else
|
81
|
+
raise Jirarest2::ForbiddenError, result.body
|
82
|
+
end
|
83
|
+
when Net::HTTPNotFound # 404
|
80
84
|
raise Jirarest2::NotFoundError, result.body
|
85
|
+
|
81
86
|
end
|
82
87
|
|
83
88
|
return Jirarest2::Result.new(result)
|
@@ -90,7 +95,10 @@ class Connect
|
|
90
95
|
begin
|
91
96
|
begin
|
92
97
|
ret = (execute("Get","dashboard","").code == "200")
|
93
|
-
|
98
|
+
# TODO is the 404 really possible?
|
99
|
+
rescue Jirarest2::NotFoundError
|
100
|
+
return false
|
101
|
+
rescue Jirarest2::BadRequestError
|
94
102
|
return false
|
95
103
|
end
|
96
104
|
end
|
data/lib/jirarest2/exceptions.rb
CHANGED
@@ -19,10 +19,14 @@
|
|
19
19
|
module Jirarest2
|
20
20
|
## connections.rb
|
21
21
|
|
22
|
-
#
|
22
|
+
# 400 -
|
23
|
+
class BadRequestError < StandardError ; end
|
24
|
+
# 401 Authentification failed
|
23
25
|
class AuthentificationError < StandardError ; end
|
24
|
-
# Authentification failed and JIRA(tm) requires a login with captcha to continue
|
26
|
+
# 403 Authentification failed and JIRA(tm) requires a login with captcha to continue
|
25
27
|
class AuthentificationCaptchaError < StandardError ; end
|
28
|
+
# 403 Authentification failed
|
29
|
+
class ForbiddenError < StandardError ; end
|
26
30
|
# 404 - Results in HTML body - not JSON
|
27
31
|
class NotFoundError < StandardError ; end
|
28
32
|
# Could not heal URI
|
data/lib/jirarest2/services.rb
CHANGED
@@ -28,7 +28,8 @@ class Services
|
|
28
28
|
end
|
29
29
|
|
30
30
|
# Send the GET request
|
31
|
-
# @param [Hash] data to be sent to Connection.execute
|
31
|
+
# @param [Hash,String] data to be sent to Connection.execute
|
32
|
+
# @return [Hash] The result as constructed by Connection.execute transformed from a json hash
|
32
33
|
def get(data = "")
|
33
34
|
return @connection.execute("Get",@uritail,data).result
|
34
35
|
end
|
@@ -36,15 +37,23 @@ class Services
|
|
36
37
|
|
37
38
|
# Send the POST request
|
38
39
|
# @param [Hash] data to be sent to Connection.execute
|
40
|
+
# @return [Result] The result as constructed by Connection.execute
|
39
41
|
def post(data = "")
|
40
42
|
return @connection.execute("Post",@uritail,data)
|
41
|
-
end
|
42
|
-
|
43
|
+
end
|
43
44
|
|
44
45
|
# Send the DELETE request
|
45
46
|
# @param [Hash] data to be sent to Connection.execute
|
47
|
+
# @return [Result] The result as constructed by Connection.execute
|
46
48
|
def delete(data = "")
|
47
49
|
return @connection.execute("Delete",@uritail,data)
|
48
50
|
end
|
49
51
|
|
52
|
+
# Send the PUT request
|
53
|
+
# @param [HASH] data to be sent to Connection.execute
|
54
|
+
# @return [Hash] The result as constructed by Connection.execute transformed from a json hash
|
55
|
+
def put(data = "")
|
56
|
+
return @connection.execute("Put",@uritail,data).result
|
57
|
+
end
|
58
|
+
|
50
59
|
end #class
|
@@ -0,0 +1,118 @@
|
|
1
|
+
# Comment class
|
2
|
+
# Copyright (C) 2012 Cyril Bitterich
|
3
|
+
#
|
4
|
+
# This program is free software: you can redistribute it and/or modify
|
5
|
+
# it under the terms of the GNU General Public License as published by
|
6
|
+
# the Free Software Foundation, either version 3 of the License, or
|
7
|
+
# (at your option) any later version.
|
8
|
+
#
|
9
|
+
# This program is distributed in the hope that it will be useful,
|
10
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
11
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
12
|
+
# GNU General Public License for more details.
|
13
|
+
#
|
14
|
+
# You should have received a copy of the GNU General Public License
|
15
|
+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
16
|
+
#
|
17
|
+
|
18
|
+
require "time"
|
19
|
+
require "jirarest2/connect"
|
20
|
+
require "jirarest2/services"
|
21
|
+
|
22
|
+
#TODO give nicer answers in return to work
|
23
|
+
|
24
|
+
# One single Comment
|
25
|
+
# TODO Maybe rewrite the initalize and then get a few other parameters like the issue-id or the comment-id
|
26
|
+
class CommentElement
|
27
|
+
#The author of the comment
|
28
|
+
# @return [String]
|
29
|
+
attr_reader :author
|
30
|
+
#text of the comment
|
31
|
+
# @return [String]
|
32
|
+
attr_reader :text
|
33
|
+
#creation date
|
34
|
+
# @return [Time]
|
35
|
+
attr_reader :cdate
|
36
|
+
#last modify date
|
37
|
+
# @return [Time]
|
38
|
+
attr_reader :mdate
|
39
|
+
|
40
|
+
# create one instance of an Comment
|
41
|
+
# @param [String] author (Last) author of the comment
|
42
|
+
# @param [String] text Text of the comment
|
43
|
+
# @param [Time,String] cdate Creation date of the comment
|
44
|
+
# @param [Time,String] mdate Date of last change to the comment
|
45
|
+
def initialize(author,text,cdate = Time.now,mdate = Time.now)
|
46
|
+
@author = author
|
47
|
+
@text = text
|
48
|
+
# parse time if needed
|
49
|
+
cdate = Time.parse(cdate) if cdate.instance_of?(String)
|
50
|
+
@cdate = cdate
|
51
|
+
mdate = Time.parse(mdate) if mdate.instance_of?(String)
|
52
|
+
@mdate = mdate
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
class Comment < Services
|
57
|
+
#TODO See to documentation for "DELETE" as we use the superclass here and it will not be shown
|
58
|
+
|
59
|
+
# Set our uritail
|
60
|
+
# @param [Connection] connection
|
61
|
+
# @param [String] issueid The id or key of the issue in question
|
62
|
+
def initialize(connection, issueid, commentid = nil)
|
63
|
+
if commentid then
|
64
|
+
@uritail = "issue/#{issueid}/comment/#{commentid}"
|
65
|
+
else
|
66
|
+
@uritail = "issue/#{issueid}/comment"
|
67
|
+
end
|
68
|
+
super(connection)
|
69
|
+
end
|
70
|
+
|
71
|
+
# Add a comment to an issue
|
72
|
+
# @param [String] text to add
|
73
|
+
# @return [Result] The result as constructed by Connection.execute
|
74
|
+
def add(text)
|
75
|
+
post({"body" => text})
|
76
|
+
end
|
77
|
+
|
78
|
+
# Split the returned hash and fill the CommentElement
|
79
|
+
# @param [Hash] result The json based hash of one Comment
|
80
|
+
# @return [CommentElement] One comment
|
81
|
+
private
|
82
|
+
def create_element(result)
|
83
|
+
text = result["body"]
|
84
|
+
author = result["updateAuthor"]["displayName"]
|
85
|
+
ctime = result["created"]
|
86
|
+
mtime = result["updated"]
|
87
|
+
return CommentElement.new(author,text,ctime,mtime)
|
88
|
+
end
|
89
|
+
|
90
|
+
public
|
91
|
+
# Get a certain comment
|
92
|
+
# @param [String] data Additional data to send via GET
|
93
|
+
# @return [Nil] If there is no comment in the Project
|
94
|
+
# @return [Array(CommentElement)] If there is one or more than one result - TODO See if this is going to be changed for a special type that keeps startAt, maxResults and total
|
95
|
+
def get(data = "")
|
96
|
+
result = super("")
|
97
|
+
if result["comments"].nil? then
|
98
|
+
return [create_element(result)]
|
99
|
+
elsif result["comments"].empty? then
|
100
|
+
return nil
|
101
|
+
else
|
102
|
+
resultarray = Array.new
|
103
|
+
result["comments"].each { |singleresult|
|
104
|
+
resultarray << create_element(singleresult)
|
105
|
+
}
|
106
|
+
return resultarray
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
# Update an comment
|
111
|
+
# @param [String] text The new text for the comment
|
112
|
+
# @return [CommentElement] The new comment
|
113
|
+
def update(text)
|
114
|
+
result = put({"body" => text})
|
115
|
+
return CommentElement.new(result["updateAuthor"]["displayName"], result["body"], result["created"], result["updated"])
|
116
|
+
end
|
117
|
+
|
118
|
+
end # Comment
|
@@ -0,0 +1,5 @@
|
|
1
|
+
HTTP/1.1 200 OK
|
2
|
+
Server: Apache-Coyote/1.1
|
3
|
+
Content-Type: application/json;charset=UTF-8
|
4
|
+
|
5
|
+
{"startAt":0,"maxResults":4,"total":4,"comments":[{"self":"http://localhost:2990/jira/rest/api/2/issue/10116/comment/10223","id":"10223","author":{"self":"http://localhost:2990/jira/rest/api/2/user?username=test","name":"test","emailAddress":"jira-test@localhost","avatarUrls":{"16x16":"http://localhost:2990/jira/secure/useravatar?size=small&avatarId=10122","48x48":"http://localhost:2990/jira/secure/useravatar?avatarId=10122"},"displayName":"Test User","active":true},"body":"1st comment","updateAuthor":{"self":"http://localhost:2990/jira/rest/api/2/user?username=test","name":"test","emailAddress":"jira-test@localhost","avatarUrls":{"16x16":"http://localhost:2990/jira/secure/useravatar?size=small&avatarId=10122","48x48":"http://localhost:2990/jira/secure/useravatar?avatarId=10122"},"displayName":"Test User","active":true},"created":"2012-07-29T18:43:22.654+0200","updated":"2012-07-29T18:43:22.654+0200"},{"self":"http://localhost:2990/jira/rest/api/2/issue/10116/comment/10224","id":"10224","author":{"self":"http://localhost:2990/jira/rest/api/2/user?username=test","name":"test","emailAddress":"jira-test@localhost","avatarUrls":{"16x16":"http://localhost:2990/jira/secure/useravatar?size=small&avatarId=10122","48x48":"http://localhost:2990/jira/secure/useravatar?avatarId=10122"},"displayName":"Test User","active":true},"body":"2nd comment","updateAuthor":{"self":"http://localhost:2990/jira/rest/api/2/user?username=test","name":"test","emailAddress":"jira-test@localhost","avatarUrls":{"16x16":"http://localhost:2990/jira/secure/useravatar?size=small&avatarId=10122","48x48":"http://localhost:2990/jira/secure/useravatar?avatarId=10122"},"displayName":"Test User","active":true},"created":"2012-07-29T18:43:36.648+0200","updated":"2012-07-29T18:43:36.648+0200"},{"self":"http://localhost:2990/jira/rest/api/2/issue/10116/comment/10225","id":"10225","author":{"self":"http://localhost:2990/jira/rest/api/2/user?username=test","name":"test","emailAddress":"jira-test@localhost","avatarUrls":{"16x16":"http://localhost:2990/jira/secure/useravatar?size=small&avatarId=10122","48x48":"http://localhost:2990/jira/secure/useravatar?avatarId=10122"},"displayName":"Test User","active":true},"body":"3rd comment","updateAuthor":{"self":"http://localhost:2990/jira/rest/api/2/user?username=test","name":"test","emailAddress":"jira-test@localhost","avatarUrls":{"16x16":"http://localhost:2990/jira/secure/useravatar?size=small&avatarId=10122","48x48":"http://localhost:2990/jira/secure/useravatar?avatarId=10122"},"displayName":"Test User","active":true},"created":"2012-07-29T18:43:47.769+0200","updated":"2012-07-29T18:43:47.769+0200"},{"self":"http://localhost:2990/jira/rest/api/2/issue/10116/comment/10226","id":"10226","author":{"self":"http://localhost:2990/jira/rest/api/2/user?username=test","name":"test","emailAddress":"jira-test@localhost","avatarUrls":{"16x16":"http://localhost:2990/jira/secure/useravatar?size=small&avatarId=10122","48x48":"http://localhost:2990/jira/secure/useravatar?avatarId=10122"},"displayName":"Test User","active":true},"body":"4th comment","updateAuthor":{"self":"http://localhost:2990/jira/rest/api/2/user?username=test","name":"test","emailAddress":"jira-test@localhost","avatarUrls":{"16x16":"http://localhost:2990/jira/secure/useravatar?size=small&avatarId=10122","48x48":"http://localhost:2990/jira/secure/useravatar?avatarId=10122"},"displayName":"Test User","active":true},"created":"2012-07-29T18:44:03.321+0200","updated":"2012-07-29T18:44:03.321+0200","visibility":{"type":"role","value":"Users"}}]}
|
data/test/data/issuespec.txt
CHANGED
@@ -1,14 +1,5 @@
|
|
1
1
|
HTTP/1.1 200 OK
|
2
2
|
Server: Apache-Coyote/1.1
|
3
|
-
X-AREQUESTID: 1205x110x1
|
4
|
-
Set-Cookie: JSESSIONID=3D7C4DCDAD212D6D5227E08E5059A347; Path=/
|
5
|
-
X-Seraph-LoginReason: OK
|
6
|
-
Set-Cookie: atlassian.xsrf.token=BP8Q-WXN6-SKX3-NB5M|09078c4ba23629ddc418efa11cc75a215f98ce1d|lin; Path=/jira
|
7
|
-
X-ASESSIONID: 1lodmqg
|
8
|
-
X-AUSERNAME: test
|
9
|
-
Cache-Control: no-cache, no-store, no-transform
|
10
3
|
Content-Type: application/json;charset=UTF-8
|
11
|
-
Transfer-Encoding: chunked
|
12
|
-
Date: Mon, 23 Jul 2012 18:05:26 GMT
|
13
4
|
|
14
|
-
{"expand":"projects","projects":[{"expand":"issuetypes","self":"http://localhost:2990/jira/rest/api/2/project/MFTP","id":"10000","key":"MFTP","name":"My first Test Project","avatarUrls":{"16x16":"http://localhost:2990/jira/secure/projectavatar?size=small&pid=10000&avatarId=10011","48x48":"http://localhost:2990/jira/secure/projectavatar?pid=10000&avatarId=10011"},"issuetypes":[{"self":"http://localhost:2990/jira/rest/api/2/issuetype/6","id":"6","description":"An own issue type","iconUrl":"http://localhost:2990/jira/images/icons/ico_epic.png","name":"My issue type","subtask":false,"expand":"fields","fields":{"summary":{"required":true,"schema":{"type":"string","system":"summary"},"name":"Summary","operations":["set"]},"timetracking":{"required":false,"schema":{"type":"timetracking","system":"timetracking"},"name":"Time Tracking","operations":["set","edit"]},"customfield_10102":{"required":false,"schema":{"type":"string","custom":"com.atlassian.jira.plugin.system.customfieldtypes:textfield","customId":10102},"name":"projects","operations":["set"]},"customfield_10101":{"required":false,"schema":{"type":"string","custom":"com.atlassian.jira.plugin.system.customfieldtypes:textfield","customId":10101},"name":"Issue Type","operations":["set"]},"customfield_10100":{"required":false,"schema":{"type":"string","custom":"com.atlassian.jira.plugin.system.customfieldtypes:textfield","customId":10100},"name":"issuetype","operations":["set"]},"issuetype":{"required":true,"schema":{"type":"issuetype","system":"issuetype"},"name":"Issue Type","operations":[],"allowedValues":[{"self":"http://localhost:2990/jira/rest/api/2/issuetype/6","id":"6","description":"An own issue type","iconUrl":"http://localhost:2990/jira/images/icons/ico_epic.png","name":"My issue type","subtask":false}]},"customfield_10006":{"required":false,"schema":{"type":"string","custom":"com.atlassian.jira.plugin.system.customfieldtypes:select","customId":10006},"name":"List select","operations":["set"],"allowedValues":[{"self":"http://localhost:2990/jira/rest/api/2/customFieldOption/10015","value":"Räuber","id":"10015"},{"self":"http://localhost:2990/jira/rest/api/2/customFieldOption/10016","value":"Kabale und Liebe","id":"10016"},{"self":"http://localhost:2990/jira/rest/api/2/customFieldOption/10017","value":"Faust","id":"10017"},{"self":"http://localhost:2990/jira/rest/api/2/customFieldOption/10018","value":"Landleben","id":"10018"}]},"customfield_10005":{"required":false,"schema":{"type":"array","items":"string","custom":"com.atlassian.jira.plugin.system.customfieldtypes:multiselect","customId":10005},"name":"Multi Select","operations":["add","set","remove"],"allowedValues":[{"self":"http://localhost:2990/jira/rest/api/2/customFieldOption/10023","value":"Glocke","id":"10023"},{"self":"http://localhost:2990/jira/rest/api/2/customFieldOption/10024","value":"Kabale und Liebe","id":"10024"},{"self":"http://localhost:2990/jira/rest/api/2/customFieldOption/10025","value":"Schiller","id":"10025"},{"self":"http://localhost:2990/jira/rest/api/2/customFieldOption/10026","value":"Göthe","id":"10026"},{"self":"http://localhost:2990/jira/rest/api/2/customFieldOption/10027","value":"Faust","id":"10027"}]},"labels":{"required":false,"schema":{"type":"array","items":"string","system":"labels"},"name":"Labels","autoCompleteUrl":"http://localhost:2990/jira/rest/api/1.0/labels/suggest?query=","operations":["add","set","remove"]},"resolution":{"required":false,"schema":{"type":"resolution","system":"resolution"},"name":"Resolution","operations":["set"],"allowedValues":[{"self":"http://localhost:2990/jira/rest/api/2/resolution/1","name":"Fixed","id":"1"},{"self":"http://localhost:2990/jira/rest/api/2/resolution/2","name":"Won't Fix","id":"2"},{"self":"http://localhost:2990/jira/rest/api/2/resolution/3","name":"Duplicate","id":"3"},{"self":"http://localhost:2990/jira/rest/api/2/resolution/4","name":"Incomplete","id":"4"},{"self":"http://localhost:2990/jira/rest/api/2/resolution/5","name":"Cannot Reproduce","id":"5"}]},"attachment":{"required":false,"schema":{"type":"array","items":"attachment","system":"attachment"},"name":"Attachment","operations":[]},"project":{"required":true,"schema":{"type":"project","system":"project"},"autoCompleteUrl":"Project","operations":["set"],"allowedValues":[{"self":"http://localhost:2990/jira/rest/api/2/project/MFTP","id":"10000","key":"MFTP","name":"My first Test Project","avatarUrls":{"16x16":"http://localhost:2990/jira/secure/projectavatar?size=small&pid=10000&avatarId=10011","48x48":"http://localhost:2990/jira/secure/projectavatar?pid=10000&avatarId=10011"}}]},"versions":{"required":false,"schema":{"type":"array","items":"version","system":"versions"},"name":"Affects Version/s","operations":["set","add","remove"],"allowedValues":[]},"environment":{"required":false,"schema":{"type":"string","system":"environment"},"name":"Environment","operations":["set"]},"priority":{"required":false,"schema":{"type":"priority","system":"priority"},"name":"Priority","operations":["set"],"allowedValues":[{"self":"http://localhost:2990/jira/rest/api/2/priority/1","iconUrl":"http://localhost:2990/jira/images/icons/priority_blocker.gif","name":"Blocker","id":"1"},{"self":"http://localhost:2990/jira/rest/api/2/priority/2","iconUrl":"http://localhost:2990/jira/images/icons/priority_critical.gif","name":"Critical","id":"2"},{"self":"http://localhost:2990/jira/rest/api/2/priority/3","iconUrl":"http://localhost:2990/jira/images/icons/priority_major.gif","name":"Major","id":"3"},{"self":"http://localhost:2990/jira/rest/api/2/priority/4","iconUrl":"http://localhost:2990/jira/images/icons/priority_minor.gif","name":"Minor","id":"4"},{"self":"http://localhost:2990/jira/rest/api/2/priority/5","iconUrl":"http://localhost:2990/jira/images/icons/priority_trivial.gif","name":"Trivial","id":"5"}]},"description":{"required":false,"schema":{"type":"string","system":"description"},"name":"Description","operations":["set"]},"customfield_10001":{"required":false,"schema":{"type":"datetime","custom":"com.atlassian.jira.plugin.system.customfieldtypes:datetime","customId":10001},"name":"Date Time Field","operations":["set"]},"customfield_10002":{"required":false,"schema":{"type":"date","custom":"com.atlassian.jira.plugin.system.customfieldtypes:datepicker","customId":10002},"name":"Date Picker","operations":["set"]},"customfield_10003":{"required":false,"schema":{"type":"string","custom":"com.atlassian.jira.plugin.system.customfieldtypes:textarea","customId":10003},"name":"Großes Text","operations":["set"]},"customfield_10004":{"required":false,"schema":{"type":"array","items":"string","custom":"com.atlassian.jira.plugin.system.customfieldtypes:multicheckboxes","customId":10004},"name":"Multi Checkboxes","operations":["add","set","remove"],"allowedValues":[{"self":"http://localhost:2990/jira/rest/api/2/customFieldOption/10019","value":"Göthe","id":"10019"},{"self":"http://localhost:2990/jira/rest/api/2/customFieldOption/10020","value":"Schiller","id":"10020"},{"self":"http://localhost:2990/jira/rest/api/2/customFieldOption/10021","value":"Heine","id":"10021"},{"self":"http://localhost:2990/jira/rest/api/2/customFieldOption/10022","value":"Kafka","id":"10022"}]},"components":{"required":false,"schema":{"type":"array","items":"component","system":"components"},"name":"Component/s","operations":["add","set","remove"],"allowedValues":[]},"customfield_10000":{"required":false,"schema":{"type":"array","items":"string","custom":"com.atlassian.jira.plugin.system.customfieldtypes:cascadingselect","customId":10000},"name":"Cascading Select Test","operations":["set"],"allowedValues":[{"self":"http://localhost:2990/jira/rest/api/2/customFieldOption/10000","value":"English","id":"10000","children":[{"self":"http://localhost:2990/jira/rest/api/2/customFieldOption/10003","value":"One","id":"10003"},{"self":"http://localhost:2990/jira/rest/api/2/customFieldOption/10004","value":"Two","id":"10004"},{"self":"http://localhost:2990/jira/rest/api/2/customFieldOption/10005","value":"Three","id":"10005"},{"self":"http://localhost:2990/jira/rest/api/2/customFieldOption/10006","value":"Four","id":"10006"}]},{"self":"http://localhost:2990/jira/rest/api/2/customFieldOption/10001","value":"German","id":"10001","children":[{"self":"http://localhost:2990/jira/rest/api/2/customFieldOption/10007","value":"Eins","id":"10007"},{"self":"http://localhost:2990/jira/rest/api/2/customFieldOption/10008","value":"zwei","id":"10008"},{"self":"http://localhost:2990/jira/rest/api/2/customFieldOption/10009","value":"drEi","id":"10009"},{"self":"http://localhost:2990/jira/rest/api/2/customFieldOption/10010","value":"vier","id":"10010"}]},{"self":"http://localhost:2990/jira/rest/api/2/customFieldOption/10002","value":"ISO","id":"10002","children":[{"self":"http://localhost:2990/jira/rest/api/2/customFieldOption/10011","value":"Unaone","id":"10011"},{"self":"http://localhost:2990/jira/rest/api/2/customFieldOption/10012","value":"Bissotwo","id":"10012"},{"self":"http://localhost:2990/jira/rest/api/2/customFieldOption/10013","value":"Terrathree","id":"10013"},{"self":"http://localhost:2990/jira/rest/api/2/customFieldOption/10014","value":"Kartefour","id":"10014"}]}]}}}]}]}
|
5
|
+
{"expand":"projects","projects":[{"expand":"issuetypes","self":"http://localhost:2990/jira/rest/api/2/project/MFTP","id":"10000","key":"MFTP","name":"My first Test Project","avatarUrls":{"16x16":"http://localhost:2990/jira/secure/projectavatar?size=small&pid=10000&avatarId=10011","48x48":"http://localhost:2990/jira/secure/projectavatar?pid=10000&avatarId=10011"},"issuetypes":[{"self":"http://localhost:2990/jira/rest/api/2/issuetype/6","id":"6","description":"An own issue type","iconUrl":"http://localhost:2990/jira/images/icons/ico_epic.png","name":"My issue type","subtask":false,"expand":"fields","fields":{"summary":{"required":true,"schema":{"type":"string","system":"summary"},"name":"Summary","operations":["set"]},"timetracking":{"required":false,"schema":{"type":"timetracking","system":"timetracking"},"name":"Time Tracking","operations":["set","edit"]},"customfield_10102":{"required":false,"schema":{"type":"string","custom":"com.atlassian.jira.plugin.system.customfieldtypes:textfield","customId":10102},"name":"projects","operations":["set"]},"customfield_10101":{"required":false,"schema":{"type":"string","custom":"com.atlassian.jira.plugin.system.customfieldtypes:textfield","customId":10101},"name":"Issue Type","operations":["set"]},"customfield_10100":{"required":false,"schema":{"type":"string","custom":"com.atlassian.jira.plugin.system.customfieldtypes:textfield","customId":10100},"name":"issuetype","operations":["set"]},"issuetype":{"required":true,"schema":{"type":"issuetype","system":"issuetype"},"name":"Issue Type","operations":[],"allowedValues":[{"self":"http://localhost:2990/jira/rest/api/2/issuetype/6","id":"6","description":"An own issue type","iconUrl":"http://localhost:2990/jira/images/icons/ico_epic.png","name":"My issue type","subtask":false}]},"customfield_10006":{"required":false,"schema":{"type":"string","custom":"com.atlassian.jira.plugin.system.customfieldtypes:select","customId":10006},"name":"List select","operations":["set"],"allowedValues":[{"self":"http://localhost:2990/jira/rest/api/2/customFieldOption/10015","value":"Räuber","id":"10015"},{"self":"http://localhost:2990/jira/rest/api/2/customFieldOption/10016","value":"Kabale und Liebe","id":"10016"},{"self":"http://localhost:2990/jira/rest/api/2/customFieldOption/10017","value":"Faust","id":"10017"},{"self":"http://localhost:2990/jira/rest/api/2/customFieldOption/10018","value":"Landleben","id":"10018"}]},"customfield_10005":{"required":false,"schema":{"type":"array","items":"string","custom":"com.atlassian.jira.plugin.system.customfieldtypes:multiselect","customId":10005},"name":"Multi Select","operations":["add","set","remove"],"allowedValues":[{"self":"http://localhost:2990/jira/rest/api/2/customFieldOption/10023","value":"Glocke","id":"10023"},{"self":"http://localhost:2990/jira/rest/api/2/customFieldOption/10024","value":"Kabale und Liebe","id":"10024"},{"self":"http://localhost:2990/jira/rest/api/2/customFieldOption/10025","value":"Schiller","id":"10025"},{"self":"http://localhost:2990/jira/rest/api/2/customFieldOption/10026","value":"Göthe","id":"10026"},{"self":"http://localhost:2990/jira/rest/api/2/customFieldOption/10027","value":"Faust","id":"10027"}]},"labels":{"required":false,"schema":{"type":"array","items":"string","system":"labels"},"name":"Labels","autoCompleteUrl":"http://localhost:2990/jira/rest/api/1.0/labels/suggest?query=","operations":["add","set","remove"]},"resolution":{"required":false,"schema":{"type":"resolution","system":"resolution"},"name":"Resolution","operations":["set"],"allowedValues":[{"self":"http://localhost:2990/jira/rest/api/2/resolution/1","name":"Fixed","id":"1"},{"self":"http://localhost:2990/jira/rest/api/2/resolution/2","name":"Won't Fix","id":"2"},{"self":"http://localhost:2990/jira/rest/api/2/resolution/3","name":"Duplicate","id":"3"},{"self":"http://localhost:2990/jira/rest/api/2/resolution/4","name":"Incomplete","id":"4"},{"self":"http://localhost:2990/jira/rest/api/2/resolution/5","name":"Cannot Reproduce","id":"5"}]},"attachment":{"required":false,"schema":{"type":"array","items":"attachment","system":"attachment"},"name":"Attachment","operations":[]},"project":{"required":true,"schema":{"type":"project","system":"project"},"autoCompleteUrl":"Project","operations":["set"],"allowedValues":[{"self":"http://localhost:2990/jira/rest/api/2/project/MFTP","id":"10000","key":"MFTP","name":"My first Test Project","avatarUrls":{"16x16":"http://localhost:2990/jira/secure/projectavatar?size=small&pid=10000&avatarId=10011","48x48":"http://localhost:2990/jira/secure/projectavatar?pid=10000&avatarId=10011"}}]},"versions":{"required":false,"schema":{"type":"array","items":"version","system":"versions"},"name":"Affects Version/s","operations":["set","add","remove"],"allowedValues":[]},"environment":{"required":false,"schema":{"type":"string","system":"environment"},"name":"Environment","operations":["set"]},"priority":{"required":false,"schema":{"type":"priority","system":"priority"},"name":"Priority","operations":["set"],"allowedValues":[{"self":"http://localhost:2990/jira/rest/api/2/priority/1","iconUrl":"http://localhost:2990/jira/images/icons/priority_blocker.gif","name":"Blocker","id":"1"},{"self":"http://localhost:2990/jira/rest/api/2/priority/2","iconUrl":"http://localhost:2990/jira/images/icons/priority_critical.gif","name":"Critical","id":"2"},{"self":"http://localhost:2990/jira/rest/api/2/priority/3","iconUrl":"http://localhost:2990/jira/images/icons/priority_major.gif","name":"Major","id":"3"},{"self":"http://localhost:2990/jira/rest/api/2/priority/4","iconUrl":"http://localhost:2990/jira/images/icons/priority_minor.gif","name":"Minor","id":"4"},{"self":"http://localhost:2990/jira/rest/api/2/priority/5","iconUrl":"http://localhost:2990/jira/images/icons/priority_trivial.gif","name":"Trivial","id":"5"}]},"description":{"required":false,"schema":{"type":"string","system":"description"},"name":"Description","operations":["set"]},"customfield_10001":{"required":false,"schema":{"type":"datetime","custom":"com.atlassian.jira.plugin.system.customfieldtypes:datetime","customId":10001},"name":"Date Time Field","operations":["set"]},"customfield_10002":{"required":false,"schema":{"type":"date","custom":"com.atlassian.jira.plugin.system.customfieldtypes:datepicker","customId":10002},"name":"Date Picker","operations":["set"]},"customfield_10003":{"required":false,"schema":{"type":"string","custom":"com.atlassian.jira.plugin.system.customfieldtypes:textarea","customId":10003},"name":"Großes Text","operations":["set"]},"customfield_10004":{"required":false,"schema":{"type":"array","items":"string","custom":"com.atlassian.jira.plugin.system.customfieldtypes:multicheckboxes","customId":10004},"name":"Multi Checkboxes","operations":["add","set","remove"],"allowedValues":[{"self":"http://localhost:2990/jira/rest/api/2/customFieldOption/10019","value":"Göthe","id":"10019"},{"self":"http://localhost:2990/jira/rest/api/2/customFieldOption/10020","value":"Schiller","id":"10020"},{"self":"http://localhost:2990/jira/rest/api/2/customFieldOption/10021","value":"Heine","id":"10021"},{"self":"http://localhost:2990/jira/rest/api/2/customFieldOption/10022","value":"Kafka","id":"10022"}]},"components":{"required":false,"schema":{"type":"array","items":"component","system":"components"},"name":"Component/s","operations":["add","set","remove"],"allowedValues":[]},"customfield_10000":{"required":false,"schema":{"type":"array","items":"string","custom":"com.atlassian.jira.plugin.system.customfieldtypes:cascadingselect","customId":10000},"name":"Cascading Select Test","operations":["set"],"allowedValues":[{"self":"http://localhost:2990/jira/rest/api/2/customFieldOption/10000","value":"English","id":"10000","children":[{"self":"http://localhost:2990/jira/rest/api/2/customFieldOption/10003","value":"One","id":"10003"},{"self":"http://localhost:2990/jira/rest/api/2/customFieldOption/10004","value":"Two","id":"10004"},{"self":"http://localhost:2990/jira/rest/api/2/customFieldOption/10005","value":"Three","id":"10005"},{"self":"http://localhost:2990/jira/rest/api/2/customFieldOption/10006","value":"Four","id":"10006"}]},{"self":"http://localhost:2990/jira/rest/api/2/customFieldOption/10001","value":"German","id":"10001","children":[{"self":"http://localhost:2990/jira/rest/api/2/customFieldOption/10007","value":"Eins","id":"10007"},{"self":"http://localhost:2990/jira/rest/api/2/customFieldOption/10008","value":"zwei","id":"10008"},{"self":"http://localhost:2990/jira/rest/api/2/customFieldOption/10009","value":"drEi","id":"10009"},{"self":"http://localhost:2990/jira/rest/api/2/customFieldOption/10010","value":"vier","id":"10010"}]},{"self":"http://localhost:2990/jira/rest/api/2/customFieldOption/10002","value":"ISO","id":"10002","children":[{"self":"http://localhost:2990/jira/rest/api/2/customFieldOption/10011","value":"Unaone","id":"10011"},{"self":"http://localhost:2990/jira/rest/api/2/customFieldOption/10012","value":"Bissotwo","id":"10012"},{"self":"http://localhost:2990/jira/rest/api/2/customFieldOption/10013","value":"Terrathree","id":"10013"},{"self":"http://localhost:2990/jira/rest/api/2/customFieldOption/10014","value":"Kartefour","id":"10014"}]}]}}}]}]}
|
@@ -0,0 +1,88 @@
|
|
1
|
+
require "minitest/autorun"
|
2
|
+
require "webmock/minitest"
|
3
|
+
require "jirarest2/connect"
|
4
|
+
require "jirarest2/credentials"
|
5
|
+
require "jirarest2/services/comment"
|
6
|
+
|
7
|
+
class TestComment < MiniTest::Unit::TestCase
|
8
|
+
def setup
|
9
|
+
cred = Credentials.new("http://localhost:2990/jira/rest/api/2/","test","1234")
|
10
|
+
@con = Connect.new(cred)
|
11
|
+
end
|
12
|
+
|
13
|
+
def test_get_comment_filled
|
14
|
+
comment = Comment.new(@con,"SP-15")
|
15
|
+
raw_response_file = File.new(File.dirname(__FILE__)+"/data/get-comments.txt")
|
16
|
+
stub_request(:get, "http://test:1234@localhost:2990/jira/rest/api/2/issue/SP-15/comment").with(:headers => {'Accept'=>'*/*', 'Content-Type'=>'application/json;charset=UTF-8', 'User-Agent'=>'Ruby'}).to_return(raw_response_file)
|
17
|
+
result = comment.get
|
18
|
+
assert_equal 4,result.size
|
19
|
+
assert_equal "2nd comment", result[1].text
|
20
|
+
assert_equal true, Time.parse("2012-07-29 18:44:03 +0200").ctime == result[3].mdate.ctime
|
21
|
+
end
|
22
|
+
|
23
|
+
def test_get_comment_empty
|
24
|
+
comment = Comment.new(@con,"SP-14")
|
25
|
+
stub_request(:get, "http://test:1234@localhost:2990/jira/rest/api/2/issue/SP-14/comment").with(:headers => {'Accept'=>'*/*', 'Content-Type'=>'application/json;charset=UTF-8', 'User-Agent'=>'Ruby'}).to_return(:status => 200, :body => '{"startAt":0,"maxResults":0,"total":0,"comments":[]}', :headers => {})
|
26
|
+
assert_equal nil, comment.get
|
27
|
+
end
|
28
|
+
|
29
|
+
def test_add_comment_fail
|
30
|
+
stub_request(:post, "http://test:1234@localhost:2990/jira/rest/api/2/issue/SP-3/comment").with(:body => "{\"body\":\"\"}", :headers => {'Accept'=>'*/*', 'Content-Type'=>'application/json;charset=UTF-8', 'User-Agent'=>'Ruby'}).to_return(:status => 400, :body => '{"errorMessages":[],"errors":{"comment":"Comment body can not be empty!"}}', :headers => {})
|
31
|
+
comment = Comment.new(@con,"SP-3")
|
32
|
+
assert_raises(Jirarest2::BadRequestError) {
|
33
|
+
comment.add("")
|
34
|
+
}
|
35
|
+
stub_request(:post, "http://test:1234@localhost:2990/jira/rest/api/2/issue/SPP-3/comment").with(:headers => {'Accept'=>'*/*', 'Content-Type'=>'application/json;charset=UTF-8', 'User-Agent'=>'Ruby'}).to_return(:status => 404, :body => '{"errorMessages":["Issue Does Not Exist"],"errors":{}}', :headers => {})
|
36
|
+
comment = Comment.new(@con,"SPP-3")
|
37
|
+
assert_raises(Jirarest2::NotFoundError) {
|
38
|
+
comment.add("Text")
|
39
|
+
}
|
40
|
+
end
|
41
|
+
|
42
|
+
def test_add_comment_success
|
43
|
+
stub_request(:post, "http://test:1234@localhost:2990/jira/rest/api/2/issue/SP-3/comment").with(:body => "{\"body\":\"Text for the long run\"}",:headers => {'Accept'=>'*/*', 'Content-Type'=>'application/json;charset=UTF-8', 'User-Agent'=>'Ruby'}).to_return(:status => 201, :body => '{"self":"http://localhost:2990/jira/rest/api/2/issue/10104/comment/10110","id":"10110","author":{"self":"http://localhost:2990/jira/rest/api/2/user?username=test","name":"test","emailAddress":"jira-test@localhost","avatarUrls":{"16x16":"http://localhost:2990/jira/secure/useravatar?size=small&avatarId=10122","48x48":"http://localhost:2990/jira/secure/useravatar?avatarId=10122"},"displayName":"Test User","active":true},"body":"Text for the long run","updateAuthor":{"self":"http://localhost:2990/jira/rest/api/2/user?username=test","name":"test","emailAddress":"jira-test@localhost","avatarUrls":{"16x16":"http://localhost:2990/jira/secure/useravatar?size=small&avatarId=10122","48x48":"http://localhost:2990/jira/secure/useravatar?avatarId=10122"},"displayName":"Test User","active":true},"created":"2012-07-27T20:36:07.832+0200","updated":"2012-07-27T20:36:07.832+0200"}', :headers => {})
|
44
|
+
|
45
|
+
comment = Comment.new(@con,"SP-3")
|
46
|
+
assert_match /,"body":"Text for the long run","updateAuthor"/, comment.add("Text for the long run").body
|
47
|
+
assert_instance_of Jirarest2::Result, comment.add("Text for the long run")
|
48
|
+
end
|
49
|
+
|
50
|
+
def test_get_special_comment_fail
|
51
|
+
comment = Comment.new(@con,"SP-3",12345)
|
52
|
+
stub_request(:get, "http://test:1234@localhost:2990/jira/rest/api/2/issue/SP-3/comment/12345").with(:headers => {'Accept'=>'*/*', 'Content-Type'=>'application/json;charset=UTF-8', 'User-Agent'=>'Ruby'}).to_return(:status => 404, :body => '{"errorMessages":["Can not find a comment for the id: 12345."],"errors":{}}', :headers => {})
|
53
|
+
assert_raises(Jirarest2::NotFoundError) {
|
54
|
+
comment.get()
|
55
|
+
}
|
56
|
+
end
|
57
|
+
|
58
|
+
|
59
|
+
def test__get_special_comment_success
|
60
|
+
comment = Comment.new(@con,"SP-3",10109)
|
61
|
+
stub_request(:get, "http://test:1234@localhost:2990/jira/rest/api/2/issue/SP-3/comment/10109").with(:headers => {'Accept'=>'*/*', 'Content-Type'=>'application/json;charset=UTF-8', 'User-Agent'=>'Ruby'}).to_return(:status => 200, :body => '{"self":"http://localhost:2990/jira/rest/api/2/issue/10104/comment/10109","id":"10109","author":{"self":"http://localhost:2990/jira/rest/api/2/user?username=test","name":"test","emailAddress":"jira-test@localhost","avatarUrls":{"16x16":"http://localhost:2990/jira/secure/useravatar?size=small&avatarId=10122","48x48":"http://localhost:2990/jira/secure/useravatar?avatarId=10122"},"displayName":"Test User","active":true},"body":"Text for the long run","updateAuthor":{"self":"http://localhost:2990/jira/rest/api/2/user?username=test","name":"test","emailAddress":"jira-test@localhost","avatarUrls":{"16x16":"http://localhost:2990/jira/secure/useravatar?size=small&avatarId=10122","48x48":"http://localhost:2990/jira/secure/useravatar?avatarId=10122"},"displayName":"Test User","active":true},"created":"2012-07-27T20:36:07.651+0200","updated":"2012-07-27T20:36:07.651+0200"}', :headers => {})
|
62
|
+
result = comment.get
|
63
|
+
assert_equal "Text for the long run", result[0].text
|
64
|
+
assert_equal "Test User", result[0].author
|
65
|
+
assert_instance_of CommentElement, result[0]
|
66
|
+
assert_instance_of Time, result[0].mdate
|
67
|
+
end
|
68
|
+
|
69
|
+
|
70
|
+
def test_replace_comment
|
71
|
+
comment = Comment.new(@con,"SP-3",10210)
|
72
|
+
stub_request(:put, "http://test:1234@localhost:2990/jira/rest/api/2/issue/SP-3/comment/10210").with(:body => "{\"body\":\"New Comment\"}",:headers => {'Accept'=>'*/*', 'Content-Type'=>'application/json;charset=UTF-8', 'User-Agent'=>'Ruby'}).to_return(:status => 200, :body => '{"self":"http://localhost:2990/jira/rest/api/2/issue/10104/comment/10210","id":"10210","author":{"self":"http://localhost:2990/jira/rest/api/2/user?username=test","name":"test","emailAddress":"jira-test@localhost","avatarUrls":{"16x16":"http://localhost:2990/jira/secure/useravatar?size=small&avatarId=10122","48x48":"http://localhost:2990/jira/secure/useravatar?avatarId=10122"},"displayName":"Test User","active":true},"body":"New Comment","updateAuthor":{"self":"http://localhost:2990/jira/rest/api/2/user?username=test","name":"test","emailAddress":"jira-test@localhost","avatarUrls":{"16x16":"http://localhost:2990/jira/secure/useravatar?size=small&avatarId=10122","48x48":"http://localhost:2990/jira/secure/useravatar?avatarId=10122"},"displayName":"Test User","active":true},"created":"2012-07-29T17:31:32.230+0200","updated":"2012-07-29T18:06:22.943+0200"}', :headers => {})
|
73
|
+
|
74
|
+
result = comment.update("New Comment")
|
75
|
+
assert_equal "New Comment", result.text
|
76
|
+
assert_equal "Test User", result.author
|
77
|
+
assert_instance_of Time, result.mdate
|
78
|
+
|
79
|
+
end
|
80
|
+
|
81
|
+
|
82
|
+
def test_delete_comment
|
83
|
+
comment = Comment.new(@con,"SP-3",10208)
|
84
|
+
stub_request(:delete, "http://test:1234@localhost:2990/jira/rest/api/2/issue/SP-3/comment/10208").with(:headers => {'Accept'=>'*/*', 'Content-Type'=>'application/json;charset=UTF-8', 'User-Agent'=>'Ruby'}).to_return(:status => 204 )
|
85
|
+
assert_equal "204", comment.delete.code
|
86
|
+
end
|
87
|
+
|
88
|
+
end # class
|
data/test/test_connect.rb
CHANGED
@@ -20,13 +20,9 @@ class TestConnect < MiniTest::Unit::TestCase
|
|
20
20
|
|
21
21
|
def test_executePOST
|
22
22
|
stub_request(:post, "http://test:1234@localhost:2990/jira/rest/api/2/search/").with(:body => "{\"jql\":\"project = MFTP\",\"startAt\":0,\"maxResults\":4}",:headers => {'Accept'=>'*/*', 'Content-Type'=>'application/json;charset=UTF-8', 'User-Agent'=>'Ruby'}).to_return(:status => 200, :body => '{"expand":"schema,names","startAt":0,"maxResults":4,"total":9,"issues":[{"expand":"editmeta,renderedFields,transitions,changelog,operations","id":"10102","self":"http://localhost:2990/jira/rest/api/2/issue/10102","key":"MFTP-9","fields":{"summary":"AnotherissueatSunJul1516","progress":{"progress":0,"total":0}}}]}', :headers => {})
|
23
|
-
# WebMock.disable!
|
24
23
|
|
25
24
|
query={"jql"=>"project = MFTP", "startAt"=>0, "maxResults"=>4 }
|
26
25
|
assert_equal 4, @con.execute("Post","search/",query).result["maxResults"]
|
27
|
-
# WebMock.enable!
|
28
|
-
|
29
|
-
pp @con.execute("Post","search/",query).result["maxResults"]
|
30
26
|
end
|
31
27
|
|
32
28
|
def test_check_uri_true
|
data/test/test_result.rb
CHANGED
@@ -17,7 +17,9 @@ class TestResult < MiniTest::Unit::TestCase
|
|
17
17
|
|
18
18
|
def test_code_400
|
19
19
|
stub_request(:get, "http://test:1234@localhost:2990/jira/rest/api/2/issue/createmeta/").with(:headers => {'Content-Type'=>'application/json;charset=UTF-8'}).to_return(:status => 400, :body => "", :headers => {})
|
20
|
-
|
20
|
+
assert_raises(Jirarest2::BadRequestError) {
|
21
|
+
@con.execute("Get","issue/createmeta/","").code
|
22
|
+
}
|
21
23
|
end
|
22
24
|
|
23
25
|
|
data/test/test_watcher.rb
CHANGED
@@ -43,7 +43,7 @@ class TestWatcher < MiniTest::Unit::TestCase
|
|
43
43
|
def test_add_watcher_success
|
44
44
|
stub_request(:post, "http://test:1234@localhost:2990/jira/rest/api/2/issue/SP-1/watchers").with(:body => "\"cebit\"",:headers => {'Accept'=>'*/*', 'Content-Type'=>'application/json;charset=UTF-8', 'User-Agent'=>'Ruby'}).to_return(:status => 204, :headers => {})
|
45
45
|
watchers = Watcher.new(@con, "SP-1")
|
46
|
-
|
46
|
+
assert_equal true, watchers.add_watcher("cebit")
|
47
47
|
end
|
48
48
|
|
49
49
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jirarest2
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.10
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -50,7 +50,7 @@ cert_chain:
|
|
50
50
|
-----END CERTIFICATE-----
|
51
51
|
|
52
52
|
'
|
53
|
-
date: 2012-
|
53
|
+
date: 2012-08-02 00:00:00.000000000 Z
|
54
54
|
dependencies:
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: json
|
@@ -145,6 +145,7 @@ email:
|
|
145
145
|
- cebit-jirarest@gunnet.de
|
146
146
|
executables:
|
147
147
|
- create_issue.rb
|
148
|
+
- jira_comment
|
148
149
|
- jira_create_issue
|
149
150
|
- jira_create_issue.rb
|
150
151
|
- jira_watcher
|
@@ -161,6 +162,7 @@ files:
|
|
161
162
|
- README.txt
|
162
163
|
- Rakefile
|
163
164
|
- bin/create_issue.rb
|
165
|
+
- bin/jira_comment
|
164
166
|
- bin/jira_create_issue
|
165
167
|
- bin/jira_create_issue.rb
|
166
168
|
- bin/jira_watcher
|
@@ -173,16 +175,19 @@ files:
|
|
173
175
|
- lib/jirarest2/madbitconfig.rb
|
174
176
|
- lib/jirarest2/result.rb
|
175
177
|
- lib/jirarest2/services.rb
|
178
|
+
- lib/jirarest2/services/comment.rb
|
176
179
|
- lib/jirarest2/services/issuelink.rb
|
177
180
|
- lib/jirarest2/services/issuelinktype.rb
|
178
181
|
- lib/jirarest2/services/watcher.rb
|
179
182
|
- lib/jirarest2bin.rb
|
183
|
+
- test/data/get-comments.txt
|
180
184
|
- test/data/issuespec.txt
|
181
185
|
- test/data/test.config.data
|
182
186
|
- test/data/test.json
|
183
187
|
- test/data/test.nojson
|
184
188
|
- test/data/test.nojson1
|
185
189
|
- test/data/ticket.json
|
190
|
+
- test/test_comment.rb
|
186
191
|
- test/test_connect.rb
|
187
192
|
- test/test_credentials.rb
|
188
193
|
- test/test_issue.rb
|
@@ -224,6 +229,7 @@ test_files:
|
|
224
229
|
- test/test_madbitconfig.rb
|
225
230
|
- test/test_connect.rb
|
226
231
|
- test/test_issuelinktype.rb
|
232
|
+
- test/test_comment.rb
|
227
233
|
- test/test_credentials.rb
|
228
234
|
- test/test_issue.rb
|
229
235
|
- test/test_result.rb
|
metadata.gz.sig
CHANGED
Binary file
|