coupler 0.0.4-java → 0.0.6-java

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (78) hide show
  1. data/Gemfile +7 -8
  2. data/Gemfile.lock +43 -24
  3. data/VERSION +1 -1
  4. data/coupler.gemspec +27 -31
  5. data/features/wizard.feature +2 -1
  6. data/lib/coupler.rb +2 -2
  7. data/lib/coupler/base.rb +4 -0
  8. data/lib/coupler/extensions/connections.rb +2 -12
  9. data/lib/coupler/extensions/jobs.rb +4 -2
  10. data/lib/coupler/extensions/projects.rb +1 -1
  11. data/lib/coupler/helpers.rb +9 -1
  12. data/lib/coupler/models.rb +8 -0
  13. data/lib/coupler/models/comparison.rb +5 -4
  14. data/lib/coupler/models/connection.rb +10 -1
  15. data/lib/coupler/models/import.rb +3 -7
  16. data/lib/coupler/models/transformer.rb +1 -1
  17. data/lib/coupler/runner.rb +1 -1
  18. data/lib/coupler/scheduler.rb +1 -1
  19. data/tasks/test.rake +8 -0
  20. data/test/functional/test_base.rb +17 -0
  21. data/test/functional/test_connections.rb +81 -0
  22. data/test/functional/test_imports.rb +76 -0
  23. data/test/{integration/extensions → functional}/test_jobs.rb +21 -12
  24. data/test/functional/test_matchers.rb +108 -0
  25. data/test/functional/test_projects.rb +67 -0
  26. data/test/functional/test_resources.rb +126 -0
  27. data/test/{integration/extensions → functional}/test_results.rb +20 -29
  28. data/test/functional/test_scenarios.rb +92 -0
  29. data/test/functional/test_transformations.rb +106 -0
  30. data/test/functional/test_transformers.rb +68 -0
  31. data/test/helper.rb +30 -20
  32. data/test/integration/test_transformation.rb +6 -1
  33. data/test/unit/models/test_common_model.rb +2 -2
  34. data/test/unit/models/test_comparison.rb +8 -8
  35. data/test/unit/models/test_connection.rb +2 -2
  36. data/test/unit/models/test_field.rb +2 -2
  37. data/test/unit/models/test_import.rb +9 -4
  38. data/test/unit/models/test_job.rb +2 -2
  39. data/test/unit/models/test_matcher.rb +2 -2
  40. data/test/unit/models/test_project.rb +2 -2
  41. data/test/unit/models/test_resource.rb +2 -2
  42. data/test/unit/models/test_result.rb +2 -2
  43. data/test/unit/models/test_scenario.rb +2 -2
  44. data/test/unit/models/test_transformation.rb +2 -2
  45. data/test/unit/models/test_transformer.rb +12 -2
  46. data/test/unit/test_base.rb +1 -14
  47. data/test/unit/test_data_uploader.rb +1 -1
  48. data/test/unit/test_database.rb +1 -1
  49. data/test/unit/test_helpers.rb +2 -2
  50. data/test/unit/test_import_buffer.rb +40 -38
  51. data/test/unit/test_logger.rb +1 -1
  52. data/test/unit/test_models.rb +1 -1
  53. data/test/unit/test_runner.rb +1 -1
  54. data/test/unit/test_scheduler.rb +1 -1
  55. data/webroot/public/css/style.css +7 -5
  56. data/webroot/public/js/jquery.dataTables.min.js +130 -574
  57. data/webroot/views/connections/new.erb +41 -3
  58. data/webroot/views/imports/new.erb +2 -0
  59. data/webroot/views/jobs/list.erb +25 -21
  60. data/webroot/views/projects/index.erb +23 -15
  61. data/webroot/views/resources/list.erb +1 -2
  62. data/webroot/views/resources/new.erb +2 -2
  63. data/webroot/views/resources/show.erb +5 -2
  64. data/webroot/views/scenarios/new.erb +1 -1
  65. data/webroot/views/transformations/new.erb +1 -1
  66. metadata +30 -44
  67. data/lib/coupler/config.rb +0 -128
  68. data/test/coupler/models/test_import.rb +0 -221
  69. data/test/factories.rb +0 -91
  70. data/test/integration/extensions/test_connections.rb +0 -80
  71. data/test/integration/extensions/test_imports.rb +0 -94
  72. data/test/integration/extensions/test_matchers.rb +0 -134
  73. data/test/integration/extensions/test_projects.rb +0 -82
  74. data/test/integration/extensions/test_resources.rb +0 -150
  75. data/test/integration/extensions/test_scenarios.rb +0 -88
  76. data/test/integration/extensions/test_transformations.rb +0 -113
  77. data/test/integration/extensions/test_transformers.rb +0 -80
  78. data/vendor/h2-1.3.154.jar +0 -0
