Forceea examples

To see the details (Debug Log) of all the phases of the record creation process, add the following statement after FObject obj = new..

obj.setVerbose('debug');

Standard SObjects

Accounts

Create accounts with real addresses

FObject obj = new FObject('Account', 100);

// if you have record types. you can use the following definition
// obj.setDefinition('RecordTypeId', 'static value(BigAccount)');

// define account fields
obj.setDefinition('Name', 'static value("Company ")');
obj.setDefinition('Name', 'serial type(number) from(100) step(1) scale(0)');
obj.setDefinition('NumberOfEmployees', 'random type(number) from(10) to(1000) scale(-1)');
obj.setDefinition('AnnualRevenue', 'random type(number) from(10000000) to(100000000) scale(3)');
obj.setDefinition('Rating', 'random type(picklist) except(Hot)');
obj.setDefinition('Phone', 'random type(phone) format("(30) 210 dD-00-DD")');
obj.setDefinition('Industry', 'random type(picklist)');
obj.setDefinition('Type', 'random type(list) value(Prospect, Customer - Direct, Customer - Channel)');
obj.setDefinition('Site', 'random type(url)');

// define address
obj.setDefinition('ShippingStreet', 'random type(street) group(shipping)');
obj.setDefinition('ShippingPostalCode', 'random type(postalcode) group(shipping)');
obj.setDefinition('ShippingCity', 'random type(city) group(shipping)');
obj.setDefinition('ShippingState', 'random type(state) group(shipping)');
obj.setDefinition('ShippingCountry', 'random type(country) group(shipping)');
obj.setDefinition('BillingStreet', 'copy field(ShippingStreet)');
obj.setDefinition('BillingPostalCode', 'copy field(ShippingPostalCode)');
obj.setDefinition('BillingCity', 'copy field(ShippingCity)');
obj.setDefinition('BillingState', 'copy field(ShippingState)');
obj.setDefinition('BillingCountry', 'copy field(ShippingCountry)');

// use the following lines if you enable Set Audit Fields upon Record Creation
// obj.setDefinition('CreatedDate', 'random type(datetime) from(2010-01-01) to(2015-12-31)');
// obj.setDefinition('CreatedById', 'random lookup(User) source(salesforce)');

// insert the records
obj.insertRecords(true);

Attachments

Create attachments of email messages 

FObject obj = new FObject('Attachment');

obj.setDefinition('Name', 'static value(Attachment)');
obj.setDefinition('Name', 'serial type(number) from(1) step(1) scale(0)');
obj.setDefinition('Body', 'random type(text) minlength(30) maxlength(100)');
obj.setDefinition('ParentId', 'random lookup(EmailMessage) source(forceea)');

obj.insertRecords(true);

Cases

Create cases related to accounts and contacts

FObject obj = new FObject('Case');
obj.records = 100;

obj.setDefinition('AccountId', 'random lookup(Account) source(salesforce)');
obj.setDefinition('ContactId', 'random lookup(Contact) source(salesforce)');

obj.setDefinition('Origin', 'random type(picklist)');
obj.setDefinition('Type', 'random type(picklist)');
obj.setDefinition('Status', 'static value(Working)');
obj.setDefinition('Subject', 'random type(text) minlength(50) maxlength(200)');
obj.setDefinition('Reason', 'random type(picklist)');
obj.setDefinition('Description', 'random type(text) minlength(50) maxlength(200)');

obj.insertRecords(true);

Chatter Feeds

Create chatter feeds related to contacts

FObject obj = new FObject('FeedItem');

obj.setDefinition('Body', 'random type(text) minlength(50) maxlength(500)');
obj.setDefinition('ParentId', 'random lookup(Contact) source(forceea)');
obj.setDefinition('Status', 'static value(Published)');
obj.setDefinition('Type', 'static value(TextPost)');
obj.setDefinition('Title', 'random type(text) minlength(50) maxlength(250)');

obj.insertRecords(true);

Contacts

Create contacts with real first/last names and addresses , related to accounts

