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
Phuc Nguyen 18Phuc Nguyen 18 

Test Class Error passing parameters to Class method

Trying to call a Class method from a test class:
Class UtilHelper
global class FeeWrapper { global List<Project__c> transToUpdate; } 

public static FeeWrapper PassingRentFee(Fee_Calculation__c Config, Project__c trans, List<Project__c> transToUpdate, Map<String, Fee_Mapping__c> m_Fee)



Test class
Map<String,Fee_Mapping__c > afMap = new Map<String,Fee_Mapping__c >( [ SELECT Id, Fee_Amount__c , _Fee_Basis__c , WO__c,Group__c,Type__c,Macro_Type__c FROM Fee_Mapping__c]); 

List<Fee_Calculation__c > feeRec = [ SELECT Id, Name FROM Fee_Calculation__c]; 

List<Project__c> projectRec = [ SELECT Id, Name FROM Project__c]

UtilHelper.PassingRentFee(feeRec[0],projectRec[0],projectRec[0],afMap);

Error is Method does not exist or incorrect signature
Any suggesitons are appreciated
P
Best Answer chosen by Phuc Nguyen 18
AbhinavAbhinav (Salesforce Developers) 
Hi Phuc

UtilHelper.PassingRentFee(feeRec[0],projectRec[0],projectRec[0],afMap);

Your third parameter is a record of project , not a List<Project__c>  as per the class List<Project__c> is required.
Please pass a list there  
UtilHelper.PassingRentFee(feeRec[0],projectRec[0],projectRec,afMap);


Hope it was helpful, Please mark it as best answer so that it can help others.

Thanks!


 

All Answers

AbhinavAbhinav (Salesforce Developers) 
Hi Phuc

UtilHelper.PassingRentFee(feeRec[0],projectRec[0],projectRec[0],afMap);

Your third parameter is a record of project , not a List<Project__c>  as per the class List<Project__c> is required.
Please pass a list there  
UtilHelper.PassingRentFee(feeRec[0],projectRec[0],projectRec,afMap);


Hope it was helpful, Please mark it as best answer so that it can help others.

Thanks!


 
This was selected as the best answer
Phuc Nguyen 18Phuc Nguyen 18
Totall missed that.  Thanks Abhinav
Suraj Tripathi 47Suraj Tripathi 47

Hi,

correct code:


List<Project__c> projectRec = [ SELECT Id, Name FROM Project__c] //this list is passed as third arguement
UtilHelper.PassingRentFee(feeRec[0],projectRec[0],projectRec,afMap);
 

Thank You