buli
2022-05-14 ead4df22dca33a867279471821ca675f91dec760
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
@isTest
private class LoanerPortionDeliverControllerTest {
    static void setupTestData() {
                OlympusCalendar__c oc1 = new OlympusCalendar__c(Date__c = Date.today().addDays(1), ChangeToHoliday__c=false, ChangeToWorkday__c=true);
                OlympusCalendar__c oc2 = new OlympusCalendar__c(Date__c = Date.today().addDays(2), ChangeToHoliday__c=false, ChangeToWorkday__c=true);
                OlympusCalendar__c oc3 = new OlympusCalendar__c(Date__c = Date.today().addDays(3), ChangeToHoliday__c=false, ChangeToWorkday__c=true);
                OlympusCalendar__c oc4 = new OlympusCalendar__c(Date__c = Date.today().addDays(4), ChangeToHoliday__c=false, ChangeToWorkday__c=true);
                OlympusCalendar__c oc5 = new OlympusCalendar__c(Date__c = Date.today().addDays(5), ChangeToHoliday__c=false, ChangeToWorkday__c=true);
                OlympusCalendar__c oc6 = new OlympusCalendar__c(Date__c = Date.today().addDays(6), ChangeToHoliday__c=true, ChangeToWorkday__c=false);
                OlympusCalendar__c oc7 = new OlympusCalendar__c(Date__c = Date.today().addDays(7), ChangeToHoliday__c=true, ChangeToWorkday__c=false);
                OlympusCalendar__c oc8 = new OlympusCalendar__c(Date__c = Date.today().addDays(8), ChangeToHoliday__c=false, ChangeToWorkday__c=true);
                OlympusCalendar__c oc9 = new OlympusCalendar__c(Date__c = Date.today().addDays(9), ChangeToHoliday__c=false, ChangeToWorkday__c=true);
                OlympusCalendar__c oc10 = new OlympusCalendar__c(Date__c = Date.today().addDays(10), ChangeToHoliday__c=false, ChangeToWorkday__c=true);
                OlympusCalendar__c oc11 = new OlympusCalendar__c(Date__c = Date.today().addDays(11), ChangeToHoliday__c=false, ChangeToWorkday__c=true);
                OlympusCalendar__c oc12 = new OlympusCalendar__c(Date__c = Date.today().addDays(12), ChangeToHoliday__c=false, ChangeToWorkday__c=true);
                OlympusCalendar__c oc13 = new OlympusCalendar__c(Date__c = Date.today().addDays(-1), ChangeToHoliday__c=true, ChangeToWorkday__c=false);
                OlympusCalendar__c oc14 = new OlympusCalendar__c(Date__c = Date.today().addDays(-2), ChangeToHoliday__c=true, ChangeToWorkday__c=false);
                OlympusCalendar__c oc15 = new OlympusCalendar__c(Date__c = Date.today().addDays(-3), ChangeToHoliday__c=false, ChangeToWorkday__c=true);
                OlympusCalendar__c oc16 = new OlympusCalendar__c(Date__c = Date.today().addDays(-4), ChangeToHoliday__c=false, ChangeToWorkday__c=true);
                OlympusCalendar__c oc17 = new OlympusCalendar__c(Date__c = Date.today().addDays(-5), ChangeToHoliday__c=false, ChangeToWorkday__c=true);
 
                insert new OlympusCalendar__c[] {oc1,oc2,oc3,oc4,oc5,oc6,oc7,oc8,oc9,oc10,oc11,oc12,oc13,oc14,oc15,oc16,oc17};
            }
    @isTest static void test_method_one() {
        setupTestData();
    List<RecordType> rectLo = [select Id from RecordType where IsActive = true and SobjectType = 'loaner_application__c' and Name = 'IE'];
        
    List<RecordType> rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = 'Customer IE'];
        
        //用户
        User user = new User();
        user.LastName = 'test';
        user.FirstName = 'test';
        user.Alias = 'test';
        user.Email = 'test@test.com';
        user.Username = 'test111@test222.com';
        user.CommunityNickname = 'test';
        user.IsActive = true;
        user.EmailEncodingKey = 'ISO-2022-JP';
        user.TimeZoneSidKey = 'Asia/Tokyo';
        user.LocaleSidKey = 'ja_JP';
        user.LanguageLocaleKey = 'ja';
        user.ProfileId = System.Label.SystemAdmin;
        insert user;
 
    // 新建备品借出申请
        loaner_application__c loaner = new loaner_application__c();
        loaner.Name = 'TEST';
        loaner.RecordTypeId = rectLo[0].id;
        loaner.EC_CODE_1__C = 'DV2-CAMELEONS-CUBE';
        loaner.DEMO_PURPOSE__C = '演示';
    loaner.Request_shipping_Date__c = Date.today();
    loaner.Request_return_Date__c = Date.today();
    loaner.Status__c = '已出库指示';
    loaner.delivery_company__c = '物流公司';
    loaner.Tracking_Number__c = '1234567';
        insert loaner;
 
        // 新建 客户
        Account acc = new Account();
        acc.RecordTypeId = rectCo[0].Id;
        acc.Name         = '客户テスト1';
        acc.DivisionName__c = 'DivisionName__c';
        acc.FacilityName__c = 'FacilityName__c';
        acc.PostCode__c='000000';
        insert acc;
         
        // 新建 资产
        List<Asset> In_asset = new List<Asset>();
        Asset asset = new Asset();
        asset.Name = 'テスト機器1';
        asset.AccountId = acc.Id;
        asset.SerialNumber = 'testserial';
 
