+ Start a Discussion
Devanshu soodDevanshu sood 

I am trying to write the test class for the following code. Please help me out.How to provide value to variable in dopost method?

global class Outboundcall {

   global static String doPost() {
            string tonumber;
            string Fromnumber;
            string CallerName;
            string callSid;
            string Direction;
            string Callstatus;
            string outboundcallid;
            string res;
            string nondigits;
            string ext;
   RestRequest req = RestContext.request;
   if(Callstatus =='initiated')
        nondigits = '[^0-9]';   
           User Usr = [SELECT Phone,extension,Id FROM User WHERE Did_Number__c = : tonumber limit 1 ];
               ext= '1'+usr.extension.replaceAll(nondigits,'');
           List<outbound_call__c> outboundcall_insert= new List<outbound_call__c>(); 
           outbound_call__c obc= new outbound_call__c();
           insert outboundcall_insert; 
   else if(Callstatus=='in-progress')
     /* outbound_call__c ld = [SELECT Read_Status__c,Callstatus__c,Extension__c,Id,Fromnumber__c FROM Incoming_Calls__c WHERE Extension__c =: ext AND Read_Status__c=false limit 1];
      update ld;*/
   else if(Callstatus=='completed')
    else if(Callstatus=='rejected')
       res='<?xml version="1.0" encoding="UTF-8" ?><Response></Response>';    
        return res;
Best Answer chosen by Devanshu sood
Devanshu soodDevanshu sood

never mind
there is some mistake in code ,I corrected it