You need to sign in to do that
Don't have an account?
How to write a test class for the below method?
public class quoteFlowClass {
@InvocableMethod
Public static void attachPDF(List<string> quoteId){
Blob pdfBlob;
PageReference pdfPage = Page.QuoteGeneration;
pdfPage.getParameters().put('id',quoteId[0]);
pdfBlob = pdfPage.getContentAsPDF();
id quoteIdd = quoteId[0];
List<ContentDocumentLink> quotList = [SELECT ContentDocumentId FROM ContentDocumentLink WHERE LinkedEntityId =: quoteIdd];
integer m = quotList.isEmpty() ? 0 : quotList.size();
m=m+1;
Quote__c pdfParent = [SELECT Name FROM Quote__c WHERE Id = :quoteId[0]];
ContentVersion cv = new ContentVersion(
Title=pdfParent.Name+'-V'+m+'.pdf',
PathOnClient=pdfParent.Name+'-V'+m+'.pdf',
VersionData=pdfBlob
);
insert cv;
cv = [SELECT ContentDocumentId FROM ContentVersion WHERE Id = :cv.Id];
ContentDocumentLink cdl = new ContentDocumentLink(
ContentDocumentId = cv.ContentDocumentId,
LinkedEntityId = pdfParent.Id,
ShareType = 'I', // Inferred Share
Visibility = 'AllUsers'
);
insert cdl;
}
}
I tried doing my best, but not able to cover. This class is invoked from flows as a quick action