salesforcebulk 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (46) hide show
  1. data/.gitignore +4 -0
  2. data/.rbenv-version +1 -0
  3. data/Gemfile +2 -0
  4. data/README.md +143 -0
  5. data/Rakefile +22 -0
  6. data/lib/salesforce_bulk.rb +15 -0
  7. data/lib/salesforce_bulk/batch.rb +50 -0
  8. data/lib/salesforce_bulk/batch_result.rb +39 -0
  9. data/lib/salesforce_bulk/batch_result_collection.rb +29 -0
  10. data/lib/salesforce_bulk/client.rb +254 -0
  11. data/lib/salesforce_bulk/core_extensions/string.rb +14 -0
  12. data/lib/salesforce_bulk/job.rb +70 -0
  13. data/lib/salesforce_bulk/query_result_collection.rb +48 -0
  14. data/lib/salesforce_bulk/salesforce_error.rb +30 -0
  15. data/lib/salesforce_bulk/version.rb +3 -0
  16. data/salesforcebulk.gemspec +28 -0
  17. data/test/fixtures/batch_create_request.csv +3 -0
  18. data/test/fixtures/batch_create_response.xml +13 -0
  19. data/test/fixtures/batch_info_list_response.xml +27 -0
  20. data/test/fixtures/batch_info_response.xml +13 -0
  21. data/test/fixtures/batch_result_list_response.csv +3 -0
  22. data/test/fixtures/config.yml +7 -0
  23. data/test/fixtures/invalid_batch_error.xml +5 -0
  24. data/test/fixtures/invalid_error.xml +5 -0
  25. data/test/fixtures/invalid_job_error.xml +5 -0
  26. data/test/fixtures/invalid_session_error.xml +5 -0
  27. data/test/fixtures/job_abort_request.xml +1 -0
  28. data/test/fixtures/job_abort_response.xml +25 -0
  29. data/test/fixtures/job_close_request.xml +1 -0
  30. data/test/fixtures/job_close_response.xml +25 -0
  31. data/test/fixtures/job_create_request.xml +1 -0
  32. data/test/fixtures/job_create_response.xml +25 -0
  33. data/test/fixtures/job_info_response.xml +25 -0
  34. data/test/fixtures/login_error.xml +1 -0
  35. data/test/fixtures/login_request.xml +1 -0
  36. data/test/fixtures/login_response.xml +39 -0
  37. data/test/fixtures/query_result_list_response.xml +1 -0
  38. data/test/fixtures/query_result_response.csv +5 -0
  39. data/test/lib/test_batch.rb +258 -0
  40. data/test/lib/test_batch_result.rb +40 -0
  41. data/test/lib/test_core_extensions.rb +15 -0
  42. data/test/lib/test_initialization.rb +86 -0
  43. data/test/lib/test_job.rb +256 -0
  44. data/test/lib/test_query_result_collection.rb +87 -0
  45. data/test/test_helper.rb +32 -0
  46. metadata +222 -0
