/* * 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 strList= new List(); strList.add('Lead'); strList.add('Contact'); strList.add('Inquiry_form__c'); TestDataUtility.CreatePIPolicyConfigurations(strList); Lead leadTest = TestDataUtility.CreateLead(1)[0]; Contact cont = TestDataUtility.CreateContacts(1)[0]; Inquiry_form__c iqf = TestDataUtility.CreateInquiryform(1)[0]; } static testMethod void testMethod1() { Test.setMock(HttpCalloutMock.class, new TestDataUtility.CreateMetaDataUtilityHttpMock()); Lead leadTest = [SELECT Id FROM Lead Limit 1]; Contact cont = [SELECT Id FROM Contact Limit 1]; Inquiry_form__c iqf = [SELECT Id FROM Inquiry_form__c Limit 1]; Test.startTest(); ApexPages.StandardController con = new ApexPages.StandardController(leadTest); NewAndEditLeadController lead = new NewAndEditLeadController(con); String leadJson = JSON.serialize(leadTest); NewAndEditLeadController.saveLead(leadJson,'avgwshDFcxAS',False); NewAndEditLeadController.saveLead(leadJson,'avgwshDFcxAS',True); Test.stopTest(); } static testMethod void testMethod2() { Lead leadTest = [SELECT Id FROM Lead Limit 1]; Contact cont = [SELECT Id,AccountId FROM Contact Limit 1]; Inquiry_form__c iqf = [SELECT Id,Contact_Id__c FROM Inquiry_form__c Limit 1]; String url = ApexPages.currentPage().getParameters().put('CF00N1000000962np_lkid',iqf.id); url = ApexPages.currentPage().getParameters().put('RecordType','01210000000QiRaAAK'); url = ApexPages.currentPage().getParameters().put('CF00N10000006ps6f_lkid',iqf.Contact_Id__c); url = ApexPages.currentPage().getParameters().put('CF00N10000002CvC5_lkid',cont.AccountId); Test.startTest(); Test.setMock(HttpCalloutMock.class, new TestDataUtility.CreateMetaDataUtilityHttpMock()); ApexPages.StandardController lds = new ApexPages.StandardController(new Contact()); NewAndEditLeadController ld = new NewAndEditLeadController(lds); Test.stopTest(); } static testMethod void testMethod3() { Lead leadTest = new Lead(); Contact cont = [SELECT Id, AccountId FROM Contact Limit 1]; String url = ApexPages.currentPage().getParameters().put('CF00N10000006ps6f_lkid',cont.id); url = ApexPages.currentPage().getParameters().put('RecordType','01210000000QiRf'); Test.setMock(HttpCalloutMock.class, new TestDataUtility.CreateMetaDataUtilityHttpMock()); Test.startTest(); ApexPages.StandardController con = new ApexPages.StandardController(leadTest); NewAndEditLeadController lc = new NewAndEditLeadController(con); String jsonString = '["Department_Class__c"]'; system.debug('jsonString:'+JSON.deserializeUntyped(jsonString)); NewAndEditLeadController.queryAccount(jsonString, cont.AccountId); Test.stopTest(); } }