force-app/main/default/classes/RentalFixtureSetAssignAgencyCtrlTest.cls
@@ -2,6 +2,13 @@
private class RentalFixtureSetAssignAgencyCtrlTest {
    private static User u;
    static void setupTestData(Boolean hasAnother) {
        // 20220316 ljh add start
        // 奥林巴斯日历
        OlympusCalendar__c oc = new OlympusCalendar__c();
        oc.Date__c = System.Today();
        oc.Before_1_WorkDay__c = oc.Date__c.addDays(-1);
        insert oc;
        // 20220316 ljh add end
        System.runAs(new User(Id = Userinfo.getUserId())) {
            StaticParameter.EscapeNFM001AgencyContractTrigger = true;
            StaticParameter.EscapeNFM001Trigger = true;
@@ -72,9 +79,10 @@
        insert dep;
        // 产品
        // 20220317 ljh Fixture_Model_No__c和配套的 主体备品配套明细型号应该一致
        Product2 pro1 = new Product2(Name='name01',IsActive=true,Family='GI',
                Fixture_Model_No__c='n01',Serial_Lot_No__c='S/N tracing',
                Fixture_Model_No_T__c = 'n01', Asset_Model_No__c = 'Pro1',
                Fixture_Model_No__c='modelNo1',Serial_Lot_No__c='S/N tracing',
                Fixture_Model_No_T__c = 'modelNo1', Asset_Model_No__c = 'Pro1',
                ProductCode_Ext__c='pc01',Manual_Entry__c=false);
        Product2 pro2 = new Product2(Name='name02',IsActive=true,Family='GI',
                Fixture_Model_No__c='n02',Serial_Lot_No__c='Lot tracing',
@@ -89,8 +97,8 @@
        //20210524 ljh add 1829 start
        // 产品
        Product2 pro10 = new Product2(Name='name010',IsActive=true,Family='GI',
                Fixture_Model_No__c='n010',Serial_Lot_No__c='S/N tracing',
                Fixture_Model_No_T__c = 'n010', Asset_Model_No__c = 'Pro10',
                Fixture_Model_No__c='modelNo10',Serial_Lot_No__c='S/N tracing',
                Fixture_Model_No_T__c = 'modelNo10', Asset_Model_No__c = 'Pro10',
                ProductCode_Ext__c='pc010',Manual_Entry__c=false);
        Product2 pro20 = new Product2(Name='name020',IsActive=true,Family='GI',
                Fixture_Model_No__c='n020',Serial_Lot_No__c='Lot tracing',
@@ -523,6 +531,7 @@
            // 申请单变为已批准
            raObj.Status__c = '已批准';
            raObj.Request_approval_time__c = Datetime.now().addDays(-1);// 20220317 ljh add 审批时间
            update raObj;
        }
@@ -632,7 +641,7 @@
        controller.init();
        // 第一次分配
        controller.esdList[0].checked = true;
        controller.parentObj.Asset_loaner_start_day__c = Date.today()+1;//20210513 ljh update
        controller.parentObj.Asset_loaner_start_day__c = Date.today().addDays(1);//20210513 ljh update
        controller.applyDate();
        controller.stepName = '分配';
@@ -644,7 +653,7 @@
        // controller.esdList[0].checked = true;
        // controller.stockDown();// 20210624 ljh update SFDC-C448GR
        ref = new PageReference('/apex/RentalFixtureSetAssignAgency?pt_recid=' + esList[0].Id);
        /*ref = new PageReference('/apex/RentalFixtureSetAssignAgency?pt_recid=' + esList[0].Id);
        Test.setCurrentPage(ref);
        controller = new RentalFixtureSetAssignAgencyController();
        // 下架后重新分配
@@ -653,7 +662,7 @@
        controller.esdList[0].checked = true;
        controller.qrcode = '51110001;2;'+controller.esdList[0].rec.Rental_Apply_Equipment_Set__c;
        controller.scanAndMatch();
        controller.assign();
        controller.assign();*/
        Test.stopTest();
@@ -745,7 +754,8 @@
    }
    @isTest
    // 20220317 ljh 控制必须填,写在前端了所以这个不需要了
    /*@isTest
    public static void test_cancelSet_error() {
        setupTestData(false);
@@ -762,10 +772,9 @@
        Test.stopTest();
        List<Apexpages.message> msgs = ApexPages.getMessages();
        //System.assertEquals('取消理由和取消理由备注不可为空!', msgs[0].getDetail());
        //System.debug('init Error');
    }
        System.assertEquals('取消理由和取消理由备注不可为空!', msgs[0].getDetail());
        System.debug('init Error');
    }*/
    @isTest
    public static void test_shipment() {
@@ -801,12 +810,10 @@
        controller.parentObj.Delivery_Agency__c = '北京市';
        controller.shipment();
        Test.stopTest();
        //System.assertEquals(true, controller.done_flg);
        //List<Apexpages.message> msgs = ApexPages.getMessages();
        //System.assertEquals('必须填写【物流公司】', msgs[0].getDetail());
        //System.debug('init Error');
        System.assertEquals(true, controller.done_flg);
        // 20220317 ljh add 验证数据使用 start
        // List<Apexpages.message> msgs = ApexPages.getMessages();
        // System.assertEquals('test', msgs[0].getDetail());
    }
    @isTest
@@ -841,8 +848,8 @@
        Test.stopTest();
        List<Apexpages.message> msgs = ApexPages.getMessages();
        //System.assertEquals('n01未分配不可发货!', msgs[0].getDetail());
        System.debug('init Success');
        System.assertEquals('发货-办事处为空,不能发货', msgs[0].getDetail());
        System.debug('init Error');
    }
@@ -882,9 +889,4 @@
        System.debug('init Success');
    }
    /**
    static testMethod void updaue() {
        RentalFixtureSetAssignAgencyController.test();//先调用这个,然后继续补充测试类
    }
    **/
}