leap_salesforce 1.4.0 → 1.4.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ChangeLog +7 -0
- data/README.md +2 -1
- data/exe/leap_salesforce +14 -6
- data/lib/leap_salesforce/auth.rb +2 -0
- data/lib/leap_salesforce/generator/soql_objects.rb +15 -13
- data/lib/leap_salesforce/generator/templates/soql_object_field_names.Java.erb +5 -2
- data/lib/leap_salesforce/leaps.rb +0 -1
- data/lib/leap_salesforce/parameters.rb +3 -3
- data/lib/leap_salesforce/session.rb +3 -2
- data/lib/leap_salesforce/soql_data/soql.rb +6 -6
- data/lib/leap_salesforce/soql_data/soql_data.rb +1 -1
- data/lib/leap_salesforce/version.rb +1 -1
- data/lib/leap_salesforce.rb +0 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 727cda791511d2d4114ed478b5686cdcdf194d57d38b43258180f1e9edf2dda8
|
4
|
+
data.tar.gz: 3ee6582c6ec6365ea2e64fb1fe8368047171414086c2278689e0bd3c7de7f274
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7382790fba0ca2416cd50d4a547c46572e16ac575b9e989b27dbbf921e8074507b8627db3daf0acbdb60533c02a65aaeeac35ed4475ad64c166ac1ee263f1b86
|
7
|
+
data.tar.gz: 431a449bec6a0989ec7188b2dbd2a24fbe5d806b941c5b62dad86c1db027f559d8397545d17f3765d190ffe56ccab91a7f1b1cbd31d2769ac6fddbb5a704e476
|
data/ChangeLog
CHANGED
@@ -1,3 +1,10 @@
|
|
1
|
+
Version 1.4.2
|
2
|
+
* Fixed leap_salesforce version method
|
3
|
+
|
4
|
+
Version 1.4.1
|
5
|
+
* Fixed method names that need to match types
|
6
|
+
* Fixed file name created. Needs to be with '.java' in lower case
|
7
|
+
|
1
8
|
Version 1.4
|
2
9
|
* Ability to generate Java classes from metadata using the exe 'leap_salesforce create_soql_objects --language=java'
|
3
10
|
|
data/README.md
CHANGED
@@ -3,7 +3,8 @@
|
|
3
3
|
Welcome to LeapSalesforce gem. This gem helps ones to perform integration tests on Salesforce. It reads the Metadata
|
4
4
|
from Salesforce and creates the foundation for API tests.
|
5
5
|
|
6
|
-
Support for UI testing is being worked on in another gem [leap_salesforce_ui](https://gitlab.com/leap-dojo/leap_salesforce_ui)
|
6
|
+
Support for UI testing is being worked on in another gem [leap_salesforce_ui](https://gitlab.com/leap-dojo/leap_salesforce_ui).
|
7
|
+
An example using this and the learnings it involved are in a Java Project [Leap Salesforce Java](https://gitlab.com/leap-dojo/leap_salesforce_java)
|
7
8
|
|
8
9
|
## Is this for you?
|
9
10
|
|
data/exe/leap_salesforce
CHANGED
@@ -4,11 +4,10 @@
|
|
4
4
|
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..', 'lib')
|
5
5
|
|
6
6
|
require 'thor'
|
7
|
-
require '
|
8
|
-
Dotenv.load
|
7
|
+
require 'leap_salesforce/error'
|
9
8
|
require 'leap_salesforce/parameters'
|
10
9
|
require 'leap_salesforce/generator/generator'
|
11
|
-
require 'leap_salesforce/
|
10
|
+
require 'leap_salesforce/version'
|
12
11
|
require 'colorize'
|
13
12
|
|
14
13
|
module LeapSalesforce
|
@@ -62,15 +61,24 @@ Please ignore "config/credentials/" and "logs/"'.colorize :red
|
|
62
61
|
end
|
63
62
|
|
64
63
|
desc 'create_soql_objects', 'Creates SOQL objects from metadata based on .leap_salesforce.yml'
|
65
|
-
option :language
|
64
|
+
option :language
|
66
65
|
def create_soql_objects
|
67
|
-
LeapSalesforce.language = options[:language]
|
68
|
-
require 'leap_salesforce/generator/soql_objects'
|
66
|
+
LeapSalesforce.language = options[:language] if options[:language]
|
67
|
+
require 'leap_salesforce/generator/soql_objects'
|
69
68
|
LeapSalesforce.oauth_working?
|
70
69
|
LeapSalesforce::Users.execute_as_if_present key: :admin do
|
71
70
|
LeapSalesforce::Generator::SoqlObjects.new.create_all
|
72
71
|
end
|
73
72
|
end
|
73
|
+
|
74
|
+
desc 'version', 'Version this library'
|
75
|
+
def version
|
76
|
+
puts LeapSalesforce::VERSION
|
77
|
+
end
|
78
|
+
|
79
|
+
def self.exit_on_failure?
|
80
|
+
true
|
81
|
+
end
|
74
82
|
end
|
75
83
|
end
|
76
84
|
|
data/lib/leap_salesforce/auth.rb
CHANGED
@@ -12,7 +12,7 @@ module LeapSalesforce
|
|
12
12
|
class SoqlObjects
|
13
13
|
include Generator
|
14
14
|
|
15
|
-
SOQL_DATA_FOLDER = LeapSalesforce.language ==
|
15
|
+
SOQL_DATA_FOLDER = LeapSalesforce.language == 'java' ? 'SoqlObjects' : 'soql_data'
|
16
16
|
SOQL_OBJECT_FOLDER = File.join(LeapSalesforce.lib_folder, SOQL_DATA_FOLDER).freeze
|
17
17
|
FACTORY_FOLDER = File.join(LeapSalesforce.lib_folder, 'factories').freeze
|
18
18
|
|
@@ -32,7 +32,8 @@ module LeapSalesforce
|
|
32
32
|
raise LeapSalesforce::SetupError, "Error producing Soql data for '#{@soql_class}', soql table " \
|
33
33
|
" '#{@soql_object.backend_name}'. Error message: '#{desc.error_message}'"
|
34
34
|
end
|
35
|
-
return unless LeapSalesforce.language ==
|
35
|
+
return unless LeapSalesforce.language == 'ruby'
|
36
|
+
|
36
37
|
content = read_template 'soql_object.rb.erb', binding
|
37
38
|
file = File.join(SOQL_OBJECT_FOLDER, "#{@soql_object.reference}.rb")
|
38
39
|
generate_file file, content, overwrite: false
|
@@ -40,21 +41,22 @@ module LeapSalesforce
|
|
40
41
|
|
41
42
|
# Generate module with fields for Soql Object
|
42
43
|
def generate_field_module
|
43
|
-
if LeapSalesforce.language ==
|
44
|
+
if LeapSalesforce.language == 'ruby'
|
44
45
|
field_content = read_template 'soql_object_field_names.rb.erb', binding
|
45
46
|
field_file = File.join(SOQL_OBJECT_FOLDER, "#{@field_name_file}.rb")
|
46
|
-
elsif LeapSalesforce.language ==
|
47
|
-
field_content = read_template 'soql_object_field_names.
|
48
|
-
field_file = File.join(SOQL_OBJECT_FOLDER, "#{@soql_object.class_name}.
|
47
|
+
elsif LeapSalesforce.language == 'java'
|
48
|
+
field_content = read_template 'soql_object_field_names.java.erb', binding
|
49
|
+
field_file = File.join(SOQL_OBJECT_FOLDER, "#{@soql_object.class_name}.java")
|
49
50
|
else
|
50
51
|
raise LeapSalesforce::SetupError, "Unsupported language '#{LeapSalesforce.language}'"
|
51
|
-
end
|
52
|
-
generate_file field_file, field_content
|
52
|
+
end
|
53
|
+
generate_file field_file, field_content
|
53
54
|
end
|
54
55
|
|
55
56
|
# Generate factory for mass generating objects using FactoryBot
|
56
57
|
def generate_factory
|
57
|
-
return unless LeapSalesforce.language ==
|
58
|
+
return unless LeapSalesforce.language == 'ruby'
|
59
|
+
|
58
60
|
@default_fields, @other_fields = filter_fields
|
59
61
|
content = read_template 'factory.rb.erb', binding
|
60
62
|
file = File.join(FACTORY_FOLDER, "#{@soql_object.reference}.rb")
|
@@ -72,10 +74,10 @@ module LeapSalesforce
|
|
72
74
|
generate_field_module
|
73
75
|
generate_factory
|
74
76
|
end
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
77
|
+
return unless LeapSalesforce.language == 'ruby'
|
78
|
+
|
79
|
+
`rubocop -A #{SOQL_OBJECT_FOLDER} --enable-pending-cops`
|
80
|
+
`rubocop -A #{FACTORY_FOLDER} --enable-pending-cops`
|
79
81
|
end
|
80
82
|
|
81
83
|
private
|
@@ -15,8 +15,11 @@ public class <%= @soql_object.class_name %> {
|
|
15
15
|
<% end %>
|
16
16
|
|
17
17
|
<% @soql_class.fields.each do |field| %>
|
18
|
-
public String get<%= field['
|
19
|
-
|
18
|
+
public String get<%= field['name'].camelize(:upper) %>() { return <%= field['name'].camelize(:lower) %>; }
|
19
|
+
/**
|
20
|
+
* Label: '<%= field['label'] %>', Type: <%= field['type'] %><%= ", Relationship:" + field['relationshipName'] if field['relationshipName'] %>
|
21
|
+
*/
|
22
|
+
public void set<%= field['name'].camelize(:upper) %>(String <%= field['name'].camelize(:lower) %>) { this.<%= field['name'].camelize(:lower) %> = <%= field['name'].camelize(:lower) %>; }
|
20
23
|
<% end %>
|
21
24
|
}
|
22
25
|
|
@@ -16,8 +16,8 @@ module LeapSalesforce
|
|
16
16
|
@client_id = ENV['client_id']
|
17
17
|
@client_secret = ENV['client_secret']
|
18
18
|
@password = ENV['password']
|
19
|
-
@language =
|
20
|
-
@soql_field_start_text =
|
19
|
+
@language = 'ruby'
|
20
|
+
@soql_field_start_text = ''
|
21
21
|
@environment = nil
|
22
22
|
@logger = Logger.new $stdout
|
23
23
|
@sfdx = false
|
@@ -135,7 +135,7 @@ module LeapSalesforce
|
|
135
135
|
# @return [Symbol] Name of the language used
|
136
136
|
attr_accessor :language
|
137
137
|
|
138
|
-
# @return [String] Text to be added as start of auto generated Soql field names
|
138
|
+
# @return [String] Text to be added as start of auto generated Soql field names
|
139
139
|
# classes in the Salesforce object
|
140
140
|
attr_accessor :soql_field_start_text
|
141
141
|
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require_relative 'auth'
|
2
4
|
require 'savon'
|
3
5
|
require 'json'
|
@@ -21,12 +23,11 @@ module LeapSalesforce
|
|
21
23
|
end
|
22
24
|
|
23
25
|
class << self
|
24
|
-
|
25
26
|
# Login via SOAP API
|
26
27
|
def soap_login(username, password, security_token)
|
27
28
|
client = Savon.client do
|
28
29
|
endpoint "#{SoqlHandler.instance_url}/services/Soap/u/51.0"
|
29
|
-
namespace
|
30
|
+
namespace 'urn:partner.soap.sforce.com'
|
30
31
|
log true # See request and response. (Put this in traffic file)
|
31
32
|
log_level :debug
|
32
33
|
logger Soaspec::SpecLogger.create
|
@@ -120,7 +120,7 @@ module LeapSalesforce
|
|
120
120
|
value = value.nil? ? 'null' : value.to_s
|
121
121
|
operator, value = case value[0]
|
122
122
|
when '>', '<', '!', 'I' then extract_comparator(value)
|
123
|
-
when '~' then ['LIKE', value[1
|
123
|
+
when '~' then ['LIKE', value[1..]]
|
124
124
|
else ['=', value]
|
125
125
|
end
|
126
126
|
case soql_table.type_for(field_name)
|
@@ -142,18 +142,18 @@ module LeapSalesforce
|
|
142
142
|
# @return [Array] Extract of operator, value, taking >, >, >= from string and rest of string
|
143
143
|
def extract_comparator(value)
|
144
144
|
if value[1] == '='
|
145
|
-
[value[0..1], value[2
|
145
|
+
[value[0..1], value[2..]]
|
146
146
|
elsif value[0..2] == '!IN'
|
147
|
-
['NOT IN', value[3
|
147
|
+
['NOT IN', value[3..].to_soql_array]
|
148
148
|
elsif value[0..1] == 'IN'
|
149
|
-
['IN', value[2
|
149
|
+
['IN', value[2..].to_soql_array]
|
150
150
|
elsif value[0] == 'I' # 'N' not 2nd character
|
151
151
|
['=', value]
|
152
152
|
elsif value[0] == '!'
|
153
|
-
remaining = value[1
|
153
|
+
remaining = value[1..] == 'nil' ? 'null' : value[1..]
|
154
154
|
['!=', remaining]
|
155
155
|
else
|
156
|
-
[value[0], value[1
|
156
|
+
[value[0], value[1..]]
|
157
157
|
end
|
158
158
|
end
|
159
159
|
end
|
@@ -49,7 +49,7 @@ class SoqlData < Exchange
|
|
49
49
|
if @override_parameters && @override_parameters[:suburl]
|
50
50
|
suburl_passed = @override_parameters[:suburl]
|
51
51
|
@override_parameters[:suburl] = if suburl_passed.include?('sobjects')
|
52
|
-
suburl_passed[suburl_passed.index('sobjects')
|
52
|
+
suburl_passed[suburl_passed.index('sobjects')..]
|
53
53
|
else
|
54
54
|
suburl_passed
|
55
55
|
end
|
data/lib/leap_salesforce.rb
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'leap_salesforce/version'
|
4
|
-
|
5
4
|
require 'facets/string/snakecase'
|
6
5
|
require 'soaspec'
|
7
6
|
Soaspec::OAuth2.refresh_token = :once # Save access token and reuse it
|
@@ -21,8 +20,6 @@ require 'faker' # For fake data
|
|
21
20
|
require 'leap_salesforce/error'
|
22
21
|
require 'leap_salesforce/loader'
|
23
22
|
require 'leap_salesforce/session'
|
24
|
-
require 'dotenv'
|
25
|
-
Dotenv.load
|
26
23
|
|
27
24
|
# If variable is present within LeapSalesforce set it
|
28
25
|
def load_variables_from(file)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: leap_salesforce
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.4.
|
4
|
+
version: 1.4.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- IQA
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date: 2024-09-
|
12
|
+
date: 2024-09-29 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|