You need to sign in to do that
Don't have an account?
Guru 91
Test Class for Account Related Class?
Hi Everyone,
can you please help me with test class
public class AccntExtension {
public List<AccHierarchy> accountList{get;set;}
public String chumma{get;set;}
public Map<id,Account> accMap{get;set;}
public AccHierarchy hier;
public AccntExtension(ApexPages.StandardController c){
accMap= new Map<id,Account>([SELECT (SELECT Name,Market__r.Name,Type,StageName FROM Opportunities) from Account]);
accountList = new List<AccHierarchy>();
List<AccHierarchy> chilList = null;
for(Account acc : accMap.values()){
if(acc.ParentId == null){
hier = new AccHierarchy();
hier.setAccount(acc);
accMap.remove(acc.id);
//accountList=
accountList.add(hier);
chilList = getChildAccount(acc.id);
hier.setChildVal(chilList);
}
}
system.debug('FinalList'+accountList);
}
private List<AccHierarchy> getChildAccount(Id parentId){
List<AccHierarchy> accList = new List<AccHierarchy>();
for(Account acc : accMap.values()){
if(parentId == acc.ParentId){
accMap.remove(acc.id);
AccHierarchy hierChd = new AccHierarchy();
hierChd.setAccount(acc);
accList.add(hierChd);
List<AccHierarchy> chilList = null;
chilList = getChildAccount(acc.id);
hierChd.setChildVal(chilList);
}
}
system.debug('Loop top '+accList);
return accList;
}
}
can you please help me with test class
public class AccntExtension {
public List<AccHierarchy> accountList{get;set;}
public String chumma{get;set;}
public Map<id,Account> accMap{get;set;}
public AccHierarchy hier;
public AccntExtension(ApexPages.StandardController c){
accMap= new Map<id,Account>([SELECT (SELECT Name,Market__r.Name,Type,StageName FROM Opportunities) from Account]);
accountList = new List<AccHierarchy>();
List<AccHierarchy> chilList = null;
for(Account acc : accMap.values()){
if(acc.ParentId == null){
hier = new AccHierarchy();
hier.setAccount(acc);
accMap.remove(acc.id);
//accountList=
accountList.add(hier);
chilList = getChildAccount(acc.id);
hier.setChildVal(chilList);
}
}
system.debug('FinalList'+accountList);
}
private List<AccHierarchy> getChildAccount(Id parentId){
List<AccHierarchy> accList = new List<AccHierarchy>();
for(Account acc : accMap.values()){
if(parentId == acc.ParentId){
accMap.remove(acc.id);
AccHierarchy hierChd = new AccHierarchy();
hierChd.setAccount(acc);
accList.add(hierChd);
List<AccHierarchy> chilList = null;
chilList = getChildAccount(acc.id);
hierChd.setChildVal(chilList);
}
}
system.debug('Loop top '+accList);
return accList;
}
}
All Answers
I am getting error
Error: Compile Error: Field does not exist: LocaleSidKey on Opportunity at line 8 column 39,
Error: Compile Error: Dependent class is invalid and needs recompilation:
Class AccntExtension : Invalid type: AccHierarchy at line 2 column 31
Error: Compile Error: Method does not exist or incorrect signature: void getChildAccount(Id) from the type AccntExtension at line 31 column 20
Error: Compile Error: Dependent class is invalid and needs recompilation:
Class AccntExtension : Invalid type: AccHierarchy at line 2 column 31
I able resolve issue in AccHierarchy class
Now my class also passed