@@ -1,134 +0,0 @@
1
- require 'helper'
2
-
3
- module TestExtensions
4
- class TestMatchers < Coupler::Test::IntegrationTest
5
- def self.startup
6
- super
7
- conn = new_connection('h2', :name => 'foo')
8
- conn.database do |db|
9
- db.create_table!(:foo) do
10
- primary_key :id
11
- String :foo
12
- String :bar
13
- end
14
- db[:foo].insert({:foo => 'foo', :bar => 'bar'})
15
- db[:foo].insert({:foo => 'bar', :bar => 'foo'})
16
- end
17
- end
18
-
19
- def setup
20
- super
21
- @connection = new_connection('h2', :name => 'foo').save!
22
- @project = Project.create!(:name => 'foo')
23
- @resource = Resource.create!(:name => 'foo', :project => @project, :table_name => 'foo', :connection => @connection)
24
- @scenario = Scenario.create!(:name => 'foo', :project => @project, :resource_1 => @resource)
25
- end
26
-
27
- test "new" do
28
- get "/projects/#{@project.id}/scenarios/#{@scenario.id}/matchers/new"
29
- assert last_response.ok?
30
- end
31
-
32
- test "new with non existant project" do
33
- get "/projects/8675309/scenarios/#{@scenario.id}/matchers/new"
34
- assert last_response.redirect?
35
- assert_equal "http://example.org/projects", last_response['location']
36
- follow_redirect!
37
- assert_match /The project you were looking for doesn't exist/, last_response.body
38
- end
39
-
40
- test "new with non existant scenario" do
41
- get "/projects/#{@project.id}/scenarios/8675309/matchers/new"
42
- assert last_response.redirect?
43
- assert_equal "http://example.org/projects/#{@project.id}/scenarios", last_response['location']
44
- follow_redirect!
45
- assert_match /The scenario you were looking for doesn't exist/, last_response.body
46
- end
47
-
48
- test "successfully creating matcher" do
49
- field = @resource.fields_dataset[:name => 'foo']
50
- attribs = {
51
- 'comparisons_attributes' => {
52
- '0' => {
53
- 'lhs_type' => 'field', 'raw_lhs_value' => field.id.to_s,
54
- 'rhs_type' => 'field', 'raw_rhs_value' => field.id.to_s,
55
- 'operator' => 'equals'
56
- }
57
- }
58
- }
59
- post("/projects/#{@project.id}/scenarios/#{@scenario.id}/matchers", { 'matcher' => attribs })
60
- assert last_response.redirect?, "Wasn't redirected"
61
- assert_equal "http://example.org/projects/#{@project.id}/scenarios/#{@scenario.id}", last_response['location']
62
-
63
- assert @scenario.matcher
64
- end
65
-
66
- test "edit" do
67
- field = @resource.fields_dataset[:name => 'foo']
68
- matcher = Matcher.create!({
69
- :scenario => @scenario,
70
- :comparisons_attributes => [{
71
- 'lhs_type' => 'field', 'raw_lhs_value' => field.id, 'lhs_which' => 1,
72
- 'rhs_type' => 'field', 'raw_rhs_value' => field.id, 'rhs_which' => 2,
73
- 'operator' => 'equals'
74
- }]
75
- })
76
- get "/projects/#{@project.id}/scenarios/#{@scenario.id}/matchers/#{matcher.id}/edit"
77
- assert last_response.ok?
78
- end
79
-
80
- test "edit with non existant matcher" do
81
- get "/projects/#{@project.id}/scenarios/#{@scenario.id}/matchers/8675309/edit"
82
- assert last_response.redirect?
83
- assert_equal "http://example.org/projects/#{@project.id}/scenarios/#{@scenario.id}", last_response['location']
84
- follow_redirect!
85
- assert_match /The matcher you were looking for doesn't exist/, last_response.body
86
- end
87
-
88
- test "updating matcher" do
89
- foo = @resource.fields_dataset[:name => 'foo']
90
- bar = @resource.fields_dataset[:name => 'foo']
91
- matcher = Matcher.create!({
92
- :scenario => @scenario,
93
- :comparisons_attributes => [{
94
- 'lhs_type' => 'field', 'raw_lhs_value' => foo.id, 'lhs_which' => 1,
95
- 'rhs_type' => 'field', 'raw_rhs_value' => bar.id, 'rhs_which' => 2,
96
- 'operator' => 'equals'
97
- }]
98
- })
99
- comparison = matcher.comparisons.first
100
-
101
- attribs = {
102
- 'comparisons_attributes' => {
103
- '0' => { 'id' => comparison.id, '_delete' => true },
104
- '1' => {
105
- 'lhs_type' => 'field', 'raw_lhs_value' => bar.id.to_s,
106
- 'rhs_type' => 'field', 'raw_rhs_value' => foo.id.to_s,
107
- 'operator' => 'equals'
108
- }
109
- }
110
- }
111
- put "/projects/#{@project.id}/scenarios/#{@scenario.id}/matchers/#{matcher.id}", :matcher => attribs
112
-
113
- assert last_response.redirect?, "Wasn't redirected"
114
- assert_equal "http://example.org/projects/#{@project.id}/scenarios/#{@scenario.id}", last_response['location']
115
- end
116
-
117
- test "delete" do
118
- field = @resource.fields_dataset[:name => 'foo']
119
- matcher = Matcher.create!({
120
- :scenario => @scenario,
121
- :comparisons_attributes => [{
122
- 'lhs_type' => 'field', 'raw_lhs_value' => field.id, 'lhs_which' => 1,
123
- 'rhs_type' => 'field', 'raw_rhs_value' => field.id, 'rhs_which' => 2,
124
- 'operator' => 'equals'
125
- }]
126
- })
127
- delete "/projects/#{@project.id}/scenarios/#{@scenario.id}/matchers/#{matcher.id}"
128
- assert_equal 0, Models::Matcher.filter(:id => matcher.id).count
129
-
130
- assert last_response.redirect?, "Wasn't redirected"
131
- assert_equal "http://example.org/projects/#{@project.id}/scenarios/#{@scenario.id}", last_response['location']
132
- end
133
- end
134
- end
@@ -1,82 +0,0 @@
1
- require 'helper'
2
-
3
- module TestExtensions
4
- class TestProjects < Coupler::Test::IntegrationTest
5
- test "projects" do
6
- get "/projects"
7
- assert last_response.ok?
8
- end
9
-
10
- test "new project" do
11
- get "/projects/new"
12
- assert last_response.ok?
13
-
14
- doc = Nokogiri::HTML(last_response.body)
15
- assert_equal 1, doc.css('form[action="/projects"]').length
16
- %w{name description}.each do |name|
17
- assert_equal 1, doc.css("input[name='project[#{name}]']").length
18
- end
19
- end
20
-
21
- test "create project" do
22
- post "/projects", {
23
- 'project' => {
24
- 'name' => 'foo', 'description' => 'foo bar',
25
- }
26
- }
27
- assert_equal 1, Project.count
28
- assert last_response.redirect?, "Wasn't redirected"
29
- follow_redirect!
30
-
31
- project = Project.first
32
- assert_equal "http://example.org/projects/#{project.id}", last_request.url
33
- assert_match /Project successfully created/, last_response.body
34
- end
35
-
36
- test "show project" do
37
- project = Project.create(:name => 'foo')
38
- get "/projects/#{project.id}"
39
- assert last_response.ok?
40
- assert_match /foo/, last_response.body
41
- end
42
-
43
- test "showing invalid project when projects exist" do
44
- project = Project.create(:name => 'foo')
45
- get "/projects/8675309"
46
- assert last_response.redirect?
47
- assert_equal "http://example.org/projects", last_response['location']
48
- follow_redirect!
49
- assert_match /The project you were looking for doesn't exist/, last_response.body
50
- end
51
-
52
- test "edit project" do
53
- project = Project.create(:name => 'foo')
54
- get "/projects/#{project.id}/edit"
55
- assert last_response.ok?
56
- end
57
-
58
- test "update project" do
59
- project = Project.create(:name => 'foo')
60
- put "/projects/#{project.id}", :project => {:name => "Hee haw"}
61
- assert last_response.redirect?
62
- assert_equal "http://example.org/projects", last_response['location']
63
- end
64
-
65
- test "delete" do
66
- project = Project.create(:name => 'foo')
67
- delete "/projects/#{project.id}"
68
- assert_nil Project[:id => project.id]
69
- assert last_response.redirect?
70
- assert_equal "http://example.org/projects", last_response['location']
71
- end
72
-
73
- test "delete with versions" do
74
- project = Project.create(:name => 'foo')
75
- delete "/projects/#{project.id}", :nuke => "true"
76
- assert_nil Project[:id => project.id]
77
- assert_nil Database.instance[:projects_versions][:current_id => project.id]
78
- assert last_response.redirect?
79
- assert_equal "http://example.org/projects", last_response['location']
80
- end
81
- end
82
- end
@@ -1,150 +0,0 @@
1
- require 'helper'
2
-
3
- module TestExtensions
4
- class TestResources < Coupler::Test::IntegrationTest
5
- def self.startup
6
- super
7
- conn = new_connection('h2', :name => 'foo')
8
- conn.database do |db|
9
- db.create_table!(:foo) do
10
- primary_key :id
11
- String :foo
12
- String :bar
13
- end
14
- db[:foo].insert({:foo => 'foo', :bar => 'bar'})
15
- db[:foo].insert({:foo => 'bar', :bar => 'foo'})
16
-
17
- db.create_table!(:bar) do
18
- primary_key :id
19
- String :baz
20
- String :quux
21
- end
22
- end
23
- end
24
-
25
- def setup
26
- super
27
- stamp = Time.now - 50
28
- @project = Project.create(:name => 'foo', :created_at => stamp)
29
- @connection = new_connection('h2', :name => 'h2 connection', :created_at => stamp).save!
30
- end
31
-
32
- test "index" do
33
- resource = Resource.create(:name => 'foo', :project => @project, :connection => @connection, :table_name => 'foo')
34
- get "/projects/#{@project.id}/resources"
35
- assert last_response.ok?
36
- assert @project.reload.last_accessed_at
37
- end
38
-
39
- test "index with non existant project" do
40
- get "/projects/8675309/resources"
41
- assert last_response.redirect?
42
- assert_equal "http://example.org/projects", last_response['location']
43
- follow_redirect!
44
- assert_match /The project you were looking for doesn't exist/, last_response.body
45
- end
46
-
47
- test "new resource" do
48
- get "/projects/#{@project.id}/resources/new"
49
- assert last_response.ok?
50
-
51
- doc = Nokogiri::HTML(last_response.body)
52
- assert_equal 1, doc.css("form[action='/projects/#{@project.id}/resources']").length
53
- %w{name table_name}.each do |name|
54
- assert_equal 1, doc.css("input[name='resource[#{name}]']").length
55
- end
56
- end
57
-
58
- test "successfully creating resource" do
59
- attribs = {
60
- 'connection_id' => @connection.id.to_s,
61
- 'name' => 'bar',
62
- 'table_name' => 'bar'
63
- }
64
- post "/projects/#{@project.id}/resources", { 'resource' => attribs }
65
- resource = Resource[:name => 'bar', :project_id => @project.id]
66
- assert resource
67
-
68
- assert last_response.redirect?, "Wasn't redirected"
69
- assert_equal "http://example.org/projects/#{@project.id}/resources/#{resource.id}/edit", last_response['location']
70
- end
71
-
72
- test "failing to create resource" do
73
- attribs = {
74
- 'connection_id' => @connection.id.to_s,
75
- 'name' => '',
76
- 'table_name' => 'bar'
77
- }
78
- post "/projects/#{@project.id}/resources", { 'resource' => attribs }
79
- assert last_response.ok?
80
- assert_match /Name is not present/, last_response.body
81
- end
82
-
83
- test "show resource" do
84
- resource = Resource.create!(:name => 'foo', :project => @project, :connection => @connection, :table_name => 'foo')
85
- field = resource.fields_dataset[:name => 'foo']
86
- transformer = Transformer.create!(:name => 'noop', :code => 'value', :allowed_types => %w{string}, :result_type => 'same')
87
- transformation = Transformation.create!(:resource => resource, :transformer => transformer, :source_field => field)
88
-
89
- get "/projects/#{@project[:id]}/resources/#{resource.id}"
90
- assert last_response.ok?
91
-
92
- doc = Nokogiri::HTML(last_response.body)
93
- tables = doc.css('table')
94
-
95
- # resource table
96
- rows = tables[0].css('tbody tr')
97
- assert_equal 3, rows.length
98
- rows.each_with_index do |row, i|
99
- cells = row.css('td')
100
- assert_equal %w{id foo bar}[i], cells[0].inner_html
101
- end
102
- end
103
-
104
- test "schedule transform job" do
105
- resource = Resource.create!(:name => 'foo', :project => @project, :connection => @connection, :table_name => 'foo')
106
- get "/projects/#{@project[:id]}/resources/#{resource[:id]}/transform"
107
- assert last_response.redirect?, "Wasn't redirected"
108
- assert_equal "http://example.org/projects/#{@project[:id]}/resources/#{resource[:id]}", last_response['location']
109
- assert Job.filter(:name => 'transform', :resource_id => resource.id, :status => 'scheduled').count == 1
110
- end
111
-
112
- #def test_progress
113
- #resource = Factory(:resource, :project => @project, :completed => 100, :total => 1000)
114
- #get "/projects/#{@project.id}/resources/#{resource.id}/progress"
115
- #assert last_response.ok?
116
- #assert_equal "10", last_response.body
117
- #end
118
-
119
- test "edit" do
120
- resource = Resource.create!(:name => 'foo', :project => @project, :connection => @connection, :table_name => 'foo')
121
- get "/projects/#{@project[:id]}/resources/#{resource.id}/edit"
122
- assert last_response.ok?
123
- end
124
-
125
- test "update" do
126
- resource = Resource.create!(:name => 'foo', :project => @project, :connection => @connection, :table_name => 'foo')
127
- field = resource.fields_dataset[:name => 'foo']
128
- put "/projects/#{@project[:id]}/resources/#{resource.id}", :resource => {
129
- :fields_attributes => [{'id' => field.id, 'is_selected' => 0}]
130
- }
131
- assert last_response.redirect?
132
- end
133
-
134
- test "update with no attributes" do
135
- resource = Resource.create!(:name => 'foo', :project => @project, :connection => @connection, :table_name => 'foo')
136
- put "/projects/#{@project[:id]}/resources/#{resource.id}"
137
- assert last_response.redirect?
138
- end
139
-
140
- #def test_delete
141
- #pend
142
- #end
143
-
144
- test "record" do
145
- resource = Resource.create!(:name => 'foo', :project => @project, :connection => @connection, :table_name => 'foo')
146
- get "/projects/#{@project.id}/resources/#{resource.id}/record/1"
147
- assert last_response.ok?
148
- end
149
- end
150
- end
@@ -1,88 +0,0 @@
1
- require 'helper'
2
-
3
- module TestExtensions
4
- class TestScenarios < Coupler::Test::IntegrationTest
5
- def self.startup
6
- super
7
- conn = new_connection('h2', :name => 'foo')
8
- conn.database do |db|
9
- db.create_table!(:foo) do
10
- primary_key :id
11
- String :foo
12
- String :bar
13
- end
14
- db[:foo].insert({:foo => 'foo', :bar => 'bar'})
15
- db[:foo].insert({:foo => 'bar', :bar => 'foo'})
16
- end
17
- end
18
-
19
- def setup
20
- super
21
- @project = Project.create(:name => 'foo')
22
- @connection = new_connection('h2', :name => 'h2 connection').save!
23
- @resource = Resource.create(:name => 'foo', :project => @project, :connection => @connection, :table_name => 'foo')
24
- end
25
-
26
- test "index" do
27
- scenario = Scenario.create(:name => 'foo', :resource_1 => @resource, :project => @project)
28
- get "/projects/#{@project.id}/scenarios"
29
- assert last_response.ok?
30
- end
31
-
32
- test "index of non existant project" do
33
- get "/projects/8675309/scenarios"
34
- assert last_response.redirect?
35
- assert_equal "http://example.org/projects", last_response['location']
36
- follow_redirect!
37
- assert_match /The project you were looking for doesn't exist/, last_response.body
38
- end
39
-
40
- test "show" do
41
- scenario = Scenario.create(:name => 'foo', :resource_1 => @resource, :project => @project)
42
- get "/projects/#{@project.id}/scenarios/#{scenario.id}"
43
- assert last_response.ok?
44
- end
45
-
46
- test "new" do
47
- get "/projects/#{@project.id}/scenarios/new"
48
- assert last_response.ok?
49
- end
50
-
51
- test "successfully creating scenario" do
52
- attribs = {
53
- 'name' => 'foo',
54
- 'resource_ids' => [@resource.id.to_s]
55
- }
56
- post "/projects/#{@project.id}/scenarios", { 'scenario' => attribs }
57
- scenario = Scenario[:name => 'foo', :project_id => @project.id]
58
- assert scenario
59
- assert_equal [@resource], scenario.resources
60
-
61
- assert last_response.redirect?, "Wasn't redirected"
62
- assert_equal "http://example.org/projects/#{@project.id}/scenarios/#{scenario.id}", last_response['location']
63
- end
64
-
65
- test "failing to create scenario" do
66
- post "/projects/#{@project.id}/scenarios", {
67
- 'scenario' => { 'name' => nil, 'resource_ids' => [@resource.id.to_s] }
68
- }
69
- assert last_response.ok?
70
- assert_match /Name is not present/, last_response.body
71
- end
72
-
73
- test "run scenario" do
74
- scenario = Scenario.create(:name => 'foo', :resource_1 => @resource, :project => @project)
75
- get "/projects/#{@project.id}/scenarios/#{scenario.id}/run"
76
- assert last_response.redirect?, "Wasn't redirected"
77
- assert_equal "http://example.org/projects/#{@project[:id]}/scenarios/#{scenario[:id]}", last_response['location']
78
- assert Job.filter(:name => 'run_scenario', :scenario_id => scenario.id, :status => 'scheduled').count == 1
79
- end
80
-
81
- #def test_progress
82
- #scenario = Factory(:scenario, :project => @project, :completed => 100, :total => 1000)
83
- #get "/projects/#{@project.id}/scenarios/#{scenario.id}/progress"
84
- #assert last_response.ok?
85
- #assert_equal "10", last_response.body
86
- #end
87
- end
88
- end