From e6068da47c1bef5517c9e5fdc8c726766867ad4e Mon Sep 17 00:00:00 2001 From: buli <137736985@qq.com> Date: 星期五, 14 七月 2023 15:10:02 +0800 Subject: [PATCH] Merge branch 'master' into LEXUpgrade2023-Deloitte --- force-app/main/default/classes/DealerInquiryModifyStateControllerTest.cls | 89 +++++++++++++++++++++++--------------------- 1 files changed, 47 insertions(+), 42 deletions(-) diff --git a/force-app/main/default/classes/DealerInquiryModifyStateControllerTest.cls b/force-app/main/default/classes/DealerInquiryModifyStateControllerTest.cls index 9832e45..392ef3a 100644 --- a/force-app/main/default/classes/DealerInquiryModifyStateControllerTest.cls +++ b/force-app/main/default/classes/DealerInquiryModifyStateControllerTest.cls @@ -1,51 +1,56 @@ @isTest private class DealerInquiryModifyStateControllerTest { - @TestSetup static void init() { - List<RecordType> rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '鐥呴櫌']; + @TestSetup + static void init() { + List<RecordType> rectCo = [SELECT Id FROM RecordType WHERE IsActive = TRUE AND SobjectType = 'Account' AND Name = '鐥呴櫌']; if (rectCo.size() == 0) { return; } - List<RecordType> rectSct = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '鎴︾暐绉戝鍒嗛 鍛煎惛绉�']; + List<RecordType> rectSct = [ + SELECT Id + FROM RecordType + WHERE IsActive = TRUE AND SobjectType = 'Account' AND Name = '鎴︾暐绉戝鍒嗛 鍛煎惛绉�' + ]; if (rectSct.size() == 0) { return; } - List<RecordType> rectDpt = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '瑷虹檪绉� 娑堝寲绉�']; + List<RecordType> rectDpt = [SELECT Id FROM RecordType WHERE IsActive = TRUE AND SobjectType = 'Account' AND Name = '瑷虹檪绉� 娑堝寲绉�']; if (rectDpt.size() == 0) { return; } // 銉嗐偣銉堛儑銉笺偪 - + Account company = new Account(); company.RecordTypeId = rectCo[0].Id; - company.Name = 'NFM007TestCompany'; + company.Name = 'NFM007TestCompany'; insert company; Account section = new Account(); section.RecordTypeId = rectSct[0].Id; - section.Name = '*'; + section.Name = '*'; section.Department_Class_Label__c = '娑堝寲绉�'; - section.ParentId = company.Id; + section.ParentId = company.Id; section.Hospital_Department_Class__c = company.Id; insert section; // Test.startTest(); Account depart = new Account(); depart.RecordTypeId = rectDpt[0].Id; - depart.Name = '*'; - depart.Department_Name__c = 'NFM007TestDepart'; - depart.ParentId = section.Id; + depart.Name = '*'; + depart.Department_Name__c = 'NFM007TestDepart'; + depart.ParentId = section.Id; depart.Department_Class__c = section.Id; - depart.Hospital__c = company.Id; + depart.Hospital__c = company.Id; insert depart; Opportunity opp = new Opportunity(); - opp.AccountId = depart.Id; + opp.AccountId = depart.Id; opp.Department_Class__c = section.Id; - opp.Hospital__c = company.Id; - opp.SAP_Send_OK__c = false; - opp.Name = 'GZ-SP-NFM007_1'; - opp.Trade__c = '鍐呰部'; - opp.StageName = '寮曞悎'; - opp.CloseDate = date.newinstance(2022, 11, 30); + opp.Hospital__c = company.Id; + opp.SAP_Send_OK__c = false; + opp.Name = 'GZ-SP-NFM007_1'; + opp.Trade__c = '鍐呰部'; + opp.StageName = '寮曞悎'; + opp.CloseDate = Date.today(); opp.Stock_apply_status__c = '鐢宠涓�'; insert opp; Test.startTest(); @@ -60,17 +65,16 @@ contact1.LastName = 'test1鍖婚櫌'; contact1.Agency_User__c = true; insert contact1; - List<Contact> contactlist = [select Id, FirstName - from Contact - ]; + List<Contact> contactlist = [ + SELECT Id, FirstName + FROM Contact + ]; System.assertEquals('璨换鑰�', contactlist[0].FirstName); - - // User user = new User(); - Profile p = [select Id from Profile where Name = '901_缁忛攢鍟嗘椿鍔ㄧ郴缁�']; + Profile p = [SELECT Id FROM Profile WHERE Name = '901_缁忛攢鍟嗘椿鍔ㄧ郴缁�']; user.ProfileId = p.Id; user.ContactId = contact1.Id; user.FirstName = '銉︺兗銈躲兗'; @@ -84,9 +88,10 @@ user.Alias = '銉嗐儲'; user.CommunityNickname = '銉嗐偣銉堛儲銉笺偠銉�'; user.SalesManager__c = UserInfo.getUserId(); - - insert user; - List<user> users = [select Id, Name, LastName, FirstName from User where LastName = '銉嗐偣銉�']; + System.runAs(new User(Id = UserInfo.getUserId())) { + insert user; + } + List<user> users = [SELECT Id, Name, LastName, FirstName FROM User WHERE LastName = '銉嗐偣銉�']; // Agency_Hospital_Link__c agency_hospital_link = new Agency_Hospital_Link__c(); @@ -99,9 +104,14 @@ // //System.assertEquals('銉嗐偣銉�',users[0].LastName); - System.assertEquals('銉︺兗銈躲兗', users[0].FirstName ); + System.assertEquals('銉︺兗銈躲兗', users[0].FirstName); - Id rtId = [select Id, DeveloperName from RecordType where IsActive = true and SobjectType = 'Agency_Opportunity__c' and DeveloperName = 'Opportunity'].Id; + Id rtId = [ + SELECT Id, DeveloperName + FROM RecordType + WHERE IsActive = TRUE AND SobjectType = 'Agency_Opportunity__c' AND DeveloperName = 'Opportunity' + ] + .Id; // Schema.SobjectType.Agency_Opportunity__c.getRecordTypeInfosByName().get('璇环').getRecordTypeId(); Agency_opportunity__c agency_opportunity = new Agency_opportunity__c(); agency_opportunity.RecordTypeId = rtId; @@ -112,25 +122,22 @@ agency_opportunity.StageName__c = '杩樻病鐢宠棰勭畻'; agency_opportunity.OwnerId = user.Id; agency_opportunity.Change_To_Opportunity_T__c = '::CF-HQ290I'; - agency_opportunity.Sales_Manager__c =UserInfo.getUserId(); + agency_opportunity.Sales_Manager__c = UserInfo.getUserId(); insert agency_opportunity; Test.stopTest(); - } static testMethod void myUnitTest_SortKey() { - Test.startTest(); + Test.startTest(); Test.setMock(WebServiceMock.class, new NFMTest_Mock()); Test.stopTest(); PageReference page = new PageReference('/apex/DealerInquiryModifyState'); System.Test.setCurrentPage(page); - // 鍒濆鍖栨祴璇� DealerInquiryModifyStateController controller = new DealerInquiryModifyStateController(); - - + controller.init(); //System.assertEquals(1, controller.oppRecords.size());楠岃瘉棰勬湡鍊煎拰缁撴灉鍊兼纭�� // 鎺掑簭娴嬭瘯 @@ -145,7 +152,7 @@ // Test.stopTest(); } static testMethod void myUnitTest_AccSearchAndAoosearch() { - Test.startTest(); + Test.startTest(); Test.setMock(WebServiceMock.class, new NFMTest_Mock()); Test.stopTest(); PageReference page = new PageReference('/apex/DealerInquiryModifyState'); @@ -153,7 +160,7 @@ DealerInquiryModifyStateController controller = new DealerInquiryModifyStateController(); // 鍒濆鍖栨祴璇� // Test.startTest(); - + controller.init(); //鏂囨湰杈撳叆妗嗘绱� //1:缁忛攢鍟嗗尰闄� @@ -342,8 +349,7 @@ controller.chick(); controller.tmpBO.MaxActivityDate__c = date.valueOf('2018-02-09'); controller.chick(); - Test.stopTest(); - + Test.stopTest(); } static testMethod void myUnitTestTime02() { PageReference page = new PageReference('/apex/DealerInquiryModifyState'); @@ -378,7 +384,6 @@ controller.tmpBO.MaxActivityDate__c = date.valueOf('2018-02-09'); controller.chick(); Test.stopTest(); - } static testMethod void myUnitTestTimeSave() { PageReference page = new PageReference('/apex/DealerInquiryModifyState'); @@ -417,4 +422,4 @@ controller.init(); Test.stopTest(); } -} \ No newline at end of file +} -- Gitblit v1.9.1