You need to sign in to do that
Don't have an account?
shravani mil
unable to cover onundelete method in test class
unable to cover below lines in my test class:
public void onUndelete(List<Opportunity> oldOpps) {
List<AccountShare> acctSharesToAdd = new List<AccountShare>();
for (Opportunity o : oldOpps) {
ProvideAccShare(o,acctSharesToAdd);
}
if (acctSharesToAdd.size() > 0)
insert acctSharesToAdd;
}
public void onUndelete(List<Opportunity> oldOpps) {
List<AccountShare> acctSharesToAdd = new List<AccountShare>();
for (Opportunity o : oldOpps) {
ProvideAccShare(o,acctSharesToAdd);
}
if (acctSharesToAdd.size() > 0)
insert acctSharesToAdd;
}
It should be straight forward. Something like this. Please add the above code in a proper testclass / method and add assertion.
Please post your test class, if you need further help.
List<Opportunity> lstOpp = new List<Opportunity>();
Account acc1 = new Account();
acc1.name = 'acc1';
insert acc1;
Opportunity opp1 = new Opportunity();
opp1.Name = 'Opp1';
opp1.amount = 10000;
opp1.account = acc1;
opp1.closedate = System.today();
lstOpp.add(opp1);
insert lstOpp;
delete lstOpp;
lstOpp = [Select Id From Opportunity ALL ROWS];
undelete lstOpp;
Thanks
Follow the below code, it will help you.
Thanks,
Arvind Kumar