高章伟
2023-03-03 d8dc84a3d56df839895f1c417a4d9cbee763d262
force-app/main/default/classes/NewRepairControllerTest.cls
@@ -10,7 +10,13 @@
private class NewRepairControllerTest {
    static testMethod void testMethod1() {
        //1. 准备数据
        TestDataUtility.CreatePIPolicyConfiguration();
        List<String> strList = new List<String>();
        strList.add('Repair__c');
        strList.add('Address__c');
        strList.add('Contact');
        strList.add('RepairSubOrder__c');
        strList.add('Repair__cV2');
        TestDataUtility.CreatePIPolicyConfigurations(strList);
        Test.setMock(HttpCalloutMock.class, new TestDataUtility.CreateMetaDataUtilityHttpMock());
        Repair__c repTest = TestDataUtility.CreateRepairs(1)[0];
        //2. 运行代码逻辑
@@ -32,6 +38,7 @@
        strList.add('Address__c');
        strList.add('Contact');
        strList.add('RepairSubOrder__c');
        strList.add('Repair__cV2');
        TestDataUtility.CreatePIPolicyConfigurations(strList);
        Test.setMock(HttpCalloutMock.class, new TestDataUtility.CreateMetaDataUtilityHttpMock());
        String url = ApexPages.currentPage().getParameters().put('00N10000006P6SM','北京');
@@ -75,14 +82,19 @@
        
      Repair__c repTest = TestDataUtility.CreateRepairs(1)[0];
        url = ApexPages.currentPage().getParameters().put('RepairId',repTest.Id);
        url = ApexPages.currentPage().getParameters().put('retURL','%'+repTest.Id);
        Test.startTest();
        ApexPages.StandardController con =  new ApexPages.StandardController(new Repair__c());
        NewRepairController repDetail = new NewRepairController(con);
        Test.stopTest();
    }
    static testMethod void testMethod3(){
        TestDataUtility.CreatePIPolicyConfiguration('Repair__c');
        List<String> strList = new List<String>();
        strList.add('Repair__c');
        strList.add('Repair__cV2');
        strList.add('Contact');
        strList.add('Address__c');
        TestDataUtility.CreatePIPolicyConfigurations(strList);
        ApexPages.StandardController con =  new ApexPages.StandardController(new Repair__c());
        try{
            NewRepairController controllerTest = new NewRepairController(con);
@@ -91,6 +103,7 @@
        }catch(Exception e){
            system.debug('Exception from insert repair:'+e.getMessage());
        }
        NewRepairController.EncryptUpdate('a0J1m000001QqX');
        NewRepairController.EncryptUpdate('a0J1m000001QqXk');
    }