FObject obj = new FObject('Contact', 200);

obj.setDefinition('FirstName', 'random type(firstname) group(name)');
obj.setDefinition('LastName', 'random type(lastname) group(name)');
obj.setDefinition('Email', 'random type(email)');
obj.setDefinition('LeadSource', 'random type(picklist)');
obj.setDefinition('Birthdate', 'random type(date) from(1950-1-1) to(1982-12-31)');
obj.setDefinition('Title', 'random type(list) value(Developer, CFO, Account Manager, CEO, Logistics Manager)');
obj.setDefinition('Department', 'random type(list) value(Sales, Marketing, Accounting, Management)');
obj.setDefinition('AccountId', 'random lookup(Account) source(salesforce)');
obj.setDefinition('Phone', 'copy field(AccountId) from(Account.Phone)');

// define address
obj.setDefinition('MailingStreet', 'copy field(AccountId) from(Account.ShippingStreet)');
obj.setDefinition('MailingPostalCode', 'copy field(AccountId) from(Account.ShippingPostalCode)');
obj.setDefinition('MailingCity', 'copy field(AccountId) from(Account.ShippingCity)');
obj.setDefinition('MailingState', 'copy field(AccountId) from(Account.ShippingState)');
obj.setDefinition('MailingCountry', 'copy field(AccountId) from(Account.ShippingCountry)');

obj.insertRecords(true);

Email Messages

Create email messages related to Cases

FObject obj = new FObject('EmailMessage');

obj.setDefinition('Subject', 'static value(Email)');
obj.setDefinition('Subject', 'serial type(number) from(1) step(1) scale(0)');

obj.setDefinition('TextBody', 'copy field(Subject)');
obj.setDefinition('Incoming', 'static value(true)');
obj.setDefinition('Status', 'static value(0)');
obj.setDefinition('ParentId', 'random lookup(Case) source(salesforce)');

obj.insertRecords(true);

Events

Create events related to contacts

FObject obj = new FObject('Event', 100);

obj.setDefinition('Subject', 'random type(picklist)');
obj.setDefinition('Type', 'random type(picklist)');
obj.setDefinition('WhoId', 'random lookup(Contact) source(salesforce)');
obj.setDefinition('ActivityDatetime', 'random type(datetime) from(2018-1-1) to(2018-12-31)');
obj.setDefinition('DurationInMinutes', 'random type(number) from(1) to(10) scale(0)');

obj.insertRecords(true);

Leads

Create leads with real first/last names and addresses

FObject obj = new FObject('Lead'); // default records: 201

obj.setDefinition('FirstName', 'random type(firstname) group(name)');
obj.setDefinition('LastName', 'random type(lastname) group(name)');

obj.setDefinition('Email', 'random type(email)');
obj.setDefinition('Title', 'random type(list) value(Developer, CFO, Account Manager, CEO, Logistics Manager)');
obj.setDefinition('Company', 'static value("Company ")');
obj.setDefinition('Company', 'serial type(number) from(100) step(1) scale(0)');
obj.setDefinition('AnnualRevenue', 'random type(number) from(1000000) to(10000000) scale(-3)');
obj.setDefinition('NumberOfEmployees', 'random type(list) value(10,20,30)');
obj.setDefinition('Industry', 'random type(picklist)');

// define address
obj.setDefinition('Status', 'static value(Open)');
obj.setDefinition('Street', 'random type(street) group(other)');
obj.setDefinition('PostalCode', 'random type(postalcode) group(other)');
obj.setDefinition('City', 'random type(city) group(other)');
obj.setDefinition('State', 'random type(state) group(other)');
obj.setDefinition('Country', 'random type(country) group(other)');

obj.insertRecords(true);

Opportuities

Create opportunities related to accounts

FObject obj = new FObject('Opportunity', 100);

