高章伟
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
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
@isTest
private class RemoveBoxControllerTest
{
    
    static testMethod void myUnitTest() {
        // TO DO: implement unit test
        List<RecordType> rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '販売店'];
        if (rectCo.size() == 0) {
            return;
        }
        Profile prof = [select Id from Profile where Name ='901_经销商社区普通权限_2重验证(ET Email)'];
        
        
        Account myAccount2 = new Account(name='Testaccount002',Dealer_discount__c =20,RecordTypeId = rectCo[0].Id,AgentCode_Ext__c = '9999900');
        insert myAccount2;
 
        Contact core = new Contact(email='jplumber@salesforce.com', firstname='Joe',lastname='Plumber',accountid=myAccount2.id);
        insert core;
        user MyUser_Test = New User(ContactId = core.id,Alias = 'newUser',Email='newuser@testorg.com',EmailEncodingKey='UTF-8', LastName='TestUser', LanguageLocaleKey='zh_CN',LocaleSidKey='zh_CN', ProfileId = prof.Id,TimeZoneSidKey='Asia/Shanghai', UserName='testUser@testorg.com');
        insert MyUser_Test;
 
        system.runAs(myUser_Test){
            
            StaticParameter.EscapeConsumableOrderDetail2Trigger = true;
            StaticParameter.EscapeNFM007Trigger = true;
            StaticParameter.EscapeOpportunityBefUpdTrigger = true;
            StaticParameter.EscapeOpportunityHpDeptUpdTrigger = true;
            StaticParameter.EscapeSyncOpportunityTrigger = true;
            StaticParameter.EscapeSyncProduct2Trigger = true;
 
 
            Product2 prod01 = new Product2(Name='Test01',ProductCode='Test01',Asset_Model_No__c = 'Test01',SFDA_Status__c = '有効',JANCODE__c = '04953170200311',Packing_list_manual__c=12,Dealer_special_Object__c = true);
            Product2 prod02 = new Product2(Name='Test02',ProductCode='Test02',Asset_Model_No__c = 'Test02',SFDA_Status__c = '有効',JANCODE__c = '04953170200312',Packing_list_manual__c=10,Dealer_special_Object__c = true);
            Product2 prod03 = new Product2(Name='Test03',ProductCode='Test03',Asset_Model_No__c = 'Test03',SFDA_Status__c = '有効',JANCODE__c = '04953170200313',Packing_list_manual__c=1,Dealer_special_Object__c = true);
            insert new Product2[]{prod01,prod02,prod03};
            Product2__c pro1 = new Product2__c(Name='Pro001',OT_CODE_Text__c='Test001',Product2__c = prod01.Id);
            Product2__c pro2 = new Product2__c(Name='Pro002',OT_CODE_Text__c='Test002',Product2__c = prod02.Id);
            Product2__c pro3 = new Product2__c(Name='Pro003',OT_CODE_Text__c='Test003',Product2__c = prod03.Id);
            insert new Product2__c[] {pro1, pro2,pro3};
            //订单
            Consumable_order__c Order1 = new Consumable_order__c();
            Order1.Name = 'OCM_01_001';
            Order1.Order_status__c = '批准';
            Order1.Order_type__c = '订单';
            Order1.Dealer_Info__c = myAccount2.Id;
            Order1.RecordTypeid = System.Label.RT_ConOrder_Delivery;
            Order1.Order_ProType__c = 'ET';
            insert  Order1;
 
            //daoku
            Consumable_order_details2__c Orderdet2 = new Consumable_order_details2__c();
            Orderdet2.Name = 'OCM_01_001001';
            Orderdet2.Consumable_order_minor__c = Order1.Id;
            Orderdet2.Consumable_Product__c = pro1.Id;
            Orderdet2.Asset_Model_No__c = 'Test01';
            Orderdet2.Arrive_date__c = Date.today();
            Orderdet2.Bar_Code__c = '01049531702003111115120017181000105ZK250BXJRF';
            Orderdet2.Used_date__c = null;
            Orderdet2.Lose_Flag__c = false;
            Orderdet2.Return_date__c= null;
            Orderdet2.Send_Date__c= null;
            Orderdet2.Box_Piece__c = '盒';
            insert Orderdet2;
 
            //chuhe
            Consumable_order_details2__c Orderdet3 = new Consumable_order_details2__c();
            Orderdet3.Name = 'OCM_01_001002';
            Orderdet3.Consumable_order_minor__c = Order1.Id;
            Orderdet3.Consumable_Product__c = pro2.Id;
            Orderdet3.Asset_Model_No__c = 'Test02';
            Orderdet3.Arrive_date__c = Date.today();
            Orderdet3.Send_Date__c = Date.today();
            Orderdet3.Box_Piece__c = '个';
            Orderdet3.RemoveBox_date__c= Date.today();
            Orderdet3.Bar_Code__c = '01049531702003111115120017181000105ZK250BXJRA';
            Orderdet3.Used_date__c = null;
            Orderdet3.Lose_Flag__c = false;
            Orderdet3.Return_date__c= null;
            insert Orderdet3;
 
 
            //sale
            Consumable_order_details2__c Orderdet4 = new Consumable_order_details2__c();
            Orderdet4.Name = 'OCM_01_001004';
            Orderdet4.Consumable_order_minor__c = Order1.Id;
            Orderdet4.Consumable_Product__c = pro2.Id;
            Orderdet4.Asset_Model_No__c = 'Test02';
            Orderdet4.Arrive_date__c = Date.today();
            Orderdet4.Box_Piece__c = '个';
            Orderdet4.RemoveBox_date__c= Date.today();
            Orderdet4.Bar_Code__c = '011495317020843711170400172003311074K250CXSDS';
            Orderdet4.Lose_Flag__c = false;
            Orderdet4.Return_date__c= null;
            Orderdet4.Used_date__c= Date.today();
            insert Orderdet4;
 
 
            //ProductPacking_list_manual__c=1
            Consumable_order_details2__c Orderdet5 = new Consumable_order_details2__c();
            Orderdet5.Name = 'OCM_01_001004';
            Orderdet5.Consumable_order_minor__c = Order1.Id;
            Orderdet5.Consumable_Product__c = pro3.Id;
            Orderdet5.Asset_Model_No__c = 'Test03';
            Orderdet5.Arrive_date__c = Date.today();
            //Orderdet5.Used_date__c = Date.today();
            Orderdet5.Box_Piece__c = '盒';
            Orderdet5.RemoveBox_date__c= Date.today();
            Orderdet5.Used_date__c = null;
            Orderdet5.Lose_Flag__c = false;
            Orderdet5.Return_date__c= null;
            Orderdet5.Send_Date__c=null;
            Orderdet5.Bar_Code__c = '010495317014059411170400172203311074K250DCWQW';
            insert Orderdet5;
 
            //pandian
         Consumable_order_details2__c Orderdet7 = new Consumable_order_details2__c();
            Orderdet7.Name = 'OCM_01_001004';
            Orderdet7.Consumable_order_minor__c = Order1.Id;
            Orderdet7.Consumable_Product__c = pro2.Id;
            Orderdet7.Asset_Model_No__c = 'Test02';
            Orderdet7.Box_Piece__c = '盒';
            Orderdet7.Lose_Flag__c = false;
            Orderdet7.Bar_Code__c = '010495317014059411170400172203311074K250DBVUD';
            Orderdet7.RemoveBox_date__c= Date.today();
            Orderdet7.Inventory_date__c= Date.today();
            insert Orderdet7;
 
            Consumable_order_details2__c Orderdet8= new Consumable_order_details2__c();
            Orderdet8.Name = 'OCM_01_001004';
            Orderdet8.Consumable_order_minor__c = Order1.Id;
            Orderdet8.Consumable_Product__c = pro2.Id;
            Orderdet8.Asset_Model_No__c = 'Test02';
            Orderdet8.Arrive_date__c = Date.today();
            Orderdet8.Box_Piece__c = '个';
            Orderdet8.Lose_Flag__c = false;
            Orderdet8.Bar_Code__c = '010495317014059411170400172203311074K250DBVUC';
            Orderdet8.Used_date__c = null;
            Orderdet8.Lose_Flag__c = false;
            Orderdet8.Return_date__c= null;
            Orderdet8.RemoveBox_date__c=Date.today();
            Orderdet8.Send_Date__c=null;
            Orderdet8.RemoveBox_No__c =3;
            insert Orderdet8;
 
            PageReference page = new PageReference('/apex/RemoveBox');
            System.Test.setCurrentPage(page);
            RemoveBoxController Controller = new RemoveBoxController();
            //初始化测试
            System.Test.startTest();
            Controller.init();
            Controller.getinventorysize();
            //排序
            Controller.barcode = '';
            Controller.searchConsumableorderdetails();
            Controller.barcode = '01049531702003111115120017181000105ZK250BXJRF\n01049531702003111115120017181000105ZK250BXJRA\n011495317020843711170400172003311074K250CXSDS\n010495317014059411170400172203311074K250DCWQW\n010495317014059411170400172203311074K250DCWRA\n1233456666\n01049531702003111115120017181000105ZK250BXJRW\n010495317014059411170400172203311074K250DBVUD\n010495317014059411170400172203311074K250DCWRW\n010495317014059411170400172203311074K250DCWRB\n010495317014059411170400172203311074K250DCWRC';
            Controller.searchConsumableorderdetails();
           System.assertEquals('Test01', controller.ConsumableorderdetailsRecordsdummy[0].Prod.Name__c);
            System.assertEquals('OCM_01_001004', controller.ConsumableorderdetailsRecordserror[0].esd.Name);
            Controller.removeBoxConfirm();
            Controller.ConsumableorderdetailsRecordsdummy.clear();
            Controller.removeBoxConfirm();
            System.Test.stopTest();
        }
    }
 
}