You need to sign in to do that
Don't have an account?
Jonathan Wolff 7
Test class for pdf creation Apex
Hello, could you help me with test class for my apex?
public class MonthlyReport4FDB{ @InvocableMethod(Label = 'MonthlyReport4FDB' description='') public static void MonthlyReport4FDB() { PageReference page = Page.MonthlyReport; Blob contentBlob = page.getContentAsPDF(); ContentVersion cv = new ContentVersion(); cv.VersionData = contentBlob; cv.Title = System.today().year() + '_' + System.today().month() + '_FDB_Alle_Aktivitaeten'; cv.PathOnClient = System.today().year() + '_' + System.today().month() + '_FDB_Alle_Aktivitaeten.pdf'; cv.Vertraulichkeitsstufe__c = 'Intern'; cv.Dokumentenklasse__c ='Anderes Dokument (nicht aufbewahrungspflichtig)'; insert cv; cv = [SELECT Id, ContentDocumentId FROM ContentVersion WHERE Id = :cv.Id LIMIT 1]; ContentDocumentLink cdl = new ContentDocumentLink(); cdl.ContentDocumentId = cv.ContentDocumentId; cdl.ShareType = 'I'; cdl.LinkedEntityId = '001b000000Zps12AAB'; insert cdl; } }
Hi Jonathan,
You have to create the required data for the page MonthlyReport, and call the class MonthlyReport4FDB.MonthlyReport4FDB();
Here is an example :
https://salesforce.stackexchange.com/questions/244788/how-do-i-write-an-apex-unit-test
https://salesforce.stackexchange.com/questions/244794/how-do-i-increase-my-code-coverage-or-why-cant-i-cover-these-lines
Thanks!