buli
2022-04-26 ba1c90575c47f9cb5c2ce0a20da90d3b1739b5fa
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
@isTest
public class NewAndEditContactControllerTest {
    @TestSetup
    static void makeData(){
        TestDataUtility.CreatePIPolicyConfiguration();
    }
    static testMethod void NewAndEditContactController() {
        Test.setMock(HttpCalloutMock.class, new TestDataUtility.CreateMetaDataUtilityHttpMock());
        // Contact con = TestDataUtility.CreateContacts(1)[0];
        Account acc = TestDataUtility.CreateAccounts(1)[0];
        Contact con = new Contact();
        String url = ApexPages.currentPage().getParameters().put('retURL','/'+acc.Id);
 
        Test.startTest();
        ApexPages.StandardController sc =  new ApexPages.StandardController(con);
        NewAndEditContactController qis = new NewAndEditContactController(sc);
 
        String qisJson = '{"AccountId":"0010l00001Q1r4e","OwnerId":"0050l0000061MOe","Department":"","MobilePhone":"***********","Title":"","Phone":"","Salutation":"","LastName":"***","Fax":"","ContactEnglishName__c":"","OtherPhone":"","ManagementCode_Ext__c":"","Email":"*****@company.com","isBatch__c":false,"TechnicalServiceCreated__c":false,"IsNew__c":false,"isServiceCreate__c":false,"Postcode__c":"**********","Address1__c":"**********","Address2__c":"","Address3__c":"","EnglishAddress__c":"","ProductSegmentBS__c":false,"ProductSegmentRVI__c":false,"ProductSegmentIE__c":false,"ProductSegmentNDT__c":false,"ProductSegmentANI__c":false,"StatusD__c":"Draft","ContactStatus__c":"Active","CancelReason__c":"","Remark__c":"","Phone_Encrypted__c":"","OtherPhone_Encrypted__c":"","MobilePhone_Encrypted__c":"64bd0db056d0bfd21fae76cc5dbdf4d1","PhoneD_Encrypted__c":null,"OtherPhoneD_Encrypted__c":null,"MobilePhoneD_Encrypted__c":null,"Email_Encrypted__c":"68fda69bb586ec70073b015fbff6c19420b838c523e79c9737c6fe095fd5cc55","EmailD_Encrypted__c":null,"FaxD_Encrypted__c":null,"Address3D_Encrypted__c":null,"Address1D_Encrypted__c":null,"Address3_Encrypted__c":"","Address2D_Encrypted__c":null,"Address1_Encrypted__c":"2df1bc4bf3800c5e05e3d9f394c3446567d1f05482d2295650b7b50e9e4aa97a92338985c9693f576e1e6df667aaee46","EnglishAddress_Encrypted__c":"","ContactEnglishName_Encrypted__c":"","Title_Encrypted__c":"","TitleD_Encrypted__c":null,"PostcodeD_Encrypted__c":null,"Postcode_Encrypted__c":"ecec26168c09cf090b8b4a95ca524a61","LastName_Encrypted__c":"dcce196c4cfc273a83777852ddd486ab","PhoneD__c":null,"OtherPhoneD__c":null,"MobilePhoneD__c":null,"EmailD__c":null,"FaxD__c":null,"Address3D__c":null,"Address2D__c":null,"Address1D__c":null,"TitleD__c":null,"PostcodeD__c":null,"AWS_Data_Id__c":"962006242048344064"}';
        NewAndEditContactController.saveContact(qisJson,'avgwshDFcxAS',False);
        NewAndEditContactController.saveContact(qisJson,'avgwshDFcxAS',True);
        
        qis.PageLoad();
        Test.stopTest();
    }
    static testMethod void testMethod3() {
 
        Test.setMock(HttpCalloutMock.class, new TestDataUtility.CreateMetaDataUtilityHttpMock());
        // Contact contactTest = TestDataUtility.CreateContacts(1)[0];
        // Account acc = TestDataUtility.CreateAccounts(1)[0];
        //Account acc1 = [SELECT Id,Name FROM Account WHERE RecordType.DeveloperName = 'Office' OR RecordType.DeveloperName = 'AgencyContact' OR RecordType.DeveloperName = 'Agency' Limit 1];
        String accrecordTypeId = Schema.SObjectType.Account.getRecordTypeInfosByDeveloperName().get('Agency').getRecordTypeId();
        Account acc1 = new Account(Name = 'testacc1',RecordTypeId = accrecordTypeId,ProductSegment__c='BS');
        insert acc1;
        Contact contact = new Contact();
        
 
        String recordTypeId = Schema.SObjectType.Contact.getRecordTypeInfosByDeveloperName().get('SSBD').getRecordTypeId();
        String url = ApexPages.currentPage().getParameters().put('RecordType',recordTypeId);
        url = ApexPages.currentPage().getParameters().put('accid',acc1.Id);
        url = ApexPages.currentPage().getParameters().put('con4_lkid',acc1.Id);
 
        Test.startTest();
        ApexPages.StandardController con =  new ApexPages.StandardController(contact);
        NewAndEditContactController cont = new NewAndEditContactController(con);
        // cont.rtTypeId
 
        cont.PageLoad();
        Test.stopTest();
    }
}