/* * Author: Guo, Aline Yaying * Created Date: 03/22/2022 * Purpose: Test Class * History: * 03/22/2022 - Guo, Aline Yaying - Initial Code. * * */ @isTest private class NewAndEditContactControllerTest { @TestSetup static void makeData(){ TestDataUtility.CreatePIPolicyConfiguration(); } static testMethod void testMethod1() { Test.setMock(HttpCalloutMock.class, new TestDataUtility.CreateMetaDataUtilityHttpMock()); Contact contactTest = TestDataUtility.CreateContacts(1)[0]; Test.startTest(); ApexPages.StandardController con = new ApexPages.StandardController(contactTest); NewAndEditContactController cont = new NewAndEditContactController(con); String contactJson = '{"ContactType__c":"*****","Salutation":"","LastName":"***","Type__c":"","UnifiedI_Contact_ID__c":"","Doctor_Division1__c":"","ServicePlatformCode__c":"","Event_status__c":"","Isactive__c":"有效","Speciality__c":"","Decision_Maker_Type__c":"","Favorite_Equipment__c":"","HCP__c":"","OLY_follow__c":"","STMS_participant_number__c":"","Tutor_Type__c":"","Account_Visitor_Search__c":"000000000000000","Import_Data_Type__c":"","Supplement__c":"","HcpNo__c":"","Employee_No_manual__c":"","UpdateStatus__c":"","Platform_disabled_representation__c":false,"HCPLevel__c":"","RegSource__c":"","Work_Location_HR__c":"","Working_Seniority__c":"","trigger606Flag__c":false,"Phone":"***********","AssistantName":"","MobilePhone":"","AssistantPhone":"","UniqueNumber__c":"","Birthdate":"2022/03/29","Email":"","Action_plan__c":"","Follow_up_situation__c":"","Operation_Information__c":"","New_Maneuver_Needs__c":"","Ready_To_See_Date__c":"周一上午","Outpatient_Date__c":"","Inspection_Date__c":"","Operation_Date__c":"","Outside_Day__c":"","AccountId":"0011m00000Xiz4Q","OwnerId":"0051m0000030e0QAAQ","Strategic_dept_Class__c":"000000000000000","Salesdepartment_Text__c":"","dept__c":"","Dept_text__c":"","Contact_address__c":"**********","Number_of_participant_for_FOne_PJ__c":"","Number_of_participant_for_TeamPJ__c":"","Number_of_participant_for_TTC__c":"","Society1__c":"","Society3_del__c":"","Society2_del__c":"","Target_visit_for_VIP__c":"","Visit_Count1__c":"","Visit_Count7__c":"","Visit_Count2__c":"","Visit_Count8__c":"","Visit_Count3__c":"","Visit_Count9__c":"","Visit_Count4__c":"","Visit_Count10__c":"","Visit_Count5__c":"","Visit_Count11__c":"","Visit_Count6__c":"","Visit_Count12__c":"","NameOBPM__c":"","MobileOBPM__c":"","stateOBPM__c":"","OBPMDepartment__c":"","Learn_serve1__c":"","CityOBPM__c":"","Learn_serve2__c":"","Learn_name1__c":"","Learn_serve3__c":"","Learn_name2__c":"","TechnicalTitleOBPM__c":"","Learn_name3__c":"","ProfessionalField__c":"","SpecialityOBPM__c":"","WorkingSeniorityOBPM__c":"","Campaign__c":"000000000000000","Follow_state__c":"","JobStatusUpdateDate__c":"","Follow_stateUpdate__c":"2022/03/29","OnJobState__c":"","ProcessingWorkWithoutNumber__c":"","ProcessingWorkStatus__c":"未开展","IsEndoscope__c":"","IsEndoscopeUpdate__c":"","MedicalStaff_Full_name__c":"***","RecordTypeId":"01210000000QfWd","AmountofActivityHistory__c":"","LastName_Encrypted__c":"dcce196c4cfc273a83777852ddd486ab","ContactType_Encrypted__c":"b7246e7dd9d6b63025ec55e8e35b5a99","MedicalStaff_Full_name_Encrypted__c":"dcce196c4cfc273a83777852ddd486ab","Email_Encrypted__c":"","UniqueNumber_Encrypted__c":"","Doctor_Division1_Encrypted__c":"","Type_Encrypted__c":"","Contact_address_Encrypted__c":"2df1bc4bf3800c5e05e3d9f394c3446567d1f05482d2295650b7b50e9e4aa97a92338985c9693f576e1e6df667aaee46","Job_Category_picklist_Encrypted__c":null,"OLY_Assistant_Type_Encrypted__c":null,"Title_Encrypted__c":null,"MobilePhone_Encrypted__c":"","Phone_Encrypted__c":"e060533a8343becc9284a223c5a52d67","Job_Category_picklist__c":null,"OLY_Assistant_Type__c":null,"Title":null,"AWS_Data_Id__c":"958371969131085825"}'; NewAndEditContactController.saveContact(contactJson,'avgwshDFcxAS',False); Test.stopTest(); } // static testMethod void testMethod2() { // Contact contactTest = TestDataUtility.CreateContacts(1)[0]; // String recordTypeId = Schema.SObjectType.Contact.getRecordTypeInfosByDeveloperName().get('Doctor').getRecordTypeId(); // String url = ApexPages.currentPage().getParameters().put('RecordType',recordTypeId); // url = ApexPages.currentPage().getParameters().put('accid','0010l00001PPOy7AAH'); // Test.startTest(); // ApexPages.StandardController con = new ApexPages.StandardController(contactTest); // NewAndEditContactController cont = new NewAndEditContactController(con); // cont.RedirectStandardPage(); // Test.stopTest(); // } static testMethod void testMethod3() { Test.setMock(HttpCalloutMock.class, new TestDataUtility.CreateMetaDataUtilityHttpMock()); // Contact contactTest = TestDataUtility.CreateContacts(1)[0]; Account acc = TestDataUtility.CreateAccounts(1)[0]; //Account acc1 = [SELECT Id,Name FROM Account WHERE RecordType.DeveloperName = 'Office' OR RecordType.DeveloperName = 'AgencyContact' OR RecordType.DeveloperName = 'Agency' Limit 1]; String accrecordTypeId = Schema.SObjectType.Account.getRecordTypeInfosByDeveloperName().get('Agency').getRecordTypeId(); Account acc1 = new Account(Name = 'testacc1',RecordTypeId = accrecordTypeId); insert acc1; String recordTypeId = Schema.SObjectType.Contact.getRecordTypeInfosByDeveloperName().get('Doctor').getRecordTypeId(); String url = ApexPages.currentPage().getParameters().put('RecordType',recordTypeId); url = ApexPages.currentPage().getParameters().put('accid',acc1.Id); url = ApexPages.currentPage().getParameters().put('con4_lkid',acc1.Id); Test.startTest(); ApexPages.StandardController con = new ApexPages.StandardController(new Contact()); NewAndEditContactController cont = new NewAndEditContactController(con); // cont.rtTypeId cont.PageLoad(); Test.stopTest(); } }