buli
2023-07-11 80a3f59e2d3df07805bc67e329300b8de90a5b3a
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
@isTest
private class LayoutDescriberHelperTest {
    static testMethod void testMethod1() {
        String userMode = 'classic'; //classic  lightning
        String objectType = 'Contact';
        String recordTypeId = Schema.SObjectType.Contact.getRecordTypeInfosByDeveloperName().get('Doctor').getRecordTypeId();
        System.debug('record type id ===>' + recordTypeId + ' object type===>' + objectType + ' userMode===>' + userMode);
        boolean useHeader = false;
        String baseurl = System.URL.getOrgDomainUrl().getHost();
        Map<String, object> detailsMap = new Map<String, object>();
        Map<String, object> detailsMap2 = new Map<String, object>();
        Map<String, object> detailsMap3 = new Map<String, object>();
        detailsMap.put('calculated', true);
        detailsMap.put('autoNumber', false);
        detailsMap.put('type', 'address');
        detailsMap2.put('calculated', false);
        detailsMap2.put('autoNumber', false);
        detailsMap2.put('type', 'repair');
        detailsMap3.put('calculated', false);
        detailsMap3.put('autoNumber', false);
        detailsMap3.put('type', 'repair');
        String fieldTypeDetail = (String) detailsMap.get('type');
 
        List<Map<String, object>> componentMapList = new List<Map<String, object>>();
        List<Map<String, object>> componentMapList2 = new List<Map<String, object>>();
        List<Map<String, object>> componentMapList3 = new List<Map<String, object>>();
        Map<String, object> componentMap = new Map<String, object>();
        Map<String, object> componentMap2 = new Map<String, object>();
        Map<String, object> componentMap3 = new Map<String, object>();
        componentMap.put('value', 'Name');
        componentMap.put('type', 'Field');
        componentMap.put('details', detailsMap);
        componentMapList.add(componentMap);
        componentMap2.put('value', 'Name');
        componentMap2.put('type', 'Field');
        componentMap2.put('details', detailsMap2);
        componentMapList2.add(componentMap2);
        componentMap3.put('value', 'LastName');
        componentMap3.put('type', 'Field');
        componentMap3.put('details', detailsMap3);
        componentMapList3.add(componentMap3);
        String apiName = (String) componentMap.get('value');
        String fieldType = (String) componentMap.get('type');
 
        List<Map<String, object>> layoutComponentsList = new List<Map<String, object>>();
        Map<String, object> layoutComponents = new Map<String, object>();
        layoutComponents.put('layoutComponents', componentMapList);
        layoutComponents.put('label', 'Address');
        layoutComponents.put('placeholder', true);
        layoutComponents.put('editableForNew', true);
        layoutComponents.put('editableForUpdate', true);
        layoutComponents.put('required', false);
        layoutComponentsList.add(layoutComponents);
        Map<String, object> layoutComponents2 = new Map<String, object>();
        layoutComponents2.put('layoutComponents', componentMapList2);
        layoutComponents2.put('label', 'Repair');
        layoutComponents2.put('placeholder', true);
        layoutComponents2.put('editableForNew', true);
        layoutComponents2.put('editableForUpdate', true);
        layoutComponents2.put('required', false);
        layoutComponentsList.add(layoutComponents2);
        Map<String, object> layoutComponents3 = new Map<String, object>();
        layoutComponents3.put('layoutComponents', componentMapList3);
        layoutComponents3.put('label', 'Repair');
        layoutComponents3.put('placeholder', true);
        layoutComponents3.put('editableForNew', true);
        layoutComponents3.put('editableForUpdate', true);
        layoutComponents3.put('required', false);
        layoutComponentsList.add(layoutComponents3);
 
        boolean placeholderF = (boolean) layoutComponents.get('placeholder');
        boolean isEditable = (boolean) layoutComponents.get('editableForUpdate') || (boolean) layoutComponents.get('editableForNew');
        System.debug('isEditable ===>' + isEditable);
        List<Map<String, object>> itemList = new List<Map<String, object>>();
        Map<String, object> item = new Map<String, object>();
        item.put('layoutItems', layoutComponentsList);
        itemList.add(item);
        useHeader = true;
        List<Map<String, object>> sectionList = new List<Map<String, object>>();
        Map<String, object> section = new Map<String, object>();
        section.put('heading', '');
        section.put('useHeading', useHeader);
        section.put('columns', 1);
        section.put('useCollapsibleSection', true);
        section.put('layoutRows', itemList);
        sectionList.add(section);
 
        Map<String, Object> layoutSection = new Map<String, Object>();
        layoutSection.put('layouts', '123');
        layoutSection.put('editLayoutSections', sectionList);
        String layoutSectionJson = JSON.serialize(layoutSection);
        LayoutDescriberHelper.ControllerUtil();
        Test.setMock(HttpCalloutMock.class, new TestDataUtility.BaseHttpMock(layoutSectionJson, 'OK', '200'));
        Test.startTest();
        LayoutDescriberHelper.describeSectionWithFieldsWrapper(recordTypeId, objectType, userMode);
        LayoutDescriberHelper.describeSectionWithFieldsWrapper(null, objectType, userMode);
        LayoutDescriberHelper.describeSectionWithFields(recordTypeId, objectType, userMode);
        LayoutDescriberHelper.getLayoutSchema(recordTypeId, objectType, userMode);
        LayoutDescriberHelper.getUrlPrefix();
        Test.stopTest();
    }
}