You need to sign in to do that
Don't have an account?

need help for test class for wrapper class
hi,
i got 57% code coverage and confused how to give values for objects like CMAX__Business_Requirement__c,CMAX__Functional_Requirements__c and CMAX__System_Requirements__c...
public with sharing class GenerateReport4mBC
{
public string recid{get;set;}
public Map<string,CMAX__Business_Requirement__c> listBrs{get;set;}
public Map<string,list<CMAX__Functional_Requirements__c>> Frlist{get;set;}
public list<wrapBr> brListWrap{get;set;}
public boolean showFr{get;set;}
public boolean showSr{get;set;}
public String getPrintView()
{
return
'<!--[if gte mso 9]>' +
'<xml>' +
'<w:WordDocument>' +
'<w:View>Print</w:View>' +
'<w:Zoom>100</w:Zoom>' +
'<w:DoNotOptimizeForBrowser/>' +
'</w:WordDocument>' +
'</xml>' +
'<![endif]>';
}
public string getDocumentImageUrl()
{
List<Document> lstDocument = [Select Id,Name from Document where Name = 'Cvhs' limit 1];
string strOrgId = UserInfo.getOrganizationId();
string strDocUrl = 'https://c.na15.visual.force.com/servlet/servlet.ImageServer?oid=' + strOrgId + '&id=';
system.debug('DocumentUrl*********' + strDocUrl + lstDocument[0].Id);
return strDocUrl + lstDocument[0].Id;
}
public GenerateReport4mBC(ApexPages.StandardController controller)
{
recid = Apexpages.currentpage().getParameters().get('id');
string Fr = Apexpages.currentpage().getParameters().get('showFr');
string Sr = Apexpages.currentpage().getParameters().get('showSr');
if(Fr != null && Fr != ''){
showFr = Boolean.valueof(Fr);
}
if(Sr != null && Sr != ''){
showSr = Boolean.valueOf(Sr);
}
if(recid != null && recid != '')
{
brListWrap = new list<wrapBr>();
listBrs = new map<string,CMAX__Business_Requirement__c>([select id,Name,CMAX__Business_Requirements_Summary__c,CMAX__Use_Case__c,(select id,name,CMAX__FR_Description__c from CMAX__Functional_Requirements__r) from CMAX__Business_Requirement__c where CMAX__Business_Case__c=:recid]);
if(!listBrs.isEmpty())
{
for(CMAX__Business_Requirement__c br :listBrs.values())
{
wrapBr wr = new wrapBr();
if(br.CMAX__Functional_Requirements__r.size() > 0)
{
wr.FrExists = true;
}
wr.brList = br;
brListWrap.add(wr);
}
Frlist = new Map<string,list<CMAX__Functional_Requirements__c>>();
for(CMAX__Functional_Requirements__c frrecs : [select id,Name,CMAX__Business_Requirement__c,CMAX__FR_Description__c,(select Name,CMAX__SR_Description__c from CMAX__System_Requirements__r) from CMAX__Functional_Requirements__c where CMAX__Business_Requirement__c IN :listBrs.keyset()])
{
if(Frlist.containskey(frrecs.CMAX__Business_Requirement__c))
{
Frlist.get(frrecs.CMAX__Business_Requirement__c).add(frrecs);
}
else{
Frlist.put(frrecs.CMAX__Business_Requirement__c,new list<CMAX__Functional_Requirements__c>{frrecs});
}
}
}
}
}
public class wrapBr
{
public Boolean FrExists{get;set;}
public CMAX__Business_Requirement__c brList{get;set;}
}
}
thanks in advance...
i got 57% code coverage and confused how to give values for objects like CMAX__Business_Requirement__c,CMAX__Functional_Requirements__c and CMAX__System_Requirements__c...
public with sharing class GenerateReport4mBC
{
public string recid{get;set;}
public Map<string,CMAX__Business_Requirement__c> listBrs{get;set;}
public Map<string,list<CMAX__Functional_Requirements__c>> Frlist{get;set;}
public list<wrapBr> brListWrap{get;set;}
public boolean showFr{get;set;}
public boolean showSr{get;set;}
public String getPrintView()
{
return
'<!--[if gte mso 9]>' +
'<xml>' +
'<w:WordDocument>' +
'<w:View>Print</w:View>' +
'<w:Zoom>100</w:Zoom>' +
'<w:DoNotOptimizeForBrowser/>' +
'</w:WordDocument>' +
'</xml>' +
'<![endif]>';
}
public string getDocumentImageUrl()
{
List<Document> lstDocument = [Select Id,Name from Document where Name = 'Cvhs' limit 1];
string strOrgId = UserInfo.getOrganizationId();
string strDocUrl = 'https://c.na15.visual.force.com/servlet/servlet.ImageServer?oid=' + strOrgId + '&id=';
system.debug('DocumentUrl*********' + strDocUrl + lstDocument[0].Id);
return strDocUrl + lstDocument[0].Id;
}
public GenerateReport4mBC(ApexPages.StandardController controller)
{
recid = Apexpages.currentpage().getParameters().get('id');
string Fr = Apexpages.currentpage().getParameters().get('showFr');
string Sr = Apexpages.currentpage().getParameters().get('showSr');
if(Fr != null && Fr != ''){
showFr = Boolean.valueof(Fr);
}
if(Sr != null && Sr != ''){
showSr = Boolean.valueOf(Sr);
}
if(recid != null && recid != '')
{
brListWrap = new list<wrapBr>();
listBrs = new map<string,CMAX__Business_Requirement__c>([select id,Name,CMAX__Business_Requirements_Summary__c,CMAX__Use_Case__c,(select id,name,CMAX__FR_Description__c from CMAX__Functional_Requirements__r) from CMAX__Business_Requirement__c where CMAX__Business_Case__c=:recid]);
if(!listBrs.isEmpty())
{
for(CMAX__Business_Requirement__c br :listBrs.values())
{
wrapBr wr = new wrapBr();
if(br.CMAX__Functional_Requirements__r.size() > 0)
{
wr.FrExists = true;
}
wr.brList = br;
brListWrap.add(wr);
}
Frlist = new Map<string,list<CMAX__Functional_Requirements__c>>();
for(CMAX__Functional_Requirements__c frrecs : [select id,Name,CMAX__Business_Requirement__c,CMAX__FR_Description__c,(select Name,CMAX__SR_Description__c from CMAX__System_Requirements__r) from CMAX__Functional_Requirements__c where CMAX__Business_Requirement__c IN :listBrs.keyset()])
{
if(Frlist.containskey(frrecs.CMAX__Business_Requirement__c))
{
Frlist.get(frrecs.CMAX__Business_Requirement__c).add(frrecs);
}
else{
Frlist.put(frrecs.CMAX__Business_Requirement__c,new list<CMAX__Functional_Requirements__c>{frrecs});
}
}
}
}
}
public class wrapBr
{
public Boolean FrExists{get;set;}
public CMAX__Business_Requirement__c brList{get;set;}
}
}
thanks in advance...


Would you be able to post your test class so that I might be able to suggest any changes?