高章伟
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
@isTest
private class TransferEquipmentSetSRListControllerTest {
    static TransferTestDataFactory Factory;
    //查到备品明细 备品中心之间
    static testMethod void testMethod1() {
        Test.startTest();
        Factory = new TransferTestDataFactory();
        Factory.CreateTa('CenterToCenter');
        TransferApply__c raObj1 = [SELECT Id,Name,OwnerId,Status__c,Status_Text__c,Request_time__c,Request_approval_time__c  FROM TransferApply__c WHERE RecordType.DeveloperName = 'CenterToCenter' limit 1];       
        raObj1.Status__c = FixtureUtil.raStatusMap.get(FixtureUtil.RaStatus.Yi_Pi_Zhun.ordinal());
        raObj1.Status_Text__c = FixtureUtil.raStatusMap.get(FixtureUtil.RaStatus.Yi_Pi_Zhun.ordinal());
        raObj1.Request_time__c = System.now();
        raObj1.Request_approval_time__c = System.now();
        update raObj1;
 
        System_UserSetting__c config = System_UserSetting__c.getInstance(UserInfo.getUserId());
        System.assertEquals(null, config.TAS_Action_Type__c);
        PageReference ref = new PageReference('/apex/TransferEquipmentSetSRList?id=' + raObj1.Name );
        Test.setCurrentPage(ref);
        TransferEquipmentSetSRListController controller1 = new TransferEquipmentSetSRListController();
        //Test.startTest();
        controller1.init();
        controller1.selectedType = '发货';
        controller1.setType();
        Test.stopTest();
        config = System_UserSetting__c.getInstance(UserInfo.getUserId());
        System.assertEquals('发货', config.TAS_Action_Type__c);
    }
    //查到备品明细 备品中心移管至非集中管理部门
    static testMethod void testMethod2() {
        Test.startTest();
        Factory = new TransferTestDataFactory();
        Factory.CreateTa('CenterToOther');
        TransferApply__c raObj1 = [SELECT Id,Name,OwnerId,Status__c,Status_Text__c,Request_time__c,Request_approval_time__c  FROM TransferApply__c WHERE RecordType.DeveloperName = 'CenterToOther' limit 1];       
        raObj1.Status__c = FixtureUtil.raStatusMap.get(FixtureUtil.RaStatus.Yi_Pi_Zhun.ordinal());
        raObj1.Status_Text__c = FixtureUtil.raStatusMap.get(FixtureUtil.RaStatus.Yi_Pi_Zhun.ordinal());
        raObj1.Request_time__c = System.now();
        raObj1.Request_approval_time__c = System.now();
        update raObj1;
 
        System_UserSetting__c config = System_UserSetting__c.getInstance(UserInfo.getUserId());
        System.assertEquals(null, config.TAS_Action_Type__c);
        PageReference ref = new PageReference('/apex/TransferEquipmentSetSRList?id=' + raObj1.Name );
        Test.setCurrentPage(ref);
        TransferEquipmentSetSRListController controller1 = new TransferEquipmentSetSRListController();
        //Test.startTest();
        controller1.init();
        controller1.selectedType = '发货';
        controller1.setType();
        Test.stopTest();
        config = System_UserSetting__c.getInstance(UserInfo.getUserId());
        System.assertEquals('发货', config.TAS_Action_Type__c);
    }
    //查到备品明细 同备品中心
    static testMethod void testMethod3() {
        Test.startTest();
        Factory = new TransferTestDataFactory();
        Factory.CreateTa('InsideCenter');
        TransferApply__c raObj1 = [SELECT Id,Name,OwnerId,Status__c,Status_Text__c,Request_time__c,Request_approval_time__c  FROM TransferApply__c WHERE RecordType.DeveloperName = 'InsideCenter' limit 1];       
        raObj1.Status__c = FixtureUtil.raStatusMap.get(FixtureUtil.RaStatus.Yi_Pi_Zhun.ordinal());
        raObj1.Status_Text__c = FixtureUtil.raStatusMap.get(FixtureUtil.RaStatus.Yi_Pi_Zhun.ordinal());
        raObj1.Request_time__c = System.now();
        raObj1.Request_approval_time__c = System.now();
        update raObj1;
 
        System_UserSetting__c config = System_UserSetting__c.getInstance(UserInfo.getUserId());
        System.assertEquals(null, config.TAS_Action_Type__c);
        PageReference ref = new PageReference('/apex/TransferEquipmentSetSRList?id=' + raObj1.Name );
        Test.setCurrentPage(ref);
        TransferEquipmentSetSRListController controller1 = new TransferEquipmentSetSRListController();
        //Test.startTest();
        controller1.init();
        controller1.selectedType = '发货';
        controller1.setType();
        Test.stopTest();
        config = System_UserSetting__c.getInstance(UserInfo.getUserId());
        System.assertEquals('发货', config.TAS_Action_Type__c);
    }
    //AgencyToCenter  办事处到备品中心
    static testMethod void testMethod4() {
        Test.startTest();
        Factory = new TransferTestDataFactory();
        Factory.CreateTa('AgencyToCenter');
        TransferApply__c raObj1 = [SELECT Id,Name,OwnerId,Status__c,Status_Text__c,Request_time__c,Request_approval_time__c  FROM TransferApply__c WHERE RecordType.DeveloperName = 'AgencyToCenter' limit 1];       
        raObj1.Status__c = FixtureUtil.raStatusMap.get(FixtureUtil.RaStatus.Yi_Pi_Zhun.ordinal());
        raObj1.Status_Text__c = FixtureUtil.raStatusMap.get(FixtureUtil.RaStatus.Yi_Pi_Zhun.ordinal());
        raObj1.Request_time__c = System.now();
        raObj1.Request_approval_time__c = System.now();
        update raObj1;
 
        System_UserSetting__c config = System_UserSetting__c.getInstance(UserInfo.getUserId());
        System.assertEquals(null, config.TAS_Action_Type__c);
        PageReference ref = new PageReference('/apex/TransferEquipmentSetSRList?id=' + raObj1.Name );
        Test.setCurrentPage(ref);
        TransferEquipmentSetSRListController controller1 = new TransferEquipmentSetSRListController();
        //Test.startTest();
        controller1.init();
        controller1.selectedType = '发货';
        controller1.setType();
        Test.stopTest();
        config = System_UserSetting__c.getInstance(UserInfo.getUserId());
        System.assertEquals('发货', config.TAS_Action_Type__c);
    }
}