You need to sign in to do that
Don't have an account?
Venkateswarlu P
Map<String,List<Opportunity>> Test Class
public class Map_Opportunities {
public Map<string,List<Opportunity>> oppMap {set;get;}
public List<Account> accList {set;get;}
public Map_Opportunities(){
oppMap = new Map<string,List<Opportunity>>();
accList=new List<Account>();
accList = [SELECT name,(SELECT Name,stageName FROM Opportunities)FROM Account];
for (Account a :accList){
oppMap.put(a.Name, a.Opportunities);
}
}
}
-------------------------------------------
Test Class
--------------------------------------------
@isTest
static void mapOpportunits(){
Map_Opportunities mp = new Map_Opportunities();
List<Opportunity> optyList = new List<Opportunity>();
account acc = new Account();
acc.name = 'Ravi';
insert acc;
opportunity op = new Opportunity();
op.Name = 'Xyz';
op.AccountId = acc.id;
op.CloseDate = system.today();
op.StageName ='Closed Won';
optyList.add(op);
insert optyList;
mp.oppMap.put(acc.Name, optyList);
}
85% code is covered and Displaying Error : oppMap.put(a.Name, a.Opportunities);
public Map<string,List<Opportunity>> oppMap {set;get;}
public List<Account> accList {set;get;}
public Map_Opportunities(){
oppMap = new Map<string,List<Opportunity>>();
accList=new List<Account>();
accList = [SELECT name,(SELECT Name,stageName FROM Opportunities)FROM Account];
for (Account a :accList){
oppMap.put(a.Name, a.Opportunities);
}
}
}
-------------------------------------------
Test Class
--------------------------------------------
@isTest
static void mapOpportunits(){
Map_Opportunities mp = new Map_Opportunities();
List<Opportunity> optyList = new List<Opportunity>();
account acc = new Account();
acc.name = 'Ravi';
insert acc;
opportunity op = new Opportunity();
op.Name = 'Xyz';
op.AccountId = acc.id;
op.CloseDate = system.today();
op.StageName ='Closed Won';
optyList.add(op);
insert optyList;
mp.oppMap.put(acc.Name, optyList);
}
85% code is covered and Displaying Error : oppMap.put(a.Name, a.Opportunities);
Thanks, let us know if it helps you