Li Jun
2022-04-19 2f183a6b0a83ec3f7d35375d5d25d200efc2a3e1
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
/*
 * Author: Guo, Aline Yaying
 * Created Date: 03/22/2022
 * Purpose: Test Class
 * History: 
 *      03/22/2022 - Guo, Aline Yaying - Initial Code.
 * 
 * */
@isTest
private class NewAndEditBaseControllerTest {
    static testMethod void testMethod1() {
     
        RecordType rtId = [select Id, SobjectType, Name from RecordType where SobjectType = 'Tender_information__c' and Name = '千里马'];
        TestDataUtility.CreatePIPolicyConfiguration();
        Test.setMock(HttpCalloutMock.class, new TestDataUtility.CreateMetaDataUtilityHttpMock());
        //use a random sobj
        Tender_information__c tenTest = TestDataUtility.CreateTenderInformation(1)[0];
        tenTest.ResultDate__c = null;
        tenTest.InfoPublishTime__c = Datetime.now();
        tenTest.OpportunityNum__c = null;
        tenTest.Other_units__c = false;
        tenTest.AWS_Data_Id__c = '1569989';
        tenTest.RecordTypeId = rtId.Id;
        upsert tenTest;
 
        Test.startTest();
        //ApexPages.StandardController con =  new ApexPages.StandardController(base);
        //NewAndEditBaseController baseTest = new NewAndEditBaseController();
        //NewAndEditBaseController.Init(base);
        ApexPages.StandardController con =  new ApexPages.StandardController(tenTest);
        NewAndEditTenderinformationController a = new NewAndEditTenderinformationController(con);
        a.Init(tenTest);
        String AWSjson = a.AWSToSobjectMapJson;
        NewAndEditBaseController.GetReferenceField('test__c');
        NewAndEditBaseController.GetReferenceField('Id');
        NewAndEditBaseController.GetReferenceField('t');
        
        System.debug('tenTest' + tenTest);
        String baseJson = JSON.serialize(tenTest);
        System.debug('baseJson' + baseJson);
        NewAndEditBaseController.save(tenTest, baseJson, 'avgwshDFcxAS', false);
        Test.stopTest();
    }
 
    static testMethod void testMethod2() {
     
        List<String> LookUpOverrideFields = new List<String>();
        TestDataUtility.CreatePIPolicyConfiguration();
        Test.setMock(HttpCalloutMock.class, new TestDataUtility.CreateMetaDataUtilityHttpMock());
        //use a random sobj
        ASEActivity__c aseTest = TestDataUtility.CreateASEActivity(1)[0];
        aseTest.activityStartTime__c = null;
        upsert aseTest;
 
        Test.startTest();
        //ApexPages.StandardController con =  new ApexPages.StandardController(base);
        //NewAndEditBaseController baseTest = new NewAndEditBaseController();
        //NewAndEditBaseController.Init(base);
        ApexPages.StandardController con =  new ApexPages.StandardController(aseTest);
        NewAndEditASEActivityController a = new NewAndEditASEActivityController(con);
        LookUpOverrideFields.add('ReporterASE__c');
        a.Init(aseTest);
        String AWSjson = a.AWSToSobjectMapJson;
        aseTest.put('AWS_Data_Id__c','1569989');
        String baseJson = JSON.serialize(aseTest);
        System.debug('baseJson' + baseJson);
 
        NewAndEditBaseController.save(aseTest, baseJson, 'avgwshDFcxAS', true);
        NewAndEditBaseController.save(aseTest, baseJson, 'avgwshDFcxAS', null);
        Test.stopTest();
    }
 
    static testMethod void testMethod3() {
     
        List<String> LookUpOverrideFields = new List<String>();
        TestDataUtility.CreatePIPolicyConfiguration();
        Test.setMock(HttpCalloutMock.class, new TestDataUtility.CreateMetaDataUtilityHttpMock());
        //use a random sobj
        Contact contact = TestDataUtility.CreateContacts(1)[0];
        ASEActivity__c aseTest = new ASEActivity__c();
        aseTest.CustomerTel__c = '123123';
        aseTest.ReporterASE__c = contact.Id;
        aseTest.activityStartTime__c = null;
 
        Test.startTest();
        //ApexPages.StandardController con =  new ApexPages.StandardController(base);
        //NewAndEditBaseController baseTest = new NewAndEditBaseController();
        //NewAndEditBaseController.Init(base);
        ApexPages.StandardController con =  new ApexPages.StandardController(aseTest);
        NewAndEditASEActivityController a = new NewAndEditASEActivityController(con);
        LookUpOverrideFields.add('ReporterASE__c');
        a.Init(aseTest);
        String AWSjson = a.AWSToSobjectMapJson;
        aseTest.put('AWS_Data_Id__c','1569989');        
        String baseJson = JSON.serialize(aseTest);
        System.debug('baseJson' + baseJson);
        NewAndEditBaseController.save(aseTest, baseJson, 'avgwshDFcxAS', true);
        Test.stopTest();
    }
    
    
}