@isTest
private class RentalApplyEquipmentSetCheckTest {
    
    @isTest
    static  void insertRentalApply_Test() {




        OPDPlan__c oPDPlan0 = new OPDPlan__c();
        oPDPlan0.Status__c = '计划中';
        oPDPlan0.OPDPlan_ImplementDate__c = Date.today();
        oPDPlan0.NoOpp_Reason__c = 'HCP对应';
        insert oPDPlan0;
        Rental_Apply__c raObj = new Rental_Apply__c();
        raObj.Name = 'testra';
        raObj.Product_category__c = 'GI';
        raObj.Demo_purpose1__c = '维修代用';
        raObj.demo_purpose2__c = FixtureUtil.raDemo_purpose2MAP.get('baoxiuyonghu');
        raObj.direct_send__c = '医疗机构';
        raObj.Loaner_received_staff__c = '王五';
        raObj.Loaner_received_staff_phone__c = '110';
        raObj.direct_shippment_address__c = '北京市';
        raObj.ApplyPerson_Phone__c = '12345';

        raObj.Request_shipping_day__c = Date.toDay();  // 希望到货日
        raObj.Phone_number__c = '1234567890';
        raObj.OPDPlan__c = oPDPlan0.Id;
        raObj.demo_purpose2__c = '试用（无询价）';
        insert raObj;

        Rental_Apply_Equipment_Set__c raesObjC1 = new Rental_Apply_Equipment_Set__c();
        raesObjC1.Rental_Apply__c = raObj.Id;
        //raesObjC1.Fixture_Set__c = fsObjC1.Id;
        raesObjC1.Cancel_Select__c = false;
        raesObjC1.Shipment_request_time__c = Date.toDay();
        raesObjC1.Rental_Start_Date__c = Date.toDay();
        raesObjC1.Rental_End_Date__c = Date.toDay();
        raesObjC1.IndexFromUniqueKey__c = 1;
        //raesObjC1.UniqueKey__c = '1:'+ fsObjC1.Id + ':1';
        insert raesObjC1;

        OPDPlan__c oPDPlan0Clone = new OPDPlan__c();
        oPDPlan0Clone = oPDPlan0.clone();
        oPDPlan0Clone.Id = null;
        oPDPlan0Clone.RentalReson__c = '追加配套';
        oPDPlan0Clone.OriginalOpdPlanApplication__c = oPDPlan0.Id;
        insert oPDPlan0Clone;

        Rental_Apply__c raObjClone = new Rental_Apply__c();
        raObjClone = raObj.clone();
        raObjClone.Id  = null;
        raObjClone.OPDPlan__c = oPDPlan0Clone.Id;
        insert raObjClone;

        Rental_Apply_Equipment_Set__c raesObjC2 = new Rental_Apply_Equipment_Set__c();
        raesObjC2.Rental_Apply__c = raObjClone.Id;
        //raesObjC1.Fixture_Set__c = fsObjC1.Id;
        raesObjC2.Cancel_Select__c = false;
        raesObjC2.Shipment_request_time__c = Date.toDay();
        raesObjC2.Rental_Start_Date__c = Date.toDay();
        raesObjC2.Rental_End_Date__c = Date.toDay();
        raesObjC2.IndexFromUniqueKey__c = 1;
        //raesObjC1.UniqueKey__c = '1:'+ fsObjC1.Id + ':1';
        insert raesObjC2;

        Rental_Apply_Equipment_Set__c raesObjC3 = new Rental_Apply_Equipment_Set__c();
        raesObjC3.Rental_Apply__c = raObjClone.Id;
        //raesObjC1.Fixture_Set__c = fsObjC1.Id;
        raesObjC3.Cancel_Select__c = false;
        raesObjC3.Shipment_request_time__c = Date.toDay();
        raesObjC3.Rental_Start_Date__c = Date.toDay();
        raesObjC3.Rental_End_Date__c = Date.toDay();
        raesObjC3.IndexFromUniqueKey__c = 2;
        //raesObjC1.UniqueKey__c = '1:'+ fsObjC1.Id + ':1';
        insert raesObjC3;


        ////新增时触发验证规则
        //OPDPlan__c oPDPlan0Clone2 = new OPDPlan__c();
        //oPDPlan0Clone2 = oPDPlan0.clone();
        //oPDPlan0Clone2.Id = null;
        //oPDPlan0Clone2.RentalReson__c = '追加配套';
        //oPDPlan0Clone2.OriginalOpdPlanApplication__c = oPDPlan0.Id;
        //insert oPDPlan0Clone2;
        //Rental_Apply__c raObjClone2 = new Rental_Apply__c();
        //raObjClone2 = raObj.clone();
        //raObjClone2.Id  = null;
        //raObjClone2.Phone_number__c ='0522';
        //raObjClone2.OPDPlan__c = oPDPlan0Clone2.Id;
        //insert raObjClone2;

        //raObjClone.Phone_number__c = '000000';
        //update raObjClone;

        Test.startTest();
        //OpdPlanWebService.insertRentalApply(raObj.Id, oPDPlan0Clone.Id);
        Test.stopTest();
    }
}