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
sfdc@isha.ax1814sfdc@isha.ax1814 

Test class error for batch class-Need urgent help

Hi Team,

I have below test class. and iam getting below error while excetuing this testclass.
Iam attaching here the error message . pls help me tofis this issue.
@isTest
// Test Class to execute SMXNominationProcessor Class
global class SMXNominationProcessorTest{
    public static void setTestResponseValues(Integer testCaseNum){
        if(testCaseNum == 1){
            SMXNominationProcessor.testHttpStatusCode = 200;
            SMXNominationProcessor.testHttpResponseXML = '<webserviceresponse><code>0</code><description></description><row value="success"></row></webserviceresponse>';
        }else if(testCaseNum  == 2){
            SMXNominationProcessor.testHttpStatusCode = 200;
            SMXNominationProcessor.testHttpResponseXML = '<webserviceresponse><code>0</code><description></description><row value="No Send Rule is applied for the provider"></row></webserviceresponse>';        
        }else if(testCaseNum  == 3){
            SMXNominationProcessor.testHttpStatusCode = 200;
            SMXNominationProcessor.testHttpResponseXML = '<webserviceresponse><code>-1</code><description></description><row value=""></row></webserviceresponse>';        
        }else if(testCaseNum  == 4){
            SMXNominationProcessor.testHttpStatusCode = 404;
            SMXNominationProcessor.testHttpResponseXML = '<webserviceresponse><code>-1</code><description></description><row value=""></row></webserviceresponse>';        
        }      
    }
 
@isTest
   static void testFeedbackUpdate(){   
       String strFeedbackID = prepareTestData();
       for(Integer i = 1; i<=4; i++){
           SMXNominationProcessorTest.setTestResponseValues(i);
           SMXNominationProcessor.processNomination(strFeedbackID);
       }
   }
     
    static String prepareTestData(){
        //Insert account data using ShGl_TestFactory
        Map<String, Object>  accMap = new Map<String, Object> {
        };
        Account acc = (Account) ShGl_TestFactory.createSObject(new Account(),accMap);
        insert acc;
        //Check for account creation
        system.assertNotEquals(null, acc.Id);
        system.assertNotEquals('', acc.Id);
        //Insert contact data using ShGl_TestFactory       
        Map<String, Object>  conMap = new Map<String, Object> {
            'AccountId' => acc.Id
        };
        Contact con = (Contact) ShGl_TestFactory.createSObject(new Contact(),conMap);
       insert con;
        //Check for Contact creation and associated with account
        system.assertNotEquals(null, con.Id);
        system.assertNotEquals('', con.Id);
        system.assertEquals(acc.Id, con.AccountId);
        //Insert case data using ShGl_TestFactory
        Map<String, Object>  csMap = new Map<String, Object> {
            'ContactId' => con.Id
        };
        Case cs = (Case) ShGl_TestFactory.createSObject(new Case(),csMap);
        insert cs;
        //Check for Case creation and associated with contact
        system.assertNotEquals(null, cs.Id);
        system.assertNotEquals('', cs.Id);
        system.assertEquals(con.Id, cs.ContactId);
        //Insert custom object feedback__c
        Feedback__c fbk = new Feedback__c(Name = 'TEST_CRM_12345', Contact__c = con.Id, DataCollectionId__c = '123456', Status__c = 'Test_Nominated', DataCollectionName__c = 'Test Survey Name', PrimaryScore__c = 9, PrimaryComment__c = 'Test comment', StatusDescription__c = 'Test Description', Case__c = cs.Id);
        insert fbk;
        //Check for Survey record Creation with Name, SurveyID, SurveyName and Staus not BLANK
        system.assertNotEquals(null, fbk.Id);
        system.assertNotEquals('', fbk.Id);
        system.assertEquals(con.Id, fbk.Contact__c);
        system.assertNotEquals('', fbk.Name);
        system.assertNotEquals(null, fbk.Name);
        system.assertNotEquals('', fbk.DataCollectionId__c);
        system.assertNotEquals(null, fbk.DataCollectionId__c);
        system.assertNotEquals('', fbk.DataCollectionName__c);
        system.assertNotEquals(null, fbk.DataCollectionName__c);
        system.assertNotEquals('', fbk.Status__c);
        system.assertNotEquals(null, fbk.Status__c);
        return fbk.Name;
    }  
}

User-added image

Regards,
ISHA
SwethaSwetha (Salesforce Developers) 
HI Isha,

"ORA-01013: user requested cancel of current operation" is an error which come up for a number of reasons. One of the reasons being the batch apex. However, you may also see it due to issues with Indexes.

Please consider optimizing your SOQL query in batch class to fix the issue.

Related article: https://help.salesforce.com/articleView?id=000330118&language=en_US&type=1&mode=1

https://help.salesforce.com/articleView?id=000336230&type=1&language=en_US&mode=1

https://help.salesforce.com/articleView?language=en_US%C2%A0&type=1&mode=1&id=000325247

https://help.salesforce.com/articleView?id=000336230&language=en_US&type=1&mode=1
 
Hope this helps you. Please mark this answer as best so that others facing the
same issue will find this information useful.
 
Thank you