19626
2023-06-20 0c67f7b596da5f6473ac68ea8376cad060971a0a
提高代码覆盖率
3个文件已修改
7053 ■■■■ 已修改文件
force-app/main/default/classes/NewAndEditLeadControllerTest.cls 63 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/classes/UpdateTenderInformationBatchTest.cls 233 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/classes/XinDailyReportControllerTest.cls 6757 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/classes/NewAndEditLeadControllerTest.cls
@@ -33,9 +33,72 @@
        Test.stopTest();
    }
    static testMethod void testMethod2() {
        Lead leadTest = new Lead();
        leadTest.LastName = 'test';
        leadTest.Company = 'test';
        insert leadTest;
        String url = ApexPages.currentPage().getParameters().put('CF00N10000006ps6f_lkid','000000000000000');
        url = ApexPages.currentPage().getParameters().put('CF00N10000002CvC5_lkid','000000000000000');
        url = ApexPages.currentPage().getParameters().put('RecordType','01210000000QiRf');
        Test.startTest();
        try{
            NewAndEditLeadController.ControllerUtil();
            ApexPages.StandardController con =  new ApexPages.StandardController(leadTest);
            NewAndEditLeadController lc = new NewAndEditLeadController(con);
            String jsonString = '["Department_Class__c"]';
            system.debug('jsonString:'+JSON.deserializeUntyped(jsonString));
            String token = lc.awsToken;
            String AWSDataId = lc.AWSDataId;
            String AWSDataIdInquiryForm = lc.AWSDataIdInquiryForm;
            String contactId = lc.contactId;//For Lookup field
            String contactsInfo = lc.contactsInfo ;//key sfid;value awsid
            Inquiry_form__c ifc = lc.ifc;
            NewAndEditLeadController.queryAccount(jsonString, '000000000000000');
        }catch(Exception e){
            system.debug('Exception from query account:'+e.getMessage());
        }
        Test.stopTest();
    }
    static testMethod void testMethod3() {
        Lead leadTest = new Lead();
        String url = ApexPages.currentPage().getParameters().put('CF00N10000006ps6f_lkid','000000000000000');
        url = ApexPages.currentPage().getParameters().put('CF00N10000002CvC5_lkid','000000000000000');
        url = ApexPages.currentPage().getParameters().put('RecordType','01210000000QiRf');
        Test.startTest();
        try{
            NewAndEditLeadController.ControllerUtil();
            ApexPages.StandardController con =  new ApexPages.StandardController(leadTest);
            NewAndEditLeadController lc = new NewAndEditLeadController(con);
            String jsonString = '["Department_Class__c"]';
            system.debug('jsonString:'+JSON.deserializeUntyped(jsonString));
            String token = lc.awsToken;
            String AWSDataId = lc.AWSDataId;
            String AWSDataIdInquiryForm = lc.AWSDataIdInquiryForm;
            String contactId = lc.contactId;//For Lookup field
            String contactsInfo = lc.contactsInfo ;//key sfid;value awsid
            Inquiry_form__c ifc = lc.ifc;
            NewAndEditLeadController.queryAccount(jsonString, '000000000000000');
        }catch(Exception e){
            system.debug('Exception from query account:'+e.getMessage());
        }
        Test.stopTest();
    }
    static testMethod void testMethod4() {
        // Lead leadTest = new Lead();
        Lead leadTest = new Lead();
        leadTest.LastName = 'test';
        leadTest.Company = 'test';
        insert leadTest;
        Inquiry_form__c inquiryform = new Inquiry_form__c();
        inquiryform.Name = '2019102101';
        inquiryform.Request1__c = '需要报价';
        inquiryform.Product1__c = '超声';
        inquiryform.FSE_Owner__c  = UserInfo.getUserId();
        insert inquiryform;
        String url = ApexPages.currentPage().getParameters().put('CF00N1000000962np_lkid',inquiryform.id);
        url = ApexPages.currentPage().getParameters().put('RecordType','01210000000QiRf');
        Test.startTest();
        try{
force-app/main/default/classes/UpdateTenderInformationBatchTest.cls
@@ -897,4 +897,237 @@
        Test.stopTest();
    }
    static testMethod void testMethod07() {
        ControllerUtil.EscapeNFM001Trigger = true;
        ControllerUtil.EscapeMaintenanceContractAfterUpdateTrigger = true;
        StaticParameter.EscapeNFM001Trigger = true;
        StaticParameter.EscapeNFM001AgencyContractTrigger = true;
        StaticParameter.EscapeNFM001AgencyContractTrigger2 = true;
        StaticParameter.EscapeMaintenanceContractAfterUpdateTrigger = true;
        RecordType rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and DeveloperName = 'Hp'];
        List<RecordType> rectDpt = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and DeveloperName IN ('Department_GI', 'Department_BF') order by DeveloperName desc];
        Account acc = new Account();
        acc.RecordTypeId = rectCo.Id;
        acc.Name = 'HP test1';
        acc.Assume_Change__c = true;
        insert acc;
        List<Account> dept = [select Id, Name from Account where ParentId = :acc.Id and Department_Class_Label__c IN ('消化科', '呼吸科') order by Department_Class_Label__c];
        Account depart1 = new Account();
        depart1.RecordTypeId = rectDpt[0].Id;
        depart1.Name         = '*';
        depart1.Department_Name__c  = 'Gastoro Intestin Test';
        depart1.ParentId            = dept[0].Id;
        depart1.Department_Class__c = dept[0].Id;
        depart1.Hospital__c         = acc.Id;
        Account depart2 = new Account();
        depart2.RecordTypeId = rectDpt[1].Id;
        depart2.Name         = '*';
        depart2.Department_Name__c  = '診療科2';
        depart2.ParentId            = dept[1].Id;
        depart2.Department_Class__c = dept[1].Id;
        depart2.Hospital__c         = acc.Id;
        insert new Account[] {depart1, depart2};
        RecordType oppVND = [select id from RecordType where IsActive = true and SobjectType = 'Opportunity' and DeveloperName = 'Opportunity'];
        //招标项目
        Tender_information__c te1 = new Tender_information__c();
        te1.Name = 'TestZhaoBiao1';
        te1.IsReactionOpp__c = false;
        te1.Hospital__c = acc.Id;
        insert te1;
        Tender_information__c te2 = new Tender_information__c();
        te1.IsReactionOpp__c = false;
        te2.Name = 'TestZhaoBiao2';
        insert te2;
        //询价
        // Opportunity opp1 = new Opportunity(
        //     Name = 'test opp1',
        //     StageName = '敗戦',
        //     CurrencyIsoCode = 'USD',
        //     CloseDate = Date.today(),
        //     AccountId = depart1.Id,
        //     RecordTypeId = oppVND.Id,
        //     Closing_Bid_Date__c = Date.today().addDays(-5),
        //     Hospital__c = acc.Id,
        //     Competitor__c = 'A'
        // );
        // Opportunity opp2 = new Opportunity(
        //     Name = 'test opp2',
        //     StageName = '敗戦',
        //     CurrencyIsoCode = 'USD',
        //     CloseDate = Date.today(),
        //     AccountId = depart2.Id,
        //     RecordTypeId = oppVND.Id,
        //     Closing_Bid_Date__c = Date.today().addDays(-5),
        //     Hospital__c = acc.Id,
        //     Competitor__c = 'B',
        //     Bidding_Project_Name_Bid__c = te1.Id
        // );
        // Opportunity opp3 = new Opportunity(
        //     Name = 'test opp3',
        //     StageName = '敗戦',
        //     CurrencyIsoCode = 'USD',
        //     CloseDate = Date.today(),
        //     AccountId = depart2.Id,
        //     RecordTypeId = oppVND.Id,
        //     Closing_Bid_Date__c = Date.today().addDays(-5),
        //     Hospital__c = acc.Id,
        //     Competitor__c = 'C',
        //     Bidding_Project_Name_Bid__c = te2.Id
        // );
        // insert new Opportunity[] {opp1, opp2,opp3};
        // opp1.Bidding_Project_Name_Bid__c = te1.Id;
        // opp2.Bidding_Project_Name_Bid__c = te2.Id;
        // opp3.Bidding_Project_Name_Bid__c = null;
        // update opp1;
        // update opp2;
        // update opp3;
        List<String> tempList = new List<String>();
        tempList.add(te1.Id);
        tempList.add(te2.Id);
        System.Test.StartTest();
        UpdateTenderInformationBatch batch = new UpdateTenderInformationBatch('',false);
        Id execBTId = Database.executeBatch(batch);
        System.Test.StopTest();
    }
    static testMethod void testMethod08() {
        ControllerUtil.EscapeNFM001Trigger = true;
        ControllerUtil.EscapeMaintenanceContractAfterUpdateTrigger = true;
        StaticParameter.EscapeNFM001Trigger = true;
        StaticParameter.EscapeNFM001AgencyContractTrigger = true;
        StaticParameter.EscapeNFM001AgencyContractTrigger2 = true;
        StaticParameter.EscapeMaintenanceContractAfterUpdateTrigger = true;
        RecordType rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and DeveloperName = 'Hp'];
        List<RecordType> rectDpt = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and DeveloperName IN ('Department_GI', 'Department_BF') order by DeveloperName desc];
        Account acc = new Account();
        acc.RecordTypeId = rectCo.Id;
        acc.Name = 'HP test1';
        insert acc;
        List<Account> dept = [select Id, Name from Account where ParentId = :acc.Id and Department_Class_Label__c IN ('消化科', '呼吸科') order by Department_Class_Label__c];
        Account depart1 = new Account();
        depart1.RecordTypeId = rectDpt[0].Id;
        depart1.Name         = '*';
        depart1.Department_Name__c  = 'Gastoro Intestin Test';
        depart1.ParentId            = dept[0].Id;
        depart1.Department_Class__c = dept[0].Id;
        depart1.Hospital__c         = acc.Id;
        Account depart2 = new Account();
        depart2.RecordTypeId = rectDpt[1].Id;
        depart2.Name         = '*';
        depart2.Department_Name__c  = '診療科2';
        depart2.ParentId            = dept[1].Id;
        depart2.Department_Class__c = dept[1].Id;
        depart2.Hospital__c         = acc.Id;
        insert new Account[] {depart1, depart2};
        RecordType oppVND = [select id from RecordType where IsActive = true and SobjectType = 'Opportunity' and DeveloperName = 'Opportunity'];
        //招标项目
        Tender_information__c te1 = new Tender_information__c();
        te1.Name = 'TestZhaoBiao1';
        insert te1;
        Tender_information__c te2 = new Tender_information__c();
        te2.Name = 'TestZhaoBiao2';
        insert te2;
        //询价
        Opportunity opp1 = new Opportunity(
            Name = 'test opp1',
            StageName = '敗戦',
            CurrencyIsoCode = 'USD',
            CloseDate = Date.today(),
            AccountId = depart1.Id,
            RecordTypeId = oppVND.Id,
            Closing_Bid_Date__c = Date.today().addDays(-5),
            Hospital__c = acc.Id,
            Competitor__c = 'A'
        );
        Opportunity opp2 = new Opportunity(
            Name = 'test opp2',
            StageName = '敗戦',
            CurrencyIsoCode = 'USD',
            CloseDate = Date.today(),
            AccountId = depart2.Id,
            RecordTypeId = oppVND.Id,
            Closing_Bid_Date__c = Date.today().addDays(-5),
            Hospital__c = acc.Id,
            Competitor__c = 'B',
            Bidding_Project_Name_Bid__c = te1.Id
        );
        Opportunity opp3 = new Opportunity(
            Name = 'test opp3',
            StageName = '敗戦',
            CurrencyIsoCode = 'USD',
            CloseDate = Date.today(),
            AccountId = depart2.Id,
            RecordTypeId = oppVND.Id,
            Closing_Bid_Date__c = Date.today().addDays(-5),
            Hospital__c = acc.Id,
            Competitor__c = 'C',
            Bidding_Project_Name_Bid__c = te2.Id
        );
        insert new Opportunity[] {opp1, opp2,opp3};
        opp1.Bidding_Project_Name_Bid__c = te1.Id;
        opp2.Bidding_Project_Name_Bid__c = te2.Id;
        opp3.Bidding_Project_Name_Bid__c = null;
        update opp1;
        update opp2;
        update opp3;
        List<String> tempList = new List<String>();
        tempList.add(te1.Id);
        tempList.add(te2.Id);
        System.Test.StartTest();
        UpdateTenderInformationBatch batch = new UpdateTenderInformationBatch(opp1.Id,false,tempList);
        Id execBTId = Database.executeBatch(batch);
        System.Test.StopTest();
    }
    static testMethod void testMethod09() {
        Tender_information__c te1 = new Tender_information__c();
        te1.Name = 'TestZhaoBiao1';
        insert te1;
        Tender_information__c te2 = new Tender_information__c();
        te2.Name = 'TestZhaoBiao2';
        insert te2;
        System.Test.StartTest();
        UpdateTenderInformationBatch batch = new UpdateTenderInformationBatch(te1.Id);
        System.Test.StopTest();
    }
    static testMethod void testMethod10() {
        Tender_information__c te1 = new Tender_information__c();
        te1.Name = 'TestZhaoBiao1';
        insert te1;
        Tender_information__c te2 = new Tender_information__c();
        te2.Name = 'TestZhaoBiao2';
        insert te2;
        List<String> tempList = new List<String>();
        tempList.add(te1.Id);
        tempList.add(te2.Id);
        System.Test.StartTest();
        UpdateTenderInformationBatch batch = new UpdateTenderInformationBatch(tempList);
        System.Test.StopTest();
    }
}
force-app/main/default/classes/XinDailyReportControllerTest.cls
Diff too large