i have below code in my apex class
global class Payment implements Comparable{
public string id;
public string YearQ;
public string YearMo;
public Date asOf;
public decimal payment = 0;
public decimal revenue = 0;
public decimal attritionRate = 0;//DE420
public decimal payOnRevenue = 0;//DE 420
//only used by branch group sort (compareTo) to provide 0 values for missing payments
public Payment() {
}
public Payment(PODA_Exhibit_Payment__c pmt) {
this.id = pmt.id;
this.YearQ = pmt.PODA_Contracted_Agency_Payment__r.YearQrt__c;
this.YearMo = PODA_Util.getYearMoFromYearQ(this.YearQ);
this.payment = pmt.Total_Payment__c;
this.revenue = pmt.Total_Flown_Revenue__c;
// DE 420 - Gain Calculator 9/9/14
this.attritionRate = pmt.Attrition_Rate__c;
this.payOnRevenue = pmt.Pay_On_Revenue__c;
}
public Payment(PODA_Branch_Payment_Summary__c pmt) {
this.id = pmt.id;
this.YearQ = pmt.YearQrt__c;
this.YearMo = PODA_Util.getYearMoFromYearQ(this.YearQ);
this.payment = pmt.Total_Payment__c;
this.revenue = pmt.Total_Flown_Revenue__c;
}
public Payment(PODA_Branch_Exhibit_Payment__c pmt) {
this.id = pmt.id;
this.YearQ = pmt.YearQrt__c;
this.YearMo = PODA_Util.getYearMoFromYearQ(this.YearQ);
this.payment = pmt.Total_Payment__c;
this.revenue = pmt.Total_Flown_Revenue__c;
}
public void addPayment(PODA_Branch_Payment_Summary__c pmt) {
this.payment += pmt.Total_Payment__c;
this.revenue += pmt.Total_Flown_Revenue__c;
}
public void addPayment(PODA_Branch_Exhibit_Payment__c pmt) {
this.payment += pmt.Total_Payment__c;
this.revenue += pmt.Total_Flown_Revenue__c;
}
public void addPayment(PODA_Exhibit_Payment__c pmt) {
this.payment += pmt.Total_Payment__c;
this.revenue += pmt.Total_Flown_Revenue__c;
this.payOnRevenue += pmt.Pay_On_Revenue__c;
}
public Integer compareTo(Object compareTo) {
Payment compareToHP = (Payment)compareTo;
return this.YearQ.compareTo(compareToHP.YearQ);
}
}
/// Payments is the inner class in the main apex class and i want to write test class for this.
I am facing issue while writing test for below method in the above code
public Integer compareTo(Object compareTo) {
Payment compareToHP = (Payment)compareTo;
return this.YearQ.compareTo(compareToHP.YearQ);
}
// i have created a class with name as Object1 in the test class and try to call the main class method as below
PODA_Data.Payment objPODA = new PODA_Data.Payment();
object1 obj = new object1();
integer i = objPODA.compareTo(obj);
Facing error as below :
Error Message System.TypeException: Invalid conversion from runtime type PODA_Data_Test.object1 to PODA_Data.Payment
// could you please help me how to write test class for the above method.