Giter Site home page Giter Site logo

forceea / forceea-data-factory Goto Github PK

View Code? Open in Web Editor NEW
120.0 12.0 13.0 1.07 MB

The most advanced and powerful native open-source data factory for Salesforce.

Home Page: https://www.mitrakisconsulting.gr/forceea

License: GNU General Public License v3.0

Apex 99.44% HTML 0.11% JavaScript 0.45%
data-factory unit-testing salesforce testing-data apex

forceea-data-factory's Introduction

The Forceea project is looking for Salesforce developers who want to contribute!

Forceea Logo

To get started, download Forceea Success Guide

It has everything you need to understand and apply Forceea for an Enterprise Data Factory project.

Read Forceea articles

Forceea 2.9.0 Winter 24

What is Forceea?

Forceea (forsi:a) is the most advanced and sophisticated native open-source data factory framework for Salesforce, powered by Dadela data generation language. The framework allows developers to easily create records for test methods and facilitates administrators or business users to populate any org with records for testing or demonstration purposes.

How can you deploy it?

Forceea can be deployed to any org using an unlocked package.

The recommended deployment method is Salesforce CLI:

sf package install -w 10 -p 04t4I0000004EJHQA2 -r -o <UsernameOrOrgAlias>

You may deploy Forceea using this link for Production/Developer orgs:

Deploy to Salesforce

or this link for Sandboxes:

Deploy to Salesforce

What can Forceea do?

  • Inserts, updates and deletes records for standard or custom SObjects, synchronously (for test methods) or asynchronously (for populating your org with millions of records).
  • Inserts, updates and deletes records for standard or custom Big Objects, synchronously or asynchronously.
  • Supports all field data types of any standard or custom field.
  • Supports Dadela data generation language for field definitions.
  • Can automatically define the required fields.
  • Handles Record Types and field dependencies (dependent picklists).
  • Supports record groups for inserting, updating and deleting records.
  • Provides Templates for constructing a DataFactory class that can be used for flexible data generation.
  • Uses DML Optimizer to reduce the number of insert statements with Templates.
  • Supports variables and functions.
  • Validates the definitions based on the field data type.
  • Has an extended error messaging system.

forceea-data-factory's People

Contributors

nmitrakis avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

forceea-data-factory's Issues

New method insertRecords(allOrNone) replaces insertRecords()

  • The allOrNone parameter will work as apex Database.insert method does.
  • If you specify false for this parameter and a record fails, the remainder of the DML operation can still succeed.
  • If the parameter is set true, an exception is thrown if the method is not successful.
  • Currently insertRecords() works like insertRecords(false). This method will de deprecated in release 1.3

New static method getInsertedRecords(OBJECT) will retrieve all inserted records of an object

  • The static method will return all the inserted by Forceea records of an SObject during the current transaction.
  • The method will have no arguments.
  • The method will return a List of SObject records: List.
  • For a previously created FObject (during the current transaction), e.g. for the SObject MyObject, this static method FObject.getInsertedRecords('MyObject') and the instance method, e.g. obj.getInsertedRecords(), will return the same resuts.

The new method will allow users to get the inserted records of any lookup object created by Forceea, for exampe when the definition random lookup(OBJECT) source(forceea) has been used.

Respect dependent picklists when generating sample data for picklist fields

  • If the controller field is not defined, Forceea will set the defnition of the controller field with random type(picklist).
  • If the controller field has a controller field itself, Forccea will repeat this process for the controller field. The process will be iterative.
  • The defintion of a controller field should be positioned before the definition of the dependent field. Consequently, the sample data of the controlling field will be generated before the data of the dependent field.
  • If the definition of the dependent field is random type(picklist), the generated picklist items will be based on the Field Dependencies mapping.
  • If the definition of the dependent field is random type(picklist) except(VALUES), the generated field values will be based on the Field Dependencies after the except values have been removed from the mapping.
  • If the definition of the dependent field is random type(list) value(VALUES), the generated picklist items will be based on the Field Dependencies after the picklist items not included in the VALUES argument have been removed from the mapping.
  • For each of the above scenarios, the generated picklist item value of the controlling field will define the value of the dependent field.
  • If the field is restricted, Forceea will not allow any value except the picklist values of the field. If the field is unrestricted, it will allow any value for the field.

New SDDL script: random type(datetime) from(DATE) to(DATE)

  • The new script will generate random Datetime values.
  • The from value will be coverted to the YYYY-MM-DD 00:00:00 Datetime value.
  • The to value will be converted to the YYYY-MM-DD 59:59 Datetime value.
  • If the to value is less than the from value, Forceea will raise an error and the process will terminate.
  • If the from and to values are the same, e.g. random type(datetime) from(2017-10-12) to(2017-10-12) , Forceea will generate random datitime values for the same date (12 Oct. 2017).

