buli
2022-05-14 ead4df22dca33a867279471821ca675f91dec760
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
@isTest
private class CampaignUpsertContactToSapBatchTest {
    static testMethod void testMethod1() {
        List<RecordType> rectIE = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = 'Customer IE'];
        List<RecordType> rectDealer = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = 'Dealer'];
 
        Account acc = new Account();
        acc.Name = 'test001';
        acc.RecordTypeId = '01228000000TdF1';
        acc.ProductSegment__c = 'BS';
        acc.ManagementCode_Ext__c = '1234567';
        acc.AccountStatus__c = 'Active';
        acc.DepartmentName__c = 'DepartmentNametest';
        acc.DivisionName__c = 'DivisionNametest';
        acc.City__c = '北京';
        acc.Phone = '18711111111';
        acc.MobilePhoneNumber__c ='18711111112';
        acc.Fax = '18711111113';
        acc.PostCode__c = '100111';
        acc.Address1__c = 'Address1';
        acc.Sub_Use__c = 'LED';
        insert acc;
 
        Contact con = new Contact();
        con.StatusD__c = 'Pass';
        con.FirstName = 'con';
        con.LastName = 'test';
        con.AccountId = acc.Id;
        con.ManagementCode_Ext__c = '1234568';
        con.ContactStatus__c = 'Active';
        con.Phone = '01012345678';
        con.MobilePhone = '01012345679';
        acc.Fax = '18711111113';
        con.Email = 'EmailD__c@test.com';
        con.Postcode__c = '100111';
        con.Address1__c = 'Address1D';
        con.Department = 'Department';
        con.CampaignUpsertContact__c = true;
        insert con;
 
        Test.startTest();
        Id execBTId = null;
        // System.Test.StartTest();
        List<Contact> contactList = [SELECT Id,Name,isBatch__c,CampaignUpsertContact__c FROM Contact WHERE CampaignUpsertContact__c = true];
        System.assertEquals(1, contactList.size());
        execBTId = Database.executeBatch(new CampaignUpsertContactToSapBatch());
        Test.stopTest();
        contactList = [SELECT Id,Name,isBatch__c,CampaignUpsertContact__c FROM Contact WHERE CampaignUpsertContact__c = true];
        System.assertEquals(0, contactList.size());
    }
 
    static testMethod void testMethod2() {
        List<RecordType> rectIE = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = 'Customer IE'];
        List<RecordType> rectDealer = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = 'Dealer'];
 
        Account acc = new Account();
        acc.Name = 'test001';
        acc.RecordTypeId = '01228000000TdF1';
        acc.ProductSegment__c = 'BS';
        acc.ManagementCode_Ext__c = '1234567';
        acc.AccountStatus__c = 'Active';
        acc.DepartmentName__c = 'DepartmentNametest';
        acc.DivisionName__c = 'DivisionNametest';
        acc.City__c = '北京';
        acc.Phone = '18711111111';
        acc.MobilePhoneNumber__c ='18711111112';
        acc.Fax = '18711111113';
        acc.PostCode__c = '100111';
        acc.Address1__c = 'Address1';
        acc.Sub_Use__c = 'LED';
        insert acc;
 
        Contact con = new Contact();
        con.StatusD__c = 'Pass';
        con.FirstName = 'con';
        con.LastName = 'test';
        con.AccountId = acc.Id;
        con.ManagementCode_Ext__c = '1234568';
        con.ContactStatus__c = 'Active';
        con.Phone = '01012345678';
        con.MobilePhone = '01012345679';
        acc.Fax = '18711111113';
        con.Email = 'EmailD__c@test.com';
        con.Postcode__c = '100111';
        con.Address1__c = 'Address1D';
        con.Department = 'Department';
        con.CampaignUpsertContact__c = true;
        insert con;
 
        Test.startTest();
        Id execBTId = null;
        List<String> contactIdList = new List<String>();
        contactIdList.add(con.Id);
        execBTId = Database.executeBatch(new CampaignUpsertContactToSapBatch(contactIdList));
        Test.stopTest();
    }
}