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
Kyle_at_boxKyle_at_box 

method does not exist / incorrect signature

I have a similar issue to this posting here, although I'm still not able to figure out what's causing this error to show up: 

 

http://forums.sforce.com/t5/Apex-Code-Development/Method-does-not-exist-or-incorrect-signature-in-test-class/m-p/187840

 

I've written a method that takes a list of leads, iterates across it and changes certain fields, updates the appropraite records, then returns the list.  

 

public with sharing class LeadUpdate {

       public static List<Lead> changeSource(List<Lead> boxlist){
       
        for(lead a:boxlist){
        
        if (a.Source_Detail_Most_Recent__c == '??') {
         a.Source_Detail__c = '';
         a.LeadSource = 'REP NEEDS TO ASK';
          
         }       try {update boxlist;} catch ( System.DmlException e) {
 
            system.assert(e.getMessage().contains('irst error: FIELD_CUSTOM_VALIDATION_EXCEPTION, A lead with this email address already exists'),
                e.getMessage());           
 
    }
    return boxlist;
       }
}

 

 

I'll be activating this through a VF page, so my idea is just to pass a list that is populated by a SQL query into the above method.  However, when testing this method (there are actually ~100 if statements, though I'm just testing on the first one for now) I'm running into this error:

 

"Method does not exist or incorrect signature: LeadUpdate.chagneSource(List<Lead>)

 

My test looks like this:

 

 

@isTest
private class LeadUpdateTest {

	private static testmethod void updatetest(){
		List<Lead> boxlist = new List<Lead>();
		for(integer j = 0; j < 10; j++){
			lead a = new lead (LastName = 'test' + j, Source_Detail__c = '??', LeadSource = '');
			boxlist.add(a);
		}
		insert boxlist;
		
		LeadUpdate lu = new LeadUpdate();
		List<Lead> testolist = null;
		testolist = LeadUpdate.changeSource(boxlist);
		for(lead a: testolist){
			system.assertEquals('', a.Source_Detail__c);
			system.assertEquals('REP NEEDS TO ASK', a.LeadSource);
		}
	}

}

 

 

 

any ideas?  thank you all!

 

 

 

 

 

 

VPrakashVPrakash

Try this 

 

@isTest
private class LeadUpdateTest {

	private static testmethod void updatetest(){
		List<Lead> boxlist = new List<Lead>();
		for(integer j = 0; j < 10; j++){
			lead a = new lead (LastName = 'test' + j, Source_Detail__c = '??', LeadSource = '');
			boxlist.add(a);
		}
		insert boxlist;
		
		LeadUpdate lu = new LeadUpdate();
		List<Lead> testolist = null;
		testolist = lu.changeSource(boxlist);
		for(lead a: testolist){
			system.assertEquals('', a.Source_Detail__c);
			system.assertEquals('REP NEEDS TO ASK', a.LeadSource);
		}
	}

}
Kyle_at_boxKyle_at_box
Hi V, Thanks for the reply! That doesn't seem to be doing the trick. I'm getting this now: Save error: Method does not exist or incorrect signature: [LeadUpdate].changeSource(LIST)