高章伟
2022-02-18 8b5f4c6c281cfa548f92de52c8021e37aa81901e
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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
@isTest
private class CampaignTriggerBefInsHandlerTest {
    private static final RecordType campaignRC = [SELECT Id, DeveloperName FROM RecordType WHERE DeveloperName = 'Internal_training' AND SObjectType = 'Campaign'];
    private static final RecordType campaignMemberRC = [SELECT Id, DeveloperName FROM RecordType WHERE DeveloperName = 'Internal_training_participants' AND SObjectType = 'CampaignMember'];
    
    @isTest static void test_method_one() {
        StaticParameter.EscapeCampain =false;
        StaticParameter.shareToOSCMFlag = false;
        // Implement test code    
        Campaign cam = new Campaign();
        cam.Name = 'test campaign';
        cam.StartDate = Date.today().addDays(15);
        cam.EndDate = Date.today().addDays(18);
        cam.Name2__c = '1234';
        cam.Status = '申请中';
        cam.Mailflg_after45__c = true;
        cam.Mailflg_cancel__c = true;
        cam.Mailflg_before15__c = true;
        cam.Mailflg_before7__c = true;
        cam.Mailflg_after3__c = true;
        cam.HostName__c = '1';
        cam.cooperatorCompany__c = '1';
        cam.RecordTypeId = System.label.RecordType_CampaignService;
        insert cam;
        StaticParameter.EscapeCampain =false;
 
        cam.Status = '取消';
        update cam;
        
        //Campaign cam1 = new Campaign();
        //cam1.Id = cam.Id;
        // cam.Status = '时间修改申请中';
        // cam.is_true_or_false__c = true;
        // cam.is_pass_or_fail__c = 1;
        // update cam;
 
        //Campaign cam2 = new Campaign();
        //cam2.Id = cam.Id;
        // cam.Status = '时间修改申请中';
        // cam.is_true_or_false__c = true;
        // cam.is_pass_or_fail__c = 2;
        // update cam;
 
        // cam = [SELECT Id, RecordType FROM Campaign WHERE Id = :cam.Id];
        // System.assertEquals(campaignMemberRC.Id, target.CampaignMemberRecordTypeId);
 
    }
 
    static testMethod void testMethod2(){
        StaticParameter.EscapeCampain =false;
        StaticParameter.shareToOSCMFlag = false;
        // Implement test code    
        Campaign cam = new Campaign();
        cam.Name = 'test campaign';
        cam.StartDate = Date.today().addDays(15);
        cam.EndDate = Date.today().addDays(18);
        cam.Name2__c = '1234';
        cam.Status = '申请中';
        cam.Mailflg_after45__c = true;
        cam.Mailflg_cancel__c = true;
        cam.Mailflg_before15__c = true;
        cam.Mailflg_before7__c = true;
        cam.Mailflg_after3__c = true;
        cam.HostName__c = '1';
        cam.cooperatorCompany__c = '1';
        cam.RecordTypeId = System.label.RecordType_CampaignService;
        insert cam;
        StaticParameter.EscapeCampain =false;
        cam.Status = '时间修改申请中';
        cam.is_true_or_false__c = true;
        cam.is_pass_or_fail__c = 1;
        update cam;
    }
    static testMethod void testMethod3(){
        StaticParameter.EscapeCampain =false;
        StaticParameter.shareToOSCMFlag = false;
        // Implement test code    
        Campaign cam = new Campaign();
        cam.Name = 'test campaign';
        cam.StartDate = Date.today().addDays(15);
        cam.EndDate = Date.today().addDays(18);
        cam.Name2__c = '1234';
        cam.Status = '申请中';
        cam.Mailflg_after45__c = true;
        cam.Mailflg_cancel__c = true;
        cam.Mailflg_before15__c = true;
        cam.Mailflg_before7__c = true;
        cam.Mailflg_after3__c = true;
        cam.HostName__c = '1';
        cam.cooperatorCompany__c = '1';
        cam.RecordTypeId = System.label.RecordType_CampaignService;
        insert cam;
        StaticParameter.EscapeCampain =false;
        cam.Status = '时间修改申请中';
        cam.is_true_or_false__c = true;
        cam.is_pass_or_fail__c = 2;
        cam.IF_Submit__c = true;
        update cam;
    }
 
    static testMethod void testMethod4(){
        StaticParameter.EscapeCampain =false;
        StaticParameter.shareToOSCMFlag = false;
        Campaign target = new Campaign();
        target.Name = 'test campaign';
        target.RecordTypeId = campaignRC.Id;    // 内部トレーニング
        target.JingliApprovalManager__c = UserInfo.getUserId();
        insert target;
 
        StaticParameter.EscapeCampain =false;
        
        Campaign target1 = new Campaign();
        target1.Id = target.Id;
        target1.Name= 'test1 campaign'; 
        update target1;
 
        // CanpaignMemberのレコードタイプを検査
        target = [SELECT Id, CampaignMemberRecordTypeId FROM Campaign WHERE Id = :target.Id];
        System.assertEquals(campaignMemberRC.Id, target.CampaignMemberRecordTypeId);
 
    }
}