You need to sign in to do that
Don't have an account?
Kanus wave
can any one write test class to the below scenario am tried am getting 74% but i need 90+
public with sharing class LP_CreateNewCasePage_Controller
{
public String Id;
public Id ParentId;
public id selectedrecordtype;
public PageReference OtherRedirect(){
try{
System.debug('Selected RecordType is'+selectedrecordtype);
Id recTypeId = [SELECT id from RecordType WHERE id=:selectedrecordtype].id;
PageReference p = new PageReference('/' + Case.SObjectType.getDescribe().getKeyPrefix() + '/e');
Map<String, String> m = p.getParameters();
if((string)ApexPages.currentPage().getParameters().get('retURL').substring(1,4)!='500')
{
ParentId = ApexPages.currentPage().getParameters().get('retURL').substring(1,16);
Id=(string)ParentId;
if(Id.Startswith('003')){
m.putAll(ApexPages.currentPage().getParameters());
m.put('nooverride', '1');
m.put('RecordType',recTypeId);
p.setRedirect(true);
}
if(Id.Startswith('001')){
m.putAll(ApexPages.currentPage().getParameters());
m.put('nooverride', '1');
m.put('RecordType',recTypeId);
p.setRedirect(true);
}
return p;
}
else{
m.put('nooverride', '1');
m.put('RecordType',recTypeId);
p.setRedirect(true);
return p;
}
}
catch(Exception l_objEx)
{
String l_stMsg = 'Exception while redirecting to Case Creation Page.';
String l_stErrMessage = l_objEx.getTypeName()+': '+l_stMsg;
System.debug(l_stErrMessage);
return null;
}
}
}
Thanks in Advance!
{
public String Id;
public Id ParentId;
public id selectedrecordtype;
public PageReference OtherRedirect(){
try{
System.debug('Selected RecordType is'+selectedrecordtype);
Id recTypeId = [SELECT id from RecordType WHERE id=:selectedrecordtype].id;
PageReference p = new PageReference('/' + Case.SObjectType.getDescribe().getKeyPrefix() + '/e');
Map<String, String> m = p.getParameters();
if((string)ApexPages.currentPage().getParameters().get('retURL').substring(1,4)!='500')
{
ParentId = ApexPages.currentPage().getParameters().get('retURL').substring(1,16);
Id=(string)ParentId;
if(Id.Startswith('003')){
m.putAll(ApexPages.currentPage().getParameters());
m.put('nooverride', '1');
m.put('RecordType',recTypeId);
p.setRedirect(true);
}
if(Id.Startswith('001')){
m.putAll(ApexPages.currentPage().getParameters());
m.put('nooverride', '1');
m.put('RecordType',recTypeId);
p.setRedirect(true);
}
return p;
}
else{
m.put('nooverride', '1');
m.put('RecordType',recTypeId);
p.setRedirect(true);
return p;
}
}
catch(Exception l_objEx)
{
String l_stMsg = 'Exception while redirecting to Case Creation Page.';
String l_stErrMessage = l_objEx.getTypeName()+': '+l_stMsg;
System.debug(l_stErrMessage);
return null;
}
}
}
Thanks in Advance!
If Your are providing selectedrecordtype . Dont provide value in test class . it will get and show me your test class if it is possible .
Regards ,
Harish.R.
Provide me your test class i can help you nothing to worry . other wise i have to create in my account .
Regards ,
Harish.R.
Can you please share your test class.
Below i tried to make test class of the above class in my devloper org.
I hope it helps.
Thanks,
Swaraj Behera