@isTest
private class UpdateLeaderBeEmptyBatchTest {
    static testMethod void testMethod1() {

    	User hpOwner2 = new User(Test_staff__c = true, LastName = 'TestMao2', FirstName = 'TestMaoF2',
                                    Alias = 'hp', CommunityNickname = 'TestMao2', Email = 'Test2@sunbridge.com',
                                    Username = 'ooo234@sunbridge.com', IsActive = false, EmailEncodingKey = 'ISO-2022-JP', 
                                    TimeZoneSidKey = 'Asia/Tokyo', LocaleSidKey = 'ja_JP', LanguageLocaleKey = 'ja', ProfileId = System.Label.ProfileId_SystemAdmin,
                                    Stay_or_not__c = '已离职');
    	insert hpOwner2;
        // 省
        Address_Level__c al = new Address_Level__c();
        al.Name = '東京';
        al.Level1_Code__c = 'CN-99';
        al.Level1_Sys_No__c = '999999';
        insert al;
        // 市
        Address_Level2__c al2 = new Address_Level2__c();
        al2.Level1_Code__c = 'CN-99';
        al2.Level1_Sys_No__c = '999999';
        al2.Level1_Name__c = '東京';
        al2.Name = '渋谷区';
        al2.Level2_Code__c = 'CN-9999';
        al2.Level2_Sys_No__c = '9999999';
        al2.Address_Level__c = al.id;
        insert al2;

        // 病院を作る
        Account hospital = new Account();
        hospital.recordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Account' and DeveloperName = 'HP'].id;
        hospital.Name = 'test hospital';
        hospital.Is_Active__c = '有効';
        hospital.Attribute_Type__c = '卫生部';
        hospital.Speciality_Type__c = '综合医院';
        hospital.Grade__c = '一级';
        hospital.OCM_Category__c = 'SLTV';
        hospital.Is_Medical__c = '医疗机构';
        hospital.State_Master__c = al.id;
        hospital.City_Master__c = al2.id;
        hospital.Town__c = '东京';
        hospital.FSE_SP_Main_Leader__c = hpOwner2.Id;
        hospital.FSE_GI_Main_Leader__c = hpOwner2.Id;
        insert hospital;

        System.Test.startTest();
        Database.executeBatch(new UpdateLeaderBeEmptyBatch(hpOwner2.Id));
        System.Test.StopTest();
    }
    //2021-09-27  mzy SFDC-合并batch  end
    static testMethod void testMethod2() {

        User hpOwner2 = new User(Test_staff__c = true, LastName = 'TestMao2', FirstName = 'TestMaoF2',
                                    Alias = 'hp', CommunityNickname = 'TestMao2', Email = 'Test2@sunbridge.com',
                                    Username = 'ooo234@sunbridge.com', IsActive = false, EmailEncodingKey = 'ISO-2022-JP', 
                                    TimeZoneSidKey = 'Asia/Tokyo', LocaleSidKey = 'ja_JP', LanguageLocaleKey = 'ja', ProfileId = System.Label.ProfileId_SystemAdmin,
                                    Stay_or_not__c = '已离职');
        insert hpOwner2;
        // 省
        Address_Level__c al = new Address_Level__c();
        al.Name = '東京';
        al.Level1_Code__c = 'CN-99';
        al.Level1_Sys_No__c = '999999';
        insert al;
        // 市
        Address_Level2__c al2 = new Address_Level2__c();
        al2.Level1_Code__c = 'CN-99';
        al2.Level1_Sys_No__c = '999999';
        al2.Level1_Name__c = '東京';
        al2.Name = '渋谷区';
        al2.Level2_Code__c = 'CN-9999';
        al2.Level2_Sys_No__c = '9999999';
        al2.Address_Level__c = al.id;
        insert al2;

        // 病院を作る
        Account hospital = new Account();
        hospital.recordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Account' and DeveloperName = 'HP'].id;
        hospital.Name = 'test hospital';
        hospital.Is_Active__c = '有効';
        hospital.Attribute_Type__c = '卫生部';
        hospital.Speciality_Type__c = '综合医院';
        hospital.Grade__c = '一级';
        hospital.OCM_Category__c = 'SLTV';
        hospital.Is_Medical__c = '医疗机构';
        hospital.State_Master__c = al.id;
        hospital.City_Master__c = al2.id;
        hospital.Town__c = '东京';
        hospital.FSE_SP_Main_Leader__c = hpOwner2.Id;
        hospital.FSE_GI_Main_Leader__c = hpOwner2.Id;
        insert hospital;

        System.Test.startTest();
        Database.executeBatch(new UpdateLeaderBeEmptyBatch(true));
        System.Test.StopTest();
    }
    static testMethod void testMethod3() {

        User hpOwner2 = new User(Test_staff__c = true, LastName = 'TestMao2', FirstName = 'TestMaoF2',
                                    Alias = 'hp', CommunityNickname = 'TestMao2', Email = 'Test2@sunbridge.com',
                                    Username = 'ooo234@sunbridge.com', IsActive = false, EmailEncodingKey = 'ISO-2022-JP', 
                                    TimeZoneSidKey = 'Asia/Tokyo', LocaleSidKey = 'ja_JP', LanguageLocaleKey = 'ja', ProfileId = System.Label.ProfileId_SystemAdmin,
                                    Stay_or_not__c = '已离职');
        insert hpOwner2;
        // 省
        Address_Level__c al = new Address_Level__c();
        al.Name = '東京';
        al.Level1_Code__c = 'CN-99';
        al.Level1_Sys_No__c = '999999';
        insert al;
        // 市
        Address_Level2__c al2 = new Address_Level2__c();
        al2.Level1_Code__c = 'CN-99';
        al2.Level1_Sys_No__c = '999999';
        al2.Level1_Name__c = '東京';
        al2.Name = '渋谷区';
        al2.Level2_Code__c = 'CN-9999';
        al2.Level2_Sys_No__c = '9999999';
        al2.Address_Level__c = al.id;
        insert al2;

        // 病院を作る
        Account hospital = new Account();
        hospital.recordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Account' and DeveloperName = 'HP'].id;
        hospital.Name = 'test hospital';
        hospital.Is_Active__c = '有効';
        hospital.Attribute_Type__c = '卫生部';
        hospital.Speciality_Type__c = '综合医院';
        hospital.Grade__c = '一级';
        hospital.OCM_Category__c = 'SLTV';
        hospital.Is_Medical__c = '医疗机构';
        hospital.State_Master__c = al.id;
        hospital.City_Master__c = al2.id;
        hospital.Town__c = '东京';
        hospital.FSE_SP_Main_Leader__c = hpOwner2.Id;
        hospital.FSE_GI_Main_Leader__c = hpOwner2.Id;
        insert hospital;

        System.Test.startTest();
        Database.executeBatch(new UpdateLeaderBeEmptyBatch());
        System.Test.StopTest();
    }
    //2021-09-27  mzy SFDC-合并batch  end
}