I have a fairly simple custom controller that redirects to various pages based upon selection of record type when creating a new Case from an Account or the Case tab. I am trying to develop a test class to cover the controller, but I'm not quite sure how to cover the method. My class below only covers 36% and seems to only cover the 2nd condition of the redirect (i.e., where AccountId == null). Can anyone help get my test to cover the other 2 conditions?
VF Controller:
public with sharing class VF_Controller_CaseAcctSvcsNew{
public Case c1;
public VF_Controller_CaseAcctSvcsNew(ApexPages.StandardController controller){
this.c1 = (Case)controller.getRecord();
}
public PageReference CaseRedirect() {
if(ApexPages.currentPage().getParameters().get('RecordType') == '012L0000000DPwQ'){
DateTime d = Date.Today();
c1.OwnerId='00GL0000001SUhm';
c1.Due_Date_Original__c = System.now() + 1;
c1.Due_Date_AcctSvcs__c = System.now() + 1;
c1.Status = 'New';
PageReference pageRef = new PageReference('/apex/VF_AcctSvcsNew');
return pageRef;
}
else if(ApexPages.currentPage().getParameters().get('AccountId') == null){
PageReference pageRef2 = new PageReference('https://cs8.salesforce.com/500/e?RecordType='+c1.RecordTypeId+'&ent=Case&nooverride=1');
return pageRef2;
}
else{
PageReference pageRef3 = new PageReference('https://cs8.salesforce.com/500/e?def_account_id='+c1.AccountId+'&RecordType='+c1.RecordTypeId+'&ent=Case&nooverride=1');
return pageRef3;
}
}
}
Test Class:
@IsTest (SeeAllData=true)
private class TestControllerAcctSvcsCaseNew{
static testMethod void testASCcontroller1(){
Account acct1 = TestCreateRecords.createAcct(0);
insert acct1;
Contact cont1 = TestCreateRecords.createContNew(acct1.Id);
insert cont1;
Case case1 = new Case();
case1.RecordTypeId = '012L0000000DPwQ';
case1.AccountId = acct1.Id;
case1.OwnerId = '00GL0000001SUhm';
case1.Due_Date_Original__c = System.now() + 1;
case1.Due_Date_AcctSvcs__c = System.now() + 1;
case1.Status = 'New';
ApexPages.StandardController cs1 = new ApexPages.standardController(case1);
VF_Controller_CaseAcctSvcsNew cs1a = new VF_Controller_CaseAcctSvcsNew(cs1);
cs1a.c1 = case1;
cs1a.CaseRedirect();
}
}