You need to sign in to do that
Don't have an account?
Method does not exist or incorrect signature in test class
I am writing some unit tests for one of my apex class methods that is defined as follows:
public with sharing class PostalClient { //snip public Dom.Document multiUpsertSubscribers(Map<String, List<Map<String, String>>> pListFields){ //snip } //snip }
My test method is defined as follows:
static testMethod void multiUpsertSubscribers(){ PostalClient.testingMode = true; String expectedResponse = '<?xml version="1.0" encoding="UTF-8"?><response />'; Long clientId = 42; String username = 'brandon'; String password = 'password'; PostalClient client = new PostalClient(clientId, username, password); List<Map<String, String>> fieldsList = null; Map<String, List<Map<String, String>>> listFields = new Map<String, List<Map<String, String>>>(); Map<String, String> fields0 = new Map<String, String>(); fields0.put('name', 'email'); fields0.put('value', 'test@eroi.com'); fields0.put('name', 'Favorite Ice Cream'); fields0.put('value', 'Rocky Road'); fieldsList = new List<Map<String, String>>(); fieldsList.add(fields0); listFields.put('The Hit List', fieldsList); Map<String, String> fields1 = new Map<String, String>(); fields1.put('name', 'email'); fields1.put('value', 'test2@eroi.com'); fields1.put('name', 'Favorite Ice Cream'); fields1.put('value', 'Chunky Monkey'); fieldsList = new List<Map<String, String>>(); fieldsList.add(fields1); listFields.put('The Other List', fieldsList); Dom.Document xml = null; String actualResponse = null; xml = postalClient.multiUpsertSubscribers(listFields); actualResponse = xml.toXmlString(); System.assertEquals(expectedResponse, actualResponse); }
The problematic line is:
xml = postalClient.multiUpsertSubscribers(listFields);
The error that I am given is: Error: Compile Error: Method does not exist or incorrect signature: postalClient.multiUpsertSubscribers(MAP:String,LIST:MAP:String,String) at line 333 column 15
This puzzles me since there is in fact a method with this signature but it is not being recognized in the test class. I suspect it might be choking on the nested collection as a parameter but it doesn't appear to violate any limitations that I know of. Any help would be appreciated.
Are you expecting that method to be static?
All Answers
Are you expecting that method to be static?
Serious face-palm. Thank you for catching that, i was a victim of cut and paste from one of my other test methods and neglected to see the variable name did not match. It's almost 5pm and I guess I just needed another set of eyes. My test passes now. Thanks again.