Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IDGenerator support for xxxHistory SObjects #75

Open
cropredyHelix opened this issue Feb 21, 2019 · 1 comment
Open

IDGenerator support for xxxHistory SObjects #75

cropredyHelix opened this issue Feb 21, 2019 · 1 comment

Comments

@cropredyHelix
Copy link
Contributor

cropredyHelix commented Feb 21, 2019

Currently, fflib_IDGenerator.generate(ContactHistory.SObjectType) returns null000000000000 for any xxxHistory object because getDescribe().getKeyPrefix() returns null for these SObjects

Extend the class's generate method to look like this:

 public static Id generate(Schema.SObjectType sobjectType) {
   String keyPrefix = sobjectType.getDescribe().getKeyPrefix();
   if (keyPrefix == null) {
    keyPrefix =  sobjectType.getDescribe().getName().endsWith('History') ? '017' : null;
   }

   fakeIdCount++;
   String fakeIdPrefix = ID_PATTERN.substring(0, 12 - fakeIdCount.format().length());
   return Id.valueOf(keyPrefix + fakeIdPrefix + fakeIdCount);
 }

While mocking xxxHistory records is problematic as you can't mock OldValue or NewValue fields including via Json.deserialize, you can mock the other fields (Id, ParentId, Field) via Json.deserialize and hence can produce selector mocks for use cases such as testing Field History deletion (introduced in V42)

@joeythomaschaske
Copy link

This issue also affects __Share records

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants