| | |
| | | public static User user = new User(); |
| | | static void setupTestData() { |
| | | ControllerUtil.EscapeNFM001Trigger = true; |
| | | Oly_TriggerHandler.bypass(Product2Handler.Class.getName()); |
| | | Oly_TriggerHandler.bypass(ContactTriggerHandler.Class.getName()); |
| | | //// 省 |
| | | //Address_Level__c al = new Address_Level__c(); |
| | | //al.Name = '東京'; |
| | |
| | | timezonesidkey='America/Los_Angeles', |
| | | username='test@acme.com' + Datetime.now().getTime()); |
| | | insert user; |
| | | InventoryResultRecordController con = new InventoryResultRecordController(); |
| | | // con.save(); |
| | | } |
| | | //Repair__c repair = new Repair__c(); |
| | | //repair.Service_Repair_No__c = 'repair'; |
| | |
| | | //repair.Department_Class__c = strategicDep[0].id; |
| | | //repair.Delivered_Product__c = assetA2.Id; |
| | | //insert repair; |
| | | |
| | | } |
| | | |
| | | /** 点击开始盘点 |
| | |
| | | setupTestData(); |
| | | InventoryResultRecordController con = new InventoryResultRecordController(); |
| | | con.init(); |
| | | con.showResult(); |
| | | //con.bieCunFangDi = '北京 备品中心'; |
| | | |
| | | //未开始盘点 |
| | |
| | | } |
| | | //system.assert(b); |
| | | |
| | | //ihList[0].Inventory_Status__c = '已批准'; |
| | | //ihList[0].InventoryCheck_PIC__c = [SELECT Id |
| | | // FROM User WHERE Dept__c = '医疗东北营业本部' and IsActive = true limit 1].id; |
| | | //ihList[0].InventorySubmit_PIC__c = [SELECT id |
| | | // FROM User WHERE Dept__c = '医疗东北营业本部' and IsActive = true limit 1].id; |
| | | // ihList[0].Inventory_Status__c = '已批准'; |
| | | // ihList[0].InventoryCheck_PIC__c = [SELECT Id |
| | | // FROM User WHERE Dept__c = '医疗东北营业本部' and IsActive = true limit 1].id; |
| | | // ihList[0].InventorySubmit_PIC__c = [SELECT id |
| | | // FROM User WHERE Dept__c = '医疗东北营业本部' and IsActive = true limit 1].id; |
| | | // update ihList; |
| | | |
| | | //本月已有结束的盘点 |
| | | // con.showResult(); |
| | | |
| | | // // 本月已有结束的盘点 |
| | | // con.startInventory(); |
| | | // msgs = ApexPages.getMessages(); |
| | | // b = false; |
| | | // for(Apexpages.Message msg:msgs){ |
| | | // if (msg.getDetail().contains('本仓库本月已进行过盘点')) b = true; |
| | | //} |
| | | //system.assert(b); |
| | | // } |
| | | // system.assert(b); |
| | | } |
| | | |
| | | static testMethod void testMethod2() { |
| | |
| | | Database.executeBatch(new InventoryStartAssetSnapshotBatch(cunFangDi,header)); |
| | | System.Test.StopTest(); |
| | | |
| | | headerList[0].Inventory_Status__c = '已批准'; |
| | | update headerList; |
| | | |
| | | InventoryResultRecordController con = new InventoryResultRecordController(); |
| | | con.init(); |
| | | con.searchBtn(); |
| | | con.showResult(); |
| | | } |
| | | |
| | | static testMethod void testMethod3() { |
| | |
| | | con.searchBtn(); |
| | | System.assertEquals(19, con.salesdepartmentOpts.size()); |
| | | System.assertEquals(57, con.salesProvinceOpts.size()); |
| | | |
| | | List<Inventory_Header__c> headerList = [select UniqueKey__c from Inventory_Header__c]; |
| | | con.showResult(); |
| | | |
| | | headerList[0].Inventory_Status__c = '盘点中'; |
| | | update headerList; |
| | | con.showResult(); |
| | | |
| | | headerList[0].Inventory_Status__c = null; |
| | | update headerList; |
| | | con.showResult(); |
| | | |
| | | //con.inventoryDetailList[0].Inventory_Count__c = 1; |
| | | //con.save(); |
| | |
| | | } |
| | | } |
| | | static testMethod void updaue() { |
| | | InventoryResultRecordController.test();//先调用这个,然后继续补充测试类 |
| | | //InventoryResultRecordController.test();//先调用这个,然后继续补充测试类 |
| | | } |
| | | |
| | | |
| | | |
| | | //lt start |
| | | static testMethod void testMethod06() { |
| | | bp3_Setting__c conf = bp3_Setting__c.getOrgDefaults(); |
| | | conf.SH_Start_Inventory_User__c = UserInfo.getUserId(); |
| | | conf.InventoryDetailArchiveFolder__c = UserInfo.getUserId(); |
| | | insert conf; |
| | | |
| | | setupTestData(); |
| | | InventoryResultRecordController con = new InventoryResultRecordController(); |
| | | con.init(); |
| | | con.showResult(); |
| | | con.bieCunFangDi = '上海 备品中心'; |
| | | |
| | | //未开始盘点 |
| | | List<Apexpages.Message> msgs = ApexPages.getMessages(); |
| | | boolean b = false; |
| | | for(Apexpages.Message msg:msgs){ |
| | | if (msg.getDetail().contains('没有开始中的盘点,请点击开始盘点')) b = true; |
| | | } |
| | | //system.assert(b); |
| | | |
| | | Profile p = [select Id from Profile where id =:System.Label.ProfileId_SystemAdmin]; |
| | | // ユーザー作成 |
| | | User hpOwner = new User(Test_staff__c = true, LastName = 'hp', |
| | | FirstName = 'owner', Alias = 'hp', |
| | | CommunityNickname = 'hpOwner', |
| | | Email = 'olympus_hpowner@sunbridge.com', |
| | | Username = 'olympus_hpowner@sunbridge.com', |
| | | IsActive = true, EmailEncodingKey = 'ISO-2022-JP', |
| | | TimeZoneSidKey = 'Asia/Tokyo', LocaleSidKey = 'ja_JP', |
| | | LanguageLocaleKey = 'ja', ProfileId = p.id); |
| | | insert hpOwner; |
| | | System.debug('---lt123---'+hpOwner); |
| | | System.runAs(hpOwner) { |
| | | //没有开始权限 |
| | | con.startInventory(); |
| | | msgs = ApexPages.getMessages(); |
| | | b = false; |
| | | for(Apexpages.Message msg:msgs){ |
| | | if (msg.getDetail().contains('没有开始盘点的权限')) b = true; |
| | | } |
| | | } |
| | | |
| | | //第一次开始盘点 |
| | | con.startInventory(); |
| | | msgs = ApexPages.getMessages(); |
| | | b = false; |
| | | for(Apexpages.Message msg:msgs){ |
| | | if (msg.getDetail().contains('开始盘点处理,请等待Batch处理结束')) b = true; |
| | | } |
| | | List<Inventory_Header__c> ihList = [select Id,InventoryCheck_PIC__c,InventorySubmit_PIC__c from Inventory_Header__c]; |
| | | |
| | | //再次开始盘点 |
| | | con.startInventory(); |
| | | msgs = ApexPages.getMessages(); |
| | | b = false; |
| | | for(Apexpages.Message msg:msgs){ |
| | | if (msg.getDetail().contains('有未结束的盘点')) b = true; |
| | | } |
| | | } |
| | | |
| | | static testMethod void testMethod07() { |
| | | bp3_Setting__c conf = bp3_Setting__c.getOrgDefaults(); |
| | | conf.GZ_Start_Inventory_User__c = UserInfo.getUserId(); |
| | | conf.InventoryDetailArchiveFolder__c = UserInfo.getUserId(); |
| | | insert conf; |
| | | |
| | | setupTestData(); |
| | | InventoryResultRecordController con = new InventoryResultRecordController(); |
| | | con.init(); |
| | | con.showResult(); |
| | | con.bieCunFangDi = '广州 备品中心'; |
| | | |
| | | //未开始盘点 |
| | | List<Apexpages.Message> msgs = ApexPages.getMessages(); |
| | | boolean b = false; |
| | | for(Apexpages.Message msg:msgs){ |
| | | if (msg.getDetail().contains('没有开始中的盘点,请点击开始盘点')) b = true; |
| | | } |
| | | //system.assert(b); |
| | | |
| | | Profile p = [select Id from Profile where id =:System.Label.ProfileId_SystemAdmin]; |
| | | // ユーザー作成 |
| | | User hpOwner = new User(Test_staff__c = true, LastName = 'hp', |
| | | FirstName = 'owner', Alias = 'hp', |
| | | CommunityNickname = 'hpOwner', |
| | | Email = 'olympus_hpowner@sunbridge.com', |
| | | Username = 'olympus_hpowner@sunbridge.com', |
| | | IsActive = true, EmailEncodingKey = 'ISO-2022-JP', |
| | | TimeZoneSidKey = 'Asia/Tokyo', LocaleSidKey = 'ja_JP', |
| | | LanguageLocaleKey = 'ja', ProfileId = p.id); |
| | | insert hpOwner; |
| | | System.debug('---lt123---'+hpOwner); |
| | | System.runAs(hpOwner) { |
| | | //没有开始权限 |
| | | con.startInventory(); |
| | | msgs = ApexPages.getMessages(); |
| | | b = false; |
| | | for(Apexpages.Message msg:msgs){ |
| | | if (msg.getDetail().contains('没有开始盘点的权限')) b = true; |
| | | } |
| | | } |
| | | |
| | | //第一次开始盘点 |
| | | con.startInventory(); |
| | | msgs = ApexPages.getMessages(); |
| | | b = false; |
| | | for(Apexpages.Message msg:msgs){ |
| | | if (msg.getDetail().contains('开始盘点处理,请等待Batch处理结束')) b = true; |
| | | } |
| | | List<Inventory_Header__c> ihList = [select Id,InventoryCheck_PIC__c,InventorySubmit_PIC__c from Inventory_Header__c]; |
| | | |
| | | //再次开始盘点 |
| | | con.startInventory(); |
| | | msgs = ApexPages.getMessages(); |
| | | b = false; |
| | | for(Apexpages.Message msg:msgs){ |
| | | if (msg.getDetail().contains('有未结束的盘点')) b = true; |
| | | } |
| | | } |
| | | |
| | | static testMethod void testMethod37() { |
| | | Oly_TriggerHandler.bypass(InventoryHeaderHandler.Class.getName()); |
| | | |
| | | bp3_Setting__c conf = bp3_Setting__c.getOrgDefaults(); |
| | | conf.SJZ_Start_Inventory_User__c = UserInfo.getUserId(); |
| | | conf.GZ_Start_Inventory_User_Agency__c = UserInfo.getUserId(); |
| | | conf.CD_Start_Inventory_User__c = UserInfo.getUserId(); |
| | | conf.CQ_Start_Inventory_User__c = UserInfo.getUserId(); |
| | | conf.NN_Start_Inventory_User__c = UserInfo.getUserId(); |
| | | conf.KM_Start_Inventory_User__c = UserInfo.getUserId(); |
| | | conf.WH_Start_Inventory_User__c = UserInfo.getUserId(); |
| | | conf.GY_Start_Inventory_User__c = UserInfo.getUserId(); |
| | | conf.CS_Start_Inventory_User__c = UserInfo.getUserId(); |
| | | conf.HF_Start_Inventory_User__c = UserInfo.getUserId(); |
| | | conf.NC_Start_Inventory_User__c = UserInfo.getUserId(); |
| | | conf.NJ_Start_Inventory_User__c = UserInfo.getUserId(); |
| | | conf.HZ_Start_Inventory_User__c = UserInfo.getUserId(); |
| | | conf.FZ_Start_Inventory_User__c = UserInfo.getUserId(); |
| | | conf.SH_Start_Inventory_User_Agency__c = UserInfo.getUserId(); |
| | | conf.TJ_Start_Inventory_User__c = UserInfo.getUserId(); |
| | | conf.XN_Start_Inventory_User__c = UserInfo.getUserId(); |
| | | conf.YC_Start_Inventory_User__c = UserInfo.getUserId(); |
| | | // conf.CC_Start_Inventory_User__c = UserInfo.getUserId(); |
| | | // conf.HEB_Start_Inventory_User__c = UserInfo.getUserId(); |
| | | // conf.DL_Start_Inventory_User__c = UserInfo.getUserId(); |
| | | // conf.WLMQ_Start_Inventory_User__c = UserInfo.getUserId(); |
| | | // conf.LZ_Start_Inventory_User__c = UserInfo.getUserId(); |
| | | // conf.XA_Start_Inventory_User__c = UserInfo.getUserId(); |
| | | // conf.TY_Start_Inventory_User__c = UserInfo.getUserId(); |
| | | // conf.ZZ_Start_Inventory_User__c = UserInfo.getUserId(); |
| | | // conf.JN_Start_Inventory_User__c = UserInfo.getUserId(); |
| | | // conf.HHHT_Start_Inventory_User__c = UserInfo.getUserId(); |
| | | // conf.SY_Start_Inventory_User__c = UserInfo.getUserId(); |
| | | // conf.QD_Start_Inventory_User__c = UserInfo.getUserId(); |
| | | |
| | | |
| | | conf.InventoryDetailArchiveFolder__c = UserInfo.getUserId(); |
| | | insert conf; |
| | | |
| | | String biecunFangDi = '石家庄'; |
| | | Inventory_Header__c header = new Inventory_Header__c(); |
| | | header.Inventory_Start_Date__c = Date.toDay(); |
| | | header.UniqueKey__c = 'IH-0000'; |
| | | header.Inventory_Status__c = '处理中'; |
| | | header.Internal_asset_location__c = biecunFangDi; |
| | | header.InventoryCheck_PIC__c = [SELECT Id |
| | | FROM User WHERE Dept__c = '医疗东北营业本部' and IsActive = true limit 1].id; |
| | | header.InventorySubmit_PIC__c = [SELECT id |
| | | FROM User WHERE Dept__c = '医疗东北营业本部' and IsActive = true limit 1].id; |
| | | insert header; |
| | | |
| | | List<Inventory_Header__c> headerList = [select UniqueKey__c from Inventory_Header__c]; |
| | | |
| | | setupTestData(); |
| | | InventoryResultRecordController con = new InventoryResultRecordController(); |
| | | con.init(); |
| | | con.showResult(); |
| | | con.bieCunFangDi = '石家庄'; |
| | | con.showResult(); |
| | | |
| | | headerList[0].Inventory_Status__c = '盘点中'; |
| | | update headerList; |
| | | con.showResult(); |
| | | |
| | | headerList[0].Inventory_Status__c = null; |
| | | update headerList; |
| | | con.showResult(); |
| | | |
| | | //未开始盘点 |
| | | List<Apexpages.Message> msgs = ApexPages.getMessages(); |
| | | boolean b = false; |
| | | User thisUser = [SELECT Id FROM User WHERE Id = :UserInfo.getUserId()]; |
| | | Profile p = [select Id from Profile where Name = '系统管理员']; |
| | | User user1 = new User(); |
| | | user1.ProfileId = p.Id; |
| | | user1.FirstName = 'ユーザー'; |
| | | user1.LastName = 'テスト'; |
| | | user1.Email = 'test_user@example.com'; |
| | | user1.emailencodingkey='UTF-8'; |
| | | user1.languagelocalekey='zh_CN'; |
| | | user1.localesidkey='ja_JP'; |
| | | user1.timezonesidkey='Asia/Shanghai'; |
| | | user1.Username = 'test_user111@example.com'; |
| | | user1.Alias = 'テユ'; |
| | | user1.CommunityNickname = 'テストユーザー'; |
| | | user1.Dept__c = '医疗华南营业本部'; |
| | | user1.JingliEquipmentManager__c = thisUser.Id; |
| | | insert user1; |
| | | // System.runAs (user1) { |
| | | //再次开始盘点 |
| | | con.startInventory(); |
| | | con.bieCunFangDi = '成都'; |
| | | con.startInventory(); |
| | | con.bieCunFangDi = '广州'; |
| | | con.startInventory(); |
| | | con.bieCunFangDi = '重庆'; |
| | | con.startInventory(); |
| | | con.bieCunFangDi = '南宁'; |
| | | con.startInventory(); |
| | | con.bieCunFangDi = '昆明'; |
| | | con.startInventory(); |
| | | con.bieCunFangDi = '武汉'; |
| | | con.startInventory(); |
| | | con.bieCunFangDi = '贵阳'; |
| | | con.startInventory(); |
| | | con.bieCunFangDi = '长沙'; |
| | | con.startInventory(); |
| | | con.bieCunFangDi = '合肥'; |
| | | con.startInventory(); |
| | | con.bieCunFangDi = '南昌'; |
| | | con.startInventory(); |
| | | con.bieCunFangDi = '南京'; |
| | | con.startInventory(); |
| | | con.bieCunFangDi = '杭州'; |
| | | con.startInventory(); |
| | | con.bieCunFangDi = '福州'; |
| | | con.startInventory(); |
| | | con.bieCunFangDi = '上海'; |
| | | con.startInventory(); |
| | | con.bieCunFangDi = '天津'; |
| | | con.startInventory(); |
| | | con.bieCunFangDi = '西宁'; |
| | | con.startInventory(); |
| | | // con.bieCunFangDi = '银川'; |
| | | // con.startInventory(); |
| | | |
| | | // } |
| | | msgs = ApexPages.getMessages(); |
| | | b = false; |
| | | for(Apexpages.Message msg:msgs){ |
| | | if (msg.getDetail().contains('有未结束的盘点')) b = true; |
| | | } |
| | | } |
| | | |
| | | static testMethod void testMethod20() { |
| | | bp3_Setting__c conf = bp3_Setting__c.getOrgDefaults(); |
| | | conf.YC_Start_Inventory_User__c = UserInfo.getUserId(); |
| | | conf.InventoryDetailArchiveFolder__c = UserInfo.getUserId(); |
| | | |
| | | conf.CC_Start_Inventory_User__c = UserInfo.getUserId(); |
| | | conf.HEB_Start_Inventory_User__c = UserInfo.getUserId(); |
| | | conf.DL_Start_Inventory_User__c = UserInfo.getUserId(); |
| | | conf.WLMQ_Start_Inventory_User__c = UserInfo.getUserId(); |
| | | conf.LZ_Start_Inventory_User__c = UserInfo.getUserId(); |
| | | conf.XA_Start_Inventory_User__c = UserInfo.getUserId(); |
| | | conf.TY_Start_Inventory_User__c = UserInfo.getUserId(); |
| | | conf.ZZ_Start_Inventory_User__c = UserInfo.getUserId(); |
| | | conf.JN_Start_Inventory_User__c = UserInfo.getUserId(); |
| | | conf.HHHT_Start_Inventory_User__c = UserInfo.getUserId(); |
| | | conf.SY_Start_Inventory_User__c = UserInfo.getUserId(); |
| | | conf.QD_Start_Inventory_User__c = UserInfo.getUserId(); |
| | | |
| | | insert conf; |
| | | |
| | | setupTestData(); |
| | | InventoryResultRecordController con = new InventoryResultRecordController(); |
| | | con.init(); |
| | | con.showResult(); |
| | | con.bieCunFangDi = '银川'; |
| | | |
| | | //未开始盘点 |
| | | List<Apexpages.Message> msgs = ApexPages.getMessages(); |
| | | boolean b = false; |
| | | |
| | | //再次开始盘点 |
| | | con.startInventory(); |
| | | |
| | | con.bieCunFangDi = '长春'; |
| | | con.startInventory(); |
| | | con.bieCunFangDi = '哈尔滨'; |
| | | con.startInventory(); |
| | | con.bieCunFangDi = '大连'; |
| | | con.startInventory(); |
| | | con.bieCunFangDi = '乌鲁木齐'; |
| | | con.startInventory(); |
| | | con.bieCunFangDi = '兰州'; |
| | | con.startInventory(); |
| | | con.bieCunFangDi = '西安'; |
| | | con.startInventory(); |
| | | con.bieCunFangDi = '太原'; |
| | | con.startInventory(); |
| | | con.bieCunFangDi = '郑州'; |
| | | con.startInventory(); |
| | | con.bieCunFangDi = '济南'; |
| | | con.startInventory(); |
| | | con.bieCunFangDi = '呼和浩特'; |
| | | con.startInventory(); |
| | | con.bieCunFangDi = '沈阳'; |
| | | con.startInventory(); |
| | | con.bieCunFangDi = '青岛'; |
| | | con.startInventory(); |
| | | msgs = ApexPages.getMessages(); |
| | | b = false; |
| | | for(Apexpages.Message msg:msgs){ |
| | | if (msg.getDetail().contains('有未结束的盘点')) b = true; |
| | | } |
| | | } |
| | | //lt end |
| | | } |