You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am experiencing a problem when try to make relationship with two standard objects Folder and Document.
Below the code I am using:
List<Folder> folders = new List<Folder>{
new Folder(
Id = fflib_IDGenerator.generate(Folder.SObjectType),
Name = 'Test Public Folder'
)};
List<Document> allDocuments = new List<Document>{
new Document(
Id = fflib_IdGenerator.generate(Document.SObjectType),
Name = 'Test Document',
Type = 'pdf',
FolderId = folders[0].Id
)};
folders = (List<Folder>) fflib_ApexMocksUtils.makeRelationship(
List<Folder>.class,
folders,
Document.FolderId,
new List<List<Document>> {allDocuments}
);
The exception I get is:
12:56:40:000 FATAL_ERROR Class.System.JSONGenerator.writeFieldName: line 58, column 1
12:56:40:000 FATAL_ERROR Class.fflib_ApexMocksUtils.InjectChildrenEventHandler.nextToken: line 113, column 1
12:56:40:000 FATAL_ERROR Class.fflib_ApexMocksUtils.streamTokens: line 135, column 1
12:56:40:000 FATAL_ERROR Class.fflib_ApexMocksUtils.makeRelationship: line 85, column 1
The text was updated successfully, but these errors were encountered:
Yup, I'm able to replicate this. Full stack appears to be:
▸ ERROR: System.NullPointerException: null argument for JSONGenerator.writeFieldName()
▸ ERROR: Class.System.JSONGenerator.writeFieldName: line 58, column 1
▸ Class.fflib_ApexMocksUtils.InjectChildrenEventHandler.nextToken: line 113, column 1
▸ Class.fflib_ApexMocksUtils.streamTokens: line 135, column 1
▸ Class.fflib_ApexMocksUtils.makeRelationship: line 85, column 1
▸ AnonymousBlock: line 13, column 1
▸ AnonymousBlock: line 13, column 1
I also tried your code sample, switching Folders with Accounts, and Documents with Contacts. It works. The trouble is that there is no relationship field name for the child relationship from Folder to Document.
So the utility can't match Folder's child relationship to Documents parent relationship, hence your error. But even if it did, would it help? I don't think you'd be able to traverse the child relationships in the non-test Apex code, because there is relationship name for you to get a Folder's child Documents.
Closing as it seems like a Salesforce Platform limitation, rather than an issue with ApexMocks.
I am experiencing a problem when try to make relationship with two standard objects Folder and Document.
Below the code I am using:
The exception I get is:
The text was updated successfully, but these errors were encountered: