You need to sign in to do that
Don't have an account?
Angadi VC
test class coverage issue on contentdocument and contentdocumentlink
Hi,
I have 2 triggers:
1.Contentdocument 2.Contentdocumentlink
which counts the no of attachments attached in lightning and roll it up to parent object.But i have an issue in test class coverage.
It shows:Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, FilesRollupCount: execution of AfterInsert caused by: System.QueryException: Implementation restriction: ContentDocumentLink requires a filter by a single Id on C
please help me with this.Thanks in advance.
Below is my test class:
@isTest
public class ContentDocTrigger_Test{
private static Account dis1;
static testmethod void method_1(){
dis1 = Initial_Test_Data.createAccount('test Account1','Distributor');
dis1.Contact_Number_Mobile__c ='7259582222';
dis1.Party_Type__c = 'Distributor';
dis1.Status__c = 'Existing';
dis1.Ramco_ID__c = 'abc123';
insert dis1;
Promotion__c prm = new Promotion__c();
prm.Date__c=System.today();
prm.Type__c='Dealers Meet';
prm.Total_Expenses__c = 1000;
prm.Total_no_of_attendees__c = 0;
prm.State__c = 'Karnataka';
prm.Location__c = 'BTM';
prm.Distributor__c=dis1.id;
insert prm;
system.assert(prm.id != null);
ContentVersion cver = new ContentVersion();
cver.ContentLocation = 'S';
cver.VersionData = Blob.valueOf('Unit Test Attachment Body');
cver.PathOnClient = 'Retailer.png';
cver.Title = 'Retailer Image';
insert cver;
ContentVersion testContent = [SELECT id, ContentDocumentId FROM ContentVersion where Id = :cver.Id];
Promotion__c promo = [select id from Promotion__c where id=:prm.id];
//create ContentDocumentLink record
ContentDocumentLink cdl = New ContentDocumentLink();
cdl.LinkedEntityId = 'a0a2F000002whylQAA';
cdl.ContentDocumentId = testcontent.ContentDocumentId;
cdl.shareType = 'V';
insert cdl;
List<ContentDocument> cdoc = [SELECT Id, Title, LatestPublishedVersionId FROM ContentDocument where id=:testcontent.ContentDocumentId];
delete cdoc;
}
}
I have 2 triggers:
1.Contentdocument 2.Contentdocumentlink
which counts the no of attachments attached in lightning and roll it up to parent object.But i have an issue in test class coverage.
It shows:Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, FilesRollupCount: execution of AfterInsert caused by: System.QueryException: Implementation restriction: ContentDocumentLink requires a filter by a single Id on C
please help me with this.Thanks in advance.
Below is my test class:
@isTest
public class ContentDocTrigger_Test{
private static Account dis1;
static testmethod void method_1(){
dis1 = Initial_Test_Data.createAccount('test Account1','Distributor');
dis1.Contact_Number_Mobile__c ='7259582222';
dis1.Party_Type__c = 'Distributor';
dis1.Status__c = 'Existing';
dis1.Ramco_ID__c = 'abc123';
insert dis1;
Promotion__c prm = new Promotion__c();
prm.Date__c=System.today();
prm.Type__c='Dealers Meet';
prm.Total_Expenses__c = 1000;
prm.Total_no_of_attendees__c = 0;
prm.State__c = 'Karnataka';
prm.Location__c = 'BTM';
prm.Distributor__c=dis1.id;
insert prm;
system.assert(prm.id != null);
ContentVersion cver = new ContentVersion();
cver.ContentLocation = 'S';
cver.VersionData = Blob.valueOf('Unit Test Attachment Body');
cver.PathOnClient = 'Retailer.png';
cver.Title = 'Retailer Image';
insert cver;
ContentVersion testContent = [SELECT id, ContentDocumentId FROM ContentVersion where Id = :cver.Id];
Promotion__c promo = [select id from Promotion__c where id=:prm.id];
//create ContentDocumentLink record
ContentDocumentLink cdl = New ContentDocumentLink();
cdl.LinkedEntityId = 'a0a2F000002whylQAA';
cdl.ContentDocumentId = testcontent.ContentDocumentId;
cdl.shareType = 'V';
insert cdl;
List<ContentDocument> cdoc = [SELECT Id, Title, LatestPublishedVersionId FROM ContentDocument where id=:testcontent.ContentDocumentId];
delete cdoc;
}
}