New definition random type(picklist) respect(true|false)

  • The respect parameter will define if Forceea respects the Field Dependencies mapping of this field.
  • The existing definition random type(picklist) will be equivalent to random type(picklist) respect(true).
  • If the argument of the respect parameter is true, Forceea will respect the Field Dependencies mapping of this field.
  • If the argument of the respect parameter is false, Forceea will not respect the Field Dependencies mapping of this field.

The lookup records with IsActive = false will be excluded in definitions random|static lookup

  • Some standard Salesforce SObjects (e.g. BusinessHours) have the IsActive field.
  • Currently definitions random lookup and static lookup return all IsActive field values, which creates invalid lookup ID values, since lookup records with IsActive = false are usually invalid.
  • The new instance property excludeInactiveLookupRecords will have the default value true.
  • Forceea will exclude the lookup records if the value of excludeInactiveLookupRecords is true.
  • The user may change the value of the property to false, which will affect all the random|static lookup definitions of the object.
  • The new feature will minimize the possibility of creating invalid records.

New definition random type(list) respect(true|false) restrict(auto|true|false)

  • The respect parameter will define if Forceea respects the Field Dependencies mapping of this field.
  • The restrict parameter will define if Forceea restricts the created picklist values based on the existing values.
  • The existing definition random type(list) will be equivalent to random type(picklist) respect(true) restrict(auto).
  • If the argument of the respect parameter is true, Forceea will respect the Field Dependencies mapping of this field. This is the default (expected) behaviour.
  • If the argument of the respect parameter is false, Forceea will not respect the Field Dependencies mapping of this field.
  • If the argument of the restrict parameter is auto, Forceea will restrict the created picklist values based on the checkbox Restrict picklist to the values defined in the value set of the picklist or multi-select picklist field. This is the default (expected) behaviour.
  • If the argument of the restrict parameter is true, Forceea will restrict the created picklist values based on the existing values. This is equivalent to Restrict picklist to the values defined in the value set = TRUE.
  • If the argument of the restrict parameter is true, Forceea will not restrict the created picklist values. This is equivalent to Restrict picklist to the values defined in the value set = FALSE.

New method createRecords(Integer recordNumber) will handle the issue of creating records with serial data

  • Using a serial definition, e.g. serial type(number) from(1) step(1) scale(0), Forceea always creates the same serialized records. This may not be what it's expected from a data factory framework, especially when the framework is used for creating records in different transactions.
  • The new method uses the recordNumber argument, which sets the number of the next record to be created. For example, if you have created 100 records and you now want to create anoter 100 records, the recordId is 101, which is the ID of the first new record.
  • Forceea will take care of the serial type(number|data|datetime) definitions, creating serialized data with continous serial numbers.

Generate last names with SDDL: random type(lastname)

  • Taking into consideration the new properties Language and Locality, Forceea will generate realistic random last names.
  • Forceea will respect the gender when connecting a last name to a first name (e.g. a male first name to a male last name, where applicable)
  • The Locality property will define the source of data, e.g. if Locality is "Greece", we'll get Greek last names.
  • The Language property will define the display of data, e.g. if country is "Greece" and Language is "English", we'll get Greek last names written in English (if language is "Greek", we'll get Greek last names written in Greek).

Restructure the enginee of records creation

Make data creation enginee faster

  • The current enginee uses intermediate String lists to populate field data.
  • The new enginee will insert field data directly into records.
  • The speed of data creation is expected to increase substantially.
  • This restructure will impact many private FObject methods.

Generate phone numbers with definition random type(phone) format(STRING)

  • Use definition random type(phone) format(STRING) to generate random phone numbers of specific format.
  • The format string has the characters d for random digits between 1 and 9 and D for random digits between 0 and 9.
  • Format examples: (30) dD-21 DDD for phone numbers like (30) 19-21 345

Pseudorandom number generator (PRNG)

  • Create a PRNG method for generating a pseudorandom numbers sequence, which will be used in SDDL random field definitions.
  • The method will have a Long argument (seed), which will define the generated random numbers.
  • The output will be a sequence of random positive Double values, greater than or equal to 0.0 and less than 1.0, simulating the Math.random() method.
  • This feature will be very important when the user wants to get the same random records, e.g. when using data population in Salesforce DX scratch orgs, getting the same data sets in each org.

