| | |
| | | public class NewAndEditBaseControllerTest { |
| | | /* |
| | | *@Description: NewAndEditBaseControllerTest |
| | | *@Author: Dennis Rodman |
| | | *@Date: 2022-04-13 11:44:04 |
| | | */ |
| | | @isTest |
| | | private class NewAndEditBaseControllerTest { |
| | | static testMethod void testMethod1() { |
| | | |
| | | // RecordType rtId = [select Id, SobjectType, Name from RecordType where SobjectType = 'Account' and Name = 'Customer']; |
| | | TestDataUtility.CreatePIPolicyConfiguration(); |
| | | Test.setMock(HttpCalloutMock.class, new TestDataUtility.CreateMetaDataUtilityHttpMock()); |
| | | //use a random sobj |
| | | loaner_application__c tenTest = TestDataUtility.CreateLoanerApplications(1)[0]; |
| | | // tenTest.ResultDate__c = null; |
| | | // tenTest.InfoPublishTime__c = Datetime.now(); |
| | | // tenTest.OpportunityNum__c = null; |
| | | // tenTest.Other_units__c = false; |
| | | tenTest.AWS_Data_Id__c = '1569989'; |
| | | // tenTest.RecordTypeId = rtId.Id; |
| | | update tenTest; |
| | | |
| | | Test.startTest(); |
| | | //ApexPages.StandardController con = new ApexPages.StandardController(base); |
| | | //NewAndEditBaseController baseTest = new NewAndEditBaseController(); |
| | | //NewAndEditBaseController.Init(base); |
| | | ApexPages.StandardController con = new ApexPages.StandardController(tenTest); |
| | | NewAndEditLoanerApplicationController a = new NewAndEditLoanerApplicationController(con); |
| | | a.Init(tenTest); |
| | | String AWSjson = a.AWSToSobjectMapJson; |
| | | NewAndEditBaseController.GetReferenceField('test__c'); |
| | | NewAndEditBaseController.GetReferenceField('Id'); |
| | | NewAndEditBaseController.GetReferenceField('t'); |
| | | |
| | | System.debug('tenTest' + tenTest); |
| | | String baseJson = JSON.serialize(tenTest); |
| | | System.debug('baseJson' + baseJson); |
| | | NewAndEditBaseController.save(tenTest, baseJson, 'avgwshDFcxAS', false); |
| | | Test.stopTest(); |
| | | } |
| | | |
| | | static testMethod void testMethod2() { |
| | | |
| | | List<String> LookUpOverrideFields = new List<String>(); |
| | | TestDataUtility.CreatePIPolicyConfiguration(); |
| | | Test.setMock(HttpCalloutMock.class, new TestDataUtility.CreateMetaDataUtilityHttpMock()); |
| | | //use a random sobj |
| | | Contact aseTest = TestDataUtility.CreateContacts(1)[0]; |
| | | // aseTest.activityStartTime__c = null; |
| | | upsert aseTest; |
| | | |
| | | Test.startTest(); |
| | | //ApexPages.StandardController con = new ApexPages.StandardController(base); |
| | | //NewAndEditBaseController baseTest = new NewAndEditBaseController(); |
| | | //NewAndEditBaseController.Init(base); |
| | | ApexPages.StandardController con = new ApexPages.StandardController(aseTest); |
| | | NewAndEditContactController a = new NewAndEditContactController(con); |
| | | // LookUpOverrideFields.add('ReporterASE__c'); |
| | | a.Init(aseTest); |
| | | String AWSjson = a.AWSToSobjectMapJson; |
| | | aseTest.put('AWS_Data_Id__c','1569989'); |
| | | String baseJson = JSON.serialize(aseTest); |
| | | System.debug('baseJson' + baseJson); |
| | | |
| | | NewAndEditBaseController.save(aseTest, baseJson, 'avgwshDFcxAS', true); |
| | | Test.stopTest(); |
| | | } |
| | | |
| | | static testMethod void testMethod3() { |
| | | |
| | | List<String> LookUpOverrideFields = new List<String>(); |
| | | TestDataUtility.CreatePIPolicyConfiguration(); |
| | | Test.setMock(HttpCalloutMock.class, new TestDataUtility.CreateMetaDataUtilityHttpMock()); |
| | | //use a random sobj |
| | | Contact contact = TestDataUtility.CreateContacts(1)[0]; |
| | | Order aseTest = new Order(); |
| | | // aseTest.CustomerTel__c = '123123'; |
| | | // aseTest.ReporterASE__c = contact.Id; |
| | | // aseTest.activityStartTime__c = null; |
| | | |
| | | Test.startTest(); |
| | | //ApexPages.StandardController con = new ApexPages.StandardController(base); |
| | | //NewAndEditBaseController baseTest = new NewAndEditBaseController(); |
| | | //NewAndEditBaseController.Init(base); |
| | | ApexPages.StandardController con = new ApexPages.StandardController(aseTest); |
| | | NewAndEditOrderController a = new NewAndEditOrderController(con); |
| | | // LookUpOverrideFields.add('ReporterASE__c'); |
| | | a.Init(aseTest); |
| | | String AWSjson = a.AWSToSobjectMapJson; |
| | | aseTest.put('AWS_Data_Id__c','1569989'); |
| | | String baseJson = JSON.serialize(aseTest); |
| | | System.debug('baseJson' + baseJson); |
| | | NewAndEditBaseController.save(aseTest, baseJson, 'avgwshDFcxAS', true); |
| | | Test.stopTest(); |
| | | } |
| | | |
| | | static testMethod void testMethod4() { |
| | | |
| | | List<String> LookUpOverrideFields = new List<String>(); |
| | | TestDataUtility.CreatePIPolicyConfiguration(); |
| | | Test.setMock(HttpCalloutMock.class, new TestDataUtility.CreateMetaDataUtilityHttpMock()); |
| | | //use a random sobj |
| | | Contact aseTest = TestDataUtility.CreateContacts(1)[0]; |
| | | // aseTest.activityStartTime__c = null; |
| | | upsert aseTest; |
| | | |
| | | Test.startTest(); |
| | | //ApexPages.StandardController con = new ApexPages.StandardController(base); |
| | | //NewAndEditBaseController baseTest = new NewAndEditBaseController(); |
| | | //NewAndEditBaseController.Init(base); |
| | | ApexPages.StandardController con = new ApexPages.StandardController(aseTest); |
| | | NewAndEditContactController a = new NewAndEditContactController(con); |
| | | // LookUpOverrideFields.add('ReporterASE__c'); |
| | | a.Init(aseTest); |
| | | String AWSjson = a.AWSToSobjectMapJson; |
| | | aseTest.put('AWS_Data_Id__c','1569989'); |
| | | String baseJson = JSON.serialize(aseTest); |
| | | System.debug('baseJson' + baseJson); |
| | | |
| | | NewAndEditBaseController.save(aseTest, baseJson, 'avgwshDFcxAS', null); |
| | | NewAndEditBaseController.IsCurrentUserAdministrator(); |
| | | Map<string,string> mso = new Map<String,String>(); |
| | | mso.put('id','0000000000000000'); |
| | | mso.put('id','0000000000000000'); |
| | | mso.put('CF00N10000008ps61_lkid','test'); |
| | | mso.put('00N10000003Msk0','test'); |
| | | mso.put('00N2800000JCGQV','Test'); |
| | | mso.put('00N0K00000LMEJM','1'); |
| | | mso.put('Birthdate','2022-02-02'); |
| | | String myString = 'Contact'; |
| | | SObjectType sObjType = ((SObject) Type.forName(myString).newInstance()) |
| | | .getSObjectType(); |
| | | NewAndEditBaseController.AssignValueFromUrl(mso,sObjType.newSObject()); |
| | | Test.stopTest(); |
| | | } |
| | | |
| | | public static string mock_str = '{"size":3,"totalSize":3,"done":true,"queryLocator":null,"entityTypeName":"ProfileLayout","records":[{"attributes":{"type":"ProfileLayout","url":"/services/data/v41.0/tooling/sobjects/ProfileLayout/01G2800000wKyt5EAC"},"Layout":{"attributes":{"type":"Layout","url":"/services/data/v41.0/tooling/sobjects/Layout/00h28000003OBy1AAG"},"Name":"Contact layout for dealer Approval","TableEnumOrId":"Contact"},"ProfileId":"00e28000000wAuNAAU","Profile":{"attributes":{"type":"Profile","url":"/services/data/v41.0/tooling/sobjects/Profile/00e28000000wAuNAAU"},"Name":"System Administrator"},"RecordTypeId":"01228000000PvwMAAS"},{"attributes":{"type":"ProfileLayout","url":"/services/data/v41.0/tooling/sobjects/ProfileLayout/01G2800000wKysdEAC"},"Layout":{"attributes":{"type":"Layout","url":"/services/data/v41.0/tooling/sobjects/Layout/00h28000001ReZNAA0"},"Name":"Contact Layout","TableEnumOrId":"Contact"},"ProfileId":"00e28000000wAuNAAU","Profile":{"attributes":{"type":"Profile","url":"/services/data/v41.0/tooling/sobjects/Profile/00e28000000wAuNAAU"},"Name":"System Administrator"},"RecordTypeId":"01228000000PvwLAAS"},{"attributes":{"type":"ProfileLayout","url":"/services/data/v41.0/tooling/sobjects/ProfileLayout/01G2800000HvfFYEAZ"},"Layout":{"attributes":{"type":"Layout","url":"/services/data/v41.0/tooling/sobjects/Layout/00h28000001ReZNAA0"},"Name":"Contact Layout","TableEnumOrId":"Contact"},"ProfileId":"00e28000000wAuNAAU","Profile":{"attributes":{"type":"Profile","url":"/services/data/v41.0/tooling/sobjects/Profile/00e28000000wAuNAAU"},"Name":"System Administrator"},"RecordTypeId":null}]}'; |
| | | } |