Commit a7b1bf8caca9502386977ae5a5dd581e6b0739ba
Committed by
João M. M. da Silva
1 parent
8af5d1a2
Exists in
master
and in
29 other branches
[Mezuro] refactores model on call to "request" method, doesn't need to
pass endpoint anymore.
Showing
31 changed files
with
147 additions
and
399 deletions
Show diff stats
plugins/mezuro/lib/kalibro/base_tool.rb
@@ -3,11 +3,11 @@ class Kalibro::BaseTool < Kalibro::Model | @@ -3,11 +3,11 @@ class Kalibro::BaseTool < Kalibro::Model | ||
3 | attr_accessor :name, :description, :collector_class_name, :supported_metric | 3 | attr_accessor :name, :description, :collector_class_name, :supported_metric |
4 | 4 | ||
5 | def self.all_names | 5 | def self.all_names |
6 | - request("BaseTool", :all_base_tool_names)[:base_tool_name].to_a | 6 | + request(:all_base_tool_names)[:base_tool_name].to_a |
7 | end | 7 | end |
8 | 8 | ||
9 | def self.find_by_name(base_tool_name) | 9 | def self.find_by_name(base_tool_name) |
10 | - new request("BaseTool", :get_base_tool, {:base_tool_name => base_tool_name})[:base_tool] | 10 | + new request(:get_base_tool, {:base_tool_name => base_tool_name})[:base_tool] |
11 | end | 11 | end |
12 | 12 | ||
13 | def self.all | 13 | def self.all |
plugins/mezuro/lib/kalibro/compound_metric_with_error.rb
@@ -1,13 +0,0 @@ | @@ -1,13 +0,0 @@ | ||
1 | -class Kalibro::CompoundMetricWithError < Kalibro::Model | ||
2 | - | ||
3 | - attr_accessor :metric, :error | ||
4 | - | ||
5 | - def metric=(value) | ||
6 | - @metric = Kalibro::CompoundMetric.to_object value | ||
7 | - end | ||
8 | - | ||
9 | - def error=(value) | ||
10 | - @error = Kalibro::Error.to_object value | ||
11 | - end | ||
12 | - | ||
13 | -end |
plugins/mezuro/lib/kalibro/metric_configuration.rb
@@ -20,7 +20,7 @@ class Kalibro::MetricConfiguration < Kalibro::Model | @@ -20,7 +20,7 @@ class Kalibro::MetricConfiguration < Kalibro::Model | ||
20 | end | 20 | end |
21 | 21 | ||
22 | def self.metric_configurations_of(configuration_id) | 22 | def self.metric_configurations_of(configuration_id) |
23 | - hash = request("MetricConfiguration", :metric_configurations_of, {:configuration_id => configuration_id}) | 23 | + hash = request(:metric_configurations_of, {:configuration_id => configuration_id}) |
24 | hash[:metric_configuration].to_a.map { |metric_configuration| new metric_configuration } | 24 | hash[:metric_configuration].to_a.map { |metric_configuration| new metric_configuration } |
25 | end | 25 | end |
26 | 26 |
plugins/mezuro/lib/kalibro/metric_result.rb
@@ -15,15 +15,15 @@ class Kalibro::MetricResult < Kalibro::Model | @@ -15,15 +15,15 @@ class Kalibro::MetricResult < Kalibro::Model | ||
15 | end | 15 | end |
16 | 16 | ||
17 | def descendant_results | 17 | def descendant_results |
18 | - self.class.request("MetricResult", :descendant_results_of, {:metric_result_id => self.id})[:descendant_result].to_a | 18 | + self.class.request(:descendant_results_of, {:metric_result_id => self.id})[:descendant_result].to_a |
19 | end | 19 | end |
20 | 20 | ||
21 | def self.metric_results_of(module_result_id) | 21 | def self.metric_results_of(module_result_id) |
22 | - request("MetricResult", :metric_results_of, {:module_result_id => module_result_id})[:metric_result].to_a.map {|metric_result| new metric_result} | 22 | + request(:metric_results_of, {:module_result_id => module_result_id})[:metric_result].to_a.map {|metric_result| new metric_result} |
23 | end | 23 | end |
24 | 24 | ||
25 | def history_of(module_id) | 25 | def history_of(module_id) |
26 | - self.class.request("MetricResult", :history_of, {:metric_name => self.configuration.metric.name, :module_result_id => module_id})[:date_metric_result].to_a.map {|date_metric_result| Kalibro::DateMetricResult.new date_metric_result} | 26 | + self.class.request(:history_of, {:metric_name => self.configuration.metric.name, :module_result_id => module_id})[:date_metric_result].to_a.map {|date_metric_result| Kalibro::DateMetricResult.new date_metric_result} |
27 | end | 27 | end |
28 | 28 | ||
29 | end | 29 | end |
plugins/mezuro/lib/kalibro/model.rb
@@ -20,7 +20,7 @@ class Kalibro::Model | @@ -20,7 +20,7 @@ class Kalibro::Model | ||
20 | hash = {:attributes! => {}}.merge(hash) | 20 | hash = {:attributes! => {}}.merge(hash) |
21 | hash[:attributes!][field.to_sym] = { | 21 | hash[:attributes!][field.to_sym] = { |
22 | 'xmlns:xsi'=> 'http://www.w3.org/2001/XMLSchema-instance', | 22 | 'xmlns:xsi'=> 'http://www.w3.org/2001/XMLSchema-instance', |
23 | - 'xsi:type' => 'kalibro:' + xml_class_name(field_value) } | 23 | + 'xsi:type' => 'kalibro:' + xml_instance_class_name(field_value) } |
24 | end | 24 | end |
25 | end | 25 | end |
26 | end | 26 | end |
@@ -28,7 +28,7 @@ class Kalibro::Model | @@ -28,7 +28,7 @@ class Kalibro::Model | ||
28 | hash | 28 | hash |
29 | end | 29 | end |
30 | 30 | ||
31 | - def self.request(endpoint, action, request_body = nil) | 31 | + def self.request(action, request_body = nil) |
32 | response = client(endpoint).request(:kalibro, action) { soap.body = request_body } | 32 | response = client(endpoint).request(:kalibro, action) { soap.body = request_body } |
33 | response.to_hash["#{action}_response".to_sym] # response is a Savon::SOAP::Response, and to_hash is a Savon::SOAP::Response method | 33 | response.to_hash["#{action}_response".to_sym] # response is a Savon::SOAP::Response, and to_hash is a Savon::SOAP::Response method |
34 | end | 34 | end |
@@ -48,9 +48,17 @@ class Kalibro::Model | @@ -48,9 +48,17 @@ class Kalibro::Model | ||
48 | new_model | 48 | new_model |
49 | end | 49 | end |
50 | 50 | ||
51 | + def self.find(id) | ||
52 | + if(exists?(id)) | ||
53 | + new request(find_action, id_params(id))["#{class_name.underscore}".to_sym] | ||
54 | + else | ||
55 | + nil | ||
56 | + end | ||
57 | + end | ||
58 | + | ||
51 | def save | 59 | def save |
52 | begin | 60 | begin |
53 | - self.id = self.class.request(save_endpoint, save_action, save_params)["#{class_name.underscore}_id".to_sym] | 61 | + self.id = self.class.request(save_action, save_params)["#{instance_class_name.underscore}_id".to_sym] |
54 | true | 62 | true |
55 | rescue Exception => exception | 63 | rescue Exception => exception |
56 | add_error exception | 64 | add_error exception |
@@ -60,14 +68,14 @@ class Kalibro::Model | @@ -60,14 +68,14 @@ class Kalibro::Model | ||
60 | 68 | ||
61 | def destroy | 69 | def destroy |
62 | begin | 70 | begin |
63 | - self.class.request(destroy_endpoint, destroy_action, destroy_params) | 71 | + self.class.request(destroy_action, destroy_params) |
64 | rescue Exception => exception | 72 | rescue Exception => exception |
65 | add_error exception | 73 | add_error exception |
66 | end | 74 | end |
67 | end | 75 | end |
68 | 76 | ||
69 | def self.exists?(id) | 77 | def self.exists?(id) |
70 | - request(exists_endpoint, exists_action, exists_params(id)) | 78 | + request(exists_action, id_params(id))[:exists] |
71 | end | 79 | end |
72 | 80 | ||
73 | protected | 81 | protected |
@@ -86,7 +94,7 @@ class Kalibro::Model | @@ -86,7 +94,7 @@ class Kalibro::Model | ||
86 | value | 94 | value |
87 | end | 95 | end |
88 | 96 | ||
89 | - def xml_class_name(object) | 97 | + def xml_instance_class_name(object) |
90 | xml_name = object.class.name | 98 | xml_name = object.class.name |
91 | xml_name["Kalibro::"] = "" | 99 | xml_name["Kalibro::"] = "" |
92 | xml_name[0..0] = xml_name[0..0].downcase | 100 | xml_name[0..0] = xml_name[0..0].downcase |
@@ -107,48 +115,44 @@ class Kalibro::Model | @@ -107,48 +115,44 @@ class Kalibro::Model | ||
107 | date.to_s[0..18] + milliseconds + date.to_s[19..-1] | 115 | date.to_s[0..18] + milliseconds + date.to_s[19..-1] |
108 | end | 116 | end |
109 | 117 | ||
110 | - def class_name | 118 | + def instance_class_name |
111 | self.class.name.gsub(/Kalibro::/,"") | 119 | self.class.name.gsub(/Kalibro::/,"") |
112 | end | 120 | end |
113 | 121 | ||
114 | - def save_endpoint | 122 | + def self.endpoint |
115 | class_name | 123 | class_name |
116 | end | 124 | end |
117 | 125 | ||
118 | def save_action | 126 | def save_action |
119 | - "save_#{class_name.underscore}".to_sym | 127 | + "save_#{instance_class_name.underscore}".to_sym |
120 | end | 128 | end |
121 | 129 | ||
122 | def save_params | 130 | def save_params |
123 | - {class_name.underscore.to_sym => self.to_hash} | ||
124 | - end | ||
125 | - | ||
126 | - def destroy_endpoint | ||
127 | - class_name | 131 | + {instance_class_name.underscore.to_sym => self.to_hash} |
128 | end | 132 | end |
129 | 133 | ||
130 | def destroy_action | 134 | def destroy_action |
131 | - "delete_#{class_name.underscore}".to_sym | 135 | + "delete_#{instance_class_name.underscore}".to_sym |
132 | end | 136 | end |
133 | 137 | ||
134 | def destroy_params | 138 | def destroy_params |
135 | - {"#{class_name.underscore}_id".to_sym => self.id} | 139 | + {"#{instance_class_name.underscore}_id".to_sym => self.id} |
136 | end | 140 | end |
137 | 141 | ||
138 | - def self.exists_class_name | 142 | + def self.class_name |
139 | self.name.gsub(/Kalibro::/,"") | 143 | self.name.gsub(/Kalibro::/,"") |
140 | end | 144 | end |
141 | 145 | ||
142 | - def self.exists_endpoint | ||
143 | - self.exists_class_name | ||
144 | - end | ||
145 | - | ||
146 | def self.exists_action | 146 | def self.exists_action |
147 | - "#{exists_class_name.underscore}_exists".to_sym | 147 | + "#{class_name.underscore}_exists".to_sym |
148 | end | 148 | end |
149 | 149 | ||
150 | - def self.exists_params(id) | ||
151 | - {"#{exists_class_name.underscore}_id".to_sym => id} | 150 | + def self.id_params(id) |
151 | + {"#{class_name.underscore}_id".to_sym => id} | ||
152 | + end | ||
153 | + | ||
154 | + def self.find_action | ||
155 | + "get_#{class_name.underscore}".to_sym | ||
152 | end | 156 | end |
153 | 157 | ||
154 | def add_error(exception) | 158 | def add_error(exception) |
plugins/mezuro/lib/kalibro/module.rb
@@ -2,20 +2,4 @@ class Kalibro::Module < Kalibro::Model | @@ -2,20 +2,4 @@ class Kalibro::Module < Kalibro::Model | ||
2 | 2 | ||
3 | attr_accessor :name, :granularity | 3 | attr_accessor :name, :granularity |
4 | 4 | ||
5 | -=begin | ||
6 | - def self.parent_names(name) | ||
7 | - path = [] | ||
8 | - ancestors = [] | ||
9 | - name.split(".").each do |token| | ||
10 | - path << token | ||
11 | - ancestors << path.join(".") | ||
12 | - end | ||
13 | - ancestors | ||
14 | - end | ||
15 | - | ||
16 | - def ancestor_names | ||
17 | - self.class.parent_names(@name) | ||
18 | - end | ||
19 | -=end | ||
20 | - | ||
21 | end | 5 | end |
plugins/mezuro/lib/kalibro/module_node.rb
@@ -1,21 +0,0 @@ | @@ -1,21 +0,0 @@ | ||
1 | -class Kalibro::ModuleNode < Kalibro::Model | ||
2 | - | ||
3 | - attr_accessor :module, :child | ||
4 | - | ||
5 | - def module=(value) | ||
6 | - @module = Kalibro::Module.to_object value | ||
7 | - end | ||
8 | - | ||
9 | - def child=(value) | ||
10 | - @child = Kalibro::ModuleNode.to_objects_array value | ||
11 | - end | ||
12 | - | ||
13 | - def children | ||
14 | - @child | ||
15 | - end | ||
16 | - | ||
17 | - def children=(children) | ||
18 | - @child = children | ||
19 | - end | ||
20 | - | ||
21 | -end |
plugins/mezuro/lib/kalibro/module_result.rb
@@ -3,11 +3,11 @@ class Kalibro::ModuleResult < Kalibro::Model | @@ -3,11 +3,11 @@ class Kalibro::ModuleResult < Kalibro::Model | ||
3 | attr_accessor :id, :module, :grade, :parent_id | 3 | attr_accessor :id, :module, :grade, :parent_id |
4 | 4 | ||
5 | def self.find(id) | 5 | def self.find(id) |
6 | - new request('ModuleResult', :get_module_result, { :module_result_id => id })[:module_result] | 6 | + new request(:get_module_result, { :module_result_id => id })[:module_result] |
7 | end | 7 | end |
8 | 8 | ||
9 | def children | 9 | def children |
10 | - hash_array = self.class.request('ModuleResult',:children_of, {:module_result_id => self.id})[:module_result].to_a | 10 | + hash_array = self.class.request(:children_of, {:module_result_id => self.id})[:module_result].to_a |
11 | hash_array.map { |module_result| self.class.new module_result } | 11 | hash_array.map { |module_result| self.class.new module_result } |
12 | end | 12 | end |
13 | 13 |
plugins/mezuro/lib/kalibro/processing.rb
1 | class Kalibro::Processing < Kalibro::Model | 1 | class Kalibro::Processing < Kalibro::Model |
2 | 2 | ||
3 | - attr_accessor :id, :date, :state, :error, :process_times, :results_root_id | 3 | + attr_accessor :id, :date, :state, :error, :process_time, :results_root_id |
4 | 4 | ||
5 | def self.has_processing(repository_id) | 5 | def self.has_processing(repository_id) |
6 | - request('Processing', :has_processing, {:repository_id => repository_id})[:exists] | 6 | + request(:has_processing, {:repository_id => repository_id})[:exists] |
7 | end | 7 | end |
8 | 8 | ||
9 | def self.has_ready_processing(repository_id) | 9 | def self.has_ready_processing(repository_id) |
10 | - request('Processing', :has_ready_processing, {:repository_id => repository_id})[:exists] | 10 | + request(:has_ready_processing, {:repository_id => repository_id})[:exists] |
11 | end | 11 | end |
12 | 12 | ||
13 | def self.has_processing_after(repository_id, date) | 13 | def self.has_processing_after(repository_id, date) |
14 | - request('Processing', :has_processing_after, {:repository_id => repository_id, :date => date})[:exists] | 14 | + request(:has_processing_after, {:repository_id => repository_id, :date => date})[:exists] |
15 | end | 15 | end |
16 | 16 | ||
17 | def self.has_processing_before(repository_id, date) | 17 | def self.has_processing_before(repository_id, date) |
18 | - request('Processing', :has_processing_before, {:repository_id => repository_id, :date => date})[:exists] | 18 | + request(:has_processing_before, {:repository_id => repository_id, :date => date})[:exists] |
19 | end | 19 | end |
20 | 20 | ||
21 | def self.last_processing_state_of(repository_id) | 21 | def self.last_processing_state_of(repository_id) |
22 | - request('Processing', :last_processing_state, {:repository_id => repository_id})[:process_state] | 22 | + request(:last_processing_state, {:repository_id => repository_id})[:process_state] |
23 | end | 23 | end |
24 | 24 | ||
25 | def self.last_ready_processing_of(repository_id) | 25 | def self.last_ready_processing_of(repository_id) |
26 | - new request('Processing', :last_ready_processing, {:repository_id => repository_id})[:processing] | 26 | + new request(:last_ready_processing, {:repository_id => repository_id})[:processing] |
27 | end | 27 | end |
28 | 28 | ||
29 | def self.first_processing_of(repository_id) | 29 | def self.first_processing_of(repository_id) |
30 | - new request('Processing', :first_processing, {:repository_id => repository_id})[:processing] | 30 | + new request(:first_processing, {:repository_id => repository_id})[:processing] |
31 | end | 31 | end |
32 | 32 | ||
33 | def self.last_processing_of(repository_id) | 33 | def self.last_processing_of(repository_id) |
34 | - new request('Processing', :last_processing, {:repository_id => repository_id})[:processing] | 34 | + new request(:last_processing, {:repository_id => repository_id})[:processing] |
35 | end | 35 | end |
36 | 36 | ||
37 | def self.first_processing_after(repository_id, date) | 37 | def self.first_processing_after(repository_id, date) |
38 | - new request('Processing', :first_processing_after, {:repository_id => repository_id, :date => date})[:processing] | 38 | + new request(:first_processing_after, {:repository_id => repository_id, :date => date})[:processing] |
39 | end | 39 | end |
40 | 40 | ||
41 | def self.last_processing_before(repository_id, date) | 41 | def self.last_processing_before(repository_id, date) |
42 | - new request('Processing', :last_processing_before, {:repository_id => repository_id, :date => date})[:processing] | 42 | + new request(:last_processing_before, {:repository_id => repository_id, :date => date})[:processing] |
43 | end | 43 | end |
44 | 44 | ||
45 | def date=(value) | 45 | def date=(value) |
46 | @date = value.is_a?(String) ? DateTime.parse(value) : value | 46 | @date = value.is_a?(String) ? DateTime.parse(value) : value |
47 | end | 47 | end |
48 | 48 | ||
49 | + def process_times=(value) | ||
50 | + process_time=value | ||
51 | + end | ||
52 | + | ||
53 | + def process_time=(value) | ||
54 | + @process_time = Kalibro::ProcessTime.to_objects_array value | ||
55 | + end | ||
56 | + | ||
57 | + def process_times | ||
58 | + process_time | ||
59 | + end | ||
60 | + | ||
49 | end | 61 | end |
plugins/mezuro/lib/kalibro/project.rb
@@ -3,50 +3,13 @@ class Kalibro::Project < Kalibro::Model | @@ -3,50 +3,13 @@ class Kalibro::Project < Kalibro::Model | ||
3 | attr_accessor :id, :name, :description | 3 | attr_accessor :id, :name, :description |
4 | 4 | ||
5 | def self.all | 5 | def self.all |
6 | - response = request("Project", :all_projects)[:project].to_a | 6 | + response = request(:all_projects)[:project].to_a |
7 | response = [] if response.nil? | 7 | response = [] if response.nil? |
8 | response.map {|project| new project} | 8 | response.map {|project| new project} |
9 | end | 9 | end |
10 | 10 | ||
11 | - def self.find(project_id) | ||
12 | - new request("Project", :get_project, :project_id => project_id)[:project] | ||
13 | - end | ||
14 | - | ||
15 | def self.project_of(repository_id) | 11 | def self.project_of(repository_id) |
16 | - new request("Project", :project_of, :repository_id => repository_id)[:project] | ||
17 | - end | ||
18 | -=begin | ||
19 | - def error=(value) | ||
20 | - @kalibro_error = Kalibro::Error.to_object value | ||
21 | - end | ||
22 | - | ||
23 | - def process_project(days = '0') | ||
24 | - begin | ||
25 | - if days.to_i.zero? | ||
26 | - self.class.request("Kalibro", :process_project, {:project_name => name}) | ||
27 | - else | ||
28 | - self.class.request("Kalibro", :process_periodically, {:project_name => name, :period_in_days => days}) | ||
29 | - end | ||
30 | - rescue Exception => exception | ||
31 | - add_error exception | ||
32 | - end | ||
33 | - end | ||
34 | - | ||
35 | - def process_period | ||
36 | - begin | ||
37 | - self.class.request("Kalibro", :get_process_period, {:project_name => name})[:period] | ||
38 | - rescue Exception => exception | ||
39 | - add_error exception | ||
40 | - end | ||
41 | - end | ||
42 | - | ||
43 | - def cancel_periodic_process | ||
44 | - begin | ||
45 | - self.class.request("Kalibro", :cancel_periodic_process, {:project_name => name}) | ||
46 | - rescue Exception => exception | ||
47 | - add_error exception | ||
48 | - end | 12 | + new request(:project_of, :repository_id => repository_id)[:project] |
49 | end | 13 | end |
50 | -=end | ||
51 | 14 | ||
52 | end | 15 | end |
plugins/mezuro/lib/kalibro/range.rb
@@ -39,12 +39,12 @@ class Kalibro::Range < Kalibro::Model | @@ -39,12 +39,12 @@ class Kalibro::Range < Kalibro::Model | ||
39 | end | 39 | end |
40 | 40 | ||
41 | def self.ranges_of( metric_configuration_id ) | 41 | def self.ranges_of( metric_configuration_id ) |
42 | - request("Range", :ranges_of, {:metric_configuration_id => metric_configuration_id} )[:range].to_a.map { |range| new range } | 42 | + request(:ranges_of, {:metric_configuration_id => metric_configuration_id} )[:range].to_a.map { |range| new range } |
43 | end | 43 | end |
44 | 44 | ||
45 | def save( metric_configuration_id ) | 45 | def save( metric_configuration_id ) |
46 | begin | 46 | begin |
47 | - self.id = self.class.request("Range", :save_range, {:range => self.to_hash, :metric_configuration_id => metric_configuration_id})[:range_id] | 47 | + self.id = self.class.request(:save_range, {:range => self.to_hash, :metric_configuration_id => metric_configuration_id})[:range_id] |
48 | true | 48 | true |
49 | rescue Exception => exception | 49 | rescue Exception => exception |
50 | add_error exception | 50 | add_error exception |
plugins/mezuro/lib/kalibro/reading.rb
@@ -3,15 +3,15 @@ class Kalibro::Reading < Kalibro::Model | @@ -3,15 +3,15 @@ class Kalibro::Reading < Kalibro::Model | ||
3 | attr_accessor :id, :label, :grade, :color | 3 | attr_accessor :id, :label, :grade, :color |
4 | 4 | ||
5 | def self.find(id) | 5 | def self.find(id) |
6 | - new request("Reading", :get_reading, {:reading_id => id})[:reading] | 6 | + new request(:get_reading, {:reading_id => id})[:reading] |
7 | end | 7 | end |
8 | 8 | ||
9 | def self.readings_of( group_id ) | 9 | def self.readings_of( group_id ) |
10 | - request("Reading", :readings_of, {:group_id => group_id})[:reading].to_a.map { |reading| new reading } | 10 | + request(:readings_of, {:group_id => group_id})[:reading].to_a.map { |reading| new reading } |
11 | end | 11 | end |
12 | 12 | ||
13 | def self.reading_of( range_id ) | 13 | def self.reading_of( range_id ) |
14 | - new request("Reading", :reading_of, {:range_id => range_id} )[:reading] | 14 | + new request(:reading_of, {:range_id => range_id} )[:reading] |
15 | end | 15 | end |
16 | 16 | ||
17 | end | 17 | end |
plugins/mezuro/lib/kalibro/reading_group.rb
@@ -2,21 +2,17 @@ class Kalibro::ReadingGroup < Kalibro::Model | @@ -2,21 +2,17 @@ class Kalibro::ReadingGroup < Kalibro::Model | ||
2 | 2 | ||
3 | attr_accessor :id, :name, :description | 3 | attr_accessor :id, :name, :description |
4 | 4 | ||
5 | - def self.find(id) | ||
6 | - new request("ReadingGroup", :get_reading_group, {:group_id => id})[:reading_group] | ||
7 | - end | ||
8 | - | ||
9 | def self.all | 5 | def self.all |
10 | - request("ReadingGroup", :all_reading_groups)[:reading_group].to_a.map { |reading_group| new reading_group } | 6 | + request(:all_reading_groups)[:reading_group].to_a.map { |reading_group| new reading_group } |
11 | end | 7 | end |
12 | 8 | ||
13 | def self.reading_group_of( metric_configuration_id ) | 9 | def self.reading_group_of( metric_configuration_id ) |
14 | - new request("ReadingGroup", :reading_group_of, {:metric_configuration_id => metric_configuration_id} )[:reading_group] | 10 | + new request(:reading_group_of, {:metric_configuration_id => metric_configuration_id} )[:reading_group] |
15 | end | 11 | end |
16 | 12 | ||
17 | private | 13 | private |
18 | 14 | ||
19 | - def self.exists_params(id) | 15 | + def self.id_params(id) |
20 | {:group_id => id} | 16 | {:group_id => id} |
21 | end | 17 | end |
22 | 18 |
plugins/mezuro/lib/kalibro/repository.rb
@@ -3,23 +3,23 @@ class Kalibro::Repository < Kalibro::Model | @@ -3,23 +3,23 @@ class Kalibro::Repository < Kalibro::Model | ||
3 | attr_accessor :id, :name, :description, :license, :process_period, :type, :address, :configuration_id | 3 | attr_accessor :id, :name, :description, :license, :process_period, :type, :address, :configuration_id |
4 | 4 | ||
5 | def self.repository_types | 5 | def self.repository_types |
6 | - request("Repository", :supported_repository_types)[:repository_type].to_a | 6 | + request(:supported_repository_types)[:repository_type].to_a |
7 | end | 7 | end |
8 | 8 | ||
9 | def self.repository_of(processing_id) | 9 | def self.repository_of(processing_id) |
10 | - new request("Repository", :repository_of, {:processing_id => processing_id})[:repository] | 10 | + new request(:repository_of, {:processing_id => processing_id})[:repository] |
11 | end | 11 | end |
12 | 12 | ||
13 | def self.repositories_of(project_id) | 13 | def self.repositories_of(project_id) |
14 | - request("Repository", :repositories_of, {:project_id => project_id})[:repository].to_a.map { |repository| new repository } | 14 | + request(:repositories_of, {:project_id => project_id})[:repository].to_a.map { |repository| new repository } |
15 | end | 15 | end |
16 | 16 | ||
17 | def process_repository | 17 | def process_repository |
18 | - self.class.request("Repository", :process_repository, {:repository_id => self.id}); | 18 | + self.class.request(:process_repository, {:repository_id => self.id}); |
19 | end | 19 | end |
20 | 20 | ||
21 | def cancel_processing_of_repository | 21 | def cancel_processing_of_repository |
22 | - self.class.request("Repository", :cancel_processing_of_repository, {:repository_id => self.id}); | 22 | + self.class.request(:cancel_processing_of_repository, {:repository_id => self.id}); |
23 | end | 23 | end |
24 | 24 | ||
25 | end | 25 | end |
plugins/mezuro/test/fixtures/compound_metric_with_error_fixtures.rb
@@ -1,20 +0,0 @@ | @@ -1,20 +0,0 @@ | ||
1 | -require File.dirname(__FILE__) + '/error_fixtures' | ||
2 | -require File.dirname(__FILE__) + '/compound_metric_fixtures' | ||
3 | - | ||
4 | -class CompoundMetricWithErrorFixtures | ||
5 | - | ||
6 | - def self.compound_metric_with_error | ||
7 | - Kalibro::CompoundMetricWithError.new compound_metric_with_error_hash | ||
8 | - end | ||
9 | - | ||
10 | - def self.compound_metric_with_error_hash | ||
11 | - {:metric => CompoundMetricFixtures.compound_metric_hash, :error => ErrorFixtures.error_hash, | ||
12 | - :attributes! => {:metric => { | ||
13 | - 'xmlns:xsi'=> 'http://www.w3.org/2001/XMLSchema-instance', | ||
14 | - 'xsi:type' => 'kalibro:compoundMetricXml' }, | ||
15 | - :error => { | ||
16 | - 'xmlns:xsi'=> 'http://www.w3.org/2001/XMLSchema-instance', | ||
17 | - 'xsi:type' => 'kalibro:errorXml' }}} | ||
18 | - end | ||
19 | - | ||
20 | -end |
plugins/mezuro/test/fixtures/module_node_fixtures.rb
@@ -1,47 +0,0 @@ | @@ -1,47 +0,0 @@ | ||
1 | -require File.dirname(__FILE__) + '/module_fixtures' | ||
2 | - | ||
3 | -class ModuleNodeFixtures | ||
4 | - | ||
5 | - def self.module_node | ||
6 | - Kalibro::ModuleNode.new module_node_hash | ||
7 | - end | ||
8 | - | ||
9 | - def self.module_node_hash | ||
10 | - { | ||
11 | - :module => ModuleFixtures.module_hash,:attributes! => {:module => { | ||
12 | - 'xmlns:xsi'=> 'http://www.w3.org/2001/XMLSchema-instance', | ||
13 | - 'xsi:type' => 'kalibro:moduleXml' }}, | ||
14 | - :child => [{ | ||
15 | - :module => { | ||
16 | - :name => 'org', | ||
17 | - :granularity => 'PACKAGE' | ||
18 | - },:attributes! => {:module => { | ||
19 | - 'xmlns:xsi'=> 'http://www.w3.org/2001/XMLSchema-instance', | ||
20 | - 'xsi:type' => 'kalibro:moduleXml' }}, | ||
21 | - :child => [{ | ||
22 | - :module => { | ||
23 | - :name => 'org.Window', | ||
24 | - :granularity => 'CLASS' | ||
25 | - },:attributes! => {:module => { | ||
26 | - 'xmlns:xsi'=> 'http://www.w3.org/2001/XMLSchema-instance', | ||
27 | - 'xsi:type' => 'kalibro:moduleXml' }} | ||
28 | - }] | ||
29 | - },{ | ||
30 | - :module => { | ||
31 | - :name => 'Dialog', | ||
32 | - :granularity => 'CLASS' | ||
33 | - },:attributes! => {:module => { | ||
34 | - 'xmlns:xsi'=> 'http://www.w3.org/2001/XMLSchema-instance', | ||
35 | - 'xsi:type' => 'kalibro:moduleXml' }} | ||
36 | - },{ | ||
37 | - :module => { | ||
38 | - :name => 'main', | ||
39 | - :granularity => 'CLASS' | ||
40 | - },:attributes! => {:module => { | ||
41 | - 'xmlns:xsi'=> 'http://www.w3.org/2001/XMLSchema-instance', | ||
42 | - 'xsi:type' => 'kalibro:moduleXml' }} | ||
43 | - }] | ||
44 | - } | ||
45 | - end | ||
46 | - | ||
47 | -end |
plugins/mezuro/test/fixtures/processing_fixtures.rb
@@ -11,7 +11,7 @@ class ProcessingFixtures | @@ -11,7 +11,7 @@ class ProcessingFixtures | ||
11 | :id => 31, | 11 | :id => 31, |
12 | :date => '2011-10-20T18:26:43.151+00:00', | 12 | :date => '2011-10-20T18:26:43.151+00:00', |
13 | :state => 'READY', | 13 | :state => 'READY', |
14 | - :process_times => [ProcessTimeFixtures.process_time_hash], | 14 | + :process_time => [ProcessTimeFixtures.process_time_hash], |
15 | :results_root_id => 13 | 15 | :results_root_id => 13 |
16 | } | 16 | } |
17 | end | 17 | end |
plugins/mezuro/test/unit/kalibro/base_tool_test.rb
@@ -12,21 +12,15 @@ class BaseToolTest < ActiveSupport::TestCase | @@ -12,21 +12,15 @@ class BaseToolTest < ActiveSupport::TestCase | ||
12 | assert_equal @hash[:name], Kalibro::BaseTool.new(@hash).name | 12 | assert_equal @hash[:name], Kalibro::BaseTool.new(@hash).name |
13 | end | 13 | end |
14 | 14 | ||
15 | -# Mezuro will not send a base_tool hash back to Kalibro | ||
16 | -# | ||
17 | -# should 'convert base tool to hash' do | ||
18 | -# assert_equal @hash, @base_tool.to_hash | ||
19 | -# end | ||
20 | - | ||
21 | should 'get base tool names' do | 15 | should 'get base tool names' do |
22 | names = ['Analizo', 'Checkstyle'] | 16 | names = ['Analizo', 'Checkstyle'] |
23 | - Kalibro::BaseTool.expects(:request).with("BaseTool", :all_base_tool_names).returns({:base_tool_name => names}) | 17 | + Kalibro::BaseTool.expects(:request).with(:all_base_tool_names).returns({:base_tool_name => names}) |
24 | assert_equal names, Kalibro::BaseTool.all_names | 18 | assert_equal names, Kalibro::BaseTool.all_names |
25 | end | 19 | end |
26 | 20 | ||
27 | should 'get base tool by name' do | 21 | should 'get base tool by name' do |
28 | request_body = {:base_tool_name => @base_tool.name} | 22 | request_body = {:base_tool_name => @base_tool.name} |
29 | - Kalibro::BaseTool.expects(:request).with("BaseTool", :get_base_tool, request_body).returns({:base_tool => @hash}) | 23 | + Kalibro::BaseTool.expects(:request).with(:get_base_tool, request_body).returns({:base_tool => @hash}) |
30 | assert_equal @base_tool.name, Kalibro::BaseTool.find_by_name(@base_tool.name).name | 24 | assert_equal @base_tool.name, Kalibro::BaseTool.find_by_name(@base_tool.name).name |
31 | end | 25 | end |
32 | 26 |
plugins/mezuro/test/unit/kalibro/compound_metric_with_error_test.rb
@@ -1,20 +0,0 @@ | @@ -1,20 +0,0 @@ | ||
1 | -require "test_helper" | ||
2 | - | ||
3 | -require "#{RAILS_ROOT}/plugins/mezuro/test/fixtures/compound_metric_with_error_fixtures" | ||
4 | - | ||
5 | -class CompoundMetricWithErrorTest < ActiveSupport::TestCase | ||
6 | - | ||
7 | - def setup | ||
8 | - @hash = CompoundMetricWithErrorFixtures.compound_metric_with_error_hash | ||
9 | - @compound_metric_with_error = CompoundMetricWithErrorFixtures.compound_metric_with_error | ||
10 | - end | ||
11 | - | ||
12 | - should 'create error from hash' do | ||
13 | - assert_equal @hash[:error][:message], Kalibro::CompoundMetricWithError.new(@hash).error.message | ||
14 | - end | ||
15 | - | ||
16 | - should 'convert error to hash' do | ||
17 | - assert_equal @hash, @compound_metric_with_error.to_hash | ||
18 | - end | ||
19 | - | ||
20 | -end |
plugins/mezuro/test/unit/kalibro/metric_configuration_test.rb
@@ -22,27 +22,27 @@ class MetricConfigurationTest < ActiveSupport::TestCase | @@ -22,27 +22,27 @@ class MetricConfigurationTest < ActiveSupport::TestCase | ||
22 | configuration_id = 13 | 22 | configuration_id = 13 |
23 | request_body = { :configuration_id => configuration_id } | 23 | request_body = { :configuration_id => configuration_id } |
24 | response_hash = {:metric_configuration => [@native_metric_configuration_hash]} | 24 | response_hash = {:metric_configuration => [@native_metric_configuration_hash]} |
25 | - Kalibro::MetricConfiguration.expects(:request).with("MetricConfiguration", :metric_configurations_of, request_body).returns(response_hash) | 25 | + Kalibro::MetricConfiguration.expects(:request).with(:metric_configurations_of, request_body).returns(response_hash) |
26 | assert_equal @native_metric_configuration.code, Kalibro::MetricConfiguration.metric_configurations_of(configuration_id).first.code | 26 | assert_equal @native_metric_configuration.code, Kalibro::MetricConfiguration.metric_configurations_of(configuration_id).first.code |
27 | end | 27 | end |
28 | 28 | ||
29 | should 'return true when metric configuration is saved successfully' do | 29 | should 'return true when metric configuration is saved successfully' do |
30 | id_from_kalibro = 1 | 30 | id_from_kalibro = 1 |
31 | configuration_id = @created_metric_configuration.configuration_id | 31 | configuration_id = @created_metric_configuration.configuration_id |
32 | - Kalibro::MetricConfiguration.expects(:request).with("MetricConfiguration", :save_metric_configuration, {:metric_configuration => @created_metric_configuration.to_hash, :configuration_id => configuration_id}).returns(:metric_configuration_id => id_from_kalibro) | 32 | + Kalibro::MetricConfiguration.expects(:request).with(:save_metric_configuration, {:metric_configuration => @created_metric_configuration.to_hash, :configuration_id => configuration_id}).returns(:metric_configuration_id => id_from_kalibro) |
33 | assert @created_metric_configuration.save | 33 | assert @created_metric_configuration.save |
34 | assert_equal id_from_kalibro, @created_metric_configuration.id | 34 | assert_equal id_from_kalibro, @created_metric_configuration.id |
35 | end | 35 | end |
36 | 36 | ||
37 | should 'return false when metric configuration is not saved successfully' do | 37 | should 'return false when metric configuration is not saved successfully' do |
38 | configuration_id = @created_metric_configuration.configuration_id | 38 | configuration_id = @created_metric_configuration.configuration_id |
39 | - Kalibro::MetricConfiguration.expects(:request).with("MetricConfiguration", :save_metric_configuration, {:metric_configuration => @created_metric_configuration.to_hash, :configuration_id => configuration_id}).raises(Exception.new) | 39 | + Kalibro::MetricConfiguration.expects(:request).with(:save_metric_configuration, {:metric_configuration => @created_metric_configuration.to_hash, :configuration_id => configuration_id}).raises(Exception.new) |
40 | assert !(@created_metric_configuration.save) | 40 | assert !(@created_metric_configuration.save) |
41 | assert_nil @created_metric_configuration.id | 41 | assert_nil @created_metric_configuration.id |
42 | end | 42 | end |
43 | 43 | ||
44 | should 'destroy metric configuration' do | 44 | should 'destroy metric configuration' do |
45 | - Kalibro::MetricConfiguration.expects(:request).with("MetricConfiguration", :delete_metric_configuration, :metric_configuration_id => @native_metric_configuration.id) | 45 | + Kalibro::MetricConfiguration.expects(:request).with(:delete_metric_configuration, :metric_configuration_id => @native_metric_configuration.id) |
46 | @native_metric_configuration.destroy | 46 | @native_metric_configuration.destroy |
47 | end | 47 | end |
48 | 48 |
plugins/mezuro/test/unit/kalibro/metric_result_test.rb
@@ -21,19 +21,19 @@ class MetricResultTest < ActiveSupport::TestCase | @@ -21,19 +21,19 @@ class MetricResultTest < ActiveSupport::TestCase | ||
21 | 21 | ||
22 | should 'return descendant results of a metric result' do | 22 | should 'return descendant results of a metric result' do |
23 | descendant = [31, 13] | 23 | descendant = [31, 13] |
24 | - Kalibro::MetricResult.expects(:request).with("MetricResult", :descendant_results_of, {:metric_result_id => @result.id}).returns({:descendant_result => descendant}) | 24 | + Kalibro::MetricResult.expects(:request).with(:descendant_results_of, {:metric_result_id => @result.id}).returns({:descendant_result => descendant}) |
25 | assert_equal descendant, @result.descendant_results | 25 | assert_equal descendant, @result.descendant_results |
26 | end | 26 | end |
27 | 27 | ||
28 | should 'return metric results of a module result' do | 28 | should 'return metric results of a module result' do |
29 | id = 31 | 29 | id = 31 |
30 | - Kalibro::MetricResult.expects(:request).with("MetricResult", :metric_results_of, {:module_result_id => id}).returns(:metric_result => [@native_hash, @compound_hash]) | 30 | + Kalibro::MetricResult.expects(:request).with(:metric_results_of, {:module_result_id => id}).returns(:metric_result => [@native_hash, @compound_hash]) |
31 | assert_equal @native_hash[:id], Kalibro::MetricResult.metric_results_of(id).first.id | 31 | assert_equal @native_hash[:id], Kalibro::MetricResult.metric_results_of(id).first.id |
32 | end | 32 | end |
33 | 33 | ||
34 | should 'return history of a metric with a module result id' do | 34 | should 'return history of a metric with a module result id' do |
35 | module_id = 31 | 35 | module_id = 31 |
36 | - Kalibro::MetricResult.expects(:request).with("MetricResult", :history_of, {:metric_name => @result.configuration.metric.name, :module_result_id => module_id}).returns({:date_metric_result => [DateMetricResultFixtures.date_metric_result_hash]}) | 36 | + Kalibro::MetricResult.expects(:request).with(:history_of, {:metric_name => @result.configuration.metric.name, :module_result_id => module_id}).returns({:date_metric_result => [DateMetricResultFixtures.date_metric_result_hash]}) |
37 | assert_equal DateMetricResultFixtures.date_metric_result_hash[:metric_result][:id], @result.history_of(module_id).first.metric_result.id | 37 | assert_equal DateMetricResultFixtures.date_metric_result_hash[:metric_result][:id], @result.history_of(module_id).first.metric_result.id |
38 | end | 38 | end |
39 | 39 |
plugins/mezuro/test/unit/kalibro/module_node_test.rb
@@ -1,19 +0,0 @@ | @@ -1,19 +0,0 @@ | ||
1 | -require "test_helper" | ||
2 | -require "#{RAILS_ROOT}/plugins/mezuro/test/fixtures/module_node_fixtures" | ||
3 | - | ||
4 | -class ModuleNodeTest < ActiveSupport::TestCase | ||
5 | - | ||
6 | - def setup | ||
7 | - @hash = ModuleNodeFixtures.module_node_hash | ||
8 | - @node = ModuleNodeFixtures.module_node | ||
9 | - end | ||
10 | - | ||
11 | - should 'create module node from hash' do | ||
12 | - assert_equal( @node.child[0].module.name, Kalibro::ModuleNode.new(@hash).child[0].module.name) | ||
13 | - end | ||
14 | - | ||
15 | - should 'convert children hash to array of ModuleNode' do | ||
16 | - assert_equal @hash, @node.to_hash | ||
17 | - end | ||
18 | - | ||
19 | -end |
plugins/mezuro/test/unit/kalibro/module_result_test.rb
@@ -8,6 +8,7 @@ class ModuleResultTest < ActiveSupport::TestCase | @@ -8,6 +8,7 @@ class ModuleResultTest < ActiveSupport::TestCase | ||
8 | @hash = ModuleResultFixtures.module_result_hash | 8 | @hash = ModuleResultFixtures.module_result_hash |
9 | @module_result = ModuleResultFixtures.module_result | 9 | @module_result = ModuleResultFixtures.module_result |
10 | end | 10 | end |
11 | + | ||
11 | should 'create module result' do | 12 | should 'create module result' do |
12 | assert_equal @hash[:id] , Kalibro::ModuleResult.new(@hash).id | 13 | assert_equal @hash[:id] , Kalibro::ModuleResult.new(@hash).id |
13 | end | 14 | end |
@@ -18,13 +19,13 @@ class ModuleResultTest < ActiveSupport::TestCase | @@ -18,13 +19,13 @@ class ModuleResultTest < ActiveSupport::TestCase | ||
18 | 19 | ||
19 | should 'find module result' do | 20 | should 'find module result' do |
20 | response = {:module_result => @hash} | 21 | response = {:module_result => @hash} |
21 | - Kalibro::ModuleResult.expects(:request).with('ModuleResult',:get_module_result, {:module_result_id => @module_result.id}).returns(response) | 22 | + Kalibro::ModuleResult.expects(:request).with(:get_module_result, {:module_result_id => @module_result.id}).returns(response) |
22 | assert_equal @module_result.grade, Kalibro::ModuleResult.find(@module_result.id).grade | 23 | assert_equal @module_result.grade, Kalibro::ModuleResult.find(@module_result.id).grade |
23 | end | 24 | end |
24 | 25 | ||
25 | should 'return children of a module result' do | 26 | should 'return children of a module result' do |
26 | response = {:module_result => [@hash]} | 27 | response = {:module_result => [@hash]} |
27 | - Kalibro::ModuleResult.expects(:request).with('ModuleResult',:children_of, {:module_result_id => @module_result.id}).returns(response) | 28 | + Kalibro::ModuleResult.expects(:request).with(:children_of, {:module_result_id => @module_result.id}).returns(response) |
28 | assert @hash[:id], @module_result.children.first.id | 29 | assert @hash[:id], @module_result.children.first.id |
29 | end | 30 | end |
30 | 31 |
plugins/mezuro/test/unit/kalibro/module_test.rb
@@ -17,16 +17,4 @@ class ModuleTest < ActiveSupport::TestCase | @@ -17,16 +17,4 @@ class ModuleTest < ActiveSupport::TestCase | ||
17 | assert_equal @hash, @module.to_hash | 17 | assert_equal @hash, @module.to_hash |
18 | end | 18 | end |
19 | 19 | ||
20 | -=begin | ||
21 | - should 'list ancestor names' do | ||
22 | - @module.name = "org.kalibro.core" | ||
23 | - assert_equal ["org", "org.kalibro", "org.kalibro.core"], @module.ancestor_names | ||
24 | - end | ||
25 | - | ||
26 | - should 'list ancestor with one name' do | ||
27 | - @module.name = "org" | ||
28 | - assert_equal ["org"], @module.ancestor_names | ||
29 | - end | ||
30 | -=end | ||
31 | - | ||
32 | end | 20 | end |
plugins/mezuro/test/unit/kalibro/processing_test.rb
@@ -9,21 +9,11 @@ class ProcessingTest < ActiveSupport::TestCase | @@ -9,21 +9,11 @@ class ProcessingTest < ActiveSupport::TestCase | ||
9 | @processing = ProcessingFixtures.processing | 9 | @processing = ProcessingFixtures.processing |
10 | 10 | ||
11 | @repository_id = 31 | 11 | @repository_id = 31 |
12 | - | ||
13 | -=begin | ||
14 | - @project_name = @processing.project.name | ||
15 | - @date = @processing.date | ||
16 | - @flag = DateTime.now.sec % 2 == 0 #random choose between true or false | ||
17 | - | ||
18 | - @request = {:project_name => @project_name} | ||
19 | - @request_with_date = {:project_name => @project_name, :date => @date} | ||
20 | - @flag_response = {:has_results => @flag} | ||
21 | - @result_response = {:processing => @processing.to_hash} | ||
22 | -=end | ||
23 | end | 12 | end |
24 | 13 | ||
25 | should 'create project result from hash' do | 14 | should 'create project result from hash' do |
26 | - assert_equal @processing.results_root_id, Kalibro::Processing.new(@hash).results_root_id | 15 | + assert_equal @hash[:results_root_id], Kalibro::Processing.new(@hash).results_root_id |
16 | + assert_equal @hash[:process_time].first[:state], Kalibro::Processing.new(@hash).process_times.first.state | ||
27 | end | 17 | end |
28 | 18 | ||
29 | should 'convert project result to hash' do | 19 | should 'convert project result to hash' do |
@@ -34,8 +24,8 @@ class ProcessingTest < ActiveSupport::TestCase | @@ -34,8 +24,8 @@ class ProcessingTest < ActiveSupport::TestCase | ||
34 | true_repository_id = 31 | 24 | true_repository_id = 31 |
35 | false_repository_id = 32 | 25 | false_repository_id = 32 |
36 | 26 | ||
37 | - Kalibro::Processing.expects(:request).with('Processing',:has_processing, {:repository_id => true_repository_id}).returns({:exists => true}) | ||
38 | - Kalibro::Processing.expects(:request).with('Processing',:has_processing, {:repository_id => false_repository_id}).returns({:exists => false}) | 27 | + Kalibro::Processing.expects(:request).with(:has_processing, {:repository_id => true_repository_id}).returns({:exists => true}) |
28 | + Kalibro::Processing.expects(:request).with(:has_processing, {:repository_id => false_repository_id}).returns({:exists => false}) | ||
39 | 29 | ||
40 | assert Kalibro::Processing.has_processing(true_repository_id) | 30 | assert Kalibro::Processing.has_processing(true_repository_id) |
41 | assert !Kalibro::Processing.has_processing(false_repository_id) | 31 | assert !Kalibro::Processing.has_processing(false_repository_id) |
@@ -45,8 +35,8 @@ class ProcessingTest < ActiveSupport::TestCase | @@ -45,8 +35,8 @@ class ProcessingTest < ActiveSupport::TestCase | ||
45 | true_repository_id = 31 | 35 | true_repository_id = 31 |
46 | false_repository_id = 32 | 36 | false_repository_id = 32 |
47 | 37 | ||
48 | - Kalibro::Processing.expects(:request).with('Processing',:has_ready_processing, {:repository_id => true_repository_id}).returns({:exists => true}) | ||
49 | - Kalibro::Processing.expects(:request).with('Processing',:has_ready_processing, {:repository_id => false_repository_id}).returns({:exists => false}) | 38 | + Kalibro::Processing.expects(:request).with(:has_ready_processing, {:repository_id => true_repository_id}).returns({:exists => true}) |
39 | + Kalibro::Processing.expects(:request).with(:has_ready_processing, {:repository_id => false_repository_id}).returns({:exists => false}) | ||
50 | 40 | ||
51 | assert Kalibro::Processing.has_ready_processing(true_repository_id) | 41 | assert Kalibro::Processing.has_ready_processing(true_repository_id) |
52 | assert !Kalibro::Processing.has_ready_processing(false_repository_id) | 42 | assert !Kalibro::Processing.has_ready_processing(false_repository_id) |
@@ -56,8 +46,8 @@ class ProcessingTest < ActiveSupport::TestCase | @@ -56,8 +46,8 @@ class ProcessingTest < ActiveSupport::TestCase | ||
56 | true_repository_id = 31 | 46 | true_repository_id = 31 |
57 | false_repository_id = 32 | 47 | false_repository_id = 32 |
58 | 48 | ||
59 | - Kalibro::Processing.expects(:request).with('Processing',:has_processing_after, {:repository_id => true_repository_id, :date => @processing.date}).returns({:exists => true}) | ||
60 | - Kalibro::Processing.expects(:request).with('Processing',:has_processing_after, {:repository_id => false_repository_id, :date => @processing.date}).returns({:exists => false}) | 49 | + Kalibro::Processing.expects(:request).with(:has_processing_after, {:repository_id => true_repository_id, :date => @processing.date}).returns({:exists => true}) |
50 | + Kalibro::Processing.expects(:request).with(:has_processing_after, {:repository_id => false_repository_id, :date => @processing.date}).returns({:exists => false}) | ||
61 | 51 | ||
62 | assert Kalibro::Processing.has_processing_after(true_repository_id, @processing.date) | 52 | assert Kalibro::Processing.has_processing_after(true_repository_id, @processing.date) |
63 | assert !Kalibro::Processing.has_processing_after(false_repository_id, @processing.date) | 53 | assert !Kalibro::Processing.has_processing_after(false_repository_id, @processing.date) |
@@ -67,67 +57,41 @@ class ProcessingTest < ActiveSupport::TestCase | @@ -67,67 +57,41 @@ class ProcessingTest < ActiveSupport::TestCase | ||
67 | true_repository_id = 31 | 57 | true_repository_id = 31 |
68 | false_repository_id = 32 | 58 | false_repository_id = 32 |
69 | 59 | ||
70 | - Kalibro::Processing.expects(:request).with('Processing',:has_processing_before, {:repository_id => true_repository_id, :date => @processing.date}).returns({:exists => true}) | ||
71 | - Kalibro::Processing.expects(:request).with('Processing',:has_processing_before, {:repository_id => false_repository_id, :date => @processing.date}).returns({:exists => false}) | 60 | + Kalibro::Processing.expects(:request).with(:has_processing_before, {:repository_id => true_repository_id, :date => @processing.date}).returns({:exists => true}) |
61 | + Kalibro::Processing.expects(:request).with(:has_processing_before, {:repository_id => false_repository_id, :date => @processing.date}).returns({:exists => false}) | ||
72 | 62 | ||
73 | assert Kalibro::Processing.has_processing_before(true_repository_id, @processing.date) | 63 | assert Kalibro::Processing.has_processing_before(true_repository_id, @processing.date) |
74 | assert !Kalibro::Processing.has_processing_before(false_repository_id, @processing.date) | 64 | assert !Kalibro::Processing.has_processing_before(false_repository_id, @processing.date) |
75 | end | 65 | end |
76 | 66 | ||
77 | should 'get last processing state of a repository' do | 67 | should 'get last processing state of a repository' do |
78 | - Kalibro::Processing.expects(:request).with('Processing',:last_processing_state, {:repository_id => @repository_id}).returns({:process_state => @processing.state}) | 68 | + Kalibro::Processing.expects(:request).with(:last_processing_state, {:repository_id => @repository_id}).returns({:process_state => @processing.state}) |
79 | assert_equal @processing.state, Kalibro::Processing.last_processing_state_of(@repository_id) | 69 | assert_equal @processing.state, Kalibro::Processing.last_processing_state_of(@repository_id) |
80 | end | 70 | end |
81 | 71 | ||
82 | should 'get last ready processing of a repository' do | 72 | should 'get last ready processing of a repository' do |
83 | - Kalibro::Processing.expects(:request).with('Processing', :last_ready_processing, {:repository_id => @repository_id}).returns({:processing => @hash}) | 73 | + Kalibro::Processing.expects(:request).with(:last_ready_processing, {:repository_id => @repository_id}).returns({:processing => @hash}) |
84 | assert_equal @processing.id, Kalibro::Processing.last_ready_processing_of(@repository_id).id | 74 | assert_equal @processing.id, Kalibro::Processing.last_ready_processing_of(@repository_id).id |
85 | end | 75 | end |
86 | 76 | ||
87 | should 'get first processing of a repository' do | 77 | should 'get first processing of a repository' do |
88 | - Kalibro::Processing.expects(:request).with('Processing', :first_processing, {:repository_id => @repository_id}).returns({:processing => @hash}) | 78 | + Kalibro::Processing.expects(:request).with(:first_processing, {:repository_id => @repository_id}).returns({:processing => @hash}) |
89 | assert_equal @processing.id, Kalibro::Processing.first_processing_of(@repository_id).id | 79 | assert_equal @processing.id, Kalibro::Processing.first_processing_of(@repository_id).id |
90 | end | 80 | end |
91 | 81 | ||
92 | should 'get last processing of a repository' do | 82 | should 'get last processing of a repository' do |
93 | - Kalibro::Processing.expects(:request).with('Processing', :last_processing, {:repository_id => @repository_id}).returns({:processing => @hash}) | 83 | + Kalibro::Processing.expects(:request).with(:last_processing, {:repository_id => @repository_id}).returns({:processing => @hash}) |
94 | assert_equal @processing.id, Kalibro::Processing.last_processing_of(@repository_id).id | 84 | assert_equal @processing.id, Kalibro::Processing.last_processing_of(@repository_id).id |
95 | end | 85 | end |
96 | 86 | ||
97 | should 'get first processing after a date of a repository' do | 87 | should 'get first processing after a date of a repository' do |
98 | - Kalibro::Processing.expects(:request).with('Processing', :first_processing_after, {:repository_id => @repository_id, :date => @processing.date}).returns({:processing => @hash}) | 88 | + Kalibro::Processing.expects(:request).with(:first_processing_after, {:repository_id => @repository_id, :date => @processing.date}).returns({:processing => @hash}) |
99 | assert_equal @processing.id, Kalibro::Processing.first_processing_after(@repository_id, @processing.date).id | 89 | assert_equal @processing.id, Kalibro::Processing.first_processing_after(@repository_id, @processing.date).id |
100 | end | 90 | end |
101 | 91 | ||
102 | should 'get last processing before a date of a repository' do | 92 | should 'get last processing before a date of a repository' do |
103 | - Kalibro::Processing.expects(:request).with('Processing', :last_processing_before, {:repository_id => @repository_id, :date => @processing.date}).returns({:processing => @hash}) | 93 | + Kalibro::Processing.expects(:request).with(:last_processing_before, {:repository_id => @repository_id, :date => @processing.date}).returns({:processing => @hash}) |
104 | assert_equal @processing.id, Kalibro::Processing.last_processing_before(@repository_id, @processing.date).id | 94 | assert_equal @processing.id, Kalibro::Processing.last_processing_before(@repository_id, @processing.date).id |
105 | end | 95 | end |
106 | - | ||
107 | -=begin | ||
108 | - | ||
109 | - should 'retrieve formatted load time' do | ||
110 | - assert_equal '00:00:14', @processing.formatted_load_time | ||
111 | - end | ||
112 | - | ||
113 | - should 'retrieve formatted analysis time' do | ||
114 | - assert_equal '00:00:01', @processing.formatted_analysis_time | ||
115 | - end | ||
116 | 96 | ||
117 | - should 'retrive complex module' do | ||
118 | - assert_equal @hash[:source_tree][:child][0][:child].first, @processing.node("org.Window").to_hash | ||
119 | - end | ||
120 | - | ||
121 | - should 'return source tree node when nil is given' do | ||
122 | - assert_equal @hash[:source_tree], @processing.node(nil).to_hash | ||
123 | - end | ||
124 | - | ||
125 | - should 'return source tree node when project name is given' do | ||
126 | - assert_equal @hash[:source_tree], @processing.node(@processing.project.name).to_hash | ||
127 | - end | ||
128 | - | ||
129 | - should 'return correct node when module name is given' do | ||
130 | - assert_equal @hash[:source_tree][:child][2], @processing.node("main").to_hash | ||
131 | - end | ||
132 | -=end | ||
133 | end | 97 | end |
plugins/mezuro/test/unit/kalibro/project_test.rb
@@ -8,7 +8,6 @@ class ProjectTest < ActiveSupport::TestCase | @@ -8,7 +8,6 @@ class ProjectTest < ActiveSupport::TestCase | ||
8 | @hash = ProjectFixtures.project_hash | 8 | @hash = ProjectFixtures.project_hash |
9 | @project = ProjectFixtures.project | 9 | @project = ProjectFixtures.project |
10 | @created_project = ProjectFixtures.created_project | 10 | @created_project = ProjectFixtures.created_project |
11 | - @project_content = ProjectFixtures.project_content | ||
12 | end | 11 | end |
13 | 12 | ||
14 | should 'initialize new project from hash' do | 13 | should 'initialize new project from hash' do |
@@ -22,75 +21,53 @@ class ProjectTest < ActiveSupport::TestCase | @@ -22,75 +21,53 @@ class ProjectTest < ActiveSupport::TestCase | ||
22 | end | 21 | end |
23 | 22 | ||
24 | should 'answer if project exists in kalibro' do | 23 | should 'answer if project exists in kalibro' do |
25 | - Kalibro::Project.expects(:request).with("Project", :project_exists, {:project_id => @project.id}).returns({:exists => true}) | 24 | + Kalibro::Project.expects(:request).with(:project_exists, {:project_id => @project.id}).returns({:exists => true}) |
26 | assert Kalibro::Project.exists?(@project.id) | 25 | assert Kalibro::Project.exists?(@project.id) |
27 | end | 26 | end |
28 | 27 | ||
29 | should 'find project' do | 28 | should 'find project' do |
30 | - Kalibro::Project.expects(:request).with("Project", :get_project, {:project_id => @project.id}).returns(:project => @hash) | 29 | + Kalibro::Project.expects(:request).with(:project_exists, {:project_id => @project.id}).returns({:exists => true}) |
30 | + Kalibro::Project.expects(:request).with(:get_project, {:project_id => @project.id}).returns(:project => @hash) | ||
31 | assert_equal @hash[:name], Kalibro::Project.find(@project.id).name | 31 | assert_equal @hash[:name], Kalibro::Project.find(@project.id).name |
32 | end | 32 | end |
33 | 33 | ||
34 | - should 'raise error when project doesnt exist' do | ||
35 | - request_body = {:project_id => @project.id} | ||
36 | - Kalibro::Project.expects(:request).with("Project", :get_project, request_body).raises(Exception.new("(S:Server) There is no project with id #{@project.id}")) | ||
37 | - assert_raise Exception do Kalibro::Project.find(@project.id) end | 34 | + should 'verify when project doesnt exist' do |
35 | + Kalibro::Project.expects(:request).with(:project_exists, {:project_id => @project.id}).returns({:exists => false}) | ||
36 | + assert_nil Kalibro::Project.find(@project.id) | ||
38 | end | 37 | end |
39 | 38 | ||
40 | should 'get project of a repository' do | 39 | should 'get project of a repository' do |
41 | repository_id = 31 | 40 | repository_id = 31 |
42 | - Kalibro::Project.expects(:request).with("Project", :project_of, {:repository_id => repository_id}).returns({:project => @hash}) | 41 | + Kalibro::Project.expects(:request).with(:project_of, {:repository_id => repository_id}).returns({:project => @hash}) |
43 | assert_equal @hash[:name], Kalibro::Project.project_of(repository_id).name | 42 | assert_equal @hash[:name], Kalibro::Project.project_of(repository_id).name |
44 | end | 43 | end |
45 | 44 | ||
46 | should 'get all project' do | 45 | should 'get all project' do |
47 | - Kalibro::Project.expects(:request).with("Project", :all_projects).returns({:project => [@hash]}) | 46 | + Kalibro::Project.expects(:request).with(:all_projects).returns({:project => [@hash]}) |
48 | assert_equal @hash[:name], Kalibro::Project.all.first.name | 47 | assert_equal @hash[:name], Kalibro::Project.all.first.name |
49 | end | 48 | end |
50 | 49 | ||
51 | should 'return empty when there are no projects' do | 50 | should 'return empty when there are no projects' do |
52 | - Kalibro::Project.expects(:request).with("Project", :all_projects).returns({:project => nil}) | 51 | + Kalibro::Project.expects(:request).with(:all_projects).returns({:project => nil}) |
53 | assert_equal [], Kalibro::Project.all | 52 | assert_equal [], Kalibro::Project.all |
54 | end | 53 | end |
55 | 54 | ||
56 | should 'return true when project is saved successfully' do | 55 | should 'return true when project is saved successfully' do |
57 | id_from_kalibro = 1 | 56 | id_from_kalibro = 1 |
58 | - Kalibro::Project.expects(:request).with("Project", :save_project, {:project => @created_project.to_hash}).returns(:project_id => id_from_kalibro) | 57 | + Kalibro::Project.expects(:request).with(:save_project, {:project => @created_project.to_hash}).returns(:project_id => id_from_kalibro) |
59 | assert @created_project.save | 58 | assert @created_project.save |
60 | assert_equal id_from_kalibro, @created_project.id | 59 | assert_equal id_from_kalibro, @created_project.id |
61 | end | 60 | end |
62 | 61 | ||
63 | should 'return false when project is not saved successfully' do | 62 | should 'return false when project is not saved successfully' do |
64 | - Kalibro::Project.expects(:request).with("Project", :save_project, {:project => @project.to_hash}).raises(Exception.new) | ||
65 | - assert !(@project.save) | 63 | + Kalibro::Project.expects(:request).with(:save_project, {:project => @created_project.to_hash}).raises(Exception.new) |
64 | + assert !(@created_project.save) | ||
66 | assert_nil @created_project.id | 65 | assert_nil @created_project.id |
67 | end | 66 | end |
68 | 67 | ||
69 | should 'remove existent project from service' do | 68 | should 'remove existent project from service' do |
70 | - Kalibro::Project.expects(:request).with("Project", :delete_project, {:project_id => @project.id}) | 69 | + Kalibro::Project.expects(:request).with(:delete_project, {:project_id => @project.id}) |
71 | @project.destroy | 70 | @project.destroy |
72 | end | 71 | end |
73 | 72 | ||
74 | -=begin | ||
75 | - should 'process project without days' do | ||
76 | - Kalibro::Project.expects(:request).with('Kalibro', :process_project, {:project_name => @project.name}) | ||
77 | - @project.process_project | ||
78 | - end | ||
79 | - | ||
80 | - should 'process project with days' do | ||
81 | - Kalibro::Project.expects(:request).with('Kalibro', :process_periodically, {:project_name => @project.name, :period_in_days => "1"}) | ||
82 | - @project.process_project "1" | ||
83 | - end | ||
84 | - | ||
85 | - should 'process period' do | ||
86 | - Kalibro::Project.expects(:request).with('Kalibro', :get_process_period, {:project_name => @project.name}).returns({:period => "1"}) | ||
87 | - assert_equal "1", @project.process_period | ||
88 | - end | ||
89 | - | ||
90 | - should 'cancel periodic process' do | ||
91 | - Kalibro::Project.expects(:request).with("Kalibro", :cancel_periodic_process, {:project_name => @project.name}) | ||
92 | - @project.cancel_periodic_process | ||
93 | - end | ||
94 | -=end | ||
95 | - | ||
96 | end | 73 | end |
plugins/mezuro/test/unit/kalibro/range_test.rb
@@ -20,27 +20,27 @@ class RangeTest < ActiveSupport::TestCase | @@ -20,27 +20,27 @@ class RangeTest < ActiveSupport::TestCase | ||
20 | 20 | ||
21 | should 'get ranges of a metric configuration' do | 21 | should 'get ranges of a metric configuration' do |
22 | metric_configuration_id = 31 | 22 | metric_configuration_id = 31 |
23 | - Kalibro::Range.expects(:request).with("Range", :ranges_of, {:metric_configuration_id => metric_configuration_id}).returns({:range => [@hash]}) | 23 | + Kalibro::Range.expects(:request).with(:ranges_of, {:metric_configuration_id => metric_configuration_id}).returns({:range => [@hash]}) |
24 | assert_equal @hash[:comments], Kalibro::Range.ranges_of(metric_configuration_id).first.comments | 24 | assert_equal @hash[:comments], Kalibro::Range.ranges_of(metric_configuration_id).first.comments |
25 | end | 25 | end |
26 | 26 | ||
27 | should 'return true when range is saved successfully' do | 27 | should 'return true when range is saved successfully' do |
28 | id_from_kalibro = 1 | 28 | id_from_kalibro = 1 |
29 | metric_configuration_id = 2 | 29 | metric_configuration_id = 2 |
30 | - Kalibro::Range.expects(:request).with("Range", :save_range, {:range => @created_range.to_hash, :metric_configuration_id => metric_configuration_id}).returns(:range_id => id_from_kalibro) | 30 | + Kalibro::Range.expects(:request).with(:save_range, {:range => @created_range.to_hash, :metric_configuration_id => metric_configuration_id}).returns(:range_id => id_from_kalibro) |
31 | assert @created_range.save(metric_configuration_id) | 31 | assert @created_range.save(metric_configuration_id) |
32 | assert_equal id_from_kalibro, @created_range.id | 32 | assert_equal id_from_kalibro, @created_range.id |
33 | end | 33 | end |
34 | 34 | ||
35 | should 'return false when range is not saved successfully' do | 35 | should 'return false when range is not saved successfully' do |
36 | metric_configuration_id = 2 | 36 | metric_configuration_id = 2 |
37 | - Kalibro::Range.expects(:request).with("Range", :save_range, {:range => @created_range.to_hash, :metric_configuration_id => metric_configuration_id}).raises(Exception.new) | 37 | + Kalibro::Range.expects(:request).with(:save_range, {:range => @created_range.to_hash, :metric_configuration_id => metric_configuration_id}).raises(Exception.new) |
38 | assert !(@created_range.save(metric_configuration_id)) | 38 | assert !(@created_range.save(metric_configuration_id)) |
39 | assert_nil @created_range.id | 39 | assert_nil @created_range.id |
40 | end | 40 | end |
41 | 41 | ||
42 | should 'destroy range by id' do | 42 | should 'destroy range by id' do |
43 | - Kalibro::Range.expects(:request).with("Range", :delete_range, {:range_id => @range.id}) | 43 | + Kalibro::Range.expects(:request).with(:delete_range, {:range_id => @range.id}) |
44 | @range.destroy | 44 | @range.destroy |
45 | end | 45 | end |
46 | 46 |
plugins/mezuro/test/unit/kalibro/reading_group_test.rb
@@ -18,42 +18,48 @@ class ReadingGroupTest < ActiveSupport::TestCase | @@ -18,42 +18,48 @@ class ReadingGroupTest < ActiveSupport::TestCase | ||
18 | end | 18 | end |
19 | 19 | ||
20 | should 'verify existence of reading group' do | 20 | should 'verify existence of reading group' do |
21 | - Kalibro::ReadingGroup.expects(:request).with("ReadingGroup", :reading_group_exists, {:group_id => @hash[:id]}).returns({:exists => true}) | 21 | + fake_id = 0 |
22 | + Kalibro::ReadingGroup.expects(:request).with(:reading_group_exists, {:group_id => fake_id}).returns({:exists => false}) | ||
23 | + Kalibro::ReadingGroup.expects(:request).with(:reading_group_exists, {:group_id => @hash[:id]}).returns({:exists => true}) | ||
24 | + assert !Kalibro::ReadingGroup.exists?(fake_id) | ||
22 | assert Kalibro::ReadingGroup.exists?(@hash[:id]) | 25 | assert Kalibro::ReadingGroup.exists?(@hash[:id]) |
23 | end | 26 | end |
24 | 27 | ||
25 | should 'get reading group' do | 28 | should 'get reading group' do |
26 | - Kalibro::ReadingGroup.expects(:request).with("ReadingGroup", :get_reading_group, {:group_id => @hash[:id]}). | 29 | + Kalibro::ReadingGroup.expects(:request).with(:reading_group_exists, {:group_id => @hash[:id]}).returns({:exists => true}) |
30 | + Kalibro::ReadingGroup.expects(:request).with(:get_reading_group, {:group_id => @hash[:id]}). | ||
27 | returns({:reading_group => @hash}) | 31 | returns({:reading_group => @hash}) |
28 | assert_equal @hash[:name], Kalibro::ReadingGroup.find(@hash[:id]).name | 32 | assert_equal @hash[:name], Kalibro::ReadingGroup.find(@hash[:id]).name |
29 | end | 33 | end |
30 | 34 | ||
35 | + | ||
36 | + | ||
31 | should 'get all reading groups' do | 37 | should 'get all reading groups' do |
32 | - Kalibro::ReadingGroup.expects(:request).with("ReadingGroup", :all_reading_groups).returns({:reading_group => [@hash]}) | 38 | + Kalibro::ReadingGroup.expects(:request).with(:all_reading_groups).returns({:reading_group => [@hash]}) |
33 | assert_equal @hash[:name], Kalibro::ReadingGroup.all.first.name | 39 | assert_equal @hash[:name], Kalibro::ReadingGroup.all.first.name |
34 | end | 40 | end |
35 | 41 | ||
36 | should 'get reading group of a metric configuration' do | 42 | should 'get reading group of a metric configuration' do |
37 | id = 31 | 43 | id = 31 |
38 | - Kalibro::ReadingGroup.expects(:request).with("ReadingGroup", :reading_group_of, {:metric_configuration_id => id}).returns({:reading_group => @hash}) | 44 | + Kalibro::ReadingGroup.expects(:request).with(:reading_group_of, {:metric_configuration_id => id}).returns({:reading_group => @hash}) |
39 | assert_equal @hash[:name], Kalibro::ReadingGroup.reading_group_of(id).name | 45 | assert_equal @hash[:name], Kalibro::ReadingGroup.reading_group_of(id).name |
40 | end | 46 | end |
41 | 47 | ||
42 | should 'return true when reading group is saved successfully' do | 48 | should 'return true when reading group is saved successfully' do |
43 | id_from_kalibro = 1 | 49 | id_from_kalibro = 1 |
44 | - Kalibro::ReadingGroup.expects(:request).with("ReadingGroup", :save_reading_group, {:reading_group => @created_reading_group.to_hash}).returns(:reading_group_id => id_from_kalibro) | 50 | + Kalibro::ReadingGroup.expects(:request).with(:save_reading_group, {:reading_group => @created_reading_group.to_hash}).returns(:reading_group_id => id_from_kalibro) |
45 | assert @created_reading_group.save | 51 | assert @created_reading_group.save |
46 | assert_equal id_from_kalibro, @created_reading_group.id | 52 | assert_equal id_from_kalibro, @created_reading_group.id |
47 | end | 53 | end |
48 | 54 | ||
49 | should 'return false when reading group is not saved successfully' do | 55 | should 'return false when reading group is not saved successfully' do |
50 | - Kalibro::ReadingGroup.expects(:request).with("ReadingGroup", :save_reading_group, {:reading_group => @created_reading_group.to_hash}).raises(Exception.new) | 56 | + Kalibro::ReadingGroup.expects(:request).with(:save_reading_group, {:reading_group => @created_reading_group.to_hash}).raises(Exception.new) |
51 | assert !(@created_reading_group.save) | 57 | assert !(@created_reading_group.save) |
52 | assert_nil @created_reading_group.id | 58 | assert_nil @created_reading_group.id |
53 | end | 59 | end |
54 | 60 | ||
55 | should 'destroy reading group by id' do | 61 | should 'destroy reading group by id' do |
56 | - Kalibro::ReadingGroup.expects(:request).with("ReadingGroup", :delete_reading_group, {:group_id => @reading_group.id}) | 62 | + Kalibro::ReadingGroup.expects(:request).with(:delete_reading_group, {:group_id => @reading_group.id}) |
57 | @reading_group.destroy | 63 | @reading_group.destroy |
58 | end | 64 | end |
59 | 65 |
plugins/mezuro/test/unit/kalibro/reading_test.rb
@@ -18,38 +18,38 @@ class ReadingTest < ActiveSupport::TestCase | @@ -18,38 +18,38 @@ class ReadingTest < ActiveSupport::TestCase | ||
18 | end | 18 | end |
19 | 19 | ||
20 | should 'get reading' do | 20 | should 'get reading' do |
21 | - Kalibro::Reading.expects(:request).with("Reading", :get_reading, {:reading_id => @hash[:id]}). | 21 | + Kalibro::Reading.expects(:request).with(:get_reading, {:reading_id => @hash[:id]}). |
22 | returns({:reading => @hash}) | 22 | returns({:reading => @hash}) |
23 | assert_equal @hash[:label], Kalibro::Reading.find(@hash[:id]).label | 23 | assert_equal @hash[:label], Kalibro::Reading.find(@hash[:id]).label |
24 | end | 24 | end |
25 | 25 | ||
26 | should 'get reading of a range' do | 26 | should 'get reading of a range' do |
27 | range_id = 31 | 27 | range_id = 31 |
28 | - Kalibro::Reading.expects(:request).with("Reading", :reading_of, {:range_id => range_id}).returns({:reading => @hash}) | 28 | + Kalibro::Reading.expects(:request).with(:reading_of, {:range_id => range_id}).returns({:reading => @hash}) |
29 | assert_equal @hash[:label], Kalibro::Reading.reading_of(range_id).label | 29 | assert_equal @hash[:label], Kalibro::Reading.reading_of(range_id).label |
30 | end | 30 | end |
31 | 31 | ||
32 | should 'get readings of a reading group' do | 32 | should 'get readings of a reading group' do |
33 | reading_group_id = 31 | 33 | reading_group_id = 31 |
34 | - Kalibro::Reading.expects(:request).with("Reading", :readings_of, {:group_id => reading_group_id}).returns({:reading => [@hash]}) | 34 | + Kalibro::Reading.expects(:request).with(:readings_of, {:group_id => reading_group_id}).returns({:reading => [@hash]}) |
35 | assert_equal @hash[:label], Kalibro::Reading.readings_of(reading_group_id).first.label | 35 | assert_equal @hash[:label], Kalibro::Reading.readings_of(reading_group_id).first.label |
36 | end | 36 | end |
37 | 37 | ||
38 | should 'return true when reading is saved successfully' do | 38 | should 'return true when reading is saved successfully' do |
39 | id_from_kalibro = 1 | 39 | id_from_kalibro = 1 |
40 | - Kalibro::Reading.expects(:request).with("Reading", :save_reading, {:reading => @created_reading.to_hash}).returns(:reading_id => id_from_kalibro) | 40 | + Kalibro::Reading.expects(:request).with(:save_reading, {:reading => @created_reading.to_hash}).returns(:reading_id => id_from_kalibro) |
41 | assert @created_reading.save | 41 | assert @created_reading.save |
42 | assert_equal id_from_kalibro, @created_reading.id | 42 | assert_equal id_from_kalibro, @created_reading.id |
43 | end | 43 | end |
44 | 44 | ||
45 | should 'return false when reading is not saved successfully' do | 45 | should 'return false when reading is not saved successfully' do |
46 | - Kalibro::Reading.expects(:request).with("Reading", :save_reading, {:reading => @created_reading.to_hash}).raises(Exception.new) | 46 | + Kalibro::Reading.expects(:request).with(:save_reading, {:reading => @created_reading.to_hash}).raises(Exception.new) |
47 | assert !(@created_reading.save) | 47 | assert !(@created_reading.save) |
48 | assert_nil @created_reading.id | 48 | assert_nil @created_reading.id |
49 | end | 49 | end |
50 | 50 | ||
51 | should 'destroy reading by id' do | 51 | should 'destroy reading by id' do |
52 | - Kalibro::Reading.expects(:request).with("Reading", :delete_reading, {:reading_id => @reading.id}) | 52 | + Kalibro::Reading.expects(:request).with(:delete_reading, {:reading_id => @reading.id}) |
53 | @reading.destroy | 53 | @reading.destroy |
54 | end | 54 | end |
55 | 55 |
plugins/mezuro/test/unit/kalibro/repository_test.rb
@@ -20,47 +20,47 @@ class RepositoryTest < ActiveSupport::TestCase | @@ -20,47 +20,47 @@ class RepositoryTest < ActiveSupport::TestCase | ||
20 | 20 | ||
21 | should 'get supported repository types' do | 21 | should 'get supported repository types' do |
22 | types = ['BAZAAR', 'GIT', 'SUBVERSION'] | 22 | types = ['BAZAAR', 'GIT', 'SUBVERSION'] |
23 | - Kalibro::Repository.expects(:request).with('Repository', :supported_repository_types).returns({:repository_type => types}) | 23 | + Kalibro::Repository.expects(:request).with(:supported_repository_types).returns({:repository_type => types}) |
24 | assert_equal types, Kalibro::Repository.repository_types | 24 | assert_equal types, Kalibro::Repository.repository_types |
25 | end | 25 | end |
26 | 26 | ||
27 | should 'get repository of a precessing' do | 27 | should 'get repository of a precessing' do |
28 | id = 31 | 28 | id = 31 |
29 | - Kalibro::Repository.expects(:request).with("Repository", :repository_of, {:processing_id => id}).returns({:repository => @hash}) | 29 | + Kalibro::Repository.expects(:request).with(:repository_of, {:processing_id => id}).returns({:repository => @hash}) |
30 | assert_equal @hash[:name], Kalibro::Repository.repository_of(id).name | 30 | assert_equal @hash[:name], Kalibro::Repository.repository_of(id).name |
31 | end | 31 | end |
32 | 32 | ||
33 | should 'get repositories of a project' do | 33 | should 'get repositories of a project' do |
34 | project_id = 31 | 34 | project_id = 31 |
35 | - Kalibro::Repository.expects(:request).with("Repository", :repositories_of, {:project_id => project_id}).returns({:repository => [@hash]}) | 35 | + Kalibro::Repository.expects(:request).with(:repositories_of, {:project_id => project_id}).returns({:repository => [@hash]}) |
36 | assert_equal @hash[:name], Kalibro::Repository.repositories_of(project_id).first.name | 36 | assert_equal @hash[:name], Kalibro::Repository.repositories_of(project_id).first.name |
37 | end | 37 | end |
38 | 38 | ||
39 | should 'return true when repository is saved successfully' do | 39 | should 'return true when repository is saved successfully' do |
40 | id_from_kalibro = 1 | 40 | id_from_kalibro = 1 |
41 | - Kalibro::Repository.expects(:request).with("Repository", :save_repository, {:repository => @created_repository.to_hash}).returns(:repository_id => id_from_kalibro) | 41 | + Kalibro::Repository.expects(:request).with(:save_repository, {:repository => @created_repository.to_hash}).returns(:repository_id => id_from_kalibro) |
42 | assert @created_repository.save | 42 | assert @created_repository.save |
43 | assert_equal id_from_kalibro, @created_repository.id | 43 | assert_equal id_from_kalibro, @created_repository.id |
44 | end | 44 | end |
45 | 45 | ||
46 | should 'return false when repository is not saved successfully' do | 46 | should 'return false when repository is not saved successfully' do |
47 | - Kalibro::Repository.expects(:request).with("Repository", :save_repository, {:repository => @created_repository.to_hash}).raises(Exception.new) | 47 | + Kalibro::Repository.expects(:request).with(:save_repository, {:repository => @created_repository.to_hash}).raises(Exception.new) |
48 | assert !(@created_repository.save) | 48 | assert !(@created_repository.save) |
49 | assert_nil @created_repository.id | 49 | assert_nil @created_repository.id |
50 | end | 50 | end |
51 | 51 | ||
52 | should 'destroy repository by id' do | 52 | should 'destroy repository by id' do |
53 | - Kalibro::Repository.expects(:request).with("Repository", :delete_repository, {:repository_id => @repository.id}) | 53 | + Kalibro::Repository.expects(:request).with(:delete_repository, {:repository_id => @repository.id}) |
54 | @repository.destroy | 54 | @repository.destroy |
55 | end | 55 | end |
56 | 56 | ||
57 | should 'process repository' do | 57 | should 'process repository' do |
58 | - Kalibro::Repository.expects(:request).with("Repository", :process_repository, {:repository_id => @repository.id}); | 58 | + Kalibro::Repository.expects(:request).with(:process_repository, {:repository_id => @repository.id}); |
59 | @repository.process_repository | 59 | @repository.process_repository |
60 | end | 60 | end |
61 | 61 | ||
62 | should 'cancel processing of a repository' do | 62 | should 'cancel processing of a repository' do |
63 | - Kalibro::Repository.expects(:request).with("Repository", :cancel_processing_of_repository, {:repository_id => @repository.id}); | 63 | + Kalibro::Repository.expects(:request).with(:cancel_processing_of_repository, {:repository_id => @repository.id}); |
64 | @repository.cancel_processing_of_repository | 64 | @repository.cancel_processing_of_repository |
65 | end | 65 | end |
66 | 66 |
plugins/mezuro/test/unit/mezuro_plugin/project_content_test.rb
1 | require "test_helper" | 1 | require "test_helper" |
2 | 2 | ||
3 | require "#{RAILS_ROOT}/plugins/mezuro/test/fixtures/project_fixtures" | 3 | require "#{RAILS_ROOT}/plugins/mezuro/test/fixtures/project_fixtures" |
4 | -require "#{RAILS_ROOT}/plugins/mezuro/test/fixtures/project_result_fixtures" | ||
5 | require "#{RAILS_ROOT}/plugins/mezuro/test/fixtures/module_fixtures" | 4 | require "#{RAILS_ROOT}/plugins/mezuro/test/fixtures/module_fixtures" |
6 | require "#{RAILS_ROOT}/plugins/mezuro/test/fixtures/module_result_fixtures" | 5 | require "#{RAILS_ROOT}/plugins/mezuro/test/fixtures/module_result_fixtures" |
7 | 6 |