function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
roshrosh 

Please help me to write test class for this?? its an urgent

public class Tpm_SchemeCommunicationHandler {
    @AuraEnabled(cacheable=true)
    public static void sendSMS(String schPdfId) {
        //VConnect_SchemePDFHandler.pdfLink(schPdfId);
        //VConnect_SchemePDFHandler.sendSMS(schPdfId);
        System.debug('schPdfId'+schPdfId);
        Id jobId = Database.executeBatch(new VConnect_SchemeSMSBatch(schPdfId)); // optional batch size can be provides as well.
        System.debug('jobId'+jobId);
    }
}
Best Answer chosen by rosh
roshrosh
its not working

All Answers

AnkaiahAnkaiah (Salesforce Developers) 
Hi Roshni,

try with below code.
 
@istest 
public class Tpm_SchemeCommunicationHandler_Test{
 
    static testMethod void testAttachments()
    {

//Replace the account with an object which is used in your code.
        Account acc=new Account(Name='Acme Inc');
        insert acc;
 
        ContentVersion contentVersion = new ContentVersion(
            Title = 'Penguins',
            PathOnClient = 'Penguins.pdf',
            VersionData = Blob.valueOf('Test Content'),
            IsMajorVersion = true
        );
        insert contentVersion;    
        List<ContentDocument> documents = [SELECT Id, Title, LatestPublishedVersionId FROM ContentDocument];
		
		//create ContentDocumentLink  record 
        ContentDocumentLink cdl = New ContentDocumentLink();
        cdl.LinkedEntityId = acc.id;
        cdl.ContentDocumentId = documents[0].Id;
        cdl.shareType = 'V';
        insert cdl;
		
		Tpm_SchemeCommunicationHandler.sendSMS(contentVersion.id);
		}
		
}

If this helps, please mark it as best answer.

Thanks!!


 
roshrosh
its not working
This was selected as the best answer
roshrosh
I only have to make change in object.. rest of all its same?