+ Start a Discussion
Prema -Prema - 

Can anybody please help me in writing the test class for this method as I am getting error : methods defined as TestMethod do not support Web service callouts

******************/
        public pageReference AuthenticateUser(){
            
            system.debug('username :' +userName + ' alreadyApproved :'+alreadyApproved);            
            if(userName != '' && passWord !='')
            {   
                //calling startAppSession service
                ICSwwwViadComSecurityV2.AppSessionInfo obj ;
                ICSwwwViadComSecurityV2.BasicHttpBinding_IAuthenticationService Iobj = new ICSwwwViadComSecurityV2.BasicHttpBinding_IAuthenticationService(); 
                obj = Iobj.StartAppSession('SalesForce','76v.H-_7};9^+4(]J.;3','','');
                system.debug('app session response : '+obj.SessionID);

                //calling authicate userinfo service.
                ICSwwwViadComV1.DirectoryResult objUserInfo;
                objUserInfo = Iobj.AuthenticateUser(obj.SessionID,userName,passWord);
                system.debug('UserInfo response : '+objUserInfo.user_x.emailaddress);
                system.debug('UserInfo response : '+objUserInfo.IsSuccessful+ ' username :'+ userName + ' emailId :'+ emailid); 
                if(objUserInfo.IsSuccessful) 
                {
                    if(emailid.containsIgnoreCase(objUserInfo.user_x.emailaddress) )
                    {
                        renderApprovalPageBlock = true;
                        isAuthenticated=true;
                    }                   
                    else
                    {
                        system.debug('ICS case ID ::'+icsCaseId );
                        List<Customer_Service_Inquiries_ICS__c> lstCase = new List<Customer_Service_Inquiries_ICS__c>();
                        lstCase = [select id,(SELECT Del_AR1_Approver_Email__c,Del_AR2_Approver_Email__c,Del_CSO_Approver_Email__c FROM Refunds_ICS__r ),
                        (select id,Del_AR1_Approver_Email__c,Del_AR2_Approver_Email__c,Del_CSO_Approver_Email__c,Del_DAM_LOB_Approver_Email__c,Del_F_R_Approver_Email__c from AR_Adjustments_Approvals__r),
                        (SELECT Del_Additional_Approver_Email__c,Del_AR1_Approver_Email__c,Del_AR2_Approver_Email__c,Del_CSO_Approver_Email__c,
                        Del_F_R_Approver_Email__c,Del_LOB_Approver_Email__c FROM ICS_Credit_Memo__r) from Customer_Service_Inquiries_ICS__c where id=:icsCaseId ];
                        string DelegatedApprovers ='';
                        
                        if(!lstCase[0].Refunds_ICS__r.isEmpty())
                        {
                            for(Refunds_ICS__c tempR : lstCase[0].Refunds_ICS__r)
                            {
                                DelegatedApprovers = DelegatedApprovers +tempR.Del_AR1_Approver_Email__c + ';';
                                DelegatedApprovers = DelegatedApprovers +tempR.Del_AR2_Approver_Email__c + ';';     
                                DelegatedApprovers = DelegatedApprovers +tempR.Del_CSO_Approver_Email__c + ';';
                            }
                            system.debug( 'Refund DelegatedApprovers :::: '+DelegatedApprovers);
                        }
                        else if(!lstCase[0].AR_Adjustments_Approvals__r.isEmpty())
                        {
                            for(AR_Adjustments__c tempAR : lstCase[0].AR_Adjustments_Approvals__r)
                            {
                                DelegatedApprovers = DelegatedApprovers +tempAR.Del_AR1_Approver_Email__c + ';';
                                DelegatedApprovers = DelegatedApprovers +tempAR.Del_AR2_Approver_Email__c + ';';        
                                DelegatedApprovers = DelegatedApprovers +tempAR.Del_CSO_Approver_Email__c + ';';
                                DelegatedApprovers = DelegatedApprovers +tempAR.Del_DAM_LOB_Approver_Email__c + ';';
                                DelegatedApprovers = DelegatedApprovers +tempAR.Del_F_R_Approver_Email__c + ';';
                            }
                            system.debug( 'AR Adjustment DelegatedApprovers :::: '+DelegatedApprovers);
                        }
                        else If(!lstCase[0].ICS_Credit_Memo__r.isEmpty())
                        {
                            for(Credit_Memo_ICS__c tempCM : lstCase[0].ICS_Credit_Memo__r)
                            {
                                DelegatedApprovers = DelegatedApprovers +tempCM.Del_AR1_Approver_Email__c + ';';
                                DelegatedApprovers = DelegatedApprovers +tempCM.Del_AR2_Approver_Email__c + ';';        
                                DelegatedApprovers = DelegatedApprovers +tempCM.Del_CSO_Approver_Email__c + ';';
                                DelegatedApprovers = DelegatedApprovers +tempCM.Del_LOB_Approver_Email__c + ';';
                                DelegatedApprovers = DelegatedApprovers +tempCM.Del_Additional_Approver_Email__c + ';';
                                DelegatedApprovers = DelegatedApprovers +tempCM.Del_F_R_Approver_Email__c + ';' ;
                            }
                            system.debug( 'Credit Memo DelegatedApprovers :::: '+DelegatedApprovers);
                        }
                        system.debug( 'DelegatedApprovers :::: '+DelegatedApprovers);
                        if(DelegatedApprovers != '' && DelegatedApprovers != 'null' && DelegatedApprovers.containsIgnoreCase(objUserInfo.user_x.emailaddress) )
                        {
                            renderApprovalPageBlock = true;
                            isAuthenticated=true;
                        }                       
                        else
                        {
                            ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error, 'You are not authorized for approval'));
                        }                       
                    }       
                }else
                {
                    ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error, 'You are not authorized for approval'));
                }
            }           
            return null;
            
        }