diff --git a/plugins/mezuro/lib/kalibro/base_tool.rb b/plugins/mezuro/lib/kalibro/base_tool.rb index c665773..93b8e40 100644 --- a/plugins/mezuro/lib/kalibro/base_tool.rb +++ b/plugins/mezuro/lib/kalibro/base_tool.rb @@ -3,11 +3,11 @@ class Kalibro::BaseTool < Kalibro::Model attr_accessor :name, :description, :collector_class_name, :supported_metric def self.all_names - request("BaseTool", :all_base_tool_names)[:base_tool_name].to_a + request(:all_base_tool_names)[:base_tool_name].to_a end def self.find_by_name(base_tool_name) - new request("BaseTool", :get_base_tool, {:base_tool_name => base_tool_name})[:base_tool] + new request(:get_base_tool, {:base_tool_name => base_tool_name})[:base_tool] end def self.all diff --git a/plugins/mezuro/lib/kalibro/compound_metric_with_error.rb b/plugins/mezuro/lib/kalibro/compound_metric_with_error.rb deleted file mode 100644 index 0a0f1d1..0000000 --- a/plugins/mezuro/lib/kalibro/compound_metric_with_error.rb +++ /dev/null @@ -1,13 +0,0 @@ -class Kalibro::CompoundMetricWithError < Kalibro::Model - - attr_accessor :metric, :error - - def metric=(value) - @metric = Kalibro::CompoundMetric.to_object value - end - - def error=(value) - @error = Kalibro::Error.to_object value - end - -end diff --git a/plugins/mezuro/lib/kalibro/metric_configuration.rb b/plugins/mezuro/lib/kalibro/metric_configuration.rb index 464b6a4..eecba24 100644 --- a/plugins/mezuro/lib/kalibro/metric_configuration.rb +++ b/plugins/mezuro/lib/kalibro/metric_configuration.rb @@ -20,7 +20,7 @@ class Kalibro::MetricConfiguration < Kalibro::Model end def self.metric_configurations_of(configuration_id) - hash = request("MetricConfiguration", :metric_configurations_of, {:configuration_id => configuration_id}) + hash = request(:metric_configurations_of, {:configuration_id => configuration_id}) hash[:metric_configuration].to_a.map { |metric_configuration| new metric_configuration } end diff --git a/plugins/mezuro/lib/kalibro/metric_result.rb b/plugins/mezuro/lib/kalibro/metric_result.rb index 62484b6..d797af0 100644 --- a/plugins/mezuro/lib/kalibro/metric_result.rb +++ b/plugins/mezuro/lib/kalibro/metric_result.rb @@ -15,15 +15,15 @@ class Kalibro::MetricResult < Kalibro::Model end def descendant_results - self.class.request("MetricResult", :descendant_results_of, {:metric_result_id => self.id})[:descendant_result].to_a + self.class.request(:descendant_results_of, {:metric_result_id => self.id})[:descendant_result].to_a end def self.metric_results_of(module_result_id) - request("MetricResult", :metric_results_of, {:module_result_id => module_result_id})[:metric_result].to_a.map {|metric_result| new metric_result} + request(:metric_results_of, {:module_result_id => module_result_id})[:metric_result].to_a.map {|metric_result| new metric_result} end def history_of(module_id) - 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} + 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} end end diff --git a/plugins/mezuro/lib/kalibro/model.rb b/plugins/mezuro/lib/kalibro/model.rb index 00ec520..5b581cb 100644 --- a/plugins/mezuro/lib/kalibro/model.rb +++ b/plugins/mezuro/lib/kalibro/model.rb @@ -20,7 +20,7 @@ class Kalibro::Model hash = {:attributes! => {}}.merge(hash) hash[:attributes!][field.to_sym] = { 'xmlns:xsi'=> 'http://www.w3.org/2001/XMLSchema-instance', - 'xsi:type' => 'kalibro:' + xml_class_name(field_value) } + 'xsi:type' => 'kalibro:' + xml_instance_class_name(field_value) } end end end @@ -28,7 +28,7 @@ class Kalibro::Model hash end - def self.request(endpoint, action, request_body = nil) + def self.request(action, request_body = nil) response = client(endpoint).request(:kalibro, action) { soap.body = request_body } response.to_hash["#{action}_response".to_sym] # response is a Savon::SOAP::Response, and to_hash is a Savon::SOAP::Response method end @@ -48,9 +48,17 @@ class Kalibro::Model new_model end + def self.find(id) + if(exists?(id)) + new request(find_action, id_params(id))["#{class_name.underscore}".to_sym] + else + nil + end + end + def save begin - self.id = self.class.request(save_endpoint, save_action, save_params)["#{class_name.underscore}_id".to_sym] + self.id = self.class.request(save_action, save_params)["#{instance_class_name.underscore}_id".to_sym] true rescue Exception => exception add_error exception @@ -60,14 +68,14 @@ class Kalibro::Model def destroy begin - self.class.request(destroy_endpoint, destroy_action, destroy_params) + self.class.request(destroy_action, destroy_params) rescue Exception => exception add_error exception end end def self.exists?(id) - request(exists_endpoint, exists_action, exists_params(id)) + request(exists_action, id_params(id))[:exists] end protected @@ -86,7 +94,7 @@ class Kalibro::Model value end - def xml_class_name(object) + def xml_instance_class_name(object) xml_name = object.class.name xml_name["Kalibro::"] = "" xml_name[0..0] = xml_name[0..0].downcase @@ -107,48 +115,44 @@ class Kalibro::Model date.to_s[0..18] + milliseconds + date.to_s[19..-1] end - def class_name + def instance_class_name self.class.name.gsub(/Kalibro::/,"") end - def save_endpoint + def self.endpoint class_name end def save_action - "save_#{class_name.underscore}".to_sym + "save_#{instance_class_name.underscore}".to_sym end def save_params - {class_name.underscore.to_sym => self.to_hash} - end - - def destroy_endpoint - class_name + {instance_class_name.underscore.to_sym => self.to_hash} end def destroy_action - "delete_#{class_name.underscore}".to_sym + "delete_#{instance_class_name.underscore}".to_sym end def destroy_params - {"#{class_name.underscore}_id".to_sym => self.id} + {"#{instance_class_name.underscore}_id".to_sym => self.id} end - def self.exists_class_name + def self.class_name self.name.gsub(/Kalibro::/,"") end - def self.exists_endpoint - self.exists_class_name - end - def self.exists_action - "#{exists_class_name.underscore}_exists".to_sym + "#{class_name.underscore}_exists".to_sym end - def self.exists_params(id) - {"#{exists_class_name.underscore}_id".to_sym => id} + def self.id_params(id) + {"#{class_name.underscore}_id".to_sym => id} + end + + def self.find_action + "get_#{class_name.underscore}".to_sym end def add_error(exception) diff --git a/plugins/mezuro/lib/kalibro/module.rb b/plugins/mezuro/lib/kalibro/module.rb index 69fa66e..5bd75d9 100644 --- a/plugins/mezuro/lib/kalibro/module.rb +++ b/plugins/mezuro/lib/kalibro/module.rb @@ -2,20 +2,4 @@ class Kalibro::Module < Kalibro::Model attr_accessor :name, :granularity -=begin - def self.parent_names(name) - path = [] - ancestors = [] - name.split(".").each do |token| - path << token - ancestors << path.join(".") - end - ancestors - end - - def ancestor_names - self.class.parent_names(@name) - end -=end - end diff --git a/plugins/mezuro/lib/kalibro/module_node.rb b/plugins/mezuro/lib/kalibro/module_node.rb deleted file mode 100644 index b71978d..0000000 --- a/plugins/mezuro/lib/kalibro/module_node.rb +++ /dev/null @@ -1,21 +0,0 @@ -class Kalibro::ModuleNode < Kalibro::Model - - attr_accessor :module, :child - - def module=(value) - @module = Kalibro::Module.to_object value - end - - def child=(value) - @child = Kalibro::ModuleNode.to_objects_array value - end - - def children - @child - end - - def children=(children) - @child = children - end - -end diff --git a/plugins/mezuro/lib/kalibro/module_result.rb b/plugins/mezuro/lib/kalibro/module_result.rb index f8f7336..17bb5c3 100644 --- a/plugins/mezuro/lib/kalibro/module_result.rb +++ b/plugins/mezuro/lib/kalibro/module_result.rb @@ -3,11 +3,11 @@ class Kalibro::ModuleResult < Kalibro::Model attr_accessor :id, :module, :grade, :parent_id def self.find(id) - new request('ModuleResult', :get_module_result, { :module_result_id => id })[:module_result] + new request(:get_module_result, { :module_result_id => id })[:module_result] end def children - hash_array = self.class.request('ModuleResult',:children_of, {:module_result_id => self.id})[:module_result].to_a + hash_array = self.class.request(:children_of, {:module_result_id => self.id})[:module_result].to_a hash_array.map { |module_result| self.class.new module_result } end diff --git a/plugins/mezuro/lib/kalibro/processing.rb b/plugins/mezuro/lib/kalibro/processing.rb index cf11e8d..684fad1 100644 --- a/plugins/mezuro/lib/kalibro/processing.rb +++ b/plugins/mezuro/lib/kalibro/processing.rb @@ -1,49 +1,61 @@ class Kalibro::Processing < Kalibro::Model - attr_accessor :id, :date, :state, :error, :process_times, :results_root_id + attr_accessor :id, :date, :state, :error, :process_time, :results_root_id def self.has_processing(repository_id) - request('Processing', :has_processing, {:repository_id => repository_id})[:exists] + request(:has_processing, {:repository_id => repository_id})[:exists] end def self.has_ready_processing(repository_id) - request('Processing', :has_ready_processing, {:repository_id => repository_id})[:exists] + request(:has_ready_processing, {:repository_id => repository_id})[:exists] end def self.has_processing_after(repository_id, date) - request('Processing', :has_processing_after, {:repository_id => repository_id, :date => date})[:exists] + request(:has_processing_after, {:repository_id => repository_id, :date => date})[:exists] end def self.has_processing_before(repository_id, date) - request('Processing', :has_processing_before, {:repository_id => repository_id, :date => date})[:exists] + request(:has_processing_before, {:repository_id => repository_id, :date => date})[:exists] end def self.last_processing_state_of(repository_id) - request('Processing', :last_processing_state, {:repository_id => repository_id})[:process_state] + request(:last_processing_state, {:repository_id => repository_id})[:process_state] end def self.last_ready_processing_of(repository_id) - new request('Processing', :last_ready_processing, {:repository_id => repository_id})[:processing] + new request(:last_ready_processing, {:repository_id => repository_id})[:processing] end def self.first_processing_of(repository_id) - new request('Processing', :first_processing, {:repository_id => repository_id})[:processing] + new request(:first_processing, {:repository_id => repository_id})[:processing] end def self.last_processing_of(repository_id) - new request('Processing', :last_processing, {:repository_id => repository_id})[:processing] + new request(:last_processing, {:repository_id => repository_id})[:processing] end def self.first_processing_after(repository_id, date) - new request('Processing', :first_processing_after, {:repository_id => repository_id, :date => date})[:processing] + new request(:first_processing_after, {:repository_id => repository_id, :date => date})[:processing] end def self.last_processing_before(repository_id, date) - new request('Processing', :last_processing_before, {:repository_id => repository_id, :date => date})[:processing] + new request(:last_processing_before, {:repository_id => repository_id, :date => date})[:processing] end def date=(value) @date = value.is_a?(String) ? DateTime.parse(value) : value end + def process_times=(value) + process_time=value + end + + def process_time=(value) + @process_time = Kalibro::ProcessTime.to_objects_array value + end + + def process_times + process_time + end + end diff --git a/plugins/mezuro/lib/kalibro/project.rb b/plugins/mezuro/lib/kalibro/project.rb index a071241..324a9bf 100644 --- a/plugins/mezuro/lib/kalibro/project.rb +++ b/plugins/mezuro/lib/kalibro/project.rb @@ -3,50 +3,13 @@ class Kalibro::Project < Kalibro::Model attr_accessor :id, :name, :description def self.all - response = request("Project", :all_projects)[:project].to_a + response = request(:all_projects)[:project].to_a response = [] if response.nil? response.map {|project| new project} end - def self.find(project_id) - new request("Project", :get_project, :project_id => project_id)[:project] - end - def self.project_of(repository_id) - new request("Project", :project_of, :repository_id => repository_id)[:project] - end -=begin - def error=(value) - @kalibro_error = Kalibro::Error.to_object value - end - - def process_project(days = '0') - begin - if days.to_i.zero? - self.class.request("Kalibro", :process_project, {:project_name => name}) - else - self.class.request("Kalibro", :process_periodically, {:project_name => name, :period_in_days => days}) - end - rescue Exception => exception - add_error exception - end - end - - def process_period - begin - self.class.request("Kalibro", :get_process_period, {:project_name => name})[:period] - rescue Exception => exception - add_error exception - end - end - - def cancel_periodic_process - begin - self.class.request("Kalibro", :cancel_periodic_process, {:project_name => name}) - rescue Exception => exception - add_error exception - end + new request(:project_of, :repository_id => repository_id)[:project] end -=end end diff --git a/plugins/mezuro/lib/kalibro/range.rb b/plugins/mezuro/lib/kalibro/range.rb index e7ab565..4933bf4 100644 --- a/plugins/mezuro/lib/kalibro/range.rb +++ b/plugins/mezuro/lib/kalibro/range.rb @@ -39,12 +39,12 @@ class Kalibro::Range < Kalibro::Model end def self.ranges_of( metric_configuration_id ) - request("Range", :ranges_of, {:metric_configuration_id => metric_configuration_id} )[:range].to_a.map { |range| new range } + request(:ranges_of, {:metric_configuration_id => metric_configuration_id} )[:range].to_a.map { |range| new range } end def save( metric_configuration_id ) begin - self.id = self.class.request("Range", :save_range, {:range => self.to_hash, :metric_configuration_id => metric_configuration_id})[:range_id] + self.id = self.class.request(:save_range, {:range => self.to_hash, :metric_configuration_id => metric_configuration_id})[:range_id] true rescue Exception => exception add_error exception diff --git a/plugins/mezuro/lib/kalibro/reading.rb b/plugins/mezuro/lib/kalibro/reading.rb index 4e6f2fd..51e2b3f 100644 --- a/plugins/mezuro/lib/kalibro/reading.rb +++ b/plugins/mezuro/lib/kalibro/reading.rb @@ -3,15 +3,15 @@ class Kalibro::Reading < Kalibro::Model attr_accessor :id, :label, :grade, :color def self.find(id) - new request("Reading", :get_reading, {:reading_id => id})[:reading] + new request(:get_reading, {:reading_id => id})[:reading] end def self.readings_of( group_id ) - request("Reading", :readings_of, {:group_id => group_id})[:reading].to_a.map { |reading| new reading } + request(:readings_of, {:group_id => group_id})[:reading].to_a.map { |reading| new reading } end def self.reading_of( range_id ) - new request("Reading", :reading_of, {:range_id => range_id} )[:reading] + new request(:reading_of, {:range_id => range_id} )[:reading] end end diff --git a/plugins/mezuro/lib/kalibro/reading_group.rb b/plugins/mezuro/lib/kalibro/reading_group.rb index 0eede2a..c818cd6 100644 --- a/plugins/mezuro/lib/kalibro/reading_group.rb +++ b/plugins/mezuro/lib/kalibro/reading_group.rb @@ -2,21 +2,17 @@ class Kalibro::ReadingGroup < Kalibro::Model attr_accessor :id, :name, :description - def self.find(id) - new request("ReadingGroup", :get_reading_group, {:group_id => id})[:reading_group] - end - def self.all - request("ReadingGroup", :all_reading_groups)[:reading_group].to_a.map { |reading_group| new reading_group } + request(:all_reading_groups)[:reading_group].to_a.map { |reading_group| new reading_group } end def self.reading_group_of( metric_configuration_id ) - new request("ReadingGroup", :reading_group_of, {:metric_configuration_id => metric_configuration_id} )[:reading_group] + new request(:reading_group_of, {:metric_configuration_id => metric_configuration_id} )[:reading_group] end private - def self.exists_params(id) + def self.id_params(id) {:group_id => id} end diff --git a/plugins/mezuro/lib/kalibro/repository.rb b/plugins/mezuro/lib/kalibro/repository.rb index 2b83d44..d57fbea 100644 --- a/plugins/mezuro/lib/kalibro/repository.rb +++ b/plugins/mezuro/lib/kalibro/repository.rb @@ -3,23 +3,23 @@ class Kalibro::Repository < Kalibro::Model attr_accessor :id, :name, :description, :license, :process_period, :type, :address, :configuration_id def self.repository_types - request("Repository", :supported_repository_types)[:repository_type].to_a + request(:supported_repository_types)[:repository_type].to_a end def self.repository_of(processing_id) - new request("Repository", :repository_of, {:processing_id => processing_id})[:repository] + new request(:repository_of, {:processing_id => processing_id})[:repository] end def self.repositories_of(project_id) - request("Repository", :repositories_of, {:project_id => project_id})[:repository].to_a.map { |repository| new repository } + request(:repositories_of, {:project_id => project_id})[:repository].to_a.map { |repository| new repository } end def process_repository - self.class.request("Repository", :process_repository, {:repository_id => self.id}); + self.class.request(:process_repository, {:repository_id => self.id}); end def cancel_processing_of_repository - self.class.request("Repository", :cancel_processing_of_repository, {:repository_id => self.id}); + self.class.request(:cancel_processing_of_repository, {:repository_id => self.id}); end end diff --git a/plugins/mezuro/test/fixtures/compound_metric_with_error_fixtures.rb b/plugins/mezuro/test/fixtures/compound_metric_with_error_fixtures.rb deleted file mode 100644 index c104ef3..0000000 --- a/plugins/mezuro/test/fixtures/compound_metric_with_error_fixtures.rb +++ /dev/null @@ -1,20 +0,0 @@ -require File.dirname(__FILE__) + '/error_fixtures' -require File.dirname(__FILE__) + '/compound_metric_fixtures' - -class CompoundMetricWithErrorFixtures - - def self.compound_metric_with_error - Kalibro::CompoundMetricWithError.new compound_metric_with_error_hash - end - - def self.compound_metric_with_error_hash - {:metric => CompoundMetricFixtures.compound_metric_hash, :error => ErrorFixtures.error_hash, - :attributes! => {:metric => { - 'xmlns:xsi'=> 'http://www.w3.org/2001/XMLSchema-instance', - 'xsi:type' => 'kalibro:compoundMetricXml' }, - :error => { - 'xmlns:xsi'=> 'http://www.w3.org/2001/XMLSchema-instance', - 'xsi:type' => 'kalibro:errorXml' }}} - end - -end diff --git a/plugins/mezuro/test/fixtures/module_node_fixtures.rb b/plugins/mezuro/test/fixtures/module_node_fixtures.rb deleted file mode 100644 index 1c94081..0000000 --- a/plugins/mezuro/test/fixtures/module_node_fixtures.rb +++ /dev/null @@ -1,47 +0,0 @@ -require File.dirname(__FILE__) + '/module_fixtures' - -class ModuleNodeFixtures - - def self.module_node - Kalibro::ModuleNode.new module_node_hash - end - - def self.module_node_hash - { - :module => ModuleFixtures.module_hash,:attributes! => {:module => { - 'xmlns:xsi'=> 'http://www.w3.org/2001/XMLSchema-instance', - 'xsi:type' => 'kalibro:moduleXml' }}, - :child => [{ - :module => { - :name => 'org', - :granularity => 'PACKAGE' - },:attributes! => {:module => { - 'xmlns:xsi'=> 'http://www.w3.org/2001/XMLSchema-instance', - 'xsi:type' => 'kalibro:moduleXml' }}, - :child => [{ - :module => { - :name => 'org.Window', - :granularity => 'CLASS' - },:attributes! => {:module => { - 'xmlns:xsi'=> 'http://www.w3.org/2001/XMLSchema-instance', - 'xsi:type' => 'kalibro:moduleXml' }} - }] - },{ - :module => { - :name => 'Dialog', - :granularity => 'CLASS' - },:attributes! => {:module => { - 'xmlns:xsi'=> 'http://www.w3.org/2001/XMLSchema-instance', - 'xsi:type' => 'kalibro:moduleXml' }} - },{ - :module => { - :name => 'main', - :granularity => 'CLASS' - },:attributes! => {:module => { - 'xmlns:xsi'=> 'http://www.w3.org/2001/XMLSchema-instance', - 'xsi:type' => 'kalibro:moduleXml' }} - }] - } - end - -end diff --git a/plugins/mezuro/test/fixtures/processing_fixtures.rb b/plugins/mezuro/test/fixtures/processing_fixtures.rb index 806ae77..bddb81a 100644 --- a/plugins/mezuro/test/fixtures/processing_fixtures.rb +++ b/plugins/mezuro/test/fixtures/processing_fixtures.rb @@ -11,7 +11,7 @@ class ProcessingFixtures :id => 31, :date => '2011-10-20T18:26:43.151+00:00', :state => 'READY', - :process_times => [ProcessTimeFixtures.process_time_hash], + :process_time => [ProcessTimeFixtures.process_time_hash], :results_root_id => 13 } end diff --git a/plugins/mezuro/test/unit/kalibro/base_tool_test.rb b/plugins/mezuro/test/unit/kalibro/base_tool_test.rb index d39bf3b..7ae9f29 100644 --- a/plugins/mezuro/test/unit/kalibro/base_tool_test.rb +++ b/plugins/mezuro/test/unit/kalibro/base_tool_test.rb @@ -12,21 +12,15 @@ class BaseToolTest < ActiveSupport::TestCase assert_equal @hash[:name], Kalibro::BaseTool.new(@hash).name end -# Mezuro will not send a base_tool hash back to Kalibro -# -# should 'convert base tool to hash' do -# assert_equal @hash, @base_tool.to_hash -# end - should 'get base tool names' do names = ['Analizo', 'Checkstyle'] - Kalibro::BaseTool.expects(:request).with("BaseTool", :all_base_tool_names).returns({:base_tool_name => names}) + Kalibro::BaseTool.expects(:request).with(:all_base_tool_names).returns({:base_tool_name => names}) assert_equal names, Kalibro::BaseTool.all_names end should 'get base tool by name' do request_body = {:base_tool_name => @base_tool.name} - Kalibro::BaseTool.expects(:request).with("BaseTool", :get_base_tool, request_body).returns({:base_tool => @hash}) + Kalibro::BaseTool.expects(:request).with(:get_base_tool, request_body).returns({:base_tool => @hash}) assert_equal @base_tool.name, Kalibro::BaseTool.find_by_name(@base_tool.name).name end diff --git a/plugins/mezuro/test/unit/kalibro/compound_metric_with_error_test.rb b/plugins/mezuro/test/unit/kalibro/compound_metric_with_error_test.rb deleted file mode 100644 index 2b7bcc1..0000000 --- a/plugins/mezuro/test/unit/kalibro/compound_metric_with_error_test.rb +++ /dev/null @@ -1,20 +0,0 @@ -require "test_helper" - -require "#{RAILS_ROOT}/plugins/mezuro/test/fixtures/compound_metric_with_error_fixtures" - -class CompoundMetricWithErrorTest < ActiveSupport::TestCase - - def setup - @hash = CompoundMetricWithErrorFixtures.compound_metric_with_error_hash - @compound_metric_with_error = CompoundMetricWithErrorFixtures.compound_metric_with_error - end - - should 'create error from hash' do - assert_equal @hash[:error][:message], Kalibro::CompoundMetricWithError.new(@hash).error.message - end - - should 'convert error to hash' do - assert_equal @hash, @compound_metric_with_error.to_hash - end - -end diff --git a/plugins/mezuro/test/unit/kalibro/metric_configuration_test.rb b/plugins/mezuro/test/unit/kalibro/metric_configuration_test.rb index c22b92a..1194156 100644 --- a/plugins/mezuro/test/unit/kalibro/metric_configuration_test.rb +++ b/plugins/mezuro/test/unit/kalibro/metric_configuration_test.rb @@ -22,27 +22,27 @@ class MetricConfigurationTest < ActiveSupport::TestCase configuration_id = 13 request_body = { :configuration_id => configuration_id } response_hash = {:metric_configuration => [@native_metric_configuration_hash]} - Kalibro::MetricConfiguration.expects(:request).with("MetricConfiguration", :metric_configurations_of, request_body).returns(response_hash) + Kalibro::MetricConfiguration.expects(:request).with(:metric_configurations_of, request_body).returns(response_hash) assert_equal @native_metric_configuration.code, Kalibro::MetricConfiguration.metric_configurations_of(configuration_id).first.code end should 'return true when metric configuration is saved successfully' do id_from_kalibro = 1 configuration_id = @created_metric_configuration.configuration_id - 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) + 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) assert @created_metric_configuration.save assert_equal id_from_kalibro, @created_metric_configuration.id end should 'return false when metric configuration is not saved successfully' do configuration_id = @created_metric_configuration.configuration_id - Kalibro::MetricConfiguration.expects(:request).with("MetricConfiguration", :save_metric_configuration, {:metric_configuration => @created_metric_configuration.to_hash, :configuration_id => configuration_id}).raises(Exception.new) + Kalibro::MetricConfiguration.expects(:request).with(:save_metric_configuration, {:metric_configuration => @created_metric_configuration.to_hash, :configuration_id => configuration_id}).raises(Exception.new) assert !(@created_metric_configuration.save) assert_nil @created_metric_configuration.id end should 'destroy metric configuration' do - Kalibro::MetricConfiguration.expects(:request).with("MetricConfiguration", :delete_metric_configuration, :metric_configuration_id => @native_metric_configuration.id) + Kalibro::MetricConfiguration.expects(:request).with(:delete_metric_configuration, :metric_configuration_id => @native_metric_configuration.id) @native_metric_configuration.destroy end diff --git a/plugins/mezuro/test/unit/kalibro/metric_result_test.rb b/plugins/mezuro/test/unit/kalibro/metric_result_test.rb index 683e75a..b003faa 100644 --- a/plugins/mezuro/test/unit/kalibro/metric_result_test.rb +++ b/plugins/mezuro/test/unit/kalibro/metric_result_test.rb @@ -21,19 +21,19 @@ class MetricResultTest < ActiveSupport::TestCase should 'return descendant results of a metric result' do descendant = [31, 13] - Kalibro::MetricResult.expects(:request).with("MetricResult", :descendant_results_of, {:metric_result_id => @result.id}).returns({:descendant_result => descendant}) + Kalibro::MetricResult.expects(:request).with(:descendant_results_of, {:metric_result_id => @result.id}).returns({:descendant_result => descendant}) assert_equal descendant, @result.descendant_results end should 'return metric results of a module result' do id = 31 - Kalibro::MetricResult.expects(:request).with("MetricResult", :metric_results_of, {:module_result_id => id}).returns(:metric_result => [@native_hash, @compound_hash]) + Kalibro::MetricResult.expects(:request).with(:metric_results_of, {:module_result_id => id}).returns(:metric_result => [@native_hash, @compound_hash]) assert_equal @native_hash[:id], Kalibro::MetricResult.metric_results_of(id).first.id end should 'return history of a metric with a module result id' do module_id = 31 - 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]}) + 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]}) assert_equal DateMetricResultFixtures.date_metric_result_hash[:metric_result][:id], @result.history_of(module_id).first.metric_result.id end diff --git a/plugins/mezuro/test/unit/kalibro/module_node_test.rb b/plugins/mezuro/test/unit/kalibro/module_node_test.rb deleted file mode 100644 index d507452..0000000 --- a/plugins/mezuro/test/unit/kalibro/module_node_test.rb +++ /dev/null @@ -1,19 +0,0 @@ -require "test_helper" -require "#{RAILS_ROOT}/plugins/mezuro/test/fixtures/module_node_fixtures" - -class ModuleNodeTest < ActiveSupport::TestCase - - def setup - @hash = ModuleNodeFixtures.module_node_hash - @node = ModuleNodeFixtures.module_node - end - - should 'create module node from hash' do - assert_equal( @node.child[0].module.name, Kalibro::ModuleNode.new(@hash).child[0].module.name) - end - - should 'convert children hash to array of ModuleNode' do - assert_equal @hash, @node.to_hash - end - -end diff --git a/plugins/mezuro/test/unit/kalibro/module_result_test.rb b/plugins/mezuro/test/unit/kalibro/module_result_test.rb index a6624af..95f9064 100644 --- a/plugins/mezuro/test/unit/kalibro/module_result_test.rb +++ b/plugins/mezuro/test/unit/kalibro/module_result_test.rb @@ -8,6 +8,7 @@ class ModuleResultTest < ActiveSupport::TestCase @hash = ModuleResultFixtures.module_result_hash @module_result = ModuleResultFixtures.module_result end + should 'create module result' do assert_equal @hash[:id] , Kalibro::ModuleResult.new(@hash).id end @@ -18,13 +19,13 @@ class ModuleResultTest < ActiveSupport::TestCase should 'find module result' do response = {:module_result => @hash} - Kalibro::ModuleResult.expects(:request).with('ModuleResult',:get_module_result, {:module_result_id => @module_result.id}).returns(response) + Kalibro::ModuleResult.expects(:request).with(:get_module_result, {:module_result_id => @module_result.id}).returns(response) assert_equal @module_result.grade, Kalibro::ModuleResult.find(@module_result.id).grade end should 'return children of a module result' do response = {:module_result => [@hash]} - Kalibro::ModuleResult.expects(:request).with('ModuleResult',:children_of, {:module_result_id => @module_result.id}).returns(response) + Kalibro::ModuleResult.expects(:request).with(:children_of, {:module_result_id => @module_result.id}).returns(response) assert @hash[:id], @module_result.children.first.id end diff --git a/plugins/mezuro/test/unit/kalibro/module_test.rb b/plugins/mezuro/test/unit/kalibro/module_test.rb index 4274bc6..05b6310 100644 --- a/plugins/mezuro/test/unit/kalibro/module_test.rb +++ b/plugins/mezuro/test/unit/kalibro/module_test.rb @@ -17,16 +17,4 @@ class ModuleTest < ActiveSupport::TestCase assert_equal @hash, @module.to_hash end -=begin - should 'list ancestor names' do - @module.name = "org.kalibro.core" - assert_equal ["org", "org.kalibro", "org.kalibro.core"], @module.ancestor_names - end - - should 'list ancestor with one name' do - @module.name = "org" - assert_equal ["org"], @module.ancestor_names - end -=end - end diff --git a/plugins/mezuro/test/unit/kalibro/processing_test.rb b/plugins/mezuro/test/unit/kalibro/processing_test.rb index 21afecc..38d16a1 100644 --- a/plugins/mezuro/test/unit/kalibro/processing_test.rb +++ b/plugins/mezuro/test/unit/kalibro/processing_test.rb @@ -9,21 +9,11 @@ class ProcessingTest < ActiveSupport::TestCase @processing = ProcessingFixtures.processing @repository_id = 31 - -=begin - @project_name = @processing.project.name - @date = @processing.date - @flag = DateTime.now.sec % 2 == 0 #random choose between true or false - - @request = {:project_name => @project_name} - @request_with_date = {:project_name => @project_name, :date => @date} - @flag_response = {:has_results => @flag} - @result_response = {:processing => @processing.to_hash} -=end end should 'create project result from hash' do - assert_equal @processing.results_root_id, Kalibro::Processing.new(@hash).results_root_id + assert_equal @hash[:results_root_id], Kalibro::Processing.new(@hash).results_root_id + assert_equal @hash[:process_time].first[:state], Kalibro::Processing.new(@hash).process_times.first.state end should 'convert project result to hash' do @@ -34,8 +24,8 @@ class ProcessingTest < ActiveSupport::TestCase true_repository_id = 31 false_repository_id = 32 - Kalibro::Processing.expects(:request).with('Processing',:has_processing, {:repository_id => true_repository_id}).returns({:exists => true}) - Kalibro::Processing.expects(:request).with('Processing',:has_processing, {:repository_id => false_repository_id}).returns({:exists => false}) + Kalibro::Processing.expects(:request).with(:has_processing, {:repository_id => true_repository_id}).returns({:exists => true}) + Kalibro::Processing.expects(:request).with(:has_processing, {:repository_id => false_repository_id}).returns({:exists => false}) assert Kalibro::Processing.has_processing(true_repository_id) assert !Kalibro::Processing.has_processing(false_repository_id) @@ -45,8 +35,8 @@ class ProcessingTest < ActiveSupport::TestCase true_repository_id = 31 false_repository_id = 32 - Kalibro::Processing.expects(:request).with('Processing',:has_ready_processing, {:repository_id => true_repository_id}).returns({:exists => true}) - Kalibro::Processing.expects(:request).with('Processing',:has_ready_processing, {:repository_id => false_repository_id}).returns({:exists => false}) + Kalibro::Processing.expects(:request).with(:has_ready_processing, {:repository_id => true_repository_id}).returns({:exists => true}) + Kalibro::Processing.expects(:request).with(:has_ready_processing, {:repository_id => false_repository_id}).returns({:exists => false}) assert Kalibro::Processing.has_ready_processing(true_repository_id) assert !Kalibro::Processing.has_ready_processing(false_repository_id) @@ -56,8 +46,8 @@ class ProcessingTest < ActiveSupport::TestCase true_repository_id = 31 false_repository_id = 32 - Kalibro::Processing.expects(:request).with('Processing',:has_processing_after, {:repository_id => true_repository_id, :date => @processing.date}).returns({:exists => true}) - Kalibro::Processing.expects(:request).with('Processing',:has_processing_after, {:repository_id => false_repository_id, :date => @processing.date}).returns({:exists => false}) + Kalibro::Processing.expects(:request).with(:has_processing_after, {:repository_id => true_repository_id, :date => @processing.date}).returns({:exists => true}) + Kalibro::Processing.expects(:request).with(:has_processing_after, {:repository_id => false_repository_id, :date => @processing.date}).returns({:exists => false}) assert Kalibro::Processing.has_processing_after(true_repository_id, @processing.date) assert !Kalibro::Processing.has_processing_after(false_repository_id, @processing.date) @@ -67,67 +57,41 @@ class ProcessingTest < ActiveSupport::TestCase true_repository_id = 31 false_repository_id = 32 - Kalibro::Processing.expects(:request).with('Processing',:has_processing_before, {:repository_id => true_repository_id, :date => @processing.date}).returns({:exists => true}) - Kalibro::Processing.expects(:request).with('Processing',:has_processing_before, {:repository_id => false_repository_id, :date => @processing.date}).returns({:exists => false}) + Kalibro::Processing.expects(:request).with(:has_processing_before, {:repository_id => true_repository_id, :date => @processing.date}).returns({:exists => true}) + Kalibro::Processing.expects(:request).with(:has_processing_before, {:repository_id => false_repository_id, :date => @processing.date}).returns({:exists => false}) assert Kalibro::Processing.has_processing_before(true_repository_id, @processing.date) assert !Kalibro::Processing.has_processing_before(false_repository_id, @processing.date) end should 'get last processing state of a repository' do - Kalibro::Processing.expects(:request).with('Processing',:last_processing_state, {:repository_id => @repository_id}).returns({:process_state => @processing.state}) + Kalibro::Processing.expects(:request).with(:last_processing_state, {:repository_id => @repository_id}).returns({:process_state => @processing.state}) assert_equal @processing.state, Kalibro::Processing.last_processing_state_of(@repository_id) end should 'get last ready processing of a repository' do - Kalibro::Processing.expects(:request).with('Processing', :last_ready_processing, {:repository_id => @repository_id}).returns({:processing => @hash}) + Kalibro::Processing.expects(:request).with(:last_ready_processing, {:repository_id => @repository_id}).returns({:processing => @hash}) assert_equal @processing.id, Kalibro::Processing.last_ready_processing_of(@repository_id).id end should 'get first processing of a repository' do - Kalibro::Processing.expects(:request).with('Processing', :first_processing, {:repository_id => @repository_id}).returns({:processing => @hash}) + Kalibro::Processing.expects(:request).with(:first_processing, {:repository_id => @repository_id}).returns({:processing => @hash}) assert_equal @processing.id, Kalibro::Processing.first_processing_of(@repository_id).id end should 'get last processing of a repository' do - Kalibro::Processing.expects(:request).with('Processing', :last_processing, {:repository_id => @repository_id}).returns({:processing => @hash}) + Kalibro::Processing.expects(:request).with(:last_processing, {:repository_id => @repository_id}).returns({:processing => @hash}) assert_equal @processing.id, Kalibro::Processing.last_processing_of(@repository_id).id end should 'get first processing after a date of a repository' do - Kalibro::Processing.expects(:request).with('Processing', :first_processing_after, {:repository_id => @repository_id, :date => @processing.date}).returns({:processing => @hash}) + Kalibro::Processing.expects(:request).with(:first_processing_after, {:repository_id => @repository_id, :date => @processing.date}).returns({:processing => @hash}) assert_equal @processing.id, Kalibro::Processing.first_processing_after(@repository_id, @processing.date).id end should 'get last processing before a date of a repository' do - Kalibro::Processing.expects(:request).with('Processing', :last_processing_before, {:repository_id => @repository_id, :date => @processing.date}).returns({:processing => @hash}) + Kalibro::Processing.expects(:request).with(:last_processing_before, {:repository_id => @repository_id, :date => @processing.date}).returns({:processing => @hash}) assert_equal @processing.id, Kalibro::Processing.last_processing_before(@repository_id, @processing.date).id end - -=begin - - should 'retrieve formatted load time' do - assert_equal '00:00:14', @processing.formatted_load_time - end - - should 'retrieve formatted analysis time' do - assert_equal '00:00:01', @processing.formatted_analysis_time - end - should 'retrive complex module' do - assert_equal @hash[:source_tree][:child][0][:child].first, @processing.node("org.Window").to_hash - end - - should 'return source tree node when nil is given' do - assert_equal @hash[:source_tree], @processing.node(nil).to_hash - end - - should 'return source tree node when project name is given' do - assert_equal @hash[:source_tree], @processing.node(@processing.project.name).to_hash - end - - should 'return correct node when module name is given' do - assert_equal @hash[:source_tree][:child][2], @processing.node("main").to_hash - end -=end end diff --git a/plugins/mezuro/test/unit/kalibro/project_test.rb b/plugins/mezuro/test/unit/kalibro/project_test.rb index 8b7ddd1..091cfbc 100644 --- a/plugins/mezuro/test/unit/kalibro/project_test.rb +++ b/plugins/mezuro/test/unit/kalibro/project_test.rb @@ -8,7 +8,6 @@ class ProjectTest < ActiveSupport::TestCase @hash = ProjectFixtures.project_hash @project = ProjectFixtures.project @created_project = ProjectFixtures.created_project - @project_content = ProjectFixtures.project_content end should 'initialize new project from hash' do @@ -22,75 +21,53 @@ class ProjectTest < ActiveSupport::TestCase end should 'answer if project exists in kalibro' do - Kalibro::Project.expects(:request).with("Project", :project_exists, {:project_id => @project.id}).returns({:exists => true}) + Kalibro::Project.expects(:request).with(:project_exists, {:project_id => @project.id}).returns({:exists => true}) assert Kalibro::Project.exists?(@project.id) end should 'find project' do - Kalibro::Project.expects(:request).with("Project", :get_project, {:project_id => @project.id}).returns(:project => @hash) + Kalibro::Project.expects(:request).with(:project_exists, {:project_id => @project.id}).returns({:exists => true}) + Kalibro::Project.expects(:request).with(:get_project, {:project_id => @project.id}).returns(:project => @hash) assert_equal @hash[:name], Kalibro::Project.find(@project.id).name end - should 'raise error when project doesnt exist' do - request_body = {:project_id => @project.id} - Kalibro::Project.expects(:request).with("Project", :get_project, request_body).raises(Exception.new("(S:Server) There is no project with id #{@project.id}")) - assert_raise Exception do Kalibro::Project.find(@project.id) end + should 'verify when project doesnt exist' do + Kalibro::Project.expects(:request).with(:project_exists, {:project_id => @project.id}).returns({:exists => false}) + assert_nil Kalibro::Project.find(@project.id) end should 'get project of a repository' do repository_id = 31 - Kalibro::Project.expects(:request).with("Project", :project_of, {:repository_id => repository_id}).returns({:project => @hash}) + Kalibro::Project.expects(:request).with(:project_of, {:repository_id => repository_id}).returns({:project => @hash}) assert_equal @hash[:name], Kalibro::Project.project_of(repository_id).name end should 'get all project' do - Kalibro::Project.expects(:request).with("Project", :all_projects).returns({:project => [@hash]}) + Kalibro::Project.expects(:request).with(:all_projects).returns({:project => [@hash]}) assert_equal @hash[:name], Kalibro::Project.all.first.name end should 'return empty when there are no projects' do - Kalibro::Project.expects(:request).with("Project", :all_projects).returns({:project => nil}) + Kalibro::Project.expects(:request).with(:all_projects).returns({:project => nil}) assert_equal [], Kalibro::Project.all end should 'return true when project is saved successfully' do id_from_kalibro = 1 - Kalibro::Project.expects(:request).with("Project", :save_project, {:project => @created_project.to_hash}).returns(:project_id => id_from_kalibro) + Kalibro::Project.expects(:request).with(:save_project, {:project => @created_project.to_hash}).returns(:project_id => id_from_kalibro) assert @created_project.save assert_equal id_from_kalibro, @created_project.id end should 'return false when project is not saved successfully' do - Kalibro::Project.expects(:request).with("Project", :save_project, {:project => @project.to_hash}).raises(Exception.new) - assert !(@project.save) + Kalibro::Project.expects(:request).with(:save_project, {:project => @created_project.to_hash}).raises(Exception.new) + assert !(@created_project.save) assert_nil @created_project.id end should 'remove existent project from service' do - Kalibro::Project.expects(:request).with("Project", :delete_project, {:project_id => @project.id}) + Kalibro::Project.expects(:request).with(:delete_project, {:project_id => @project.id}) @project.destroy end -=begin - should 'process project without days' do - Kalibro::Project.expects(:request).with('Kalibro', :process_project, {:project_name => @project.name}) - @project.process_project - end - - should 'process project with days' do - Kalibro::Project.expects(:request).with('Kalibro', :process_periodically, {:project_name => @project.name, :period_in_days => "1"}) - @project.process_project "1" - end - - should 'process period' do - Kalibro::Project.expects(:request).with('Kalibro', :get_process_period, {:project_name => @project.name}).returns({:period => "1"}) - assert_equal "1", @project.process_period - end - - should 'cancel periodic process' do - Kalibro::Project.expects(:request).with("Kalibro", :cancel_periodic_process, {:project_name => @project.name}) - @project.cancel_periodic_process - end -=end - end diff --git a/plugins/mezuro/test/unit/kalibro/range_test.rb b/plugins/mezuro/test/unit/kalibro/range_test.rb index 58d360f..cbb608f 100644 --- a/plugins/mezuro/test/unit/kalibro/range_test.rb +++ b/plugins/mezuro/test/unit/kalibro/range_test.rb @@ -20,27 +20,27 @@ class RangeTest < ActiveSupport::TestCase should 'get ranges of a metric configuration' do metric_configuration_id = 31 - Kalibro::Range.expects(:request).with("Range", :ranges_of, {:metric_configuration_id => metric_configuration_id}).returns({:range => [@hash]}) + Kalibro::Range.expects(:request).with(:ranges_of, {:metric_configuration_id => metric_configuration_id}).returns({:range => [@hash]}) assert_equal @hash[:comments], Kalibro::Range.ranges_of(metric_configuration_id).first.comments end should 'return true when range is saved successfully' do id_from_kalibro = 1 metric_configuration_id = 2 - 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) + Kalibro::Range.expects(:request).with(:save_range, {:range => @created_range.to_hash, :metric_configuration_id => metric_configuration_id}).returns(:range_id => id_from_kalibro) assert @created_range.save(metric_configuration_id) assert_equal id_from_kalibro, @created_range.id end should 'return false when range is not saved successfully' do metric_configuration_id = 2 - Kalibro::Range.expects(:request).with("Range", :save_range, {:range => @created_range.to_hash, :metric_configuration_id => metric_configuration_id}).raises(Exception.new) + Kalibro::Range.expects(:request).with(:save_range, {:range => @created_range.to_hash, :metric_configuration_id => metric_configuration_id}).raises(Exception.new) assert !(@created_range.save(metric_configuration_id)) assert_nil @created_range.id end should 'destroy range by id' do - Kalibro::Range.expects(:request).with("Range", :delete_range, {:range_id => @range.id}) + Kalibro::Range.expects(:request).with(:delete_range, {:range_id => @range.id}) @range.destroy end diff --git a/plugins/mezuro/test/unit/kalibro/reading_group_test.rb b/plugins/mezuro/test/unit/kalibro/reading_group_test.rb index e177802..5a8fbe9 100644 --- a/plugins/mezuro/test/unit/kalibro/reading_group_test.rb +++ b/plugins/mezuro/test/unit/kalibro/reading_group_test.rb @@ -18,42 +18,48 @@ class ReadingGroupTest < ActiveSupport::TestCase end should 'verify existence of reading group' do - Kalibro::ReadingGroup.expects(:request).with("ReadingGroup", :reading_group_exists, {:group_id => @hash[:id]}).returns({:exists => true}) + fake_id = 0 + Kalibro::ReadingGroup.expects(:request).with(:reading_group_exists, {:group_id => fake_id}).returns({:exists => false}) + Kalibro::ReadingGroup.expects(:request).with(:reading_group_exists, {:group_id => @hash[:id]}).returns({:exists => true}) + assert !Kalibro::ReadingGroup.exists?(fake_id) assert Kalibro::ReadingGroup.exists?(@hash[:id]) end should 'get reading group' do - Kalibro::ReadingGroup.expects(:request).with("ReadingGroup", :get_reading_group, {:group_id => @hash[:id]}). + Kalibro::ReadingGroup.expects(:request).with(:reading_group_exists, {:group_id => @hash[:id]}).returns({:exists => true}) + Kalibro::ReadingGroup.expects(:request).with(:get_reading_group, {:group_id => @hash[:id]}). returns({:reading_group => @hash}) assert_equal @hash[:name], Kalibro::ReadingGroup.find(@hash[:id]).name end + + should 'get all reading groups' do - Kalibro::ReadingGroup.expects(:request).with("ReadingGroup", :all_reading_groups).returns({:reading_group => [@hash]}) + Kalibro::ReadingGroup.expects(:request).with(:all_reading_groups).returns({:reading_group => [@hash]}) assert_equal @hash[:name], Kalibro::ReadingGroup.all.first.name end should 'get reading group of a metric configuration' do id = 31 - Kalibro::ReadingGroup.expects(:request).with("ReadingGroup", :reading_group_of, {:metric_configuration_id => id}).returns({:reading_group => @hash}) + Kalibro::ReadingGroup.expects(:request).with(:reading_group_of, {:metric_configuration_id => id}).returns({:reading_group => @hash}) assert_equal @hash[:name], Kalibro::ReadingGroup.reading_group_of(id).name end should 'return true when reading group is saved successfully' do id_from_kalibro = 1 - Kalibro::ReadingGroup.expects(:request).with("ReadingGroup", :save_reading_group, {:reading_group => @created_reading_group.to_hash}).returns(:reading_group_id => id_from_kalibro) + Kalibro::ReadingGroup.expects(:request).with(:save_reading_group, {:reading_group => @created_reading_group.to_hash}).returns(:reading_group_id => id_from_kalibro) assert @created_reading_group.save assert_equal id_from_kalibro, @created_reading_group.id end should 'return false when reading group is not saved successfully' do - Kalibro::ReadingGroup.expects(:request).with("ReadingGroup", :save_reading_group, {:reading_group => @created_reading_group.to_hash}).raises(Exception.new) + Kalibro::ReadingGroup.expects(:request).with(:save_reading_group, {:reading_group => @created_reading_group.to_hash}).raises(Exception.new) assert !(@created_reading_group.save) assert_nil @created_reading_group.id end should 'destroy reading group by id' do - Kalibro::ReadingGroup.expects(:request).with("ReadingGroup", :delete_reading_group, {:group_id => @reading_group.id}) + Kalibro::ReadingGroup.expects(:request).with(:delete_reading_group, {:group_id => @reading_group.id}) @reading_group.destroy end diff --git a/plugins/mezuro/test/unit/kalibro/reading_test.rb b/plugins/mezuro/test/unit/kalibro/reading_test.rb index acdecc8..fe665c4 100644 --- a/plugins/mezuro/test/unit/kalibro/reading_test.rb +++ b/plugins/mezuro/test/unit/kalibro/reading_test.rb @@ -18,38 +18,38 @@ class ReadingTest < ActiveSupport::TestCase end should 'get reading' do - Kalibro::Reading.expects(:request).with("Reading", :get_reading, {:reading_id => @hash[:id]}). + Kalibro::Reading.expects(:request).with(:get_reading, {:reading_id => @hash[:id]}). returns({:reading => @hash}) assert_equal @hash[:label], Kalibro::Reading.find(@hash[:id]).label end should 'get reading of a range' do range_id = 31 - Kalibro::Reading.expects(:request).with("Reading", :reading_of, {:range_id => range_id}).returns({:reading => @hash}) + Kalibro::Reading.expects(:request).with(:reading_of, {:range_id => range_id}).returns({:reading => @hash}) assert_equal @hash[:label], Kalibro::Reading.reading_of(range_id).label end should 'get readings of a reading group' do reading_group_id = 31 - Kalibro::Reading.expects(:request).with("Reading", :readings_of, {:group_id => reading_group_id}).returns({:reading => [@hash]}) + Kalibro::Reading.expects(:request).with(:readings_of, {:group_id => reading_group_id}).returns({:reading => [@hash]}) assert_equal @hash[:label], Kalibro::Reading.readings_of(reading_group_id).first.label end should 'return true when reading is saved successfully' do id_from_kalibro = 1 - Kalibro::Reading.expects(:request).with("Reading", :save_reading, {:reading => @created_reading.to_hash}).returns(:reading_id => id_from_kalibro) + Kalibro::Reading.expects(:request).with(:save_reading, {:reading => @created_reading.to_hash}).returns(:reading_id => id_from_kalibro) assert @created_reading.save assert_equal id_from_kalibro, @created_reading.id end should 'return false when reading is not saved successfully' do - Kalibro::Reading.expects(:request).with("Reading", :save_reading, {:reading => @created_reading.to_hash}).raises(Exception.new) + Kalibro::Reading.expects(:request).with(:save_reading, {:reading => @created_reading.to_hash}).raises(Exception.new) assert !(@created_reading.save) assert_nil @created_reading.id end should 'destroy reading by id' do - Kalibro::Reading.expects(:request).with("Reading", :delete_reading, {:reading_id => @reading.id}) + Kalibro::Reading.expects(:request).with(:delete_reading, {:reading_id => @reading.id}) @reading.destroy end diff --git a/plugins/mezuro/test/unit/kalibro/repository_test.rb b/plugins/mezuro/test/unit/kalibro/repository_test.rb index 867aab7..d9d3bcb 100644 --- a/plugins/mezuro/test/unit/kalibro/repository_test.rb +++ b/plugins/mezuro/test/unit/kalibro/repository_test.rb @@ -20,47 +20,47 @@ class RepositoryTest < ActiveSupport::TestCase should 'get supported repository types' do types = ['BAZAAR', 'GIT', 'SUBVERSION'] - Kalibro::Repository.expects(:request).with('Repository', :supported_repository_types).returns({:repository_type => types}) + Kalibro::Repository.expects(:request).with(:supported_repository_types).returns({:repository_type => types}) assert_equal types, Kalibro::Repository.repository_types end should 'get repository of a precessing' do id = 31 - Kalibro::Repository.expects(:request).with("Repository", :repository_of, {:processing_id => id}).returns({:repository => @hash}) + Kalibro::Repository.expects(:request).with(:repository_of, {:processing_id => id}).returns({:repository => @hash}) assert_equal @hash[:name], Kalibro::Repository.repository_of(id).name end should 'get repositories of a project' do project_id = 31 - Kalibro::Repository.expects(:request).with("Repository", :repositories_of, {:project_id => project_id}).returns({:repository => [@hash]}) + Kalibro::Repository.expects(:request).with(:repositories_of, {:project_id => project_id}).returns({:repository => [@hash]}) assert_equal @hash[:name], Kalibro::Repository.repositories_of(project_id).first.name end should 'return true when repository is saved successfully' do id_from_kalibro = 1 - Kalibro::Repository.expects(:request).with("Repository", :save_repository, {:repository => @created_repository.to_hash}).returns(:repository_id => id_from_kalibro) + Kalibro::Repository.expects(:request).with(:save_repository, {:repository => @created_repository.to_hash}).returns(:repository_id => id_from_kalibro) assert @created_repository.save assert_equal id_from_kalibro, @created_repository.id end should 'return false when repository is not saved successfully' do - Kalibro::Repository.expects(:request).with("Repository", :save_repository, {:repository => @created_repository.to_hash}).raises(Exception.new) + Kalibro::Repository.expects(:request).with(:save_repository, {:repository => @created_repository.to_hash}).raises(Exception.new) assert !(@created_repository.save) assert_nil @created_repository.id end should 'destroy repository by id' do - Kalibro::Repository.expects(:request).with("Repository", :delete_repository, {:repository_id => @repository.id}) + Kalibro::Repository.expects(:request).with(:delete_repository, {:repository_id => @repository.id}) @repository.destroy end should 'process repository' do - Kalibro::Repository.expects(:request).with("Repository", :process_repository, {:repository_id => @repository.id}); + Kalibro::Repository.expects(:request).with(:process_repository, {:repository_id => @repository.id}); @repository.process_repository end should 'cancel processing of a repository' do - Kalibro::Repository.expects(:request).with("Repository", :cancel_processing_of_repository, {:repository_id => @repository.id}); + Kalibro::Repository.expects(:request).with(:cancel_processing_of_repository, {:repository_id => @repository.id}); @repository.cancel_processing_of_repository end diff --git a/plugins/mezuro/test/unit/mezuro_plugin/project_content_test.rb b/plugins/mezuro/test/unit/mezuro_plugin/project_content_test.rb index 9709495..1188643 100644 --- a/plugins/mezuro/test/unit/mezuro_plugin/project_content_test.rb +++ b/plugins/mezuro/test/unit/mezuro_plugin/project_content_test.rb @@ -1,7 +1,6 @@ require "test_helper" require "#{RAILS_ROOT}/plugins/mezuro/test/fixtures/project_fixtures" -require "#{RAILS_ROOT}/plugins/mezuro/test/fixtures/project_result_fixtures" require "#{RAILS_ROOT}/plugins/mezuro/test/fixtures/module_fixtures" require "#{RAILS_ROOT}/plugins/mezuro/test/fixtures/module_result_fixtures" -- libgit2 0.21.2