You need to sign in to do that
Don't have an account?
Bob_z
Test Class error help for visualforce extension controller
I have an apex extension controller that I'm trying to send to my porduction org but i am getting the following error while validating from the inbound changeset.
Here is the test class and my apex extension controller
Controller:
System.ListException: List index out of bounds: 1 Stack Trace: Class.AccountMapCtrl.buildAdditionalWhere: line 190, column 1 Class.AccountMapCtrl.getAccounts: line 84, column 1 Class.AccountMapCtrlTest.testAll: line 26, column 1
Here is the test class and my apex extension controller
@isTest(SeeAllData=true) public class AccountMapCtrlTest{ static testmethod void testAll(){ Account acc = new Account( Name = 'testAcc', Description = 'test description', Industry = 'information tech', Type = 'Press', ShippingLatitude = 22.6211, ShippingLongitude = 88.4649, RecordTypeId = Account.SObjectType.getDescribe().getRecordTypeInfosByName().get('Site').getRecordTypeId() ); insert acc; AccountMapCtrl.describePickList('AccountSource'); AccountMapCtrl.getFields('Account', 'AccountMap_Filters'); List<AccountMapCtrl.Field> fields = new List<AccountMapCtrl.Field>(); Schema.FieldSet fieldset = Schema.SObjectType.Account.fieldSets.getMap().get('AccountMap_Filters'); for(Schema.FieldSetMember member : fieldset.getFields()){ fields.add(new AccountMapCtrl.Field(member)); } AccountMapCtrl.getAccounts(Json.serialize(fields), null); AccountMapCtrl.getVendors(Json.serialize(fields), null); AccountMapCtrl.getManagers(); AccountMapCtrl.getFieldCSV('Account'); } }
Controller:
Public Class AccountExtensionController{ private Account acc; public List<Bids_Sent__c> bidsList {get;set;} public Map<String,List<Site_Bid_Details__c>> bidsMap {get;set;} public AccountExtensionController(ApexPages.StandardController sc){ acc = (Account)sc.getRecord(); bidsList = new List<Bids_Sent__c>(); bidsList = [SELECT Id,IsAddedToPDF__c,Customer__r.Service_Agreement_Verbiage__c,Site__c,Site__r.Contract_Start_Date__c,Site__r.Contract_End_Date__c,Site__r.Customer_Location_ID__c,Service_Year__c,Customer__r.Contract_Start_Date__c,Name,Customer__r.Contract_End_Date__c,Site__r.Name,Customer__r.Name,Primary_Contact__r.FirstName,Site__r.BillingCity,Site__r.BillingState,Site__r.BillingStreet,Site__r.BillingPostalCode FROM Bids_Sent__c WHERE Awarded__c =: acc.Id AND IsAddedToPDF__c=true]; Set<Id> bidId = new Set<Id>(); for(Bids_Sent__c bs : bidsList){ bidId.add(bs.Id); } bidsMap = new Map<String,List<Site_Bid_Details__c>> (); for(Site_Bid_Details__c bd : [SELECT Id, Bid_Name__r.Name,Site__c,Contract_Start_Month__c,Site__r.Customer_Location_ID__c,Cost__c,Customer__r.Contract_Month__c,Increment__c,Total__c,Price__c,Scope__c,Bid_Name__r.Service_Type__c,Number_of_Months__c,Retainer_Fee__c,Monthly_Payment__c,UOM__c FROM Site_Bid_Details__c WHERE Bid_Name__c IN : bidId]){ if(bidsMap.containsKey(bd.Bid_Name__r.Name)){ System.debug('CONTAINS KEY: ' + bd.Bid_Name__r.Name); bidsMap.get(bd.Bid_Name__r.Name).add(bd); } else { System.debug('CREATE: ' + bd.Bid_Name__r.Name); bidsMap.put(bd.Bid_Name__r.Name,new List<Site_Bid_Details__c>{bd}); } } } }