0

I am trying to write a test class so that I can send the following trigger live in our production system:

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();
    }    
}

Heres the code for the Apex Test Class that I've written:

@isTest
public class TestUpdateDocTitleFileExt {
    @isTest static void TestUpdateDocTitleFileExt() {

        // Create a case
        Case cse = new Case(Subject='Test Case For Apex Trigger');
        insert cse;

        ContentVersion contentVersionInsert = new ContentVersion(
                            Title = 'Test',
                            PathOnClient = 'Test.jpg',
                            VersionData = Blob.valueOf('Test Content Data'),
                            IsMajorVersion = true);
        insert contentVersionInsert;

        // Test INSERT
        ContentVersion contentVersionSelect = [SELECT Id, Title, ContentDocumentId FROM ContentVersion WHERE Id = :contentVersionInsert.Id LIMIT 1];
        List<ContentDocument> documents = [SELECT Id, Title, LatestPublishedVersionId FROM ContentDocument];
        System.assertEquals(documents.size(), 1);

        // Perform test
        Test.startTest();
        Test.stopTest();
    }
}

This all saves fine - but I'm getting the below error

"INVALID_ARGUMENT_TYPE" error, "argument is null or invalid", "Class.textUpdateCocTitleFileExt line 10, column 1"

when I try and run it as a test.

I've had a really good google of this error and have tried a load of code changes out but whatever I try I just can't ever seem to get round this particular error on line 10.

Anyone got any thoughts to help me get a pass on it?

  • Please highlight the line which is giving error. Error is from textUpdateCocTitleFileExt , I don't see that class – Muzammil Bajaria Aug 7 at 15:41
0

not sure why this works and yours doesn't, but this works for me:

        String clientPath = 'photo_1.jpg';
    ContentVersion cv = new ContentVersion(title='test',versiondata=Blob.valueOf('test'),pathonclient=clientPath);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.