liuyn
2024-03-11 a87f1c3df03078814ee97ad0c8ac200a232419e9
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
@isTest
private class RentalApplyEquipmentSetTriggerTest {
    
    static testMethod void myUnitTest() {
        // システム管理者
        User user = new User(Test_staff__c = true);
        user.LastName = '_サンブリッジ';
        user.FirstName = 'う';
        user.Alias = 'う';
        user.Email = 'olympusTest03@sunbridge.com';
        user.Username = 'olympusTest03@sunbridge.com';
        user.CommunityNickname = 'う';
        user.IsActive = true;
        user.EmailEncodingKey = 'ISO-2022-JP';
        user.TimeZoneSidKey = 'Asia/Tokyo';
        user.LocaleSidKey = 'ja_JP';
        user.LanguageLocaleKey = 'ja';
        user.ProfileId = System.Label.ProfileId_SystemAdmin;
        user.Job_Category__c = '销售推广';
        user.Province__c = '上海市';
        user.Use_Start_Date__c = Date.today().addMonths(-6);
        insert user;
        
        //备品借出申请
        Rental_Apply__c rentalApply = new Rental_Apply__c();
        rentalApply.OwnerId = user.Id;
        rentalApply.CurrencyIsoCode = 'CNY';
        rentalApply.Status__c = FixtureUtil.raStatusMap.get(FixtureUtil.RaStatus.Yi_Chu_Ku_Zhi_Shi.ordinal());
        rentalApply.Asset_loaner_start_day__c = Date.today();
        rentalApply.Asset_loaner_closed_day__c = Date.today().addDays(10);
//bp2        rentalApply.Rental_End_Date__c = Date.today() + 30;
        rentalApply.applyUser__c = user.Id;
        rentalApply.direct_send__c = '直送';
        rentalApply.direct_shippment_address__c = 'test';
        rentalApply.Request_return_day__c = Date.today() + 30;
        insert rentalApply;
        
//bp2 TODO Fixture_Set__c
//bp2        //备品set
//        Equipment_Set__c equipmentSet1 = new Equipment_Set__c();
//        equipmentSet1.Name = '备品Set01';
//        equipmentSet1.CurrencyIsoCode = 'CNY';
//        insert equipmentSet1;
        
        //备品借出历史
        Rental_Apply_Equipment_Set__c rentalApplyEquipmentSet1 = new Rental_Apply_Equipment_Set__c();
        rentalApplyEquipmentSet1.Rental_Apply__c = rentalApply.Id;
//bp2        rentalApplyEquipmentSet1.Equipment_Set__c = equipmentSet1.Id;
        rentalApplyEquipmentSet1.CurrencyIsoCode = 'CNY';
//bp2   rentalApplyEquipmentSet1.Shipment_request_time__c = Datetime.now();
        rentalApplyEquipmentSet1.Shippment_loaner_time__c = Datetime.now();
        rentalApplyEquipmentSet1.applyUser__c = user.Id;
        insert rentalApplyEquipmentSet1;
        
        Rental_Apply_Equipment_Set__c raes1 = [select Id,SalesManager__c,BuchangApprovalManagerSales__c,JingliApprovalManager__c,
                                                      BuchangApprovalManager__c,ZongjianApprovalManager__c 
                                                 from Rental_Apply_Equipment_Set__c 
                                                where Id = :rentalApplyEquipmentSet1.Id];
        System.assertEquals(null, raes1.SalesManager__c);
        System.assertEquals(null, raes1.BuchangApprovalManagerSales__c);
        System.assertEquals(null, raes1.JingliApprovalManager__c);
        System.assertEquals(null, raes1.BuchangApprovalManager__c);
        System.assertEquals(null, raes1.ZongjianApprovalManager__c);
        
        rentalApplyEquipmentSet1.Extend_Status__c = '申请中';
        update rentalApplyEquipmentSet1;
        
        Rental_Apply_Equipment_Set__c raes2 = [select Id,SalesManager__c,BuchangApprovalManagerSales__c,JingliApprovalManager__c,
                                                      BuchangApprovalManager__c,ZongjianApprovalManager__c 
                                                 from Rental_Apply_Equipment_Set__c 
                                                where Id = :rentalApplyEquipmentSet1.Id];
        System.assertNotEquals(null, raes2.SalesManager__c);
        System.assertNotEquals(null, raes2.BuchangApprovalManagerSales__c);
        System.assertNotEquals(null, raes2.JingliApprovalManager__c);
        System.assertNotEquals(null, raes2.BuchangApprovalManager__c);
        System.assertNotEquals(null, raes2.ZongjianApprovalManager__c);
    }
}