leap_salesforce 1.4.1 → 1.4.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.leap_salesforce.yml +3 -2
- data/ChangeLog +7 -0
- data/README.md +4 -1
- data/exe/leap_salesforce +26 -4
- data/lib/leap_salesforce/auth.rb +2 -0
- data/lib/leap_salesforce/generator/soql_enums.rb +38 -17
- data/lib/leap_salesforce/generator/soql_objects.rb +1 -1
- data/lib/leap_salesforce/generator/templates/picklist.java.erb +23 -0
- data/lib/leap_salesforce/generator/templates/soql_object_field_names.Java.erb +5 -7
- data/lib/leap_salesforce/leaps.rb +0 -1
- data/lib/leap_salesforce/parameters.rb +7 -0
- data/lib/leap_salesforce/version.rb +1 -1
- data/lib/leap_salesforce.rb +0 -3
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 65554ee3c2903f5a1d49f2433d6ae95f89b98acd1d31c110b61f34eba61c2660
|
4
|
+
data.tar.gz: f5bbc9c392441f97bfe3f38046f18c8e27529a8805ebdc6229f4a47a7f755b2d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 30edbcffe1599ee7b1a8ac199e357b7b8143a10d697c623faf492704f5aa8450fd6f81694dd6a4be5ce5c59fa23c20e069fee1bac1a4f1b69c76c6feb93f04c6
|
7
|
+
data.tar.gz: cfa46d6dc2f7e6a50c24fc5bfa1635985d823ea5fe20fb54dc5706d7acf6323fe6333c783b292fa9bd0ff7f7d08a19c9ae942c74bf4bbfe88201a15268ee96c2
|
data/.leap_salesforce.yml
CHANGED
@@ -1,10 +1,11 @@
|
|
1
1
|
environment: prod # This is irrelevant for sfdx auth which uses user/alias
|
2
2
|
lib_folder: spec/support
|
3
|
+
# enum_folder: spec/support/enum
|
3
4
|
sfdx: false
|
4
5
|
# Example of settings for generating Java classes
|
5
6
|
# language: java
|
6
|
-
# soql_field_start_text:
|
7
|
-
#
|
7
|
+
# soql_field_start_text: package com.salesforce.test.pojo.soqlObjects;
|
8
|
+
# soql_enum_start_text: package com.salesforce.test.enums
|
8
9
|
soql_objects:
|
9
10
|
- Case
|
10
11
|
- Contact
|
data/ChangeLog
CHANGED
@@ -1,3 +1,10 @@
|
|
1
|
+
Version 1.4.3
|
2
|
+
* Simplify Java POMO's created using Lombok
|
3
|
+
* Add executable to create enum objects in Java with 'leap_salesforce create_soql_enums' and 'leap_salesforce create_all' that creates both objects and enums
|
4
|
+
|
5
|
+
Version 1.4.2
|
6
|
+
* Fixed leap_salesforce version method
|
7
|
+
|
1
8
|
Version 1.4.1
|
2
9
|
* Fixed method names that need to match types
|
3
10
|
* Fixed file name created. Needs to be with '.java' in lower case
|
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
|
|
@@ -223,6 +224,8 @@ RSpec.describe 'Picklists' do
|
|
223
224
|
end
|
224
225
|
```
|
225
226
|
|
227
|
+
One can also create this using the executable, e.g `leap_salesforce create_soql_enums`.
|
228
|
+
|
226
229
|
#### Changing environment
|
227
230
|
|
228
231
|
The `LEAP_ENV` environment variable can be used to change environment in non sfdx mode. The default is set through
|
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
|
@@ -65,17 +64,40 @@ Please ignore "config/credentials/" and "logs/"'.colorize :red
|
|
65
64
|
option :language
|
66
65
|
def create_soql_objects
|
67
66
|
LeapSalesforce.language = options[:language] if options[:language]
|
68
|
-
require 'leap_salesforce/generator/soql_objects'
|
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
|
74
73
|
|
74
|
+
desc 'create_soql_enums', 'Creates enum objects for SOQL objects from metadata based on .leap_salesforce.yml'
|
75
|
+
option :language
|
76
|
+
def create_soql_enums(check_auth = true)
|
77
|
+
LeapSalesforce.language = options[:language] if options[:language]
|
78
|
+
require 'leap_salesforce/generator/soql_enums'
|
79
|
+
LeapSalesforce::Users.execute_as_if_present key: :admin do
|
80
|
+
LeapSalesforce::Generator::SoqlEnums.new.create
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
desc 'create_all', 'Creates SOQL objects and enum objects from metadata based on .leap_salesforce.yml'
|
85
|
+
option :language
|
86
|
+
def create_all
|
87
|
+
puts 'Creating soql objects'.colorize :yellow
|
88
|
+
create_soql_objects
|
89
|
+
puts 'Creating soql enums'.colorize :yellow
|
90
|
+
create_soql_enums
|
91
|
+
end
|
92
|
+
|
75
93
|
desc 'version', 'Version this library'
|
76
94
|
def version
|
77
95
|
puts LeapSalesforce::VERSION
|
78
96
|
end
|
97
|
+
|
98
|
+
def self.exit_on_failure?
|
99
|
+
true
|
100
|
+
end
|
79
101
|
end
|
80
102
|
end
|
81
103
|
|
data/lib/leap_salesforce/auth.rb
CHANGED
@@ -1,26 +1,31 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require_relative 'soql_objects'
|
4
|
+
require_relative '../soql_data/soql_data'
|
4
5
|
|
5
6
|
module LeapSalesforce
|
6
7
|
# Generators for creating code
|
7
8
|
module Generator
|
8
|
-
# Creates Soql Enumerations / Picklists from objects in LeapSalesforce.
|
9
|
+
# Creates Soql Enumerations / Picklists from objects in LeapSalesforce.soql_objects
|
9
10
|
class SoqlEnums
|
10
11
|
include Generator
|
11
12
|
|
12
13
|
# @return [String] Folder where enumeration objects are stored
|
13
|
-
|
14
|
+
if LeapSalesforce.enum_folder
|
15
|
+
ENUM_FOLDER = LeapSalesforce.enum_folder
|
16
|
+
else
|
17
|
+
ENUM_FOLDER = File.join(LeapSalesforce.lib_folder, 'metadata', 'enum').freeze
|
18
|
+
end
|
14
19
|
|
15
|
-
# Create Soql enumerations for all objects specified
|
20
|
+
# Create Soql enumerations for all objects specified in .leap_salesforce.yml
|
16
21
|
def create
|
17
|
-
if LeapSalesforce.
|
18
|
-
raise LeapSalesforce::SetupError, 'LeapSalesforce.
|
19
|
-
'Please set the list of objects you want to
|
22
|
+
if LeapSalesforce.soql_objects.empty?
|
23
|
+
raise LeapSalesforce::SetupError, 'LeapSalesforce.soql_objects is empty. ' \
|
24
|
+
'Please set the list of objects you want to create enums for in .leap_salesforce:soql_objects ' \
|
20
25
|
'and then run task "leaps:create_soql_objects" to create objects'
|
21
26
|
end
|
22
27
|
reset_enum_folder
|
23
|
-
LeapSalesforce.
|
28
|
+
LeapSalesforce.soql_objects.each { |entity| create_picklists_for entity }
|
24
29
|
cleanup_files_created
|
25
30
|
end
|
26
31
|
|
@@ -28,16 +33,23 @@ module LeapSalesforce
|
|
28
33
|
# @param [LeapSalesforce::SoqlData] entity An object representing an object in Salesforce
|
29
34
|
# Object inheriting from SoqlData that has picklists underneath it
|
30
35
|
def create_picklists_for(entity)
|
31
|
-
soql_object = LeapSalesforce.soql_objects.find { |so| so.class_name == entity.to_s }
|
32
|
-
|
33
|
-
|
36
|
+
soql_object = entity # LeapSalesforce.soql_objects.find { |so| so.class_name == entity.to_s }
|
37
|
+
@soql_data_object = Class.new(SoqlData) do
|
38
|
+
soql_object soql_object.backend_name
|
39
|
+
end
|
40
|
+
@entity_name = entity.class_name
|
41
|
+
unless soql_object
|
42
|
+
LeapSalesforce.logger.warn "Could not find soql object for '#{@entity_name}', ignoring"
|
43
|
+
return
|
44
|
+
end
|
45
|
+
|
34
46
|
unless soql_object.create_enum != false
|
35
|
-
puts "Skipping picklists for #{
|
47
|
+
puts "Skipping picklists for #{@entity_name}"
|
36
48
|
return
|
37
49
|
end
|
38
|
-
puts "Creating picklists for #{
|
39
|
-
|
40
|
-
picklists =
|
50
|
+
puts "Creating picklists for #{@entity_name}"
|
51
|
+
|
52
|
+
picklists = @soql_data_object.picklists
|
41
53
|
puts "#{picklists.count} picklists found"
|
42
54
|
picklists.each do |picklist|
|
43
55
|
if soql_object.excludes?(picklist)
|
@@ -53,13 +65,20 @@ module LeapSalesforce
|
|
53
65
|
@picklist = picklist
|
54
66
|
@enum_name = picklist.to_class_name
|
55
67
|
picklist_name = picklist.to_key_name
|
56
|
-
values = @
|
68
|
+
values = @soql_data_object.picklist_for(picklist)
|
57
69
|
@enum_values = {}
|
58
70
|
values.each do |value|
|
59
71
|
@enum_values[value.to_key_name_for(@enum_values)] = value
|
60
72
|
end
|
61
|
-
|
62
|
-
|
73
|
+
if LeapSalesforce.language == "ruby"
|
74
|
+
content = read_template 'picklist.rb.erb', binding
|
75
|
+
file = File.join(ENUM_FOLDER, @entity_name.to_s.snakecase, "#{picklist_name}.rb")
|
76
|
+
elsif LeapSalesforce.language == 'java'
|
77
|
+
content = read_template 'picklist.java.erb', binding
|
78
|
+
file = File.join(ENUM_FOLDER, @entity_name.to_s, "#{@enum_name}.java")
|
79
|
+
else
|
80
|
+
raise LeapSalesforce::SetupError, "Unsupported language '#{LeapSalesforce.language}'"
|
81
|
+
end
|
63
82
|
generate_file file, content
|
64
83
|
end
|
65
84
|
|
@@ -70,6 +89,8 @@ module LeapSalesforce
|
|
70
89
|
|
71
90
|
# Clean up files generated for all picklists
|
72
91
|
def cleanup_files_created
|
92
|
+
return unless LeapSalesforce.language == "ruby"
|
93
|
+
|
73
94
|
`rubocop -A #{ENUM_FOLDER} --display-only-fail-level-offenses --enable-pending-cops`
|
74
95
|
end
|
75
96
|
end
|
@@ -44,7 +44,7 @@ module LeapSalesforce
|
|
44
44
|
if LeapSalesforce.language == 'ruby'
|
45
45
|
field_content = read_template 'soql_object_field_names.rb.erb', binding
|
46
46
|
field_file = File.join(SOQL_OBJECT_FOLDER, "#{@field_name_file}.rb")
|
47
|
-
elsif LeapSalesforce.language ==
|
47
|
+
elsif LeapSalesforce.language == 'java'
|
48
48
|
field_content = read_template 'soql_object_field_names.java.erb', binding
|
49
49
|
field_file = File.join(SOQL_OBJECT_FOLDER, "#{@soql_object.class_name}.java")
|
50
50
|
else
|
@@ -0,0 +1,23 @@
|
|
1
|
+
<%= LeapSalesforce.soql_enum_start_text %>.<%= @entity_name %>;
|
2
|
+
|
3
|
+
/** This file is generated and updated automatically so best not to edit manually
|
4
|
+
* Helps handle picklist values for <%= "#{@entity_name}, #{@enum_name}" %>
|
5
|
+
*/
|
6
|
+
public enum <%= @enum_name %> {
|
7
|
+
<% @enum_values.each_with_index do |value, index| %>
|
8
|
+
<%= value[0].camelize(:upper).to_s %>("<%= value[1] %>")<%= index == @enum_values.length - 1 ? ';' : ',' %><% end%>
|
9
|
+
|
10
|
+
private String displayName;
|
11
|
+
|
12
|
+
public String displayName() { return displayName; }
|
13
|
+
|
14
|
+
@Override public String toString() { return displayName; }
|
15
|
+
|
16
|
+
<%= @enum_name %>(String displayName) {
|
17
|
+
this.displayName = displayName;
|
18
|
+
}
|
19
|
+
|
20
|
+
public static <%= @enum_name %> getRandom() {
|
21
|
+
return values()[(int) (Math.random() * values().length)];
|
22
|
+
}
|
23
|
+
}
|
@@ -2,24 +2,22 @@
|
|
2
2
|
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
3
3
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
4
4
|
|
5
|
+
import lombok.Data;
|
6
|
+
|
5
7
|
/**
|
6
8
|
* Auto-generated code created by leap_salesforce. Do not manually
|
7
9
|
* update as this can be overwritten when `leap_salesforce create_soql_objects` is run
|
8
10
|
*/
|
9
11
|
@JsonIgnoreProperties(ignoreUnknown=true)
|
12
|
+
@Data
|
10
13
|
public class <%= @soql_object.class_name %> {
|
11
14
|
|
12
15
|
<% @soql_class.fields.each do |field| %>
|
13
|
-
@JsonProperty(value="<%= field['name'] %>")
|
14
|
-
String <%= field['name'].camelize(:lower) %>;
|
15
|
-
<% end %>
|
16
|
-
|
17
|
-
<% @soql_class.fields.each do |field| %>
|
18
|
-
public String get<%= field['name'].camelize(:upper) %>() { return <%= field['name'].camelize(:lower) %>; }
|
19
16
|
/**
|
20
17
|
* Label: '<%= field['label'] %>', Type: <%= field['type'] %><%= ", Relationship:" + field['relationshipName'] if field['relationshipName'] %>
|
21
18
|
*/
|
22
|
-
|
19
|
+
@JsonProperty(value="<%= field['name'] %>")
|
20
|
+
String <%= field['name'].camelize(:lower) %>;
|
23
21
|
<% end %>
|
24
22
|
}
|
25
23
|
|
@@ -11,6 +11,7 @@ CREATE_APP_LINK = 'https://trailhead.salesforce.com/content/learn/projects/autom
|
|
11
11
|
module LeapSalesforce
|
12
12
|
@config_folder = 'config'
|
13
13
|
@lib_folder = File.join('lib', 'leap_salesforce').freeze
|
14
|
+
@enum_folder = nil
|
14
15
|
@objects_to_verify = []
|
15
16
|
@soql_objects = []
|
16
17
|
@client_id = ENV['client_id']
|
@@ -18,6 +19,7 @@ module LeapSalesforce
|
|
18
19
|
@password = ENV['password']
|
19
20
|
@language = 'ruby'
|
20
21
|
@soql_field_start_text = ''
|
22
|
+
@soql_enum_start_text = ''
|
21
23
|
@environment = nil
|
22
24
|
@logger = Logger.new $stdout
|
23
25
|
@sfdx = false
|
@@ -124,6 +126,8 @@ module LeapSalesforce
|
|
124
126
|
attr_accessor :security_token
|
125
127
|
# @return [String] Path where library generated assets are stored. By default lib/leap_salesforce
|
126
128
|
attr_accessor :lib_folder
|
129
|
+
# @return [String] Path where generated enum files are stored. By default this is null and just appeneded to lib_folder
|
130
|
+
attr_accessor :enum_folder
|
127
131
|
# @return [Array] List of objects to verify metadata for. This includes enums, required values
|
128
132
|
# Changes to these values will need to be version controlled
|
129
133
|
attr_accessor :objects_to_verify
|
@@ -139,6 +143,9 @@ module LeapSalesforce
|
|
139
143
|
# classes in the Salesforce object
|
140
144
|
attr_accessor :soql_field_start_text
|
141
145
|
|
146
|
+
# @return [String] Text to be added as start of auto generated Soql enums
|
147
|
+
attr_accessor :soql_enum_start_text
|
148
|
+
|
142
149
|
# @return [Array] list_of_soql_objects Array describing Soql objects taken from .leap_salesforce.yml
|
143
150
|
def soql_objects=(list_of_soql_objects)
|
144
151
|
@soql_objects = list_of_soql_objects.collect do |soql_object_desc|
|
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.3
|
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-
|
12
|
+
date: 2024-10-01 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -358,6 +358,7 @@ files:
|
|
358
358
|
- lib/leap_salesforce/generator/templates/config/environments/specific_file.rb.erb
|
359
359
|
- lib/leap_salesforce/generator/templates/config/general.rb.erb
|
360
360
|
- lib/leap_salesforce/generator/templates/factory.rb.erb
|
361
|
+
- lib/leap_salesforce/generator/templates/picklist.java.erb
|
361
362
|
- lib/leap_salesforce/generator/templates/picklist.rb.erb
|
362
363
|
- lib/leap_salesforce/generator/templates/soql_object.rb.erb
|
363
364
|
- lib/leap_salesforce/generator/templates/soql_object_field_names.Java.erb
|