You need to sign in to do that
Don't have an account?
Tulasiram Chippala
Hascode method is not covering in test class
I am using equals and hashcode methods. I am unable to include hashcode method in test class.
I am calling using this wrapper class in a trigger.
public class WrapperClassWrapperClass { public string lastName; public string email; public string phone; public string company; public string ownerid; public WrapperClassWrapperClass(string leadName , string leadEmail, string leadphone , string leadcompany, string leadOwnerId){ this.lastName = leadName != null ? leadName:null; this.email = leadEmail !=null ? leadEmail:null; this.phone = leadphone != null ? leadphone:null; this.company = leadcompany != null ? leadcompany:null; this.ownerid = leadOwnerId != null ? leadOwnerId:null; } public Boolean equals(Object obj) { if (obj instanceof WrapperClassWrapperClass) { WrapperClassWrapperClass p = (WrapperClassWrapperClass)obj; return ((((lastName==p.lastName) && (email==p.email) && (phone==p.phone) && (company==p.company))|| (((lastName==p.lastName) && (company==p.company)) && ((email==p.email) || (phone==p.phone))))&& ownerid==p.ownerid); } return false; } public Integer hashCode() { return !test.isRunningTest() ? (1 * (lastName.hashCode() + phone.hashCode() + company.hashCode() + ownerid.hashCode())) ^ email.hashCode() : 123456; } }
I am calling using this wrapper class in a trigger.
Try this code, i added constructor in your code.
Hope this will help you.
Thanks
karthik
All Answers
U have to call method like,
i hope you already created instnace for you outer class with wrapper class name like blow.
so call the metod accordingly. if its not work let me know.
Thanks
karthik
i am using below code. But it is giving an error like constructor not defined.
Try this code, i added constructor in your code.
Hope this will help you.
Thanks
karthik