/**
|
* @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();
|
|
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":"社内员工(无CIC)","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":"販売店","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();
|
|
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;
|
System.debug('data = ' + JSON.serialize(data));
|
NewAgencyContactController.Save(null, ac.Id+'');
|
|
Test.stopTest();
|
}
|
}
|