• Michael Rothwell
  • NEWBIE
  • 0 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 0
    Replies
Hi,

I am trying to disable one of our triggers but a test class has started throwing an error.
 
System.ListException: List index out of bounds: 0
Stack Trace: Class.tstctrlAgentCaseToAccount.testctrlAgentCaseToAccount: line 78, column 1
Here is the test class
@isTest(SeeAllData=true)
public class tstctrlAgentCaseToAccount{

    public static testMethod void testctrlAgentCaseToAccount() {
        Test.startTest();
        
        Id agentRecTypeId =  [Select Id, Name from recordtype where sObjecttype = 'Account' and name = 'Agent Organisation Record'].Id;
        
        user u = [Select Id from user where Division_Role__c = 'HE' limit 1];
        System.runAs(u) 
        {
            Test.setMock(WebServiceMock.class, new WebCADAgentPushServiceMockImpl());
            
            list<account> accountList = new list<account>();
            account acc = new account();
            acc.name='testcasetoagent';
            acc.recordtypeId=agentRecTypeId;
            acc.BillingCity = 'test';
            acc.BillingCountry = 'test';
            acc.BillingState = 'test';
            acc.BillingStreet = 'test';
            acc.BillingPostalCode = '43213';
            acc.Fax = '4321234';
            acc.Name = 'xdfg';
            acc.AKA_Name__c = 'test';
            acc.Phone = '4534534';
            acc.Website = 'test.com';
            accountList.add(acc);
            insert accountList;
            
            Case c = new Case();
            c.Status = 'test';
            c.Company_Name__c = 'xdfg';
            c.Billing_Street_Address__c = 'test1';
            c.BillingCity__c = 'test1';
            c.Billing_State__c = 'test1';
            c.Billing_Postcode__c = 'test1';
            c.Billing_Country__c = 'test';
            c.Fax__c = '34523134';
            c.Phone__c = '523452345';
            c.Website__c = 'test1';
            c.Business_Registration_Number__c = '654356';
            c.Start_Year_Agent__c = '2013';
            c.No_of_Counsellors__c = '2';
            c.Title_Corr__c = 'test1';
            c.First_Name__c = 'test1';
            c.Family_Name__c = 'test1';
            c.Position_job_title__c = 'test1';
            c.Direct_telephone__c = '768578565';
            c.Email__c = 'test1@test.com';
            c.Mobile__c = '8765467';
            c.Title_Add__c = 'test2';
            c.First_Name_Add__c = 'test2';
            c.Family_Name_Add__c = 'test2';
            c.Position_job_title_Add__c = 'test2';
            c.Direct_telephone_Add__c = '13563473';
            c.Email_Add__c = 'test2@test.com';
            c.Mobile_Add__c = '888876555';
            c.Bank_Name__c = 'test';
            c.Bank_Account_Name__c = 'test';
            c.Bank_Account_Number__c = 'test';
            c.Bank_Sort_Code__c = 'test';
            c.Bank_Address_1__c = 'test';
            c.Bank_Address_2__c = 'test';
            c.Bank_City__c = 'test';
            c.Bank_Postal_Code__c = 'test';
            c.Bank_Country__c = 'test';
            insert c;
            
            
            //Maintain Portfolio page
            PageReference pageRef = Page.casetoaccount;
            Test.setCurrentPage(pageRef);
            ApexPages.currentPage().getParameters().put('caseid', c.Id);
            ctrlAgentCaseToAccount controller = new ctrlAgentCaseToAccount(); 
            //Select matching account
            List<ctrlAgentCaseToAccount.accountWrapper> tempAccSearchList = controller.getsimilarAccounts();
            tempAccSearchList[0].selected = true;
            controller.setsimilarAccounts(tempAccSearchList);
            pageRef = controller.createNew();
            pageRef = controller.mergeAccounts();
            List<ctrlAgentCaseToAccount.mergeWrapper> tempMergeList = controller.getmergeList();
            for(ctrlAgentCaseToAccount.mergeWrapper mw: tempMergeList)
                mw.overrideExisting = true;
            controller.setmergeList(tempMergeList);
            pageRef = controller.finalMerge();
            pageRef = controller.cancel();
            
            
        }
        Test.stopTest();
    }
}

Any suggestions?

Thanks,
Michael