        In_asset.add(asset);
 
        insert In_asset;
 
        // 新建 借出明细
        List<loaner_application_detail__c> In_detail = new List<loaner_application_detail__c>();
        loaner_application_detail__c detail = new loaner_application_detail__c();
 
        detail.loaner_application__c = loaner.Id;
        detail.loaner__c = In_asset[0].id;
        detail.name = '000';
        detail.RAESD_STATUS__C = '出库前已检测';
        detail.Return_to_wh_staff__c = user.id;
        In_detail.add(detail);
 
        insert In_detail;
 
        OlympusCalendar__c oc1 = new OlympusCalendar__c(Date__c = Date.today().addDays(1), ChangeToHoliday__c=false, ChangeToWorkday__c=true);
        OlympusCalendar__c oc2 = new OlympusCalendar__c(Date__c = Date.today().addDays(2), ChangeToHoliday__c=false, ChangeToWorkday__c=true);
        OlympusCalendar__c oc3 = new OlympusCalendar__c(Date__c = Date.today().addDays(3), ChangeToHoliday__c=false, ChangeToWorkday__c=true);
        OlympusCalendar__c oc4 = new OlympusCalendar__c(Date__c = Date.today().addDays(4), ChangeToHoliday__c=false, ChangeToWorkday__c=true);
        OlympusCalendar__c oc5 = new OlympusCalendar__c(Date__c = Date.today().addDays(5), ChangeToHoliday__c=false, ChangeToWorkday__c=true);
        OlympusCalendar__c oc6 = new OlympusCalendar__c(Date__c = Date.today().addDays(6), ChangeToHoliday__c=true, ChangeToWorkday__c=false);
        OlympusCalendar__c oc7 = new OlympusCalendar__c(Date__c = Date.today().addDays(7), ChangeToHoliday__c=true, ChangeToWorkday__c=false);
        OlympusCalendar__c oc8 = new OlympusCalendar__c(Date__c = Date.today().addDays(8), ChangeToHoliday__c=false, ChangeToWorkday__c=true);
        OlympusCalendar__c oc9 = new OlympusCalendar__c(Date__c = Date.today().addDays(9), ChangeToHoliday__c=false, ChangeToWorkday__c=true);
        OlympusCalendar__c oc10 = new OlympusCalendar__c(Date__c = Date.today().addDays(10), ChangeToHoliday__c=false, ChangeToWorkday__c=true);
        OlympusCalendar__c oc11 = new OlympusCalendar__c(Date__c = Date.today().addDays(11), ChangeToHoliday__c=false, ChangeToWorkday__c=true);
        OlympusCalendar__c oc12 = new OlympusCalendar__c(Date__c = Date.today().addDays(12), ChangeToHoliday__c=false, ChangeToWorkday__c=true);
 
        insert new OlympusCalendar__c[] {oc1,oc2,oc3,oc4,oc5,oc6,oc7,oc8,oc9,oc10,oc11,oc12};
    
        PageReference page = new PageReference('/apex/LoanerPortionDeliverController?Id=' + loaner.Id + '&step=LPortionDeliver');
        System.Test.setCurrentPage(page);
        LoanerPortionDeliverController  controller = new LoanerPortionDeliverController();
 
        controller.init();
        controller.cancelBtn();
        controller.getDatalineSize();
        controller.dataLines[0].checkFlag = true;
        controller.saveBtn();
        controller.sos();
 
 
        //system.assertEquals(null,ApexPages.getMessages()[0].getDetail());
 
        // 物流信息
        List<Loaner_Express__c> leList = [select name, Consignor_LogisticsNumber__c, Consignor_LogisticsCompany__c, consignor__r.name, Shipment_Request_Date__c, NotReceivingNum__c from Loaner_Express__c];
        //system.assertEquals('1234567', leList[0].Consignor_LogisticsNumber__c);
        //system.assertEquals('物流公司', leList[0].Consignor_LogisticsCompany__c);
        //system.assertEquals('test', leList[0].consignor__r.name);
        //system.assertEquals(Date.today(), leList[0].Shipment_Request_Date__c);
        //system.assertEquals(1, leList[0].NotReceivingNum__c);
 
        List<loaner_application__c> laList = [select Return_to_wh_staff__c, Status__c, Shipping_Finished_Date_All__c, Shipping_Finished_Date__c from loaner_application__c];
        //system.assertEquals('全部发货', laList[0].Status__c);
        //system.assertEquals(Date.today(), laList[0].Shipping_Finished_Date_All__c);
        //system.assertEquals(Date.today(), laList[0].Shipping_Finished_Date__c);
 
        List<loaner_application_detail__c> updList = [select RAESD_Status__c, Shipment_Request_Date__c, Return_to_wh_staff__c, delivery_company__c, Tracking_Number__c from loaner_application_detail__c order by name];
        //system.assertEquals(Date.today(), updList[0].Shipment_Request_Date__c);
        //system.assertEquals('已出库', updList[0].RAESD_Status__c);
        //system.assertEquals(laList[0].Return_to_wh_staff__c, updList[0].Return_to_wh_staff__c);
        //system.assertEquals('123', updList[0].Return_to_wh_staff__c);
        //system.assertEquals('物流公司', updList[0].delivery_company__c);
        //system.assertEquals('1234567', updList[0].Tracking_Number__c);
 
        List<Asset> assList = [select status from Asset order by name];
        //system.assertEquals('出借', assList[0].status);
 
 
    }
    
    @isTest static void test_method_two() {
        // Implement test code
    }
    
}