You need to sign in to do that
Don't have an account?
Mahesh Tandan 6
test a method
hi i'm here
please can somebody help me in test class
this is my extension
How can I test this method
please can somebody help me in test class
this is my extension
public class addContactExtension { public List<Id> getFileId() { List<Id> ListOfImagesIds= new List<Id>();//store files/images Ids for(ContentDocumentLink CDL : [Select ContentDocument.LatestPublishedVersionId from ContentDocumentLink where LinkedEntityId IN(select Id from Campaign where Id=:camId.id) order by ContentDocument.CreatedDate ASC]){ ListOfImagesIds.add(CDL.ContentDocument.LatestPublishedVersionId); //System.debug('Total Id'+ ListOfImagesIds); } return ListOfImagesIds; }//dynamically Images Fetching from Files Ends here. }
How can I test this method
As per your, my under standing was Content document is shared with the Campaign) so please records in order in test class.
First - Create Campaign record
2nd - Create ContentDocument
3rd - Create ContentDocumentLink
Please create ablve records in stepwise and call this main class for test coverage. Foe more details refer below link (ContentDocument & ContentDocumentLink)
https://developer.salesforce.com/docs/atlas.en-us.api.meta/api/sforce_api_objects_contentdocumentlink.htm
Regards,
Raghu
skype :raghup101
Try this code.Kindly modify according to requirements.
Hope this helps you
Let me know if this helps you. Kindly mark it as solved so that it may help others in future.
Thanks and Regards