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
@IsTest
class LexNewAndEditContactPIPLControllerTest {
    public static String rectCo = Schema.SObjectType.Account.getRecordTypeInfosByDeveloperName().get('Agency').getRecordTypeId();
    public static String rectHp = Schema.SObjectType.Account.getRecordTypeInfosByDeveloperName().get('HP').getRecordTypeId();
    public static String rectOffice = Schema.SObjectType.Account.getRecordTypeInfosByDeveloperName().get('office').getRecordTypeId();
    public static String rectAg = Schema.SObjectType.Contact.getRecordTypeInfosByDeveloperName().get('Agency').getRecordTypeId();
    public static String rectIs = Schema.SObjectType.Contact.getRecordTypeInfosByDeveloperName().get('Internal_staff').getRecordTypeId();
    public static List<Contact> contList;
    @testSetup 
    static void testSetup() {
        Account testRectcoAccounts = new Account(Name = 'testRectcoAccount', RecordTypeId = rectHp,Is_Active__c = '有効');
        insert testRectcoAccounts;
        Account testRectHpAccounts = new Account(Name = 'testRectHpAccount', RecordTypeId = rectCo, Hospital__c = testRectcoAccounts.id,Is_Active__c = '有効');
        insert testRectHpAccounts;
        Account testRectOfficeAccounts = new Account(Name = 'testRectOfficeAccounts', RecordTypeId = rectOffice);
        insert testRectOfficeAccounts;
        Contact testRectAgContacts = new Contact(email='jplumber@salesforce.com', firstname='Joe', lastname='testRectAgContacts',RecordTypeId = rectAg, AWS_Data_Id__c = 'TestContact', accountId = testRectcoAccounts.id);
        insert testRectAgContacts;
        Contact testRectIsContacts = new Contact(email='jplumber@salesforce.com', firstname='Joe', lastname='testRectIsContacts',RecordTypeId = rectIs, accountId = testRectHpAccounts.Id);
        insert testRectIsContacts;
        contList = new List<Contact>();
        contList.add(testRectAgContacts);
        contList.add(testRectIsContacts);
    }
    @isTest
    static void testInitDataMethod1(){
        Account acctRectHp = [SELECT Id,Name FROM Account WHERE Name='testRectcoAccount' LIMIT 1];
        Account acctRectCo = [SELECT Id,Name FROM Account WHERE Name='testRectHpAccount' LIMIT 1];
        Contact contRectAg = [SELECT Id,RecordTypeId,accountId FROM Contact WHERE LastName = 'testRectAgContacts' LIMIT 1];
        Contact contRectIs = [SELECT Id,RecordTypeId,accountId FROM Contact WHERE LastName = 'testRectIsContacts' LIMIT 1];
        System.Test.startTest();
        LexNewAndEditContactPIPLController.initData(contRectAg.Id,rectAg,'Contact',contRectAg.accountId);
        LexNewAndEditContactPIPLController.initData(contRectIs.Id,null,'Contact',contRectIs.accountId);
        LexNewAndEditContactPIPLController.initData(contRectAg.Id,null,'Contact',null);
        LexNewAndEditContactPIPLController.searchContactByAccountId(contRectAg.accountId,rectAg,'有效');
        // LexNewAndEditContactPIPLController.searchContactByAccountId('',rectAg,'有效');
        LexNewAndEditContactPIPLController.ResponseV2 c2 = new LexNewAndEditContactPIPLController.ResponseV2();
        c2.contactList = contList;
        c2.accountName = acctRectHp.Name;
        c2.dataIdManageCodeMap = null;
        c2.isMobileVerif = True;
        c2.isNameMobileVerif = True;
        c2.message = null;
        c2.status = 'success';
        System.Test.stopTest();
    }
}