public class XYZcontroller{
public object__c sr{get;set;}
public String srid;
public XYZcontroller(ApexPages.StandardController controller) {
sr = (object__c) controller.getRecord();
srid = String.valueOf(sr.Id).substring(0, 15);
String pageMessage = ApexPages.currentPage().getParameters().get('pageMessage');
boolean doNotDisplay;
String referrer = ApexPages.currentPage().getHeaders().get('REFERER');
if(referrer.contains(srid+ '/e')){
doNotDisplay=false;
}else{
doNotDisplay=true;
}
}
}
@isTest
public class xyzControllerTest{
static testMethod void testMethod1(){
object__c sr = new object__c (Name='test');
insert sr;
PageReference pageRef = Page.Thepage;
Test.setCurrentPage(pageRef);
ApexPages.currentPage().getParameters().put('pageMessage', 'Amessage');
ApexPages.currentPage().getHeaders().put('REFERER', sr.id + '/e');
ApexPages.StandardController stdcontroller = new ApexPages.StandardController(sr);
xyzController controller = new xyzController(stdcontroller);
}
}
Error Message System.NullPointerException: Argument 1 cannot be null
Stack Trace External entry point
Class.xyzControllerTest.testMethod1: line 14, column 1
Error Message:
System.NullPointerException: Argument 1 cannot be null Stack Trace External entry point Class.xyzControllerTest.testMethod1: line 14, column 1