/* * Author: Guo, Aline Yaying * Created Date: 03/22/2022 * Purpose: Test Class * History: * 03/22/2022 - Guo, Aline Yaying - Initial Code. * * */ @isTest private class NewAndEditCaseControllerTest { static testMethod void testMethod1() { TestDataUtility.CreatePIPolicyConfiguration(); //Test.setMock(HttpCalloutMock.class, new TestDataUtility.CreateMetaDataUtilityHttpMock()); //Case caseTest = TestDataUtility.CreateCase(1)[0]; //Contact conTest = TestDataUtility.CreateContacts(1)[0]; case caseTest = new case(); //caseTest.ContactId = contact5.id;//客户人员姓名, Contact //caseTest.Account__c = aC.Id;//客户名称, Account caseTest.Subject = 'Test For Case'; caseTest.AWS_Data_Id__c = '956935867849506816'; insert caseTest; Test.startTest(); ApexPages.StandardController con = new ApexPages.StandardController(caseTest); NewAndEditCaseController cas = new NewAndEditCaseController(con); String caseJson = Json.serialize(caseTest); NewAndEditCaseController.saveCase(caseJson,'avgwshDFcxAS',False); Test.stopTest(); } static testMethod void testMethod2() { TestDataUtility.CreatePIPolicyConfiguration(); //Test.setMock(HttpCalloutMock.class, new TestDataUtility.CreateMetaDataUtilityHttpMock()); // Case caseTest = TestDataUtility.CreateCase(1)[0]; // Contact conTest = TestDataUtility.CreateContacts(1)[0]; String recordTypeId = Schema.SObjectType.Case.getRecordTypeInfosByDeveloperName().get('CICRecordType').getRecordTypeId(); String url = ApexPages.currentPage().getParameters().put('RecordType',recordTypeId); url = ApexPages.currentPage().getParameters().put('00N10000003M4vA','询问内容'); url = ApexPages.currentPage().getParameters().put('00N10000003M4v8','回答内容详细'); url = ApexPages.currentPage().getParameters().put('00N10000003LhT8','0'); url = ApexPages.currentPage().getParameters().put('CreatedDate','2022-07-19'); url = ApexPages.currentPage().getParameters().put('00N10000003M4v7','2022-07-19'); url = ApexPages.currentPage().getParameters().put('00N10000005Ht1B','1'); Test.startTest(); ApexPages.StandardController con = new ApexPages.StandardController(new Case()); NewAndEditCaseController cas = new NewAndEditCaseController(con); String aws = cas.awsToken; String conid = cas.contactId; case caseTest = new case(); caseTest.answer_day__c = Date.today(); caseTest.CreatedDate = Date.today(); caseTest.ClosedDate = null; caseTest.Costs__c = 100; caseTest.SI_PJ__c = true; //caseTest.ContactId = contact5.id;//客户人员姓名, Contact //caseTest.Account__c = aC.Id;//客户名称, Account caseTest.Subject = 'Test For Case'; caseTest.AWS_Data_Id__c = '956935867849506816'; //String caseJson = '{\"RecordTypeId\":\"01210000000QsYk\",\"CurrencyIsoCode\":\"CNY\",\"Costs__c\":\"\",\"CreatedDate\":\"2022-03-28T12:28:16.000+0000\",\"ContactId\":\"'+conTest.Id+'\",\"Plan_Costs__c\":\"\",\"SunBridge_Owner__c\":\"\",\"Development_Phase__c\":\"\",\"Service_dept__c\":false,\"Status\":\"新規\",\"Type\":\"\",\"Origin\":\"本番環境\",\"Reason\":\"複雑な機能\",\"Priority\":\"中\",\"PleaseConfirm__c\":false,\"Task_category__c\":\"1\",\"endDate__c\":\"\",\"Subject_Content_Riben__c\":\"\",\"Description\":\"\",\"Comments\":\"\",\"cic_telephone__c\":null,\"CASE_CUSTOMER__c\":null,\"Customer_manual__c\":null,\"cic_telephone_Encrypted__c\":null,\"CASE_CUSTOMER_Encrypted__c\":null,\"Customer_manual_Encrypted__c\":null,\"AWS_Data_Id__c\":\"956935867849506816\"}'; String caseJson = json.serialize(caseTest); NewAndEditCaseController.saveCase(caseJson,'avgwshDFcxAS',False); Test.stopTest(); } }