黄千龙
2022-04-08 01f207d979d6be17c8cdec293feab48828c0ec3e
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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
@isTest
private class InstructReportControllerTest {
    @TestSetup 
    static void makeData(){
        TestDataUtility.CreatePIPolicyConfiguration('Contact');
        RecordType rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and DeveloperName = 'Hp'];
        List<RecordType> rectDpt = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and DeveloperName IN ('Department_GI', 'Department_BF') order by DeveloperName desc];
        Account acc = new Account();
        acc.RecordTypeId = rectCo.Id;
        acc.Name = 'HP test1';
        insert acc;
 
        List<Account> dept = [select Id, Name from Account where ParentId = :acc.Id and Department_Class_Label__c IN ('消化科', '呼吸科') order by Department_Class_Label__c];
 
        Account depart1 = new Account();
        depart1.RecordTypeId = rectDpt[0].Id;
        depart1.Name         = '*';
        depart1.Department_Name__c  = 'Gastoro Intestin Test';
        depart1.ParentId            = dept[0].Id;
        depart1.Department_Class__c = dept[0].Id;
        depart1.Hospital__c         = acc.Id;
 
        Account depart2 = new Account();
        depart2.RecordTypeId = rectDpt[1].Id;
        depart2.Name         = '*';
        depart2.Department_Name__c  = '診療科2';
        depart2.ParentId            = dept[1].Id;
        depart2.Department_Class__c = dept[1].Id;
        depart2.Hospital__c         = acc.Id;
        insert new Account[] {depart1, depart2};
 
        Contact con = new Contact();
        con.LastName = 'lastname2';
        con.FirstName = 'firstname2';
        con.Email = 'olympustest033@sunbridge.com';
        con.MobilePhone = '99999999';
        con.Work_Location_manual__c = 'location2';
        con.Post_picklist__c = '部长';
        con.Job_Category_picklist__c = '销售推广';
        con.Hire_date_text__c = Date.today().addMonths(-6);
        con.Gender_text__c = '男';
        con.dept__c = '服务本部';
        con.Pregnant_Rest__c = true;
        insert con;
 
        RecordType rectCam =
            [select Id from RecordType
             where IsActive = true and SobjectType = 'Campaign'
                              and DeveloperName = 'ServiceEngineerTraining'];
 
        Campaign cam = new Campaign();
        cam.Name = 'cam';
        cam.Name2__c = '1234';
        cam.RecordTypeId = rectCam.Id;
        cam.StartDate = Date.today().addDays(-15);
        cam.EndDate = Date.today().addDays(18);
        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;
        insert cam;
        CampaignMember__c tempCM = new  CampaignMember__c(Contact_ID__c = con.id, Campaign__c = cam.id);
        insert tempCM;
 
        Instruct_report__c temIR = new Instruct_report__c();
        temIR.Campaign__c = cam.id;
        temIR.Status__c     = '草案中';
        temIR.ServiceDesignDep__c = UserInfo.getUserId();
        temIR.Name = cam.Name + '第' + 1 + '次报告';
        //temAR.Type__c = '授课';
        insert temIR;
        Instructed_staff__c     tempARS =  new Instructed_staff__c    ();
        tempARS.CampaignMember__c = tempCM.id;
        tempARS.ContactID__c       = con.id;
        tempARS.Instruct_report__c = temIR.id;
        tempARS.Department__c = depart2.id ;
        insert tempARS;
    }
    
 
    @isTest static void test_init() {
        // Implement test code
 
        list<Campaign> camlist = [select id from Campaign];
        Campaign cam = camlist[0];
        PageReference page = new PageReference('/apex/InstructReport?camid=' + cam.Id);
        System.Test.setCurrentPage(page);
        InstructReportController cmc = new InstructReportController();
        cmc.init();
        Instruct_report__c temIR = [select id from Instruct_report__c];
        page = new PageReference('/apex/InstructReport?id=' + temIR.Id);
        System.Test.setCurrentPage(page);
        cmc = new InstructReportController();
        cmc.init();
    }
 
    @isTest static void test_CheckSaveInput() {
        Instruct_report__c temIR = [select id from Instruct_report__c];
        PageReference page = new PageReference('/apex/InstructReport?id=' + temIR.Id);
        System.Test.setCurrentPage(page);
        InstructReportController cmc = new InstructReportController();
        cmc.init();
        cmc.CheckSaveInput();
        for (InstructReportController.InstructedstaffInfo temIS : cmc.checkedISList) {
            temIS.IS.Instruct_time__c = null;
            temIS.IS.Instruct_content__c = null;
        }
        cmc.CheckSaveInput();
    }
 
    @isTest static void test_Save_Submit() {
        Instruct_report__c temIR = [select id from Instruct_report__c];
        PageReference page = new PageReference('/apex/InstructReport?id=' + temIR.Id);
        System.Test.setCurrentPage(page);
        InstructReportController cmc = new InstructReportController();
        cmc.init();
        cmc.save();
        cmc.saveAndCancel();
        cmc.Submit();
 
        cmc.Instruct_report.Instruct_Staff__c = UserInfo.getUserId();
        cmc.Instruct_report.Verifier__c = '护士长';
        cmc.Instruct_report.VerifierName__c = '护士长';
        cmc.Instruct_report.VerifierNumber__c = '护士长';
        for (InstructReportController.InstructedstaffInfo temIS : cmc.checkedISList) {
            temIS.IS.Instruct_Date__c  = Date.today();
            temIS.IS.Instructed_staff_feedback__c = 'test word';
            temIS.IS.Instruct_staff_feedback__c = 'test word';
            temIS.IS.Instruct_Date__c  = Date.today();
            temIS.IS.Instructed_staff_feedback__c = 'test word';
            temIS.IS.Instruct_staff_feedback__c = 'test word';
            temIS.IS.Instruct_time__c ='1-2';
            temIS.IS.Instruct_content__c='使用操作';
            temIS.IS.Instruct_place__c = '消化科/内镜中心';
            temIS.IS.Instruct_content_other__c = '测试';
            temIS.IS.Verifier__c = '护士长';
            temIS.IS.VerifierName__c = '精琢技术';
 
        }
        cmc.save();
        cmc.saveAndCancel();
        cmc.Submit();
 
 
    }
    @isTest static void test_exchangeInstructedstaff() {
        Instruct_report__c temIR = [select id from Instruct_report__c];
        PageReference page = new PageReference('/apex/InstructReport?id=' + temIR.Id);
        System.Test.setCurrentPage(page);
        InstructReportController cmc = new InstructReportController();
        cmc.init();
        for (InstructReportController.InstructedstaffInfo checkedIS : cmc.checkedISList) {
            checkedIS.rec_checkBox = false;
        }
        cmc.exchangeInstructedstaff();
        for (InstructReportController.InstructedstaffInfo uncheckedIS : cmc.uncheckedISList) {
            uncheckedIS.rec_checkBox = true;
        }
        cmc.exchangeInstructedstaff();
 
    }
 
    @isTest static void test_unitTest() {
        Instruct_report__c temIR = [select id from Instruct_report__c];
        PageReference page = new PageReference('/apex/InstructReport?id=' + temIR.Id);
        System.Test.setCurrentPage(page);
        InstructReportController cmc = new InstructReportController();
        cmc.init();
        cmc.EditRecord();
        cmc.getInputdisabled();
        cmc.cancel();
 
        Integer i = cmc.CheckedCnt;
        Integer j = cmc.unCheckedCnt;
        Boolean tf = cmc.getIsServiceDesignDep();
    }
}