You need to sign in to do that
Don't have an account?

How to write test class for ContentDocument file retrieval class ?
@AuraEnabled public static String getContentDetails(String recordId) { List<ContentDocumentLink> contentDocumentList = [SELECT ContentDocumentId, LinkedEntityId FROM ContentDocumentLink WHERE LinkedEntityId =: recordId]; Set<Id> contentDocumentId = new Set<Id>(); for(ContentDocumentLink cdl : contentDocumentList){ contentDocumentId.add(cdl.ContentDocumentId); } List<ContentVersion> contentVersionList = [SELECT Id, VersionData, FileType, Title, FileExtension,Last_Updated_Date__c, Comments__c,Last_Updated__c,Baseline_Category__c,CreatedBy.Name, ContentDocument.ContentSize, CreatedDate, ContentDocumentId, ContentDocument.FileType FROM ContentVersion WHERE ContentDocumentId IN : contentDocumentId order by Last_Updated_Date__c DESC ]; return JSON.serialize(contentVersionList); }This is my method for which i want to write test class
Try Below Test Class Please Mark It As Best Answer If It Helps
Thank You!
here is your test class with 100% coverage.
don't forget mark it as best answer if it helps you.
Thank you
Thanks for sol but getting errors :
You Need To Insert Custom Setting For Account In Test Class As Shown in Below Example: