- Send a copy of my card - email to Captain Kevin or bring it to the water class
- Class today
- Class on Friday
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
// Snippet from AccountTriggerHandlerTest | |
... | |
mockDataLayer = new MockDataLayer(); | |
mockFieldReader = new MockFieldReader(); | |
... | |
// First, the formula field on the child object: | |
mockFieldReader.addValueToField( | |
mockDataLayer.childAccount, |
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
// Snippet from the AccountTriggerHandler | |
... | |
// If the mock data is not being used | |
// creates new instances of the real deal | |
public AccountTriggerHandler() { | |
this(new DataLayer(), new FieldReader()); | |
} | |
// Child_Accounts__r is a nonwritable child relationship | |
// Uses the field reader to retrieve the list of child records: |
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 MockFieldReader implements IFieldReader { | |
// Map of value stored in a field by Id | |
private Map<Id, Map<String, Object>> fieldValuesByIdMap = new Map<Id, Map<String, Object>>(); | |
// ====================================================================== | |
// GETTERS | |
// The following method will try to find the field name and value | |
// in the map above, and return the correct value accordingly | |
// ====================================================================== | |
public Object getFieldValue(SObject record, String fieldName) { |
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 FieldReader implements IFieldReader { | |
// Retrieves a value from a field, as an object | |
public Object getFieldValue(SObject record, String fieldName) { | |
return record.get(fieldName); | |
} | |
// Retrieves a value from a field, as a SObject | |
public SObject getFieldRecord(SObject record, String fieldName) { | |
return record.getSObject(fieldName); |
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 IFieldReader { | |
Object getFieldValue(SObject record, String fieldName); | |
SObject getFieldRecord(SObject record, String fieldName); | |
List<SObject> getFieldRecords(SObject record, String fieldName); | |
} |
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
/****************************************** | |
Imagine three strings: | |
- one with a single space | |
- one null | |
- one not empty and not null | |
******************************************/ | |
String singleSpaceString = ' '; | |
String nullString = null; | |
String notEmptyString = 'Samwise Gamgee is the real hero'; |
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 DataLayerHandler { | |
public interface IDataLayer { | |
List<Document__c> getDocumentList(); | |
} | |
} |
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 MyUser { | |
public String username; | |
public String password; | |
public void validateCredentials() { | |
// calling an static method without creating a new instance of MySecurityClass | |
Boolean authenticated = MySecurityClass.validateCredentials(username, password); | |
System.debug('User username: ' + username); | |
System.debug('User Authentication: ' + authenticated); |
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 MySecurityClass { | |
public static Boolean validateCredentials(String username, String password){ | |
if (username == 'admin' && password == 'admin'){ | |
return true; | |
} else { | |
return false; | |
} | |
} | |
} |
NewerOlder