You need to sign in to do that
Don't have an account?
Raja Bipin Chandra M B
Test method for Controller extension for Chatter : ConnectAPI.ChatterMessages.sendMessage
Hello Folks,
I am finding hard to write a test method for the below code, Can somebody give me a headstart ?
I am finding hard to write a test method for the below code, Can somebody give me a headstart ?
public with sharing class Opportunitymanager { public String body { get; set; } public Opportunity opp; public User usr; Id oid; public Opportunitymanager(ApexPages.StandardController stdController) { opp = (Opportunity)stdController.getRecord(); oid = apexpages.currentpage().getparameters().get('ownerid'); usr = [select id,FirstName,LastName,Email,Manager.Id,Manager.Manager.Id,Manager.Manager.FirstName,Manager.Manager.LastName,Manager.FirstName,Manager.LastName,Manager.Email from User where Id= :oid]; } public User getuser() { return usr; } public PageReference submit() { ConnectAPI.ChatterMessages.sendMessage('Related to Opportunity: '+opp.Name+'\n'+'Link: https://emea.salesforce.com/'+opp.id+'\n'+body,usr.id+','+usr.Manager.Id+','+opp.Territory_Manager__c); PageReference returnPage = new ApexPages.StandardController(opp).view(); returnPage.setRedirect(true); ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.Info, 'Message successfully sent')); return new PageReference('javascript:window.close()'); //return returnPage; } }
Try with below code it will help .
For detail in test class please follow below links
https://developer.salesforce.com/page/An_Introduction_to_Apex_Code_Test_Methods
https://developer.salesforce.com/page/How_to_Write_Good_Unit_Tests
Thanks
Manoj
Please mark this as solution by selecting it as best answer if this solves your problem, So that if anyone has this issue this post can help
Regards,
Raja
Check the below link it may help ,
https://github.com/alouie-sfdc/ConnectApiHelper/blob/master/ConnectApiHelperTest.cls
Let me know any issue .