From eeb7c0a2d6f037d515bb822d739036b69c4dc73a Mon Sep 17 00:00:00 2001 From: 沙世明 <shashiming@prec-tech.com> Date: 星期五, 08 四月 2022 17:14:12 +0800 Subject: [PATCH] Merge branch 'master' of http://47.92.229.245:8089/r/OlyMEBG --- force-app/main/default/classes/NewAgencyContactControllerTest.cls | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 58 insertions(+), 0 deletions(-) diff --git a/force-app/main/default/classes/NewAgencyContactControllerTest.cls b/force-app/main/default/classes/NewAgencyContactControllerTest.cls new file mode 100644 index 0000000..7097fe5 --- /dev/null +++ b/force-app/main/default/classes/NewAgencyContactControllerTest.cls @@ -0,0 +1,58 @@ +/** + * @description : + * @author : ChangeMeIn@UserSettingsUnder.SFDoc + * @group : + * @last modified on : 03-29-2022 + * @last modified by : ChangeMeIn@UserSettingsUnder.SFDoc +**/ +@isTest +public class NewAgencyContactControllerTest { + @isTest + static void testMethod1() { + TestDataUtility.CreatePIPolicyConfiguration('Agency_Contact__c'); + + Test.setMock(HttpCalloutMock.class, new TestDataUtility.CreateMetaDataUtilityHttpMock()); + Agency_Contact__c ac = TestDataUtility.CreateAgencyContacts(1)[0]; + String recordTypeId = Schema.SObjectType.Agency_Contact__c.getRecordTypeInfosByDeveloperName().get('Agency').getRecordTypeId(); + Test.startTest(); + ControllerResponse res = NewAgencyContactController.Init(ac.Id,ac.Id,recordTypeId); + System.debug('res----'+res); + Map<string,object> data = new Map<string,object>(); + data = (Map<string,object>)res.Data; + NewAgencyContactController.Save(data, ac.Id+''); + Test.stopTest(); + } + + @isTest + static void testMethod2() { + Test.startTest(); + String body = '{"size":6,"totalSize":6,"done":true,"queryLocator":null,"entityTypeName":"Layout","records":[{"attributes":{"type":"Layout","url":"/services/data/v41.0/tooling/sobjects/Layout/00h10000005qCPDAA2"},"Id":"00h10000005qCPDAA2","Name":"鍖诲斧","TableEnumOrId":"Contact","LayoutType":"Standard"},{"attributes":{"type":"Layout","url":"/services/data/v41.0/tooling/sobjects/Layout/00h10000005r604AAA"},"Id":"00h10000005r604AAA","Name":"绀惧唴鍛樺伐","TableEnumOrId":"Contact","LayoutType":"Standard"},{"attributes":{"type":"Layout","url":"/services/data/v41.0/tooling/sobjects/Layout/00h100000088sb2AAA"},"Id":"00h100000088sb2AAA","Name":"绀惧唴鍛樺伐(澶囧搧)","TableEnumOrId":"Contact","LayoutType":"Standard"},{"attributes":{"type":"Layout","url":"/services/data/v41.0/tooling/sobjects/Layout/00h10000005r63hAAA"},"Id":"00h10000005r63hAAA","Name":"绀惧唴鍛樺伐(鏃燙IC)","TableEnumOrId":"Contact","LayoutType":"Standard"},{"attributes":{"type":"Layout","url":"/services/data/v41.0/tooling/sobjects/Layout/00h10000009lFA2AAM"},"Id":"00h10000009lFA2AAM","Name":"绯荤粺绠$悊鍛樺壇鏈�","TableEnumOrId":"Contact","LayoutType":"Standard"},{"attributes":{"type":"Layout","url":"/services/data/v41.0/tooling/sobjects/Layout/00h10000005qCPIAA2"},"Id":"00h10000005qCPIAA2","Name":"璨╁2搴�","TableEnumOrId":"Contact","LayoutType":"Standard"}]}'; + Test.setMock(HttpCalloutMock.class, new TestDataUtility.BaseHttpMock(body,'1','200')); + MetaDataUtility.GetAllPageLayout('Contact'); + // Agency_Contact__c ac = TestDataUtility.CreateAgencyContacts(1)[0]; + // String recordTypeId = Schema.SObjectType.Agency_Contact__c.getRecordTypeInfosByDeveloperName().get('Agency').getRecordTypeId(); + // ControllerResponse response = NewAgencyContactController.Init('a2R0l000000QNoQEAW', ac.Id, recordTypeId); + // System.debug('response----'+response); + Test.stopTest(); + } + + @isTest + static void testMethod3() { + TestDataUtility.CreatePIPolicyConfiguration('Agency_Contact__c'); + + Test.setMock(HttpCalloutMock.class, new TestDataUtility.CreateMetaDataUtilityHttpMock()); + String rid = ''; + Agency_Contact__c ac = TestDataUtility.CreateAgencyContacts(1)[0]; + String recordTypeId = Schema.SObjectType.Agency_Contact__c.getRecordTypeInfosByDeveloperName().get('Agency').getRecordTypeId(); + Test.startTest(); + ControllerResponse res = NewAgencyContactController.Init(rid, ac.Id, recordTypeId); + System.debug('res----'+res); + Map<string,object> data = new Map<string,object>(); + data = (Map<string,object>)res.Data; + data.put('AWS_Data_Id__c','321'); + System.debug('data = ' + JSON.serialize(data)); + NewAgencyContactController.Save(data, ac.Id+''); + + Test.stopTest(); + } +} \ No newline at end of file -- Gitblit v1.9.1