@@ -0,0 +1,87 @@
1
+ require 'test_helper'
2
+
3
+ class TestQueryResultCollection < Test::Unit::TestCase
4
+
5
+ def setup
6
+ options = {
7
+ :username => 'myusername',
8
+ :password => 'mypassword',
9
+ :token => "somelongtoken"
10
+ }
11
+
12
+ @client = SalesforceBulk::Client.new(options)
13
+ @job_id = "123"
14
+ @batch_id = "234"
15
+ @result_ids = ["12","23","34"]
16
+ @result_id = @result_ids[1]
17
+ @collection = SalesforceBulk::QueryResultCollection.new(@client, @job_id, @batch_id, @result_id, @result_ids)
18
+ end
19
+
20
+ test "initilize using defaults" do
21
+ collection = SalesforceBulk::QueryResultCollection.new(@client, @job_id, @batch_id)
22
+
23
+ assert_equal collection.client, @client
24
+ assert_equal collection.job_id, @job_id
25
+ assert_equal collection.batch_id, @batch_id
26
+ assert_nil collection.result_id
27
+ assert_equal collection.result_ids, []
28
+ assert_equal collection.instance_variable_get('@current_index'), 0
29
+ end
30
+
31
+ test "initilize with all values" do
32
+ assert_equal @collection.client, @client
33
+ assert_equal @collection.job_id, @job_id
34
+ assert_equal @collection.batch_id, @batch_id
35
+ assert_equal @collection.result_id, @result_id
36
+ assert_equal @collection.result_ids, @result_ids
37
+ end
38
+
39
+ test "next?" do
40
+ assert @collection.next?
41
+
42
+ @collection.instance_variable_set('@current_index', @result_ids.length - 1)
43
+ assert !@collection.next?
44
+
45
+ @collection.instance_variable_set('@result_ids', [])
46
+ assert !@collection.next?
47
+
48
+ @collection.instance_variable_set('@result_ids', nil)
49
+ assert !@collection.next?
50
+ end
51
+
52
+ test "next" do
53
+ @client.expects(:query_result).once.with(@job_id, @batch_id, @result_ids.last).returns([])
54
+
55
+ @collection.next
56
+
57
+ assert_kind_of SalesforceBulk::QueryResultCollection, @collection
58
+ assert @collection.previous?
59
+ assert !@collection.next?
60
+ assert !@collection.next.any?
61
+ end
62
+
63
+ test "previous?" do
64
+ assert @collection.previous?
65
+
66
+ @collection.instance_variable_set('@current_index', 0)
67
+ assert !@collection.previous?
68
+
69
+ @collection.instance_variable_set('@result_ids', [])
70
+ assert !@collection.previous?
71
+
72
+ @collection.instance_variable_set('@result_ids', nil)
73
+ assert !@collection.previous?
74
+ end
75
+
76
+ test "previous" do
77
+ @client.expects(:query_result).once.with(@job_id, @batch_id, @result_ids.first).returns([])
78
+
79
+ @collection.previous
80
+
81
+ assert_kind_of SalesforceBulk::QueryResultCollection, @collection
82
+ assert @collection.next?
83
+ assert !@collection.previous?
84
+ assert !@collection.previous.any?
85
+ end
86
+
87
+ end
@@ -0,0 +1,32 @@
1
+ require 'rubygems'
2
+ require 'test/unit'
3
+ require 'shoulda'
4
+ require 'mocha'
5
+ require 'webmock/test_unit'
6
+ require 'salesforce_bulk'
7
+
8
+ class Test::Unit::TestCase
9
+
10
+ def self.test(name, &block)
11
+ define_method("test #{name.inspect}", &block)
12
+ end
13
+
14
+ def api_url(client)
15
+ "https://#{client.host}/services/async/#{client.version}/"
16
+ end
17
+
18
+ def bypass_authentication(client)
19
+ client.instance_variable_set('@session_id', '123456789')
20
+ client.instance_variable_set('@host', 'na9.salesforce.com')
21
+ client.instance_variable_set('@instance_host', 'na9.salesforce.com')
22
+ end
23
+
24
+ def fixture_path(file)
25
+ File.expand_path("../fixtures/#{file}", __FILE__)
26
+ end
27
+
28
+ def fixture(file)
29
+ File.new(fixture_path(file)).read
30
+ end
31
+
32
+ end
metadata ADDED
@@ -0,0 +1,222 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: salesforcebulk
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Javier Julio
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-08-17 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: active_support
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: xml-simple
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :runtime
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ - !ruby/object:Gem::Dependency
47
+ name: mocha
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ - !ruby/object:Gem::Dependency
63
+ name: rake
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ type: :development
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ - !ruby/object:Gem::Dependency
79
+ name: shoulda
80
+ requirement: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ! '>='
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
86
+ type: :development
87
+ prerelease: false
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ! '>='
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
94
+ - !ruby/object:Gem::Dependency
95
+ name: webmock
96
+ requirement: !ruby/object:Gem::Requirement
97
+ none: false
98
+ requirements:
99
+ - - ! '>='
100
+ - !ruby/object:Gem::Version
101
+ version: '0'
102
+ type: :development
103
+ prerelease: false
104
+ version_requirements: !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ! '>='
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
110
+ description: This gem is a simple interface to the Salesforce Bulk API providing support
111
+ for insert, update, upsert, delete, and query.
112
+ email:
113
+ - jjfutbol@gmail.com
114
+ executables: []
115
+ extensions: []
116
+ extra_rdoc_files: []
117
+ files:
118
+ - .gitignore
119
+ - .rbenv-version
120
+ - Gemfile
121
+ - README.md
122
+ - Rakefile
123
+ - lib/salesforce_bulk.rb
124
+ - lib/salesforce_bulk/batch.rb
125
+ - lib/salesforce_bulk/batch_result.rb
126
+ - lib/salesforce_bulk/batch_result_collection.rb
127
+ - lib/salesforce_bulk/client.rb
128
+ - lib/salesforce_bulk/core_extensions/string.rb
129
+ - lib/salesforce_bulk/job.rb
130
+ - lib/salesforce_bulk/query_result_collection.rb
131
+ - lib/salesforce_bulk/salesforce_error.rb
132
+ - lib/salesforce_bulk/version.rb
133
+ - salesforcebulk.gemspec
134
+ - test/fixtures/batch_create_request.csv
135
+ - test/fixtures/batch_create_response.xml
136
+ - test/fixtures/batch_info_list_response.xml
137
+ - test/fixtures/batch_info_response.xml
138
+ - test/fixtures/batch_result_list_response.csv
139
+ - test/fixtures/config.yml
140
+ - test/fixtures/invalid_batch_error.xml
141
+ - test/fixtures/invalid_error.xml
142
+ - test/fixtures/invalid_job_error.xml
143
+ - test/fixtures/invalid_session_error.xml
144
+ - test/fixtures/job_abort_request.xml
145
+ - test/fixtures/job_abort_response.xml
146
+ - test/fixtures/job_close_request.xml
147
+ - test/fixtures/job_close_response.xml
148
+ - test/fixtures/job_create_request.xml
149
+ - test/fixtures/job_create_response.xml
150
+ - test/fixtures/job_info_response.xml
151
+ - test/fixtures/login_error.xml
152
+ - test/fixtures/login_request.xml
153
+ - test/fixtures/login_response.xml
154
+ - test/fixtures/query_result_list_response.xml
155
+ - test/fixtures/query_result_response.csv
156
+ - test/lib/test_batch.rb
157
+ - test/lib/test_batch_result.rb
158
+ - test/lib/test_core_extensions.rb
159
+ - test/lib/test_initialization.rb
160
+ - test/lib/test_job.rb
161
+ - test/lib/test_query_result_collection.rb
162
+ - test/test_helper.rb
163
+ homepage: https://github.com/javierjulio/salesforce_bulk
164
+ licenses: []
165
+ post_install_message:
166
+ rdoc_options: []
167
+ require_paths:
168
+ - lib
169
+ required_ruby_version: !ruby/object:Gem::Requirement
170
+ none: false
171
+ requirements:
172
+ - - ! '>='
173
+ - !ruby/object:Gem::Version
174
+ version: '0'
175
+ segments:
176
+ - 0
177
+ hash: -2880599603417728951
178
+ required_rubygems_version: !ruby/object:Gem::Requirement
179
+ none: false
180
+ requirements:
181
+ - - ! '>='
182
+ - !ruby/object:Gem::Version
183
+ version: '0'
184
+ segments:
185
+ - 0
186
+ hash: -2880599603417728951
187
+ requirements: []
188
+ rubyforge_project:
189
+ rubygems_version: 1.8.24
190
+ signing_key:
191
+ specification_version: 3
192
+ summary: Ruby support for the Salesforce Bulk API
193
+ test_files:
194
+ - test/fixtures/batch_create_request.csv
195
+ - test/fixtures/batch_create_response.xml
196
+ - test/fixtures/batch_info_list_response.xml
197
+ - test/fixtures/batch_info_response.xml
198
+ - test/fixtures/batch_result_list_response.csv
199
+ - test/fixtures/config.yml
200
+ - test/fixtures/invalid_batch_error.xml
201
+ - test/fixtures/invalid_error.xml
202
+ - test/fixtures/invalid_job_error.xml
203
+ - test/fixtures/invalid_session_error.xml
204
+ - test/fixtures/job_abort_request.xml
205
+ - test/fixtures/job_abort_response.xml
206
+ - test/fixtures/job_close_request.xml
207
+ - test/fixtures/job_close_response.xml
208
+ - test/fixtures/job_create_request.xml
209
+ - test/fixtures/job_create_response.xml
210
+ - test/fixtures/job_info_response.xml
211
+ - test/fixtures/login_error.xml
212
+ - test/fixtures/login_request.xml
213
+ - test/fixtures/login_response.xml
214
+ - test/fixtures/query_result_list_response.xml
215
+ - test/fixtures/query_result_response.csv
216
+ - test/lib/test_batch.rb
217
+ - test/lib/test_batch_result.rb
218
+ - test/lib/test_core_extensions.rb
219
+ - test/lib/test_initialization.rb
220
+ - test/lib/test_job.rb
221
+ - test/lib/test_query_result_collection.rb
222
+ - test/test_helper.rb