@isTest private class OCSMToUserTriggerTest { static testMethod void testMethod1() { Profile p = [select id from Profile where id =:System.Label.ProfileId_SystemAdmin]; String loginId = UserInfo.getUserId(); User sys = [select id from User where Id = :loginId]; User u1 = new User(Test_staff__c = true); u1.LastName = '_サンブリッジ'; u1.FirstName = 'あ'; u1.Batch_User__c = true; u1.Alias = 'あ'; u1.Email = 'olympusTest01@sunbridge.com'; u1.Username = 'olympusTest10@sunbridge.com'; u1.CommunityNickname = 'あ1'; u1.IsActive = true; u1.EmailEncodingKey = 'ISO-2022-JP'; u1.TimeZoneSidKey = 'Asia/Tokyo'; u1.LocaleSidKey = 'ja_JP'; u1.LanguageLocaleKey = 'ja'; u1.ProfileId = p.id; u1.Job_Category__c = '销售服务'; u1.Province__c = '東京'; User u2 = new User(Test_staff__c = true); u2.LastName = '_サンブリッジ'; u2.FirstName = 'い'; u2.Batch_User__c = true; u2.Alias = 'い'; u2.Email = 'olympusTest02@sunbridge.com'; u2.Username = 'olympusTest02@sunbridge.com'; u2.CommunityNickname = 'い'; u2.IsActive = true; u2.EmailEncodingKey = 'ISO-2022-JP'; u2.TimeZoneSidKey = 'Asia/Tokyo'; u2.LocaleSidKey = 'ja_JP'; u2.LanguageLocaleKey = 'ja'; u2.ProfileId = p.id; u2.Job_Category__c = '销售推广'; u2.Province__c = '東京'; User u3 = new User(Test_staff__c = true); u3.LastName = '_サンブリッジ'; u3.Batch_User__c = true; u3.FirstName = 'う'; u3.Alias = 'う'; u3.Email = 'olympusTest03@sunbridge.com'; u3.Username = 'olympusTest03@sunbridge.com'; u3.CommunityNickname = 'う'; u3.IsActive = true; u3.EmailEncodingKey = 'ISO-2022-JP'; u3.TimeZoneSidKey = 'Asia/Tokyo'; u3.LocaleSidKey = 'ja_JP'; u3.LanguageLocaleKey = 'ja'; u3.ProfileId = p.id; u3.Job_Category__c = '支援'; u3.Province__c = '東京'; u3.Dept__c = '能量事业本部'; insert new User[] {u1, u2, u3}; System.runAs(sys) { OCM_Management_Province__c mp1 = new OCM_Management_Province__c(); mp1.Name = '北京'; mp1.OnlinePlatformWindow1__c = u1.Id; OCM_Management_Province__c mp2 = new OCM_Management_Province__c(); mp2.Name = '上海'; mp2.OnlinePlatformWindow2__c = u2.Id; OCM_Management_Province__c mp3 = new OCM_Management_Province__c(); mp3.Name = '深圳'; mp3.OnlinePlatformWindow3__c = u3.Id; insert new OCM_Management_Province__c[] {mp1, mp2, mp3}; List omp1 = [select Id,OnlinePlatformWindow1__c,OnlinePlatformWindow2__c,OnlinePlatformWindow3__c from OCM_Management_Province__c where Id =:mp1.Id] ; List omp2 = [select Id,OnlinePlatformWindow1__c,OnlinePlatformWindow2__c,OnlinePlatformWindow3__c from OCM_Management_Province__c where Id =:mp2.Id] ; List omp3 = [select Id,OnlinePlatformWindow1__c,OnlinePlatformWindow2__c,OnlinePlatformWindow3__c from OCM_Management_Province__c where Id =:mp3.Id] ; omp1[0].OnlinePlatformWindow1__c = u3.Id; omp2[0].OnlinePlatformWindow2__c = u1.Id; omp3[0].OnlinePlatformWindow3__c = u2.Id; update new OCM_Management_Province__c[] {omp1[0], omp2[0], omp3[0]}; } } }