Closed PseudoDarwinist closed 1 year ago
@PseudoDarwinist Can you post the entire stacktrace of the error?
I think the null exception is that you try to reference file.ContentDocument.LatestPublishedVersion.VersionData;
, but there is no data in the record other than an ID. (See GIVEN part of the unit test)
@wimvelzeboer Below is the stack Trace: -- | -- Class | XYZ_DOM_ContentDocumentLinks_Test Method Name | testGetBodyAsStringByLinkedEntityId Pass/Fail | Fail Error Message | System.NullPointerException: Argument cannot be null. Stack Trace | Class.IRR_DOM_ContentDocumentLinks.getBodyAsStringByLinkedEntityId: line 13, column1 Class.IRR_DOM_ContentDocumentLinks_Test.testGetBodyAsStringByLinkedEntityId: line 33, column 1
Hi @wimvelzeboer ..Is there any way to mock CDL record with FFLIB so that I have the content version data? or Do i need to go usual DML way to test this Domain class? Help me out here.
Isn't this resolved as per Stackexchange answer ??
If the workaround offered by @cropredyHelix isn't workable, please reopen the ticket and provide a little more context since it's not clear which line is line 13 in the stack trace
We have been using FFLIB(Apex commons) in our org.I have been trying to write a test case for a Content Document Link (Salesforce Files)Domain layer But I have been getting the error : "System.NullPointerException: Argument cannot be null." I am new to the library and now that I have tried few things in the test class , I am assuming it is something to do with ContentDocumentLink. Can somebody please help me resolve this.I want to adopt the AEP and Apex mocks and not go back to writing usual test cases.
My class:
My Test Class: