高章伟
2023-03-03 d8dc84a3d56df839895f1c417a4d9cbee763d262
force-app/main/default/classes/LeadTriggerTest.cls
@@ -17,8 +17,8 @@
        ret.LastName = inputName;
        ret.Email = inputEmail;
        ret.Firstname='ZZ2';
        insert ret;
        ret = [SELECT Id, FirstName, LastName, Email FROM Contact WHERE Id = :ret.Id];
        // insert ret;
        // ret = [SELECT Id, FirstName, LastName, Email FROM Contact WHERE Id = :ret.Id];
        return ret;
    }
@@ -64,11 +64,19 @@
        // リード3件が、コンタクト3件と一対一で対応することを確認
        
        // コンタクト3件作成
        Contact con01 = createContact( 'con01', 'con01_20140519@test.com');
        Contact con02 = createContact( 'con02', 'con02_20140519@test.com');
        Contact con03 = createContact( 'con03', 'con03_20140519@test.com');
        // Contact con01 = createContact( 'con01', 'con01_20140519@test.com');
        // Contact con02 = createContact( 'con02', 'con02_20140519@test.com');
        // Contact con03 = createContact( 'con03', 'con03_20140519@test.com');
        Profile p = [select Id from Profile where id =:System.Label.ProfileId_SystemAdmin];
        User local = new User(Test_staff__c = true,Employee_No__c ='ocm99999', LastName = 'hp', FirstName = 'owner', Alias = 'hp', CommunityNickname = 'hpOwner', Email = 'olympus_hpowner@sunbridge.com', Username = 'olympus_hpowner@sunbridge.com', IsActive = true, EmailEncodingKey = 'ISO-2022-JP', TimeZoneSidKey = 'Asia/Tokyo', LocaleSidKey = 'ja_JP', LanguageLocaleKey = 'ja', ProfileId = p.id);
        local.Job_Category__c = '销售推广';
        local.Province__c = '北京市';
        insert local;
        Lead lead01 = createLead( 'con01', 'con01_20140519@test.com');
        lead01.SI_PromoteInquiry__c = true;
        lead01.OwnerId = local.Id;
        update lead01;
        Lead lead02 = createLead( 'con02', 'con02_20140519@test.com');
        Lead lead03 = createLead( 'con03', 'con03_20140519@test.com');
        
@@ -83,11 +91,19 @@
        // リード1件が、コンタクト1件と対応していることを確認する
        
        // コンタクト3件作成
        Contact con01 = createContact( 'con01', 'con01_20140519@test.com');
        Contact con02 = createContact( 'con02', 'con02_20140519@test.com');
        Contact con03 = createContact( 'con03', 'con03_20140519@test.com');
        // Contact con01 = createContact( 'con01', 'con01_20140519@test.com');
        // Contact con02 = createContact( 'con02', 'con02_20140519@test.com');
        // Contact con03 = createContact( 'con03', 'con03_20140519@test.com');
        Profile p = [select Id from Profile where id =:System.Label.ProfileId_SystemAdmin];
        User local2 = new User(Test_staff__c = true,Employee_No__c ='ocm99998', LastName = 'hp2', FirstName = 'owner', Alias = 'hp2', CommunityNickname = 'hpOwner2', Email = 'olympus_hpowner2@sunbridge.com', Username = 'olympus_hpowner2@sunbridge.com', IsActive = true, EmailEncodingKey = 'ISO-2022-JP', TimeZoneSidKey = 'Asia/Tokyo', LocaleSidKey = 'ja_JP', LanguageLocaleKey = 'ja', ProfileId = p.id);
        local2.Job_Category__c = '销售推广';
        local2.Province__c = '辽宁省';
        insert local2;
        
        Lead lead01 = createLead( 'con01', 'con01_20140519@test.com');
        lead01.SI_PromoteInquiry__c = true;
        lead01.OwnerId = local2.Id;
        update lead01;
        
        //System.assertEquals( con01.Id, lead01.Contact__c);
    }
@@ -98,11 +114,19 @@
        // リード3件が、コンタクト3件と一対一で対応することを確認
        
        // コンタクト3件作成
        Contact con01 = createContact( 'con01', 'con01_20140519@test.com');
        Contact con02 = createContact( 'con02', 'con01_20140519@test.com');
        Contact con03 = createContact( 'con03', 'con01_20140519@test.com');
        // Contact con01 = createContact( 'con01', 'con01_20140519@test.com');
        // Contact con02 = createContact( 'con02', 'con01_20140519@test.com');
        // Contact con03 = createContact( 'con03', 'con01_20140519@test.com');
        Profile p = [select Id from Profile where id =:System.Label.ProfileId_SystemAdmin];
        User local3 = new User(Test_staff__c = true,Employee_No__c ='ocm99997', LastName = 'hp3', FirstName = 'owner', Alias = 'hp3', CommunityNickname = 'hpOwner3', Email = 'olympus_hpowner3@sunbridge.com', Username = 'olympus_hpowner3@sunbridge.com', IsActive = true, EmailEncodingKey = 'ISO-2022-JP', TimeZoneSidKey = 'Asia/Tokyo', LocaleSidKey = 'ja_JP', LanguageLocaleKey = 'ja', ProfileId = p.id);
        local3.Job_Category__c = '销售推广';
        local3.Province__c = '湖北省';
        insert local3;
        Lead lead01 = createLead( 'con01', 'con01_20140519@test.com');
        lead01.SI_PromoteInquiry__c = true;
        lead01.OwnerId = local3.Id;
        update lead01;
        
        //System.assertEquals( con03.Id, lead01.Contact__c);
    }
@@ -113,12 +137,28 @@
        // リード3件が、コンタクト3件と一対一で対応しないことを確認する
        
        // コンタクト3件作成
        Contact con01 = createContact( 'con01', 'con01_20140519@test.com');
        Contact con02 = createContact( 'con02', 'con02_20140519@test.com');
        Contact con03 = createContact( 'con03', 'con03_20140519@test.com');
        // Contact con01 = createContact( 'con01', 'con01_20140519@test.com');
        // Contact con02 = createContact( 'con02', 'con02_20140519@test.com');
        // Contact con03 = createContact( 'con03', 'con03_20140519@test.com');
        Profile p = [select Id from Profile where id =:System.Label.ProfileId_SystemAdmin];
        User local = new User(Test_staff__c = true,Employee_No__c ='ocm99999', LastName = 'hp', FirstName = 'owner', Alias = 'hp', CommunityNickname = 'hpOwner', Email = 'olympus_hpowner@sunbridge.com', Username = 'olympus_hpowner@sunbridge.com', IsActive = true, EmailEncodingKey = 'ISO-2022-JP', TimeZoneSidKey = 'Asia/Tokyo', LocaleSidKey = 'ja_JP', LanguageLocaleKey = 'ja', ProfileId = p.id);
        local.Job_Category__c = '销售推广';
        local.Province__c = '四川省';
        insert local;
        User local2 = new User(Test_staff__c = true,Employee_No__c ='ocm99998', LastName = 'hp2', FirstName = 'owner', Alias = 'hp2', CommunityNickname = 'hpOwner2', Email = 'olympus_hpowner2@sunbridge.com', Username = 'olympus_hpowner2@sunbridge.com', IsActive = true, EmailEncodingKey = 'ISO-2022-JP', TimeZoneSidKey = 'Asia/Tokyo', LocaleSidKey = 'ja_JP', LanguageLocaleKey = 'ja', ProfileId = p.id);
        local2.Job_Category__c = '销售推广';
        local2.Province__c = '浙江省';
        insert local2;
        
        Lead lead01 = createLead( 'con01', 'con11_20140519@test1.com');
        lead01.SI_PromoteInquiry__c = true;
        lead01.OwnerId = local.Id;
        update lead01;
        Lead lead02 = createLead( 'con02', 'con12_20140519@test1.com');
        lead02.SI_PromoteInquiry__c = true;
        lead02.OwnerId = local2.Id;
        update lead02;
        Lead lead03 = createLead( 'con03', 'con13_20140519@test1.com');
        
        //System.assertEquals( null, lead01.Contact__c);
@@ -132,9 +172,9 @@
        // リード3件が、コンタクト3件と一対一で対応することを確認
        
        // コンタクト3件作成
        Contact con01 = createContact( 'con01', 'con01_20140519@test.com');
        Contact con02 = createContact( 'con02', 'con02_20140519@test.com');
        Contact con03 = createContact( 'con03', 'con03_20140519@test.com');
        // Contact con01 = createContact( 'con01', 'con01_20140519@test.com');
        // Contact con02 = createContact( 'con02', 'con02_20140519@test.com');
        // Contact con03 = createContact( 'con03', 'con03_20140519@test.com');
        
        Lead lead01 = createLeadData( 'con01', 'con01_20140519@test.com');
        Lead lead02 = createLeadData( 'con02', 'con02_20140519@test.com');
@@ -160,9 +200,9 @@
        // スルーされることを確認
        
        // コンタクト3件作成
        Contact con01 = createContact( 'con01', 'con01_20140519@test.com');
        Contact con02 = createContact( 'con02', 'con02_20140519@test.com');
        Contact con03 = createContact( 'con03', 'con03_20140519@test.com');
        // Contact con01 = createContact( 'con01', 'con01_20140519@test.com');
        // Contact con02 = createContact( 'con02', 'con02_20140519@test.com');
        // Contact con03 = createContact( 'con03', 'con03_20140519@test.com');
        
        Lead lead01 = createLeadData( 'con01', 'con01_20140519@test.com');
        Lead lead02 = createLeadData( 'con02', 'con02_20140519@test.com');