You need to sign in to do that
Don't have an account?
Hanna Bergsma
Please help me!! Trying to write a test class for ContentVersion after insert trigger
I've been at this for three days, I've read 300 blogs, nothing at all has gotten me even 1% test coverage on my simple trigger that updates ownerid on content version insert.
I am totally defeated.
The closest i've got is below, its giving me a "
System.InvalidParameterValueException: Provide the ID of a test-context sObject as the first parameter for setCreatedDate()." error
I am totally defeated.
trigger ConDoc on ContentVersion (after insert) { List<ContentVersion> conver = [SELECT Id, Title, OwnerId FROM ContentVersion WHERE Id IN: Trigger.newMap.keySet()]; for (ContentVersion CV: conver){ CV.OwnerId= '005F0000002QTR2'; } update conver; }
The closest i've got is below, its giving me a "
System.InvalidParameterValueException: Provide the ID of a test-context sObject as the first parameter for setCreatedDate()." error
@isTest public class Test_ConDocTrigger{ static testMethod void contentDoc() { list<ContentVersion>conver = new list<ContentVersion>(); //ContentDocument cd = [SELECT Id FROM ContentDocument ]; ContentVersion cv = new ContentVersion(); //cv.ContentDocumentId = '069M0000000Tpig'; cv.Title ='con'; conver.add(cv); test.setCreatedDate(cv.Id, DateTime.now()); insert cv; } }
trigger updateDocTitleFileExt on ContentDocumentLink (after insert) { for (ContentDocumentLink li : Trigger.new) { Map<String, Object> params = new Map<String, Object>(); params.put('content_doc_link_id', li.Id); Flow.Interview.GIS_Design_Update_File_Title updDocTitleFileExt = new Flow.Interview.GIS_Design_Update_File_Title(params); updDocTitleFileExt.start();