/* * 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]; caseTest.AWS_Data_Id__c = '956935867849506816'; Update caseTest; Test.startTest(); ApexPages.StandardController con = new ApexPages.StandardController(caseTest); NewAndEditCaseController cas = new NewAndEditCaseController(con); String caseJson = '{\"RecordTypeId\":\"01210000000QsYk\",\"CurrencyIsoCode\":\"CNY\",\"Costs__c\":\"\",\"CreatedDate\":null,\"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\"}'; 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); Test.startTest(); ApexPages.StandardController con = new ApexPages.StandardController(new Case()); NewAndEditCaseController cas = new NewAndEditCaseController(con); String aws = cas.awsToken; String conid = cas.contactId; 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\"}'; NewAndEditCaseController.saveCase(caseJson,'avgwshDFcxAS',False); Test.stopTest(); } }