41 lines
1.4 KiB
OpenEdge ABL
41 lines
1.4 KiB
OpenEdge ABL
@isTest
|
|
public class AddAttachmentToProjectTest {
|
|
@isTest static void testAddAttachments() {
|
|
// Created test data
|
|
Opportunity opp = new Opportunity(Name = 'New Opp', StageName = 'Prospecting', CloseDate = Date.today());
|
|
insert opp;
|
|
|
|
ProjectDemo__c proj = new ProjectDemo__c(Opportunity_Name__c = opp.Id);
|
|
insert proj;
|
|
|
|
ContentVersion cv = new ContentVersion(
|
|
Title = 'New Content version',
|
|
PathOnClient = 'Test.txt',
|
|
VersionData = Blob.valueOf('Test Content')
|
|
);
|
|
insert cv;
|
|
|
|
Id cdId = [SELECT ContentDocumentId FROM ContentVersion WHERE Id = :cv.Id].ContentDocumentId;
|
|
|
|
ContentDocumentLink cdl = new ContentDocumentLink(
|
|
ContentDocumentId = cdId,
|
|
LinkedEntityId = opp.Id,
|
|
ShareType = 'V',
|
|
Visibility = 'AllUsers'
|
|
);
|
|
insert cdl;
|
|
|
|
// Calling the method to test
|
|
Test.startTest();
|
|
AddAttachementToProjectHandler.AddAttachments(new List<ProjectDemo__c>{proj});
|
|
Test.stopTest();
|
|
|
|
// Verifing the results
|
|
List<ContentDocumentLink> resultCdlList = [SELECT Id FROM ContentDocumentLink WHERE LinkedEntityId = :proj.Id];
|
|
System.assertEquals(1, resultCdlList.size());
|
|
|
|
|
|
|
|
}
|
|
|
|
} |