| /* | 
|  * Author: Guo, Aline Yaying | 
|  * Created Date: 03/22/2022 | 
|  * Purpose: Test Class | 
|  * History:  | 
|  *      03/22/2022 - Guo, Aline Yaying - Initial Code. | 
|  *  | 
|  * */ | 
| @isTest | 
| private class NewAndEditLeadControllerTest { | 
|     @TestSetup | 
|     static void makeData(){ | 
|         List<String> strList= new List<String>(); | 
|         strList.add('Lead'); | 
|         strList.add('Contact'); | 
|         strList.add('Inquiry_form__c'); | 
|         TestDataUtility.CreatePIPolicyConfigurations(strList); | 
|     } | 
|     static testMethod void testMethod1() { | 
|   | 
|         Test.startTest(); | 
|         Lead leadTest = new Lead(); | 
|         Contact cont = new Contact(); | 
|         ApexPages.StandardController con =  new ApexPages.StandardController(leadTest); | 
|         NewAndEditLeadController lead = new NewAndEditLeadController(con); | 
|          | 
|         String leadJson = '{"RecordTypeId":"01210000000QiRaAAK","Lead_No__c":"IN-JS-2022040127183","Status":"未跟进","Hospital_Name__c":"0011000000VAPEt","Department_Class__c":"0011000000V9bh5","Salutation":"","LastName":"***","Contact_Name__c":"0031m00000DHrkV","Cancel_Reason__c":"","Phone":"","Opp_Name_Search__c":"000000000000000","Email":"","Opp_Name__c":"Test","owner_not_automatically_update__c":false,"Purchase_Plan__c":"有(无预算)","Lead_Inquiry_form__c":"000000000000000","Opportunity_Division__c":"询价","LeadSource":"电话","Campaign__c":"000000000000000","urgent__c":false,"SI_PromoteInquiry__c":false,"Request__c":"","Request_Detail__c":"","Opportunity_stage__c":"预算没有批准","Close_Forecasted_Date__c":"2022/04/01","Purchase_Reason__c":"更新","Sales_Method__c":"单一来源采购","Fund_Basis__c":"銀行資金","Purchase_Type__c":"一般引合","Company":"江苏省人民医院 呼吸科 呼吸科","Name_Encrypted__c":"48a2693f6bf73d16e0abd48caf7fb756","Phone_Encrypted__c":"","Email_Encrypted__c":"","AWS_Data_Id__c":"959584917346320385"}'; | 
|         NewAndEditLeadController.saveLead(leadJson,'avgwshDFcxAS',False); | 
|         NewAndEditLeadController.saveLead(leadJson,'avgwshDFcxAS',True); | 
|   | 
|         Test.stopTest(); | 
|     } | 
|   | 
|     static testMethod void testMethod3() { | 
|         Lead leadTest = new Lead(); | 
|         String url = ApexPages.currentPage().getParameters().put('CF00N10000006ps6f_lkid','000000000000000'); | 
|         // ApexPages.currentPage().getParameters().put('CF00N10000002CvC5_lkid','000000000000000'); | 
|         // ApexPages.currentPage().getParameters().put('CF00N10000002CvC5','000000000000000'); | 
|         // ApexPages.currentPage().getParameters().put('CF00N10000002CvC5','000000000000000'); | 
|          | 
|          | 
|          | 
|         url = ApexPages.currentPage().getParameters().put('RecordType','01210000000QiRf'); | 
|         Test.startTest(); | 
|         try{ | 
|             NewAndEditLeadController.ControllerUtil(); | 
|             ApexPages.StandardController con =  new ApexPages.StandardController(leadTest); | 
|             NewAndEditLeadController lc = new NewAndEditLeadController(con); | 
|             String jsonString = '["Department_Class__c"]'; | 
|             system.debug('jsonString:'+JSON.deserializeUntyped(jsonString)); | 
|             String token = lc.awsToken; | 
|             String AWSDataId = lc.AWSDataId; | 
|             String AWSDataIdInquiryForm = lc.AWSDataIdInquiryForm; | 
|             String contactId = lc.contactId;//For Lookup field | 
|             String contactsInfo = lc.contactsInfo ;//key sfid;value awsid | 
|             Inquiry_form__c ifc = lc.ifc; | 
|             NewAndEditLeadController.queryAccount(jsonString, '000000000000000'); | 
|         }catch(Exception e){ | 
|             system.debug('Exception from query account:'+e.getMessage()); | 
|         } | 
|         Test.stopTest(); | 
|     } | 
| } |