• Sharmila Sahu 20
  • NEWBIE
  • 0 Points
  • Member since 2020

  • Chatter
    Feed
  • 0
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 0
    Replies
Is it possible to change License type in profile from Salesforce to Salesforce Platform while cloning profile. From UI, It is not possible. I even tried by changing userLicense type from salesforce  to salesforce platform <userLicense>Salesforce Platform</userLicense> in retrieved XML file and tried to deploy it through workbench. But ,I got below error while deployment in workbench:

problem: Cannot update: userLicense
We have one trigger in org on sobject type Delete Content Document. I am not sure what is this object and how to create its record in test class.I am not able to write test class for it.

Please find below code of trigger:
trigger DeleteContentDocumentTrigger on Delete_Content_Document__e (after insert) {
    List<ContentDocument> contentDocumentList = new List<ContentDocument>();
    List<Attachment> attachmentList = new List<Attachment>();
    List<eLicense_Attachment__c> eLicenseAttachmentList = new List<eLicense_Attachment__c>();
       
    for (Delete_Content_Document__e event : Trigger.New) {
        if (event.Content_Document_Id__c != null) {
            contentDocumentList.add(new ContentDocument(id = event.Content_Document_Id__c));
        }
        if (event.Attachment_Id__c != null) {
            attachmentList.add(new Attachment(id = event.Attachment_Id__c));
        }
        if (event.eLicense_Attachment_Id__c != null) {
            eLicenseAttachmentList.add(new eLicense_Attachment__c(id = event.eLicense_Attachment_Id__c));
        }
   }
    
    delete contentDocumentList;
    delete attachmentList;
    delete eLicenseAttachmentList;
}

Please find below test class:
@isTest
public class DeleteContentDocumentTriggerTest {
    
    public static testmethod void test_contentDoc(){
        Test.startTest();
          //try{
    Global_Settings__c globalSettings = new Global_Settings__c(Name = 'Default', Disable_Triggers__c = true);
        if(globalSettings != null) insert globalSettings;
        Account acc = OH_Utility_UnitTestData.createTestAccount();
        insert acc;
        Blob beforeblob=Blob.valueOf('Unit Test Attachment Body');

        ContentVersion cv = new ContentVersion();
        cv.title = 'test content trigger';      
        cv.PathOnClient ='test';           
        cv.VersionData =beforeblob;          
        insert cv;             
                                                
         List<ContentDocument> documents = [SELECT Id, Title, LatestPublishedVersionId FROM ContentDocument];

        ContentDocumentLink contentlink=new ContentDocumentLink();
        contentlink.LinkedEntityId=acc.id;
        contentlink.ShareType= 'V';
        contentlink.ContentDocumentId=documents[0].Id;
        contentlink.Visibility = 'AllUsers'; 
        insert contentlink;
    
      
         delete documents;
        
         delete contentlink;
         Delete_Content_Document__e dc = new Delete_Content_Document__e();
       // EventBus.publish(dc);
            
        //}
        //catch(Exception e){}
        Test.stopTest();
    //insert dc;
    }

}
It is not covering trigger at all.
I have created a schedular class but it is not showing while trying to schedule it through UI.

Please find below batch and schedular class :
Batch Class:
public class deletePendingServiceReq implements Database.Batchable<sObject>{
    public static Date lastYear = Date.today().addMonths(-10);
    public static string statusVal='Pending';
    public Database.QueryLocator start(Database.BatchableContext context)
    {
        return Database.getQueryLocator('Select ID,createdDate,MUSW__Status__c from MUSW__Application2__c where CreatedDate < :lastYear and MUSW__Status__c=:statusVal');
    }

    public void execute(Database.BatchableContext context, List<SObject> records)
    {
        //System.debug('records to be deleted'+records);
        delete records;
    }
    
    public void finish(Database.BatchableContext BC){}   
}

Schedular:
public class deletePendingServiceReqSchedular implements Schedulable {
    
     public void execute(SchedulableContext ctx) 
    {
        Database.executeBatch(new deletePendingServiceReq());
    }

}

It is working if I am scheduling it through developer console:
System.schedule('Scheduled Job 1', '0 54 * * * ?', new deletePendingServiceReqSchedular());

But it is not showing in list of schedulable class when I am trying to schedule it through UI. 
I am system admin.
SetUp-->Apex Class-->Schedule Class
User-added image
We have one trigger in org on sobject type Delete Content Document. I am not sure what is this object and how to create its record in test class.I am not able to write test class for it.

Please find below code of trigger:
trigger DeleteContentDocumentTrigger on Delete_Content_Document__e (after insert) {
    List<ContentDocument> contentDocumentList = new List<ContentDocument>();
    List<Attachment> attachmentList = new List<Attachment>();
    List<eLicense_Attachment__c> eLicenseAttachmentList = new List<eLicense_Attachment__c>();
       
    for (Delete_Content_Document__e event : Trigger.New) {
        if (event.Content_Document_Id__c != null) {
            contentDocumentList.add(new ContentDocument(id = event.Content_Document_Id__c));
        }
        if (event.Attachment_Id__c != null) {
            attachmentList.add(new Attachment(id = event.Attachment_Id__c));
        }
        if (event.eLicense_Attachment_Id__c != null) {
            eLicenseAttachmentList.add(new eLicense_Attachment__c(id = event.eLicense_Attachment_Id__c));
        }
   }
    
    delete contentDocumentList;
    delete attachmentList;
    delete eLicenseAttachmentList;
}

Please find below test class:
@isTest
public class DeleteContentDocumentTriggerTest {
    
    public static testmethod void test_contentDoc(){
        Test.startTest();
          //try{
    Global_Settings__c globalSettings = new Global_Settings__c(Name = 'Default', Disable_Triggers__c = true);
        if(globalSettings != null) insert globalSettings;
        Account acc = OH_Utility_UnitTestData.createTestAccount();
        insert acc;
        Blob beforeblob=Blob.valueOf('Unit Test Attachment Body');

        ContentVersion cv = new ContentVersion();
        cv.title = 'test content trigger';      
        cv.PathOnClient ='test';           
        cv.VersionData =beforeblob;          
        insert cv;             
                                                
         List<ContentDocument> documents = [SELECT Id, Title, LatestPublishedVersionId FROM ContentDocument];

        ContentDocumentLink contentlink=new ContentDocumentLink();
        contentlink.LinkedEntityId=acc.id;
        contentlink.ShareType= 'V';
        contentlink.ContentDocumentId=documents[0].Id;
        contentlink.Visibility = 'AllUsers'; 
        insert contentlink;
    
      
         delete documents;
        
         delete contentlink;
         Delete_Content_Document__e dc = new Delete_Content_Document__e();
       // EventBus.publish(dc);
            
        //}
        //catch(Exception e){}
        Test.stopTest();
    //insert dc;
    }

}
It is not covering trigger at all.