Commit f5c09269742267344d7f16ef1a10537a14dc1b93
Committed by
Alessandro Palmeira
1 parent
62bff359
Exists in
master
and in
29 other branches
[Mezuro] Removed old unused code and added functional tests
Showing
6 changed files
with
45 additions
and
20 deletions
Show diff stats
plugins/mezuro/controllers/mezuro_plugin_profile_controller.rb
@@ -43,7 +43,6 @@ class MezuroPluginProfileController < ProfileController | @@ -43,7 +43,6 @@ class MezuroPluginProfileController < ProfileController | ||
43 | def choose_metric | 43 | def choose_metric |
44 | @configuration_name = params[:configuration_name] | 44 | @configuration_name = params[:configuration_name] |
45 | @collector_name = params[:collector_name] | 45 | @collector_name = params[:collector_name] |
46 | - | ||
47 | @collector = Kalibro::Client::BaseToolClient.new.base_tool(@collector_name) | 46 | @collector = Kalibro::Client::BaseToolClient.new.base_tool(@collector_name) |
48 | end | 47 | end |
49 | 48 |
plugins/mezuro/lib/kalibro/entities/configuration.rb
@@ -14,11 +14,4 @@ class Kalibro::Entities::Configuration < Kalibro::Entities::Entity | @@ -14,11 +14,4 @@ class Kalibro::Entities::Configuration < Kalibro::Entities::Entity | ||
14 | @metric_configuration = metric_configurations | 14 | @metric_configuration = metric_configurations |
15 | end | 15 | end |
16 | 16 | ||
17 | - def create_metric_configurations(metrics) | ||
18 | - @metric_configuration = [] | ||
19 | - metrics.each do |metric| | ||
20 | - @metric_configuration << create_metric_configuration(metric) | ||
21 | - end | ||
22 | - end | ||
23 | - | ||
24 | end | 17 | end |
plugins/mezuro/test/fixtures/metric_configuration_fixtures.rb
@@ -14,6 +14,15 @@ class MetricConfigurationFixtures | @@ -14,6 +14,15 @@ class MetricConfigurationFixtures | ||
14 | amloc | 14 | amloc |
15 | end | 15 | end |
16 | 16 | ||
17 | + def self.metric_configuration_without_ranges | ||
18 | + amloc = Kalibro::Entities::MetricConfiguration.new | ||
19 | + amloc.metric = NativeMetricFixtures.amloc | ||
20 | + amloc.code = 'amloc' | ||
21 | + amloc.weight = 1.0 | ||
22 | + amloc.aggregation_form = 'AVERAGE' | ||
23 | + amloc | ||
24 | + end | ||
25 | + | ||
17 | def self.sc_configuration | 26 | def self.sc_configuration |
18 | sc = Kalibro::Entities::MetricConfiguration.new | 27 | sc = Kalibro::Entities::MetricConfiguration.new |
19 | sc.metric = CompoundMetricFixtures.sc | 28 | sc.metric = CompoundMetricFixtures.sc |
plugins/mezuro/test/functional/mezuro_plugin_profile_controller_test.rb
@@ -65,6 +65,23 @@ class MezuroPluginProfileControllerTest < ActionController::TestCase | @@ -65,6 +65,23 @@ class MezuroPluginProfileControllerTest < ActionController::TestCase | ||
65 | assert_select('h5', 'Metric results for: Qt-Calculator (APPLICATION)') | 65 | assert_select('h5', 'Metric results for: Qt-Calculator (APPLICATION)') |
66 | end | 66 | end |
67 | 67 | ||
68 | + should 'assign configuration name in choose_base_tool' do | ||
69 | + get :choose_base_tool, :profile => @profile.identifier, :configuration_name => "test name" | ||
70 | + assert_equal assigns(:configuration_name), "test name" | ||
71 | + end | ||
72 | + | ||
73 | + should 'create base tool client' do | ||
74 | + get :choose_base_tool, :profile => @profile.identifier, :configuration_name => "test name" | ||
75 | + assert assigns(:tool_names).instance_of?(Kalibro::Client::BaseToolClient) | ||
76 | + end | ||
77 | + | ||
78 | + should 'assign configuration and collector name in choose_metric' do | ||
79 | + #TODO Mockar cliente | ||
80 | + get :choose_metric, :profile => @profile.identifier, :configuration_name => "test name", :collector_name => "Collector A" | ||
81 | + assert_equal assigns(:configuration_name), "test name" | ||
82 | + assert_equal assigns(:collector_name), "Collector A" | ||
83 | + end | ||
84 | + | ||
68 | private | 85 | private |
69 | 86 | ||
70 | def create_project_content | 87 | def create_project_content |
plugins/mezuro/test/unit/kalibro/entities/configuration_test.rb
@@ -17,13 +17,4 @@ class ConfigurationTest < ActiveSupport::TestCase | @@ -17,13 +17,4 @@ class ConfigurationTest < ActiveSupport::TestCase | ||
17 | assert_equal @hash, @configuration.to_hash | 17 | assert_equal @hash, @configuration.to_hash |
18 | end | 18 | end |
19 | 19 | ||
20 | - should 'create metric configuration' do | ||
21 | - configuration = Kalibro::Entities::Configuration.new | ||
22 | - configuration.create_metric_configurations(["Analizo:Metric Name"]) | ||
23 | - metric_configuration = configuration.metric_configurations[0] | ||
24 | - assert_equal metric_configuration.code, "Metric Name" | ||
25 | - assert_equal metric_configuration.metric.name, "Metric Name" | ||
26 | - assert_equal metric_configuration.metric.origin, "Analizo" | ||
27 | - end | ||
28 | - | ||
29 | end | 20 | end |
plugins/mezuro/test/unit/kalibro/entities/metric_configuration_test.rb
1 | require "test_helper" | 1 | require "test_helper" |
2 | 2 | ||
3 | require "#{RAILS_ROOT}/plugins/mezuro/test/fixtures/metric_configuration_fixtures" | 3 | require "#{RAILS_ROOT}/plugins/mezuro/test/fixtures/metric_configuration_fixtures" |
4 | +require "#{RAILS_ROOT}/plugins/mezuro/test/fixtures/range_fixtures" | ||
4 | 5 | ||
5 | class MetricConfigurationTest < ActiveSupport::TestCase | 6 | class MetricConfigurationTest < ActiveSupport::TestCase |
6 | 7 | ||
7 | def setup | 8 | def setup |
8 | @hash = MetricConfigurationFixtures.amloc_configuration_hash | 9 | @hash = MetricConfigurationFixtures.amloc_configuration_hash |
9 | - @range = MetricConfigurationFixtures.amloc_configuration | 10 | + @metric_configuration = MetricConfigurationFixtures.amloc_configuration |
11 | + @metric_configuration_without_ranges = MetricConfigurationFixtures.metric_configuration_without_ranges | ||
12 | + @range1 = RangeFixtures.amloc_excellent | ||
13 | + @range2 = RangeFixtures.amloc_bad | ||
10 | end | 14 | end |
11 | 15 | ||
12 | should 'create metric configuration from hash' do | 16 | should 'create metric configuration from hash' do |
13 | - assert_equal @range, Kalibro::Entities::MetricConfiguration.from_hash(@hash) | 17 | + assert_equal @metric_configuration, Kalibro::Entities::MetricConfiguration.from_hash(@hash) |
14 | end | 18 | end |
15 | 19 | ||
16 | should 'convert metric configuration to hash' do | 20 | should 'convert metric configuration to hash' do |
17 | - assert_equal @hash, @range.to_hash | 21 | + assert_equal @hash, @metric_configuration.to_hash |
18 | end | 22 | end |
19 | 23 | ||
20 | should 'create appropriate metric type' do | 24 | should 'create appropriate metric type' do |
@@ -24,4 +28,16 @@ class MetricConfigurationTest < ActiveSupport::TestCase | @@ -24,4 +28,16 @@ class MetricConfigurationTest < ActiveSupport::TestCase | ||
24 | assert sc.metric.instance_of?(Kalibro::Entities::CompoundMetric) | 28 | assert sc.metric.instance_of?(Kalibro::Entities::CompoundMetric) |
25 | end | 29 | end |
26 | 30 | ||
31 | + should 'add a range to an empty range list' do | ||
32 | + @metric_configuration_without_ranges.add_range @range1 | ||
33 | + assert_equal @metric_configuration_without_ranges.ranges, [@range1] | ||
34 | + end | ||
35 | + | ||
36 | + should 'add a range to an non-empty range list' do | ||
37 | + @metric_configuration_without_ranges.ranges = [@range1] | ||
38 | + @metric_configuration_without_ranges.add_range @range2 | ||
39 | + assert_equal @metric_configuration_without_ranges.ranges, [@range1, @range2] | ||
40 | + end | ||
41 | + | ||
42 | + | ||
27 | end | 43 | end |