19626
2023-10-23 1727a4f4d02e429475608e60f142a63bc24127bc
force-app/main/default/classes/eSignFormAttachmentControllerTest.cls
@@ -108,28 +108,67 @@
       eSignForm.DNName__c = '112233';
       insert eSignForm;
        list<Attachment> attachmentList = new list<Attachment>();
        Attachment attach=new Attachment();
        attach.Name='A-65224941-20200923--1.docx';
        Blob bodyBlob=Blob.valueOf('Unit Test Attachment Body');
        attach.body=bodyBlob;
        attach.parentId=eSignForm.id;
        attach.ContentType = 'application/pdf';
        attachmentList.add(attach);
        Attachment attach1=new Attachment();
        attach1.Name='H-65224945-20200928--15.jpg';
        Blob bodyBlob1=Blob.valueOf('Unit Test Attachment Body');
        attach1.body=bodyBlob1;
        attach1.parentId=eSignForm.id;
        attach1.ContentType = 'application/pdf';
        attachmentList.add(attach1);
        insert attachmentList;
        Test.startTest();
        ContentVersion version = new ContentVersion(
            Title = 'A-65224941-20200923--1.docx',
            VersionData = EncodingUtil.base64Decode('test'),
            ContentLocation = 's',
            PathOnClient = 'test.txt'
        );
        insert version;
        version = [select ContentDocumentId from ContentVersion where Id =: version.Id];
        ContentDocumentLink link = new ContentDocumentLink();
        link.ContentDocumentId = version.ContentDocumentId;
        link.LinkedEntityId = eSignForm.id;
        link.ShareType = 'I';
        link.Visibility = 'AllUsers';
        insert link;
        ContentVersion version1 = new ContentVersion(
            Title = 'H-65224945-20200928--15.jpg',
            VersionData = EncodingUtil.base64Decode('test'),
            ContentLocation = 's',
            PathOnClient = 'test.txt'
        );
        insert version1;
        version1 = [select ContentDocumentId from ContentVersion where Id =: version1.Id];
        ContentDocumentLink link1 = new ContentDocumentLink();
        link1.ContentDocumentId = version1.ContentDocumentId;
        link1.LinkedEntityId = eSignForm.id;
        link1.ShareType = 'I';
        link1.Visibility = 'AllUsers';
        insert link1;
        // list<Attachment> attachmentList = new list<Attachment>();
        // Attachment attach=new Attachment();
        // attach.Name='A-65224941-20200923--1.docx';
        // Blob bodyBlob=Blob.valueOf('Unit Test Attachment Body');
        // attach.body=bodyBlob;
        // attach.parentId=eSignForm.id;
        // attach.ContentType = 'application/pdf';
        // attachmentList.add(attach);
        // Attachment attach1=new Attachment();
        // attach1.Name='H-65224945-20200928--15.jpg';
        // Blob bodyBlob1=Blob.valueOf('Unit Test Attachment Body');
        // attach1.body=bodyBlob1;
        // attach1.parentId=eSignForm.id;
        // attach1.ContentType = 'application/pdf';
        // attachmentList.add(attach1);
        // insert attachmentList;
        PageReference page = new PageReference('/apex/eSignFormAttachment?parentId='+eSignForm.id);
        System.Test.setCurrentPage(page);
        eSignFormAttachmentController eSign = new eSignFormAttachmentController();
        eSign.init();
        Test.stopTest();
    }
}