obj.setDefinition('Name', 'static value(Opp)');
obj.setDefinition('Name', 'serial type(number) from(1) step(1) scale(0)');
obj.setDefinition('AccountId', 'random lookup(Account) field(Industry) value(Chemicals,Construction) source(salesforce)');
obj.setDefinition('Amount', 'random type(number) from(1000000) to(10000000) scale(-3)');
obj.setDefinition('StageName', 'random type(picklist)');
obj.setDefinition('CloseDate', 'random type(date) from(2017-01-01) to(2018-12-31)');

obj.insertRecords(true);

Tasks

Create tasks related to accounts

FObject obj = new FObject('Task');

obj.setDefinition('Subject', 'random type(picklist)');
obj.setDefinition('Priority', 'random type(picklist)');
obj.setDefinition('Status', 'random type(picklist)');
obj.setDefinition('Type', 'random type(picklist)');
obj.setDefinition('WhatId', 'random lookup(Account) source(salesforce)');
obj.setDefinition('ActivityDate', 'random type(date) from(2018-10-1) to(2018-12-31)');

obj.insertRecords(true);

Users

Create users with specific Profile and Role.
Attention: you can execute this script only in a test method.

FObject obj = new FObject('User', 1);

obj.setDefinition('ProfileId', 'static lookup(Profile) field(Name) value(System Administrator) source(salesforce)');
obj.setDefinition('UserRoleId', 'static lookup(UserRole) field(Name) value(CEO) source(salesforce)');

obj.insertRecords(true);

Custom SObjects

  • Forceea uses 4 custom objects (FObjectOne, FObjectTwo, FObjectThree and FObjectFour) for its test methods.
  • These objects are excellent for training on framework’s capabilities, because they include every field data type, with various picklist field dependencies.
  • The User Guide includes a detailed list of all fields.

FObjectOne

FObject obj = new FObject('FObjectOne__c');

obj.setDefinition('TestCheckbox__c', 'static value(true)');
obj.setDefinition('TestCurrency__c', 'random type(number) from(1) to(100) scale(0)');
obj.setDefinition('TestDate__c', 'random type(date) from(2017-1-1) to(2017-12-31)');
obj.setDefinition('TestDatetime__c', 'random type(datetime) from(2017-1-1) to(2017-12-31)');
obj.setDefinition('TestDecimal__c', 'random type(number) from(1) to(100) scale(3)');
obj.setDefinition('TestEmail__c', 'random type(email)');
obj.setDefinition('TestInteger__c', 'random type(number) from(1) to(100) scale(0)');
obj.setDefinition('TestLookup__c', 'random lookup(FObjectTwo__c) source(salesforce)');
obj.setDefinition('TestMultiPicklistA__c', 'random type(picklist)');
obj.setDefinition('TestPercent__c', 'random type(number) from(1) to(100) scale(1)');
obj.setDefinition('TestPhone__c', 'static value(2102525125)');
obj.setDefinition('TestPicklistA__c', 'random type(picklist) except(a0)');
obj.setDefinition('TestPicklistB__c', 'random type(picklist)');
obj.setDefinition('TestPicklistC__c', 'random type(picklist)');
obj.setDefinition('TestPicklistD__c', 'random type(picklist) except (d0,d1)');
obj.setDefinition('TestText__c', 'random type(string) minlength(10) maxlength(30) startwith(lower) include(lower,upper,digit)');
obj.setDefinition('TestTextArea__c', 'random type(string) minlength(10) maxlength(30) startwith(lower) include(lower,upper,digit)');
obj.setDefinition('TestTextAreaLong__c', 'random type(string) minlength(50) maxlength(200) startwith(lower) include(lower,upper,digit)');
obj.setDefinition('TestTextAreaRich__c', 'random type(string) minlength(50) maxlength(200) startwith(lower) include(lower,upper,digit)');
obj.setDefinition('TestTextRequired__c', 'random type(string) minlength(10) maxlength(20) startwith(upper) include(lower,upper)');
obj.setDefinition('TestTime__c', 'static value(22:10:05)');
obj.setDefinition('TestUrl__c', 'random type(url)');

obj.insertRecords(true);

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

Powered by WordPress.com.

Up ↑

%d bloggers like this: