| | |
| | | @isTest |
| | | private class UploadOBPMControllerTest { |
| | | public static Campaign cam; |
| | | |
| | | static void init(){ |
| | | static Campaign cam; |
| | | static User user2; |
| | | |
| | | static testMethod void testSample_01() { |
| | | StaticParameter.EscapeContactToUser = true; |
| | | Oly_TriggerHandler.bypass('UserProfileHandler'); |
| | | List<RecordType> rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Campaign' and Name = '1.学会/会议']; |
| | | if (rectCo.size() == 0) { |
| | | throw new ControllerUtil.myException('not found 1.学会/会议 recordtype'); |
| | |
| | | user.Dept__c = '医疗华北营业本部'; |
| | | user.Use_Start_Date__c = Date.today().addMonths(-6); |
| | | insert user; |
| | | |
| | | user2 = new User(Test_staff__c = true); |
| | | user2.LastName = '_サンブリッジ'; |
| | | user2.FirstName = 'う'; |
| | | user2.Alias = 'う'; |
| | | user2.Email = 'olympustest03@sunbridge.com'; |
| | | user2.Username = 'olympustest0123@sunbridge.com'; |
| | | user2.CommunityNickname = 'う'; |
| | | user2.IsActive = true; |
| | | user2.EmailEncodingKey = 'ISO-2022-JP'; |
| | | user2.TimeZoneSidKey = 'Asia/Tokyo'; |
| | | user2.LocaleSidKey = 'ja_JP'; |
| | | user2.LanguageLocaleKey = 'ja'; |
| | | user2.ProfileId = System.Label.ProfileId_SystemAdmin; |
| | | user2.Job_Category__c = '销售推广'; |
| | | user2.Province__c = '上海市'; |
| | | user2.Use_Start_Date__c = Date.today().addMonths(-6); |
| | | user2.Employee_No__c = '0000022174'; |
| | | user2.Stay_or_not__c = '在职'; |
| | | user2.IsActive = true; |
| | | insert user2; |
| | | cam = new Campaign(); |
| | | cam.Name = 'test campaign'; |
| | | cam.StartDate = Date.today().addDays(15); |
| | |
| | | cam.cooperatorCompany__c = '1'; |
| | | cam.RecordTypeId = rectCo[0].Id; |
| | | cam.OwnerId = user.Id; |
| | | cam.Shared_Editing__c = user2.Employee_No__c; |
| | | cam.Carbon_Copy__c = 'om123456'; |
| | | insert cam; |
| | | } |
| | | } |
| | | |
| | | static testMethod void testSample_01() { |
| | | init(); |
| | | User user = new User(); |
| | | User thisUser = [SELECT Id FROM User WHERE Id = :UserInfo.getUserId()]; |
| | | System.runAs (thisUser) { |
| | | Profile p = [SELECT Id FROM Profile WHERE Name LIKE '%2B1%' Limit 1]; |
| | | UserRole r = [SELECT Id FROM UserRole WHERE DeveloperName = 'beipin_huadong_staff' Limit 1]; |
| | | user = new User(alias = 'test', email='test@acme.com', |
| | | emailencodingkey='UTF-8', lastname='test', |
| | | languagelocalekey='en_US', |
| | | localesidkey='en_US', profileid = p.Id, userroleid = r.Id, |
| | | timezonesidkey='America/Los_Angeles', |
| | | username='test@acme.com' + Datetime.now().getTime()); |
| | | insert user; |
| | | } |
| | | PageReference page = new PageReference('/apex/BatchSelectRepairPage?id='+cam.Id); |
| | | System.Test.setCurrentPage(page); |
| | | System.Test.StartTest(); |
| | | UploadOBPMController ub = new UploadOBPMController(); |
| | | ub.init(); |
| | | ub.OBPMInfoList[0].cam.Shared_User__c = user.Id; |
| | | ub.OBPMInfoList[0].cam.Shared_User__c = user2.Id; |
| | | ub.OBPMInfoList[0].Role = '共同编辑人'; |
| | | ub.OBPMInfoList[1].cam.Shared_User__c = UserInfo.getUserId(); |
| | | ub.OBPMInfoList[1].Role = '抄送人'; |
| | | ub.addLine(); |
| | | ub.deleteLine(); |
| | | ub.uploadOBPM(); |