@isTest
private class SplitOptionListUtilTest {
    static testMethod void testMethod1() {
        RecordType rectOpp = [select id from RecordType where IsActive = true and SobjectType = 'Opportunity' and DeveloperName = 'Opportunity' ];
        // 病院を作る
            Account hospital = new Account();
            hospital.recordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Account' and DeveloperName = 'HP'].id;
            hospital.Name = 'test hospital';
            insert hospital;
        // 戦略科室を得る
        Account[] strategicDep = [SELECT ID, Name FROM Account WHERE parentId = :hospital.Id AND recordType.DeveloperName = 'Department_Class_OTH'];
            // 診療科を作る
        Account dep = new Account();
        dep.recordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Account' and DeveloperName = 'Department_OTH'].id;
        dep.Name = 'test dep';
        dep.AgentCode_Ext__c = '9999998';
        dep.ParentId = strategicDep[0].Id;
        dep.Department_Class__c = strategicDep[0].Id;
        dep.Hospital__c = hospital.Id;
        insert dep;
        Opportunity opp1 = new Opportunity(
            Name='testOpp1',
            StageName='引合',
            CloseDate=Date.today(),
            AccountId=dep.Id,
            Competitor__c ='A',
            Click_Close_Date__c = null,
            RecordType = rectOpp
            );
        insert opp1;
        
        OPDPlan__c oPDPlan0 = new OPDPlan__c();
        oPDPlan0.Status__c = '草案中';
        oPDPlan0.OPDPlan_ImplementDate__c = Date.today().addDays(1);
        oPDPlan0.NoOpp_Reason__c = 'HCP对应';
        insert oPDPlan0;

        Rental_Apply__c raObj1 = new Rental_Apply__c();
        raObj1.Rental_Start_Date__c = Date.today().addDays(1);
        raObj1.Request_return_day__c=Date.today().addDays(5);
        raObj1.DataMigration_Flag__c = true;
        raObj1.demo_purpose2__c = 'ceshi';
        raObj1.Follow_UP_Opp__c = opp1.Id;
        insert raObj1;
        

        Rental_Apply__c raObj = new Rental_Apply__c();
        raObj.Rental_Start_Date__c = Date.today().addDays(1);
        raObj.Request_return_day__c=Date.today().addDays(5);
        raObj.DataMigration_Flag__c = true;
        raObj.demo_purpose2__c = '试用（有询价）';
        raObj.Old_Rental_Apply__c = raObj1.id;
        raObj.Follow_UP_Opp__c = opp1.Id;
        raObj.Status__c = '草案中';
        raObj.OPDPlan__c = oPDPlan0.id;
        insert raObj;
        // 借出备品配套一览
        Rental_Apply_Equipment_Set__c raesObj = new Rental_Apply_Equipment_Set__c();
        raesObj.Rental_Apply__c = raObj.Id;
        raesObj.Cancel_Select__c = false;
        raesObj.Shipment_request_time__c = Date.toDay();
        raesObj.Rental_Start_Date__c = Date.toDay();
        raesObj.Rental_End_Date__c = Date.toDay();
        raesObj.IndexFromUniqueKey__c = 1;
        raesObj.UniqueKey__c = '1::1';
        raesObj.DataMigration_Flag__c =true;
        insert raesObj;
         // 借出备品配套一览明细
        Rental_Apply_Equipment_Set_Detail__c raesdObj1 = new Rental_Apply_Equipment_Set_Detail__c();
        raesdObj1.Rental_Apply__c = raObj.Id;
       // raesdObj1.Rental_Num__c = 1;
        raesdObj1.Queue_Number__c = null;
        raesdObj1.Is_Body__c = true;
        raesdObj1.IndexFromUniqueKey__c = 1;
        raesdObj1.UniqueKey__c = '1:'+ raesObj.Id +  ':1';
        raesdObj1.Salesdepartment_before__c = '1.华北营业本部';
        raesdObj1.Internal_asset_location_before__c = '北京 备品中心';
        raesdObj1.Product_category_text__c = 'GI';
        raesdObj1.Equipment_Type_text__c = '产品试用';
        raesdObj1.Rental_Apply_Equipment_Set__c = raesObj.Id;
        raesdObj1.Fixture_Model_No_text__c ='n05';
        insert raesdObj1;

        raesObj.First_RAESD__c = raesdObj1.Id;
        update raesObj;
 
        // 产品
        Product2 pro5 = new Product2(Name='name05',IsActive=true,Family='SP',
                Fixture_Model_No__c='n05',Serial_Lot_No__c='S/N tracing',
                Fixture_Model_No_T__c = 'n05',
                ProductCode_Ext__c='pc05',Manual_Entry__c=false);
        insert pro5; 

        Report__c rep1 = new Report__c();
        rep1.CurrencyIsoCode         = 'CNY';
       // rep1.RecordTypeId            = rectOPD[0].Id;
        rep1.Status__c               = '';
        rep1.Loaner_request_no1__c         = raObj.Id;
        rep1.Purpose1__c             = 'OPD';
        rep1.Purpose2__c             = '引合追及活動';        
        rep1.Reason__c               = '実施背景';
        rep1.Appeal_Point__c         = '実施目的・訴求点';
        rep1.Strategic_Department_Class__c = '1.消化科';
        rep1.Technical_Category1__c  = '消化道检查';
        rep1.Technical_Category2__c  = '普通胃镜检查';
        rep1.Patient_Status__c       = '患者状況';
        rep1.Operation_Process__c    = '手術プロセス';
        rep1.Operation_Task__c       = '手術上の課題';
        rep1.Product_Evaluation_Advantage__c = '製品評価利点';
        rep1.Product_Evaluation_Faults__c = '製品評価欠点';
        rep1.OPD_Summarize__c        = 'OPD実施総括';
        rep1.Activity_Plan__c        = '今後の活動計画';
        rep1.Opportunity_Situation__c = '引合無';
        rep1.OPD_ProductCategory1__c ='3D System';
        rep1.OPD_ProductCategory2__c ='OR Imaging Products';
        rep1.Hospital_Reference__c   = hospital.Id;
        rep1.Department_Class_Ref__c = strategicDep[0].Id;
        rep1.Hospital_Department__c  = dep.Id;
        rep1.Product_Evaluation_Advantage1__c = '操控性佳;放大细节优秀';
        rep1.Status__c = '草案中';
        rep1.Date__c= Date.today().addDays(-1);
        insert rep1;
        
        Report__c rep = [select id,Product_Evaluation_Advantage1__c from Report__c where id = :rep1.Id];
        Map<SObject,List<String>> data = new Map<SObject,List<String>>();
        List<String> cols = new List<String>();
        cols.add('Product_Evaluation_Advantage1__c');
        data.put(rep, cols);
        SplitOptionListUtil util = new SplitOptionListUtil();
        util.makeObject(data);
    }
}