This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class TaskUtility | |
{ | |
public static String getTaskPriority(String leadCountry) | |
{ | |
if(String.isBlank(leadCountry)||leadCountry.length()>2) | |
{ | |
return null; | |
} | |
String taskPriority; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@isTest | |
public class TaskUtilityTest | |
{ | |
@isTest static void testGetTaskPriority() | |
{ | |
String priority=TaskUtility.getTaskPriority('AU'); | |
System.assertEquals('Normal', priority); | |
} | |
@isTest static void testTaskHighPriority() | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@isTest | |
public class TemperatureConvertorTest { | |
@isTest static void testWarmTemp() | |
{ | |
Decimal celsius=TemperatureConvertor.FahrenheitToCelsius(70); | |
System.assertEquals(21.11, celsius); | |
} | |
@isTest static void testFreezingPoint() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class TemperatureConvertor | |
{ | |
public static Decimal FahrenheitToCelsius(Decimal fh) | |
{ | |
Decimal cs=(fh-32)*5/9; | |
System.debug('temperature in Celsius='+cs.setScale(2)); | |
return cs.setScale(2); | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
global class FutureMethodExample | |
{ | |
@future(callout=true) | |
public static void getStockQuotes(String acctName) | |
{ | |
// Perform a callout to an external service | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
global class FutureClass | |
{ | |
@future | |
public static void myFutureMethod() | |
{ | |
// Perform some operations | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public without sharing class AccountTriggerHelper { | |
public AccountTriggerHelper() { | |
System.debug('Inside AccountTriggerHelper Constructor'); | |
} | |
public void doTask1() { | |
System.debug('Inside Task 1'); | |
} | |
public void doTask2() { | |
System.debug('Inside Task 2'); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public without sharing class AccountTriggerHandler implements TriggerHandler { | |
private boolean triggerIsExecuting; | |
private integer triggerSize; | |
public AccountTriggerHelper helper; | |
public AccountTriggerHandler(boolean triggerIsExecuting, integer triggerSize) { | |
this.triggerIsExecuting = triggerIsExecuting; | |
this.triggerSize = triggerSize; | |
this.helper = new AccountTriggerHelper(); | |
} | |
public void beforeInsert(List<Account> newAccounts) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public interface TriggerHandler { | |
void beforeInsert(List<SObject> newRecords); | |
void beforeUpdate(List<SObject> oldRecords, List<SObject> newRecords, Map<ID, SObject> oldRecordMap, Map<ID, SObject> newRecordMap); | |
void beforeDelete(List<SObject> oldRecords, Map<ID, SObject> oldRecordMap); | |
void afterInsert(List<SObject> newRecords, Map<ID, SObject> newRecordMap); | |
void afterUpdate(List<SObject> oldRecords, List<SObject> newRecords, Map<ID, SObject> oldRecordMap, Map<ID, SObject> newRecordMap); | |
void afterDelete(List<SObject> oldRecords, Map<ID, SObject> oldRecordMap); | |
void afterUndelete(List<SObject> newRecords, Map<ID, SObject> newRecordMap); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
trigger AccountTrigger on Account (before insert, before update, before delete, after insert, after update, after delete, after undelete) { | |
if (Org_Specific_Setting__mdt.getInstance('Run_All_Triggers')?.Value__c == true) { | |
TriggerHandler handler = new AccountTriggerHandler(Trigger.isExecuting, Trigger.size); | |
switch on Trigger.operationType { | |
when BEFORE_INSERT { | |
// handler.beforeInsert(Trigger.new); | |
} | |
when BEFORE_UPDATE { | |
// handler.beforeUpdate(Trigger.old, Trigger.new, Trigger.oldMap, Trigger.newMap); | |
} |
NewerOlder