高章伟
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
@isTest
private class TransferApplyDetailControllerTest {
    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;
 
        List<Asset> AssetList = [SELECT Id FROM Asset];
        TransferApplySummary__c raesObj = new TransferApplySummary__c();
        TransferApplyDetail__c raesdObj2 = new TransferApplyDetail__c();
        TransferApplyDetail__c raesdObj3 = new TransferApplyDetail__c();
        raesObj.TransferApply__c = raObj1.Id;
        //raesObj.Fixture_Set__c = fsObj1.Id;
        raesObj.Cancel_Select__c = false;
        raesObj.IndexFromUniqueKey__c = 1;
        insert raesObj;
 
        raesdObj2.TransferApply__c = raObj1.Id;
        raesdObj2.Asset__c = AssetList[1].Id;
        raesdObj2.TransferApplySummary__c = raesObj.Id;
        raesdObj2.IndexFromUniqueKey__c = 1;
        raesdObj2.ApplyPersonAppended__c = true;
        raesdObj2.Create_State__c = 1;
        raesdObj2.TransferCount__c = 1;
        raesdObj2.FSD_SortInt__c = 01;
 
        raesdObj3.TransferApply__c = raObj1.Id;
        raesdObj3.Asset__c = AssetList[1].Id;
        raesdObj3.TransferApplySummary__c = raesObj.Id;
        raesdObj3.IndexFromUniqueKey__c = 1;
        raesdObj3.ApplyPersonAppended__c = true;
        raesdObj2.Create_State__c = 1;
        raesdObj3.TransferCount__c = 1;
        raesdObj3.FSD_SortInt__c = 02;
 
        insert new TransferApplyDetail__c[] {raesdObj2,raesdObj3};
 
        PageReference ref = new PageReference('/apex/TransferApplyDetailController?taId=' + raObj1.Id);
        Test.setCurrentPage(ref);
        TransferApplyDetailController controller1 = new TransferApplyDetailController();
        controller1.taId = raObj1.Id;
        controller1.gatherName = 'TransferEmail';
        controller1.varType = 'add';
        controller1.getinit();
 
        raesdObj2.Cancel_Select__c = true;
        raesdObj2.Cancel_Reason__c = 'test';
        raesdObj2.Cancel_Time__c = System.now();
        update raesdObj2;
 
        controller1.varType = 'cancel';
        controller1.getinit();
        Test.stopTest();
    }
}