New definition random lookup(OBJECT) where(WHERE_CLAUSE) source(salesforce)

  • Currently the definitions random lookup don't allow complex filters.
  • The new definition will filter the returned lookup IDs when the source is salesforce, using a user-defined WHERE clause.
  • The WHERE clause will have double quotation marks if any parenthesis is used, e.g. random lookup(Object1) where("(FieldA = 1 OR FieldB = 2) AND FieldC = 3") source(salesforce) or no double quotation marks if no parenthesis is needed, e.g. random lookup(Object1) where(FieldA = 1 OR FieldB = 2) source(salesforce).
  • The definition will provide better filtering on lookup IDs.

Fix elapsed time calculation

  • The calculation of elapsed time shows negative values.
  • Must determine if the problem happens only when Forceea generates records for related objects.

Correct method deleteRecords()

Correct the results of method deleteRecords(), which doesn't delete correctly the records from the list of sObjuect's created records.

FATAL_ERROR System.ListException: List index out of bounds: 0 when generating records with definition random lookup source(salesforce)

Use the following statements to reproduce the error:

FObject contObj = new FObject('Contact');
contObj.SetRequiredFields = true;
contObj.setDefinition('AccountId', 'random lookup(Account) source(salesforce)');
List<Contact> contacts = (List<Contact>)contObj.getRecords();

If there are no Salesforce records of the lookup object (in this example, if there are no accounts), Forceea will get the error FATAL_ERROR System.ListException: List index out of bounds: 0

Generate first names with SDDL: random type(firstname)

  • Taking into consideration the new properties Language and Locality, Forceea will generate realistic random first names.
  • Forceea will respect the gender when connecting a first name to a last name (e.g. a male first name to a male last name, where applicable)
  • The Locality property will define the source of data, e.g. if Locality is "Greece", we'll get Greek first names.
  • The Language property will define the display of data, e.g. if Locality is "Greece" and Language is "English", we'll get Greek first names written in English (if Language is "Greek", we'll get Greek first names written in Greek).

Validate lookup field in definitions: random lookup field and static lookup field

Validate the API name for the lookup field in the following definitions
random lookup(OBJECT) field(FIELD) value(VALUE1[,VALUE2,...n]) source(forceea|salesforce)
random lookup(OBJECT) field(FIELD) except(VALUE1[,VALUE2,...n]) source(forceea|salesforce)
static lookup(OBJECT) field(FIELD) value(VALUE) source(forceea|salesforce)

Enhanced definition random type(datetime) from(DATE/DATETIME) to(DATE/DATETIME)

  • The definition random type(datetime) will support Date and Datetime arguments in from and to parameters.
  • Any combination of Date and Datetime arguments are valid, e.g. from(2018-01-01 01:01:01) to(2018-01-05).
  • If the from parameter has a Date argument, e.g. from(2018-01-01), the Date argument will be parsed as start of the day (2018-01-01 00:00:00).
  • If the to parameter has a Date argument, e.g. to(2018-01-01), the Date argument will be parsed as end of the day (2018-01-01 23:59:59).

New definition random type(picklist) except(VALUES) respect(true|false)

  • The respect parameter will define if Forceea respects the Field Dependencies mapping of this field.
  • The existing definition random type(picklist) except(VALUES) will be equivalent to random type(picklist) except(VALUES) respect(true).
  • If the argument of the respect parameter is true, Forceea will respect the Field Dependencies mapping of this field.
  • If the argument of the respect parameter is false, Forceea will not respect the Field Dependencies mapping of this field.

New definition static value(VALUE) respect(true|false) restrict(auto|true|false)

  • The new definition will be used for picklist or multi-select picklist fields.
  • The respect parameter will define if Forceea respects the Field Dependencies mapping of this field.
  • The restrict parameter will define if Forceea restricts the created picklist values based on the existing values.
  • The existing definition static value(VALUE) will be equivalent to static value(VALUE) respect(true) restrict(auto).
  • If the argument of the respect parameter is true, Forceea will respect the Field Dependencies mapping of this field. This is the default (expected) behaviour.
  • If the argument of the respect parameter is false, Forceea will not respect the Field Dependencies mapping of this field.
  • If the argument of the restrict parameter is auto, Forceea will restrict the created picklist values based on the checkbox Restrict picklist to the values defined in the value set of the picklist or multi-select picklist field. This is the default (expected) behaviour.
  • If the argument of the restrict parameter is true, Forceea will restrict the created picklist values based on the existing values. This is equivalent to Restrict picklist to the values defined in the value set = TRUE.
  • If the argument of the restrict parameter is true, Forceea will not restrict the created picklist values. This is equivalent to Restrict picklist to the values defined in the value set = FALSE.

Use double quotation marks in the value arguments

Current situation:

  • The parameter arguments in the value parameter are separated with a comma, so comma can't be used in an argument, e.g. we can't use the argument One, Two and Three.
  • If we use the above argument, e.g. static value(One, Two and Three), Forceea will understand we have 2 arguments: One and Two and Three.

