My Apex class
public with sharing class helpTextClass {
public string main(string url)
{
Http h = new Http();
HttpRequest req = new HttpRequest();
req.setEndpoint(url);
req.setMethod('GET');
req.setTimeout(60000);
string hresult='';
if(isValid==true)
{
HttpResponse hres = h.send(req);
hresult = hres.getBody();
//system.debug('------'+hresult);
}else{
hresult = '<?xml version="1.0" encoding="ISO-8859-1"?><HelpTextDetails><BaseURL>http://click-pledge.v-empower.com/web/HelpText/HelpTextXml</BaseURL><HelpTab TabName="C&P InvoicePayment" label="C&P InvoicePayment"><TabSection Name="C&P InvoicePayment"></TabSection></HelpTab></HelpTextDetails>';
}
return hresult;
}
public class subTabnames{
public string description{get;set;}
public string link{get;set;}
public string video{get;set;}
}
public map<string,map<string,subTabnames>> helpText(){
finalMap = new map<string,map<string,subTabnames>>();
url = 'http://click-pledge.v-empower.com/web/HelpText/HelpTextXml/HelpTextXml.xml';
isValid=true;
try{
helpXml = main(url);
}catch(System.CalloutException e){
system.debug('Error: '+e);
}
Dom.document doc = new Dom.document();
doc.load(helpxml);
Dom.XMLNode elementsList = doc.getRootElement();
if(elementsList !=NULL){
for(Dom.XMLNode child : elementsList.getChildElements()) {
boolean checkcategory = false;
// Some code here
}
}
return finalmap;
}
My Test Class for this is
@istest
public class test_helpTextPage{
public static testmethod void helptest(){
helptextclass hc = new helpTextClass();
helpTextclass.subTabNames tabNames = new helpTextclass.subTabnames();
hc.main('http://click-pledge.v-empower.com/web/HelpText/HelpTextXml/HelpTextXml.xml');
hc.isValid = true;
hc.helpText();
}
}
the code coverage for this is 53% and it is not covering this Part
Dom.document doc = new Dom.document();
doc.load(helpxml);
Dom.XMLNode elementsList = doc.getRootElement();
if(elementsList !=NULL){
for(Dom.XMLNode child : elementsList.getChildElements()) {
boolean checkcategory = false;
// Some code here
}
}
return finalmap;
What should I do to cover this also.Help Pls!!!!!!