You need to sign in to do that
Don't have an account?
rupesh ranjan
Any one pls remove this error from test class System.NullPointerException: Argument cannot be null.
Any one pls remove this error from test class
System.NullPointerException: Argument cannot be null.
Class.Leadpage.<init>: line 19, column 1
Class.Leadtestsss.runTest1: line 31, column 1
System.NullPointerException: Argument cannot be null.
Class.Leadpage.<init>: line 19, column 1
Class.Leadtestsss.runTest1: line 31, column 1
TEST Class @isTest public class Leadtestss{ static testMethod void runTest1() { Account account = new Account(); account.Name = 'Acc3'; insert account; Contact contact = new Contact(); contact.FirstName = 'Todda'; contact.LastName = 'Wilmss'; contact.AccountID = account.Id; contact.Email = 'twilms@verisign.conm'; contact.MobilePhone = '918527116723'; insert contact; Lead lead = new Lead(); lead.FirstName = 'test'; lead.LastName = 'foo'; lead.company='Acc3'; insert lead; test.startTest(); PageReference pageRef = Page.Leadpage; pageRef.getParameters().put('Id', String.valueOf(lead.Id)); Test.setCurrentPage(pageRef); Test.setMock(HttpCalloutMock.class, new Leadpagemock()); ApexPages.StandardController sc1 = new ApexPages.StandardController(Lead);//Instance of your object Leadpage testDObj = new Leadpage(); testDObj.getperformcallout(); test.stopTest(); } }
Page MOCK Class @IsTest(seeAllData = false) global class Leadpagemock implements HttpCalloutMock { global HTTPResponse respond(HTTPRequest req) { HttpResponse res = new HttpResponse(); res.setHeader('Content-Type', 'application/json'); res.setBody('[{"foo":"bar"}]'); res.setStatusCode(200); return res; } }
Main Class public class Leadpage{ public Leadpage(ApexPages.StandardController controller) { } public Leadpage() {} public String MySessionID = UserInfo.getSessionID(); public String conId = ApexPages.currentPage().getParameters().get('Id'); public String EmailCon=[Select email from Lead where Id=:conId ].email; public String myurl= URL.getSalesforceBaseUrl().toExternalForm() + '/services/Soap/c/10.0/' + UserInfo.getOrganizationId(); public string c='eU9WzoFgU4n8Apu5PYxcNGRZswRDZJWDEMdbQVU85gw='; public String Acode='00530000000rLMxAAM'; public String Oid = UserInfo.getOrganizationId(); Blob cryptoKey= EncodingUtil.base64Decode(c); Blob data = Blob.valueOf(MySessionID ); Blob data1 = Blob.valueOf(myurl); Blob data2 = Blob.valueOf(conId); Blob data3 = Blob.valueOf(EmailCon); Blob data4 = Blob.valueOf(Acode); Blob data5 = Blob.valueOf(Oid); Blob encryptedData = Crypto.encryptWithManagedIV('AES256', cryptoKey, data); Blob encryptedData1 = Crypto.encryptWithManagedIV('AES256', cryptoKey, data1); Blob encryptedData2 = Crypto.encryptWithManagedIV('AES256', cryptoKey, data2); Blob encryptedData3 = Crypto.encryptWithManagedIV('AES256', cryptoKey, data3 ); Blob encryptedData4 = Crypto.encryptWithManagedIV('AES256', cryptoKey, data4 ); Blob encryptedData5 = Crypto.encryptWithManagedIV('AES256', cryptoKey, data5 ); public String b64Data = EncodingUtil.base64Encode(encryptedData); public String b64Data1 = EncodingUtil.base64Encode(encryptedData1); public String b64Data2 = EncodingUtil.base64Encode(encryptedData2); public String b64Data3 = EncodingUtil.base64Encode(encryptedData3); public String b64Data4 = EncodingUtil.base64Encode(encryptedData4); public String b64Data5 = EncodingUtil.base64Encode(encryptedData5); String testurl='sessionID='+EncodingUtil.urlEncode(b64Data, 'UTF-8')+'&serverUrl='+EncodingUtil.urlEncode(b64Data1, 'UTF-8')+'&contactID='+EncodingUtil.urlEncode(b64Data2, 'UTF-8')+'&email='+EncodingUtil.urlEncode(b64Data3, 'UTF-8'); public String email = EncodingUtil.urlEncode(b64Data3, 'UTF-8'); public String aucode= EncodingUtil.urlEncode(b64Data4, 'UTF-8'); public String ocode= EncodingUtil.urlEncode (b64Data5, 'UTF-8'); public List<LeadVideoViewAllWrap> ConsoleWrapperList{get;set;} public List<LeadVideoViewAllWrap> getperformcallout(){ ConsoleWrapperList = new List<LeadVideoViewAllWrap>(); HttpRequest req = new HttpRequest(); HttpResponse res = new HttpResponse(); Http http = new Http(); string url = 'https://www.demomail.net/sf/api/LeadVideoViewAllController?AUCode='+aucode+'&SOrgID='+ocode+'&Email='+email+'&session='+testurl; req.setEndpoint(url); req.setMethod('GET'); res = http.send(req); if(res.getstatusCode() == 200 && res.getbody() != null){ ConsoleWrapperList=(List<LeadVideoViewAllWrap>)json.deserialize(res.getbody(),List<LeadVideoViewAllWrap>.class); } return consolewrapperlist; } }
User followin code
Hope it helps you.
thanks,
Anjith
All Answers
User followin code
Hope it helps you.
thanks,
Anjith