New feature:

  • Forceea will optionally allow the double quotation marks " for the beginning and end of an argument, e.g. static value("One, Two and Three").
  • Te arguments may or may not use the double quotation marks, e.g. random type(list) value(One, "Two ", Three or four).
  • The presence of a space (e.g. "One " or " Two ") at the beginning or at the end of an argument will preserve the space in the created field values. This is very useful if we want to add the space between concatenated definitions of the same string. E.g. we have 2 definitions of the same field: a) static value("Company ") and random type(number) from(1) to(100) scale(0). These 2 definitions will create values like Company 12 or Company 88, something which is currently impossible.

Execution order of lookup records creation and random lookup definitions

Currently Forceea uses random lookup(OBJECT) source(forceea) for setting the definition of a required lookup field. Using this definition

  • if Forceea has already created records for the lookup object, these records are returned.
  • if no records have been created yet, Forceea will create new records for the lookup object.
  • if the new records can't (for any reason) be created, Forceea will retrieve existing Salesforce records, using the definition random lookup(OBJECT) source(salesforce).

This described process has the following issues:

  • when the required field is a Salesforce object like BusinessHours (which is used for the BusinessHoursId field of the Case object), Forceea will try to create records of this object, an action prone to creating invalid records (e.g. the IsActive field should be true in BusinessHours records).
  • a definition with source(forceea) should not return records using source(salesforce), since this violates the user intention.

To remedy the above issues:

  • when setting the definition of a required lookup field, Forceea will use the default definition random lookup(OBJECT) source(forceea) as before, but with a different order:
  1. if Forceea has already created records for the lookup object, these records are returned.
  2. If no records have been created yet (by Forceea), it will retrieve existing Salesforce records, using the definition random lookup(OBJECT) source(salesforce).
  3. if no records are returned from the previous step, Forceea will create new records for the lookup object, using the definition static value(true) for the lookup object's field IsActive.
  • a definition with source(forceea) will never return records using source(salesforce), if the records can't be created.

With the above amendments, Forceea will reduce the possibility of creating invalid records.

Visual indicators in Debug Log for successful or unsuccessful activities

  • A visual indicator will help user to easily locate successful or unsuccessful Forceea activities (e.g. definition validations)
  • All successful activities will have the โ— symbol before the debug log description
  • All unsuccessful activities will have the โ–บ symbol before the debug log description

New static method setGlobalVerbose('none'|'debug'|'info') and instance method setVerbose('none'|'debug'|'info')

  • The new static method setGlobalVerbose('none'|'debug'|'info') and the new instance method setVerbose('none'|'debug'|'info') will define if and how Forceea displays the System.debug messages.
  • The setGlobalVerbose method defines the messages at the Class level, for any FObject instance. The FObject.setGlobalVerbose('none') will restrict any message. The FObject.setGlobalVerbose('debug') will allow DEBUG and INFO messages. The FObject.setGlobalVerbose('info') will allow only INFO messages. The ERROR and WARN messages will always be displayed.
  • The setGlobalVerbose method defines the messages at the instance level. The setVerbose('none') will restrict any message. The setVerbose('debug') will allow DEBUG and INFO messages. The setVerbose('info') will allow only INFO messages. The ERROR and WARN messages will always be displayed.

Exclude auto-generated field definitions from validation

  • When using setRequiredFields = true, Forceea creates one or more field definitions.
  • These definitions are validated, as all user defined definitions.
  • Excluding these Forceea definitions from validation will decrease processing time.

New SDDL definition: copy field(FIELD)

  • The new definition copy field(FIELD) will copy the value of the field to the value of the defined field.
  • For example, if we have the definition obj.setDefinition('FieldA', 'static value(One)');
    the definition obj.setDefinition('FieldB', 'copy field(FieldA)'); will give the same value (One) to the values of field FieldB.

New parameters in SDDL script: random type(string)

The script will have the following format:
random type(string) minlength(INTEGER) maxlength(INTEGER) startwith(lower|upper|digit) include(lower,upper,digit)
The minlength and maxlength parameters will generate random strings with variable length.

Generate addresses with SDDL: random type(street), type(city), type(stateprovince), type(postalcode), type(country)

  • Taking into consideration the new properties Language and Locality, Forceea will generate realistic random addresses.
  • Forceea will populate the City, Country, Postal Code, State and Street fields.
  • The Locality property will define the source of data, e.g. if Locality='Greece' we'll get Greek addresses.
  • The Language property will define the display of data, e.g. if Locality='Greece' and Language='English' we'll get Greek addresses written in English (if Language='Greek', we'll get Greek addresses written in Greek).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.