buli
2022-04-06 2d4a8d2dcad5a17127d2c73c48ddc4b67ec79448
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
/*
 * Author: Guo, Aline Yaying
 * Created Date: 03/22/2022
 * Purpose: Test Class
 * History: 
 *      03/22/2022 - Guo, Aline Yaying - Initial Code.
 * 
 * */
@isTest
private class NewConsumApplyControllerTest {
    @TestSetup
    static void makeData(){
        List<String> strList = new List<String>();
        strList.add('Consum_Apply__c');
        strList.add('Contact');
        TestDataUtility.CreatePIPolicyConfigurations(strList);
    }
    static testMethod void testMethod1() {
     
        Test.setMock(HttpCalloutMock.class, new TestDataUtility.CreateMetaDataUtilityHttpMock());
        Consum_Apply__c consumTest = TestDataUtility.CreateConsumApply(1)[0];
 
        Test.startTest();
        ApexPages.StandardController con =  new ApexPages.StandardController(consumTest);
        NewConsumApplyController consum = new NewConsumApplyController(con);
        
        String consumJson = '{"HP_received_sign_rich__c":"","Name":"123456","Person_In_Charge__c":"00510000000fSYI","ApplyPerson_Phone__c":"","applyUser__c":"00510000000fSYI","Loaner_centre_mail_address__c":"sfdc_lvxueyan@olympus.com.cn","Is_Special_Rental__c":false,"Request_Shipping_7days_Before__c":"","Status__c":"草案中","ConsumApplyRemind_Text__c":"1、创建申请单锁定库存后,请于2个工作日内提交审批,否则系统自动释放库存。\\n2、请确保您提交的申请单在\\"希望到货日-7个工作日”前完成审批,否则申请单自动取消。\\n3、请提交22个工作日以内使用的耗材申请单。","Hospital__c":"000000000000000","Loaner_medical_Staff__c":"000000000000000","Strategic_dept__c":"000000000000000","Phone_number__c":"","Account__c":"000000000000000","Product_category__c":"ET","demo_purpose2__c":"学会展会","QIS_number__c":"000000000000000","Campaign__c":"70110000000laUw","OPDPlan__c":"000000000000000","Rental_Apply__c":"000000000000000","Demo_purpose_text__c":"test","Request_shipping_day__c":"2022-03-28:00","Shipment_address__c":"a2H10000005RQDJ","direct_send__c":"上门自提","Dealer__c":"0011000000VATK6","pickup_time__c":"2022-03-28 17:11:00","Loaner_received_staff__c":"testname","Loaner_received_staff_phone__c":"1234567890","direct_shippment_address__c":"106 Catalpa St, Coffeyville, KS 67337, USA","Post_Code__c":"12345-123","Old_Consum_Apply__c":"000000000000000","Split_Apply_Reason__c":"","DeliverySlip__c":"000000000000000","HP_received_sign_NG__c":false,"HP_received_sign_NG_Reason__c":"","AssetManageConfirm__c":false,"Cancel_Reason__c":"","Loaner_cancel_request__c":"","Consum_Received_Day__c":"","OwnerId":"0051m0000030e0Q","Request_demo_time__c":"","Request_approval_time__c":"","Application_accept_time__c":"","Request_answer_time__c":"","OPD__c":"000000000000000","OPDAmount__c":"","Shipment_Slip_tmp__c":""}';
        NewConsumApplyController.saveConsumApply(consumJson,'avgwshDFcxAS',False);
        NewConsumApplyController.saveConsumApply(consumJson,'avgwshDFcxAS',True);
        Test.stopTest();
    }
    static testMethod void testMethod2() {
 
        String recordTypeId = Schema.SObjectType.Consum_Apply__c.getRecordTypeInfosByDeveloperName().get('StandardRequest').getRecordTypeId();
        String url = ApexPages.currentPage().getParameters().put('00N10000008rdgs','北京');
        url = ApexPages.currentPage().getParameters().put('Name','RC修理');
        url = ApexPages.currentPage().getParameters().put('RecordType',recordTypeId);
        Test.setMock(HttpCalloutMock.class, new TestDataUtility.CreateMetaDataUtilityHttpMock());
 
        Test.startTest();
        ApexPages.StandardController con =  new ApexPages.StandardController(new Consum_Apply__c());
        NewConsumApplyController repDetail = new NewConsumApplyController(con);
        Test.stopTest();
    }
}