高章伟
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
@isTest
private class TransferShippmentReceived1ControllerTest {
    static TransferTestDataFactory Factory;
    static void setupTestData1() { 
        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;
    }
    static testMethod void test_init_error() {
        Test.startTest();
        setupTestData1();
        List<TransferApply__c> taList = [SELECT Id,OwnerId,Status__c FROM TransferApply__c]; 
        List<TransferApplySummary__c> essList;
        essList = [select TransferApply__r.Loaner_centre_mail_address__c, TransferApply__r.Name, TransferApply__c, Id, Name
                        from TransferApplySummary__c WHERE TransferApply__c = :taList[0].Id ];
 
        PageReference ref2 = new PageReference('/apex/TransferShippmentReceived1?id=' + '1234');
        Test.setCurrentPage(ref2);
        TransferShippmentReceived1Controller controller = new TransferShippmentReceived1Controller();
        controller.init();
        Test.stopTest();
        System.assertEquals(0, controller.esdList.size());
    }
    static testMethod  void test_save() {
        Test.startTest();
        setupTestData1();
        List<TransferApply__c> taList = [SELECT Id,OwnerId,Status__c FROM TransferApply__c]; 
        List<TransferApplySummary__c> esList;
        esList = [select TransferApply__r.Loaner_centre_mail_address__c, TransferApply__r.Name, TransferApply__c, Id, Name
                        from TransferApplySummary__c WHERE TransferApply__c = :taList[0].Id ];
        PageReference ref = new PageReference('/apex/TransferShippmentReceived1?id=' + esList[0].id);
        Test.setCurrentPage(ref);
 
        TransferShippmentReceived1Controller controller = new TransferShippmentReceived1Controller();
 
        //controller.ApplyId = '*';
        controller.init();
 
        controller.esdList[0].editable = true; 
        controller.esdList[0].rec.StockDown__c = true;
 
        controller.esdList[1].editable = true;
        controller.esdList[1].rec.StockDown__c = true;
 
        controller.esdList[2].editable = true;
        controller.esdList[2].rec.StockDown__c = false;
 
        controller.save();
        controller.Shippment1();
        controller.Shippment2();
        Test.stopTest();
 
        List<TransferApplyDetail__c> erList;
        erList = [select  StockDown__c,StockDown_time__c,StockDown_staff__c 
                        from TransferApplyDetail__c];
        System.assertEquals(true, erList[0].StockDown__c);
    }
}