Li Jun
2022-03-31 3ba0123db48f8bab81ddf0913e1b95280ef545e8
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
/*
 * 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);
        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();
    }
}