-
Notifications
You must be signed in to change notification settings - Fork 13
IdFactory
STATUS: ACTIVE
A factory class for generating bogus Ids for testing purposes.
Integer representing the length of the Id. Default is 18.
This property gives us an authentic ID for this org which we can use to grab the Instance ID according to the latest release notes: What constitutes a valid Salesforce Object ID is being redefined as Salesforce expands out the instance ID (also known as a pod identifier or server ID). The 4th, 5th, and 6th characters would be used for server ID. The 7th character still remains reserved. Any coded assumptions about the structure of a valid or invalid ID should be reevaluated going forward. Note: Existing Apex functionality around IDs will transition to the new format.
There are certain types of objects that do not return a prefix. This map contains string keys that map to known values for these 'unstable' types. This map is used to identify the correct prefix when a developer requests an Id for an unstable type. This is likely an incomplete list. If you find an unstable type that is not in this list, please add it, and submit a PR. Daniel Bollinger has a great blog post useful for filling in the gaps when an object doesn't return a prefix. http://www.fishofprey.com/2011/09/obscure-salesforce-object-key-prefixes.html
Integer to be appended to the end of the Id. Incremented each time a new Id is generated.
this method accepts a String representation of the sObject type and defers to it's sister methods to generate a bogus Id.
Param | Description |
---|---|
objectType |
String representation of the sObject type ie: Account, Contact, etc. |
Type | Description |
---|---|
Id | id a plausible, but bogus Id |
`IdFactory.get('Account');`
This method accepts a Type object and defers to it's sister methods to generate a bogus Id.
Param | Description |
---|---|
incomingType |
Type object representing the sObject type ie: Account, Contact, etc. |
Type | Description |
---|---|
Id | Id a plausible, but bogus Id |
`IdFactory.get(Type.forName('Account'));`
This method accepts a generic SObject and defers to it's sister methods to generate a bogus Id.
Param | Description |
---|---|
incomingType |
SObject representing the sObject type ie: Account, Contact, etc. |
Type | Description |
---|---|
Id | Id a plausible, but bogus Id |
All the other methods in this class defer to this method eventually to generate a bogus Id.
Param | Description |
---|---|
incomingType |
Schema.SObjectType representing the sObject type ie: Account, Contact, etc. |
Type | Description |
---|---|
Id | Id a plausible, but bogus Id |
A method for getting a bogus Id for an object that may not return a prefix via standard Schema methods. This method is used internally by the other methods in this class once a prefix has been identified.
Param | Description |
---|---|
prefix |
String three character prefix for the object type. |
Type | Description |
---|---|
Id | Id a plausible, but bogus Id |
Certain types of objects do not return a prefix via standard Schema methods. This method is used to identify them, and override the prefix with a known value.
Param | Description |
---|---|
objectType |
String representation of the sObject type ie: Account, Contact, etc. |
Type | Description |
---|---|
String | String three character prefix for the object type. |
internally thrown exception for when the incoming data type is null or invalid
Inheritance
IDFactoryException