diff --git a/plugins/mezuro/test/fixtures/project_fixtures.rb b/plugins/mezuro/test/fixtures/project_fixtures.rb index d2534b0..cde418e 100644 --- a/plugins/mezuro/test/fixtures/project_fixtures.rb +++ b/plugins/mezuro/test/fixtures/project_fixtures.rb @@ -6,6 +6,25 @@ class ProjectFixtures Kalibro::Project.new project_hash end + def self.project_hash + { + :name => 'Qt-Calculator', + :license => 'GPL', + :description => 'Calculator for Qt', + :repository => RepositoryFixtures.repository_hash, + :configuration_name => 'Kalibro for Java', + :state => 'READY', + :attributes! => + { + :repository=> + { + "xsi:type"=>"kalibro:repositoryXml", + "xmlns:xsi"=>"http://www.w3.org/2001/XMLSchema-instance" + } + } + } + end + def self.project_content content = MezuroPlugin::ProjectContent.new content.name = 'Qt-Calculator' @@ -18,15 +37,4 @@ class ProjectFixtures content end - def self.project_hash - { - :name => 'Qt-Calculator', - :license => 'GPL', - :description => 'Calculator for Qt', - :repository => RepositoryFixtures.repository_hash, - :configuration_name => 'Kalibro for Java', - :state => 'READY' - } - end - end diff --git a/plugins/mezuro/test/fixtures/project_result_fixtures.rb b/plugins/mezuro/test/fixtures/project_result_fixtures.rb index 9ac837a..e9f2be4 100644 --- a/plugins/mezuro/test/fixtures/project_result_fixtures.rb +++ b/plugins/mezuro/test/fixtures/project_result_fixtures.rb @@ -15,7 +15,20 @@ class ProjectResultFixtures :load_time => 14878, :analysis_time => 1022, :source_tree => ModuleNodeFixtures.module_node_hash, - :collect_time => 14878 + :collect_time => 14878, + :attributes! => + { + :source_tree => + { + "xmlns:xsi"=>"http://www.w3.org/2001/XMLSchema-instance", + "xsi:type"=>"kalibro:moduleNodeXml" + }, + :project => + { + "xmlns:xsi"=>"http://www.w3.org/2001/XMLSchema-instance", + "xsi:type"=>"kalibro:projectXml" + } + } } end diff --git a/plugins/mezuro/test/unit/kalibro/project_result_test.rb b/plugins/mezuro/test/unit/kalibro/project_result_test.rb index 1b21d5b..2e72842 100644 --- a/plugins/mezuro/test/unit/kalibro/project_result_test.rb +++ b/plugins/mezuro/test/unit/kalibro/project_result_test.rb @@ -8,91 +8,87 @@ class ProjectResultTest < ActiveSupport::TestCase @hash = ProjectResultFixtures.project_result_hash @project_result = ProjectResultFixtures.project_result -# Kalibro::Client::Port.expects(:new).with('ProjectResult').returns(@port) -# @client = Kalibro::Client::ProjectResultClient.new - @project_name = @project_result.project.name @date = @project_result.date -# @flag = DateTime.now.sec % 2 == 0 + @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} + @flag_response = {:has_results => @flag} @result_response = {:project_result => @project_result.to_hash} end + should 'create project result from hash' do + assert_equal @project_result.analysis_time, Kalibro::ProjectResult.new(@hash).analysis_time + end + + should 'convert project result to hash' do + assert_equal @hash, @project_result.to_hash + end + should 'get last result' do Kalibro::ProjectResult.expects(:request).with('ProjectResult',:get_last_result_of, @request).returns(@result_response) assert_equal @project_result.analysis_time , Kalibro::ProjectResult.last_result(@project_name).analysis_time end -=begin - should 'create project result from hash' do - assert_equal @result, Kalibro::ProjectResult.from_hash(@hash) + + should 'get first result' do + Kalibro::ProjectResult.expects(:request).with('ProjectResult',:get_first_result_of, @request).returns(@result_response) + assert_equal @project_result.analysis_time, Kalibro::ProjectResult.first_result(@project_name).analysis_time end - should 'convert project result to hash' do - assert_equal @hash, @result.to_hash + should 'get first result after date' do + Kalibro::ProjectResult.expects(:request).with('ProjectResult',:get_first_result_after, @request_with_date).returns(@result_response) + assert_equal @project_result.analysis_time, Kalibro::ProjectResult.first_result_after(@project_name, @date).analysis_time + end + + should 'get last result before date' do + Kalibro::ProjectResult.expects(:request).with('ProjectResult',:get_last_result_before, @request_with_date).returns(@result_response) + assert_equal @project_result.analysis_time, Kalibro::ProjectResult.last_result_before(@project_name, @date).analysis_time + end + + should 'verify if project has results' do + Kalibro::ProjectResult.expects(:request).with('ProjectResult',:has_results_for, @request).returns(@flag_response) + assert_equal @flag, Kalibro::ProjectResult.has_results?(@project_name) + end + + should 'verify if project has results before date' do + Kalibro::ProjectResult.expects(:request).with('ProjectResult',:has_results_before, @request_with_date).returns(@flag_response) + assert_equal @flag, Kalibro::ProjectResult.has_results_before?(@project_name, @date) + end + + should 'verify if project has results after date' do + Kalibro::ProjectResult.expects(:request).with('ProjectResult',:has_results_after, @request_with_date).returns(@flag_response) + assert_equal @flag, Kalibro::ProjectResult.has_results_after?(@project_name, @date) end should 'retrieve formatted load time' do - assert_equal '00:00:14', @result.formatted_load_time + assert_equal '00:00:14', @project_result.formatted_load_time end should 'retrieve formatted analysis time' do - assert_equal '00:00:01', @result.formatted_analysis_time + assert_equal '00:00:01', @project_result.formatted_analysis_time end should 'retrieve module node' do - node = @result.get_node("main") + node = @project_result.get_node("main") assert_equal @hash[:source_tree][:child][2], node.to_hash end should 'retrive complex module' do - node = @result.get_node("org.Window") + node = @project_result.get_node("org.Window") assert_equal @hash[:source_tree][:child][0][:child].first, node.to_hash end should 'return source tree node when nil is given' do - assert_equal @hash[:source_tree], @result.node_of(nil).to_hash + assert_equal @hash[:source_tree], @project_result.node_of(nil).to_hash end should 'return source tree node when project name is given' do - assert_equal @hash[:source_tree], @result.node_of(@result.project.name).to_hash + assert_equal @hash[:source_tree], @project_result.node_of(@project_result.project.name).to_hash end should 'return correct node when module name is given' do - assert_equal @hash[:source_tree][:child][2], @result.node_of("main").to_hash - end - - should 'retrieve if project has results' do - @port.expects(:request).with(:has_results_for, @request).returns(@flag_response) - assert_equal @flag, @client.has_results_for(@project_name) - end - - should 'retrieve if project has results before date' do - @port.expects(:request).with(:has_results_before, @request_with_date).returns(@flag_response) - assert_equal @flag, @client.has_results_before(@project_name, @date) + assert_equal @hash[:source_tree][:child][2], @project_result.node_of("main").to_hash end - should 'retrieve if project has results after date' do - @port.expects(:request).with(:has_results_after, @request_with_date).returns(@flag_response) - assert_equal @flag, @client.has_results_after(@project_name, @date) - end - - should 'get first result of project' do - @port.expects(:request).with(:get_first_result_of, @request).returns(@result_response) - assert_equal @result, @client.first_result(@project_name) - end - - - should 'get first result of project after date' do - @port.expects(:request).with(:get_first_result_after, @request_with_date).returns(@result_response) - assert_equal @result, @client.first_result_after(@project_name, @date) - end - - should 'get last result of project before date' do - @port.expects(:request).with(:get_last_result_before, @request_with_date).returns(@result_response) - assert_equal @result, @client.last_result_before(@project_name, @date) - end -=end end -- libgit2 0.21.2