public class ContactProcessBuilderHandler {
@InvocableMethod
public static void sendNotification(List<String> contactIds) {
sendEmailToContacts(contactIds);
}
@future //Use callout = true, for callouts
public static void sendEmailToContacts(List<String> contactIds) {
//Write your business logic
}
}
public class AccountHelper {
@future
public static void UpdateAccounts(List<Id> accountIds){
//Get those records based on the IDs
List<Account> accList = [SELECT Name FROM Account WHERE Id IN : accountIds];
//Process records
}
}
Test Class:
@isTest
public class TestAccountHelper {
private static User CreateUser(){
String orgId = UserInfo.getOrganizationId();
String standardUserProfileId = [SELECT Id From Profile WHERE Name = 'Standard User'].Id;
User u = new User(
FirstName = 'Test',
LastName = 'User',
Alias = 'TestUser',
profileId = standardUserProfileId ,
Email = orgId + '@test.org',
Username = orgId + '@test.org',
EmailEncodingKey = 'ISO-8859-1',
LanguageLocaleKey = 'en_US',
LocaleSidKey = 'en_US',
TimeZoneSidKey = 'America/Los_Angeles'
);
insert u;
return u;
}
private static Account CreateAccount(){
Account acc = new Account( Name = 'Test Account',
Type = 'Technology Partner',
Industry = 'Technology',
Phone = '9898989898'
);
insert acc;
return acc;
}
private static testMethod void testUpdateAccounts(){
User u = CreateUser();
System.runAs(u) {
Account acc = CreateAccount();
List<Id> accountIds = new List<Id>();
accountIds.add(acc.Id);
Test.startTest();
AccountHelper.UpdateAccounts(accountIds);
Test.stopTest();
}
//Verify account is inserted
List<Account> accList = [SELECT Id From Account WHERE Name = 'Test Account'];
System.assertEquals(1, accList.size());
}
}
This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish.AcceptReject