liuyn
2024-03-11 a87f1c3df03078814ee97ad0c8ac200a232419e9
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
/**
 * This class contains unit tests for validating the behavior of Apex classes
 * and triggers.
 *
 * Unit tests are class methods that verify whether a particular piece
 * of code is working properly. Unit test methods take no arguments,
 * commit no data to the database, and are flagged with the testMethod
 * keyword in the method definition.
 *
 * All test methods in an organization are executed whenever Apex code is deployed
 * to a production organization to confirm correctness, ensure code
 * coverage, and prevent regressions. All Apex classes are
 * required to have at least 75% code coverage in order to be deployed
 * to a production organization. In addition, all triggers must have some code coverage.
 *
 * The @isTest class annotation indicates this class only contains test
 * methods. Classes defined with the @isTest annotation do not count against
 * the organization size limit for all Apex scripts.
 *
 * See the Apex Language Reference for more information about Testing and Code Coverage.
 */
@isTest
private class UpdateUserTextColBatchTest {
 
    @testSetup static void methodName() {
        String loginId = UserInfo.getUserId();
        list<PermissionSetAssignment> PermissionSetAssignmentList = new list<PermissionSetAssignment>();
        PermissionSetAssignmentList.add(new PermissionSetAssignment(AssigneeId = loginId,
                                        PermissionSetId = system.Label.PermissionSet_Createdashboard_ID));
        PermissionSetAssignmentList.add(new PermissionSetAssignment(AssigneeId = loginId,
                                        PermissionSetId = system.Label.PermissionSet_ENDOPARTNER_ID));
        PermissionSetAssignmentList.add(new PermissionSetAssignment(AssigneeId = loginId,
                                        PermissionSetId = system.Label.PermissionSet_Group_purchse_dept_ID));
        PermissionSetAssignmentList.add(new PermissionSetAssignment(AssigneeId = loginId,
                                        PermissionSetId = system.Label.PermissionSet_P002_Agent_ID));
        PermissionSetAssignmentList.add(new PermissionSetAssignment(AssigneeId = loginId,
                                        PermissionSetId = system.Label.PermissionSet_P002_OCM_ID));
        PermissionSetAssignmentList.add(new PermissionSetAssignment(AssigneeId = loginId,
                                        PermissionSetId = system.Label.PermissionSet_Plan_report_permission_ID));
        PermissionSetAssignmentList.add(new PermissionSetAssignment(AssigneeId = loginId,
                                        PermissionSetId = system.Label.PermissionSet_ProductCost_ID));
        PermissionSetAssignmentList.add(new PermissionSetAssignment(AssigneeId = loginId,
                                        PermissionSetId = system.Label.PermissionSet_Report_ID));
        PermissionSetAssignmentList.add(new PermissionSetAssignment(AssigneeId = loginId,
                                        PermissionSetId = system.Label.PermissionSet_SI_ID));
        Database.upsert(PermissionSetAssignmentList, false);
 
    }
 
    static testMethod void testUpdateUserText() {
        String loginId = UserInfo.getUserId();
        Date toDate = Date.today();
        Date mon1stDate = Date.newInstance(toDate.year(), toDate.month(), 1);
        Integer SSBacth_Execute_Day = Integer.valueOf(System.Label.SSBacth_Execute_Day);
        List<OlympusCalendar__c> ocList = new List<OlympusCalendar__c>();
        for (Integer i = 0; i <= SSBacth_Execute_Day; i++) {
            OlympusCalendar__c oc = new OlympusCalendar__c(Date__c = mon1stDate.addDays(i), ChangeToWorkday__c = true);
            ocList.add(oc);
        }
        insert ocList;
 
 
        System.Test.StartTest();
        Id execBTId = Database.executeBatch(new UpdateUserTextColBatch(loginId), 20);
        System.Test.StopTest();
 
        // assert できないですね。OlympusCalendarにデータを作ったら連番できなくなります。
        //List<User> uList = [select Id, Fiscal_Worddays_System__c, Fiscal_Worddays__c from User where Id = :loginId];
        //System.assertEquals(uList[0].Fiscal_Worddays_System__c, uList[0].Fiscal_Worddays__c);
    }
 
    /* 2018-12-10 CHAN-B6W86D 根据权限集进行权限设置
     * 插入用户,对用户插入权限集
     */
 
 
 
}