From 81b0892b8c6aa064a9e8dbca09a8f7f1eb6de40e Mon Sep 17 00:00:00 2001 From: 高章伟 <gaozhangwei@prec-tech.com> Date: 星期四, 24 二月 2022 19:12:29 +0800 Subject: [PATCH] 1.15---2.24 变更代码 --- force-app/main/default/classes/ControllerUtilTest.cls | 801 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 797 insertions(+), 4 deletions(-) diff --git a/force-app/main/default/classes/ControllerUtilTest.cls b/force-app/main/default/classes/ControllerUtilTest.cls index 24e12c5..784ae65 100644 --- a/force-app/main/default/classes/ControllerUtilTest.cls +++ b/force-app/main/default/classes/ControllerUtilTest.cls @@ -1,8 +1,801 @@ +/** + * This class contains unit tests for validating the behavior of Apex classes + * and triggers. + * + * Unit tests are class methods that verify whether a particular piece + * of code is working properly. Unit test methods take no arguments, + * commit no data to the database, and are flagged with the testMethod + * keyword in the method definition. + * + * All test methods in an organization are executed whenever Apex code is deployed + * to a production organization to confirm correctness, ensure code + * coverage, and prevent regressions. All Apex classes are + * required to have at least 75% code coverage in order to be deployed + * to a production organization. In addition, all triggers must have some code coverage. + * + * The @isTest class annotation indicates this class only contains test + * methods. Classes defined with the @isTest annotation do not count against + * the organization size limit for all Apex scripts. + * + * See the Apex Language Reference for more information about Testing and Code Coverage. + */ @isTest private class ControllerUtilTest { - - @isTest static void test_ControllerUtil() { - ControllerUtil con = new ControllerUtil(); - } + //@isTest(SeeAllData=true) + //static void testOlympus_Dummy_Asset() { + // // Olympus_Dummy_Asset 瀛樺湪銇嬨儊銈с儍銈� + // Asset internalAst = [Select Id from Asset where Id = :System.Label.Olympus_Dummy_Asset]; + // // 銉囥兗銈裤亴銇傘倢銇癘K; + //} + + //@isTest(SeeAllData=true) + //static void testOlympus_AccountID_Internal_staff() { + // // Olympus_AccountID_Internal_staff 瀛樺湪銇嬨儊銈с儍銈� + // Account internalAcc = [Select Id from Account where Id = :System.Label.Olympus_AccountID_Internal_staff]; + // // 銉囥兗銈裤亴銇傘倢銇癘K; + //} + private static User getUser() { + String timenow = Datetime.now().format('yyyyMMddHHmmss'); + User user1 = new User(Test_staff__c = true, LastName = 'TestMao', FirstName = 'TestMaoF', + Alias = 'hp', CommunityNickname = 'TestMao', Email = 'Test@sunbridge.com', + Username = 'Test' + timenow + '@sunbridge.com', IsActive = true, EmailEncodingKey = 'ISO-2022-JP', + TimeZoneSidKey = 'Asia/Tokyo', LocaleSidKey = 'ja_JP', LanguageLocaleKey = 'ja', + ProfileId = System.Label.ProfileId_SystemAdmin, + Dept__c = '鍖荤枟鍗庡寳钀ヤ笟鏈儴', Job_Category__c = '閿�鍞湇鍔�', Province__c = '鍖椾含'); + + List<Profile> p = [Select Id From Profile Where Name = '2S1_閿�鍞尰闄㈡媴褰�']; + System.assertEquals(p.size(), 1); + + // User user2 = new User(Test_staff__c = true, LastName = 'TestMao1', FirstName = 'TestMaoF1', + // Alias = 'hp', CommunityNickname = 'TestMao1', Email = 'Test1@sunbridge.com', + // Username = 'Test1' + timenow + '@sunbridge.com', IsActive = true, EmailEncodingKey = 'ISO-2022-JP', + // TimeZoneSidKey = 'Asia/Tokyo', LocaleSidKey = 'ja_JP', LanguageLocaleKey = 'ja', + // ProfileId = p[0].Id, + // Dept__c = '鍖荤枟鍗庡寳钀ヤ笟鏈儴', Province__c = '鍖椾含'); + // List<User> us = new List<User>(); + // us.add(user1); + // us.add(user2); + System.runAs(new User(Id = Userinfo.getUserId())) { + insert user1; + } + return user1; + } + + private static Opportunity buildOppInstance( String inputTrade, String CurrencyIsoCode) { + Opportunity target = new Opportunity( Name='aiueo', StageName='contact', CloseDate=Date.today()); + target.Trade__c = inputTrade; + target.CurrencyIsoCode = CurrencyIsoCode; + return target; + } + + static testMethod void ControllerUtil() { + new ControllerUtil(); // 銈ㄣ儵銉笺仹銇亜銇撱仺銈掔⒑瑾� + } + static testMethod void testUpdOppList() { + List<Opportunity> opps = new List<Opportunity>(); + opps.add( buildOppInstance( '鍐呰部', 'CNY')); + insert opps; + Opportunity opportunity = [select id, trade__c from opportunity where id =:opps[0].id]; +System.assertEquals( '鍐呰部', opportunity.trade__c); +// opps[0].trade__c = '澶栬部'; +// ControllerUtil.updOppList(opps); +// opportunity = [select id, trade__c from opportunity where id = :opps[0].id]; +//System.assertEquals( '澶栬部', opportunity.trade__c); + } + + static testMethod void testGetAccessToken() { + // asset銇勩倝銇亜 + ControllerUtil.getAccessToken(); + } + + static testMethod void testOlympusCoJpCommonMessage() { + OlympusCoJpCommonMessage.Response response = new OlympusCoJpCommonMessage.Response(); + OlympusCoJpCommonMessage.LOG_element log = new OlympusCoJpCommonMessage.LOG_element(); + } + + static testMethod void addBatchIfLogTest() { + BatchIF_Log__c log = null; + ControllerUtil.addBatchIfLog('type0', 0, 'log0'); + log = [Select Type__c, Is_Error__c, log__c, ErrorLog__c from BatchIF_Log__c where Type__c = 'type0']; + System.assertEquals(0, log.Is_Error__c); + System.assertEquals('log0', log.log__c); + System.assertEquals(null, log.ErrorLog__c); + + ControllerUtil.addBatchIfLog('type1', 1, 'log1'); + log = [Select Type__c, Is_Error__c, log__c, ErrorLog__c, Account__c, Log2__c from BatchIF_Log__c where Type__c = 'type1']; + System.assertEquals(1, log.Is_Error__c); + System.assertEquals(null, log.log__c); + System.assertEquals('log1', log.ErrorLog__c); + + ControllerUtil.addBatchIfLogForCnt(log.Type__c, log.Log__c, log.Log2__c, log.Account__c); + } + + static testMethod void upsEventCTest() { + Daily_Report__c dr = new Daily_Report__c(); + dr.Reported_Date__c = Date.today(); + dr.Reporter__c = Userinfo.getUserId(); + insert dr; + Event__c ec = new Event__c(Daily_Report__c=dr.Id, StartDateTime__c=System.now(), EndDateTime__c=System.now(), Subject__c='Subject', Location__c='Location', ActivityDate__c=Date.today()); + List<Event__c> acts = new List<Event__c>(); + acts.add(ec); + ControllerUtil.upsEventC(acts); + + acts = [select Id from Event__c]; + System.assertEquals(acts.size(), 1); + + List<Daily_Report__c> deList = [select Id from Daily_Report__c]; + List<Id> ids = new List<Id>(); + ids.add(deList[0].Id); + + ControllerUtil.reportMapSelectByIds(ids); + + ControllerUtil.eventDel(acts[0].Id); + acts = [select Id from Event__c]; + System.assertEquals(acts.size(), 0); + } + + static testMethod void getOlympusWorkDayCountTest() { + OlympusCalendar__c oc1 = new OlympusCalendar__c(Date__c = Date.today().addDays(1), ChangeToHoliday__c=false, ChangeToWorkday__c=true); + OlympusCalendar__c oc2 = new OlympusCalendar__c(Date__c = Date.today().addDays(2), ChangeToHoliday__c=false, ChangeToWorkday__c=true); + OlympusCalendar__c oc3 = new OlympusCalendar__c(Date__c = Date.today().addDays(3), ChangeToHoliday__c=false, ChangeToWorkday__c=true); + OlympusCalendar__c oc4 = new OlympusCalendar__c(Date__c = Date.today().addDays(4), ChangeToHoliday__c=false, ChangeToWorkday__c=true); + OlympusCalendar__c oc5 = new OlympusCalendar__c(Date__c = Date.today().addDays(5), ChangeToHoliday__c=false, ChangeToWorkday__c=true); + OlympusCalendar__c oc6 = new OlympusCalendar__c(Date__c = Date.today().addDays(6), ChangeToHoliday__c=true, ChangeToWorkday__c=false); + OlympusCalendar__c oc7 = new OlympusCalendar__c(Date__c = Date.today().addDays(7), ChangeToHoliday__c=true, ChangeToWorkday__c=false); + OlympusCalendar__c oc8 = new OlympusCalendar__c(Date__c = Date.today().addDays(8), ChangeToHoliday__c=false, ChangeToWorkday__c=true); + OlympusCalendar__c oc9 = new OlympusCalendar__c(Date__c = Date.today().addDays(9), ChangeToHoliday__c=false, ChangeToWorkday__c=true); + OlympusCalendar__c oc10 = new OlympusCalendar__c(Date__c = Date.today().addDays(10), ChangeToHoliday__c=false, ChangeToWorkday__c=true); + OlympusCalendar__c oc11 = new OlympusCalendar__c(Date__c = Date.today().addDays(11), ChangeToHoliday__c=false, ChangeToWorkday__c=true); + OlympusCalendar__c oc12 = new OlympusCalendar__c(Date__c = Date.today().addDays(12), ChangeToHoliday__c=false, ChangeToWorkday__c=true); + + insert new OlympusCalendar__c[] {oc1,oc2,oc3,oc4,oc5,oc6,oc7,oc8,oc9,oc10,oc11,oc12}; + Integer workDayCount = ControllerUtil.getOlympusWorkDayCount(Date.today(), Date.today().addDays(2)); + System.assertEquals(workDayCount, 2); + } + + static testMethod void test_method_One() { + + Oly_TriggerHandler.bypass('PowerBIBaseHandler'); + Oly_TriggerHandler.bypass('AgencyOppUpdHandler'); + Oly_TriggerHandler.bypass('UpdateContractAimAmountHandler'); + Oly_TriggerHandler.bypass('NFM701ControllerHandler'); + StaticParameter.EscapeNFM001AgencyContractTrigger = true; + ControllerUtil.EscapeNFM001Trigger = true; + + Profile pf = [select Id from Profile where Id =:system.label.ProfileId_SystemAdmin]; + List<String> nameList = new List<String>(); + nameList.add('HP'); + nameList.add('Department_Class_ENT'); + nameList.add('Department_ENT'); + nameList.add('Doctor'); + List<RecordType> rtList = [select id,DeveloperName from RecordType where IsActive = true and SobjectType = 'Account' and DeveloperName in :nameList]; + RecordType rtHP; + RecordType rtDepClass; + RecordType rtDep; + for (RecordType rt : rtList) + { + if (rt.DeveloperName == 'HP') { + rtHP = rt; + } else if (rt.DeveloperName == 'Department_Class_ENT') { + rtDepClass = rt; + } else if (rt.DeveloperName == 'Department_ENT') { + rtDep = rt; + } + } + //RecordType rtHP = [select id from RecordType where IsActive = true and SobjectType = 'Account' and DeveloperName =:'HP']; + //RecordType rtDepClass = [select id from RecordType where IsActive = true and SobjectType = 'Account' and DeveloperName =:'Department_Class_ENT']; // 鑰抽蓟鍠夌 + //RecordType rtDep = [select id from RecordType where IsActive = true and SobjectType = 'Account' and DeveloperName =:'Department_ENT']; + RecordType rtDoc = [select id from RecordType where IsActive = true and SobjectType = 'Contact' and DeveloperName =:'Doctor']; + + Address_Level__c al = new Address_Level__c(); + al.Name = '鏉变含'; + al.Level1_Code__c = 'CN-99'; + al.Level1_Sys_No__c = '999999'; + insert al; + Address_Level2__c al2 = new Address_Level2__c(); + al2.Level1_Code__c = 'CN-99'; + al2.Level1_Sys_No__c = '999999'; + al2.Level1_Name__c = '鏉变含'; + al2.Name = '娓嬭胺鍖�'; + al2.Level2_Code__c = 'CN-9999'; + al2.Level2_Sys_No__c = '9999999'; + al2.Address_Level__c = al.id; + insert al2; + // 鐥呴櫌銈掍綔銈� + Account hospital = new Account(); + + String rid = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Account' and DeveloperName = 'HP'].id; + hospital.Name = 'test hospital'; + hospital.recordtypeId = rid; + hospital.Is_Active__c = '鏈夊姽'; + insert hospital; + + Account accHP = new Account(); + accHP.Name = '鐥呴櫌1'; + accHP.Grade__c = '涓�鑸�'; + accHP.OCM_Category__c = '涓�鑸�'; + accHP.Attribute_Type__c = '淇濋櫤鐪�'; + accHP.Speciality_Type__c = '绶忓悎鐥呴櫌'; + accHP.Is_Active__c = '鏈夊姽'; + accHP.State_Master__c = al.id; + accHP.City_Master__c = al2.id; + accHP.RecordTypeId = rid; + accHP.Valid_To__c = Date.today() + 2; + insert accHP; + // 鎴︾暐绉戝銈掑緱銈� + Account[] strategicDep = [SELECT ID, Name FROM Account WHERE parentId = :hospital.Id AND recordType.DeveloperName = 'Department_Class_OTH']; + // 瑷虹檪绉戙倰浣溿倠 + Account dep = new Account(); + dep.recordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Account' and DeveloperName = 'Department_OTH'].id; + dep.Name = 'test dep'; + dep.AgentCode_Ext__c = '9999998'; + dep.ParentId = strategicDep[0].Id; + dep.Department_Class__c = strategicDep[0].Id; + dep.Hospital__c = hospital.Id; + insert dep; + Account accDepClass = new Account(); + accDepClass.Name = '鎴︾暐绉戝鍒嗛1'; + accDepClass.Department_Class_Label__c = '鑰抽蓟鍠夌'; + accDepClass.Hospital_Department_Class__c = accHP.id; + accDepClass.ParentId = accHP.id; + accDepClass.RecordTypeId = rtDepClass.id; + insert accDepClass; + Account accDep = new Account(); + accDep.Name = '瑷虹檪绉�1'; + accDep.Department_Class_Label__c = '瑷虹檪绉�1'; + accDep.Hospital__c = accHP.id; + accDep.ParentId = accDepClass.id; + accDep.Department_Class__c = accDepClass.id; + accDep.Department_Name__c = '瑷虹檪绉�1'; + accDep.CurrencyIsoCode = 'CNY'; + accDep.RecordTypeId = rtDep.id; + insert accDep; + List<Contact> conList = new List<Contact>(); + Contact con1 = new Contact(); + con1.Firstname='ZZ1'; + con1.LastName = '鍙栧紩鍏堣铂浠昏��1'; + con1.RecordTypeId = rtDoc.id; + con1.AccountId = accDep.Id; + conList.add(con1); + + insert conList; + RecordType Type = [select id from RecordType where DeveloperName='SI_Oppor']; + String TypeID = Type.Id; + Opportunity opp1 = new Opportunity(); + opp1.Name = '寮曞悎1'; + opp1.AccountId = accDep.Id; + opp1.Opportunity_Category__c = 'ENT'; + opp1.Trade__c = '澶栬部'; + opp1.StageName = '寮曞悎'; + opp1.CurrencyIsoCode = 'CNY'; + opp1.Close_Forecasted_Date__c = date.today().addMonths(1); + opp1.CloseDate = date.today().addMonths(1); + opp1.Competitor__c = 'B'; + opp1.Purchase_Type__c ='SI锛堟墜琛撳妗堜欢锛�'; + opp1.Sales_Root__c = 'OCM鐩存帴璨╁2'; + opp1.Hospital__c = accHP.id; + //opp1.Department_Class__c = accDepClass.id; + opp1.StageName = '寮曞悎'; + opp1.RecordTypeid = TypeID; + insert opp1; + + SI_Attachment__c newSac = new SI_Attachment__c(); + newSac.Opportunity_ID__c = opp1.id; + newSac.Type__c = '椤圭洰鏂规涔�'; + newSac.Name__c = '*'; + insert newSac; + + ISO_DemandOperAndDemonsController iso = new ISO_DemandOperAndDemonsController(); + iso.init(); + iso.OpporIdStr = opp1.id; + IS_Opportunity_Demand__c ISOhead = new IS_Opportunity_Demand__c(); + ISOhead.name='*'; + ISOhead.Opportunity_ID__c = opp1.id; + ISOhead.Public_Hospital_TF__c = true; + ISOhead.Preparation_Stage_TF__c = true; + ISOhead.Data_Check_TF__c = true; + ISOhead.Operating_Room_Plane_Graph_TF__c = true; + ISOhead.Demonstration_Area_Plane_Graph_TF__c = true; + insert ISOhead; + + Oly_TriggerHandler.clearAllBypasses(); + + Test.startTest(); + + ControllerUtil.setQuote(opp1.id); + ControllerUtil.getStatusForISO(opp1.id); + ControllerUtil.setAbortSI(ISOhead.Id, 'error'); + + List<String> opporList = new List<String>(); + opporList.add(opp1.id); + ControllerUtil.updateSIodcList(opporList); + + ControllerUtil.getOppSearchSQOL(accDepClass.Id, ''); + ControllerUtil.getStandardPricebook(); + ControllerUtil.getBatchIfLogForRequest('', '', Date.today()); + + BatchIF_Log__c log = new BatchIF_Log__c(); + log.Type__c = 'type0'; + log.Is_Error__c = 0; + log.log__c = 'log0'; + ControllerUtil.insertBatchIfLog(log); + + List<String> SIopportunityIds = new List<String>(); + SIopportunityIds.add(newSac.Id); + ControllerUtil.UpdateFileDateSet(SIopportunityIds); + ControllerUtil.refreshSIOpporStatus(opp1.Id); + ControllerUtil.ISO_Submit_Func(ISOhead.Id); + + Test.stopTest(); + } + + static testMethod void test_method_Two() { + + Oly_TriggerHandler.bypass('PowerBIBaseHandler'); + Oly_TriggerHandler.bypass('AgencyOppUpdHandler'); + Oly_TriggerHandler.bypass('UpdateContractAimAmountHandler'); + Oly_TriggerHandler.bypass('NFM701ControllerHandler'); + StaticParameter.EscapeNFM001AgencyContractTrigger = true; + ControllerUtil.EscapeNFM001Trigger = true; + + Profile pf = [select Id from Profile where Id =:system.label.ProfileId_SystemAdmin]; + List<String> nameList = new List<String>(); + nameList.add('HP'); + nameList.add('Department_Class_ENT'); + nameList.add('Department_ENT'); + nameList.add('Doctor'); + List<RecordType> rtList = [select id,DeveloperName from RecordType where IsActive = true and SobjectType = 'Account' and DeveloperName in :nameList]; + RecordType rtHP; + RecordType rtDepClass; + RecordType rtDep; + for (RecordType rt : rtList) + { + if (rt.DeveloperName == 'HP') { + rtHP = rt; + } else if (rt.DeveloperName == 'Department_Class_ENT') { + rtDepClass = rt; + } else if (rt.DeveloperName == 'Department_ENT') { + rtDep = rt; + } + } + //RecordType rtHP = [select id from RecordType where IsActive = true and SobjectType = 'Account' and DeveloperName =:'HP']; + //RecordType rtDepClass = [select id from RecordType where IsActive = true and SobjectType = 'Account' and DeveloperName =:'Department_Class_ENT']; // 鑰抽蓟鍠夌 + //RecordType rtDep = [select id from RecordType where IsActive = true and SobjectType = 'Account' and DeveloperName =:'Department_ENT']; + RecordType rtDoc = [select id from RecordType where IsActive = true and SobjectType = 'Contact' and DeveloperName =:'Doctor']; + + Address_Level__c al = new Address_Level__c(); + al.Name = '鏉变含'; + al.Level1_Code__c = 'CN-99'; + al.Level1_Sys_No__c = '999999'; + insert al; + Address_Level2__c al2 = new Address_Level2__c(); + al2.Level1_Code__c = 'CN-99'; + al2.Level1_Sys_No__c = '999999'; + al2.Level1_Name__c = '鏉变含'; + al2.Name = '娓嬭胺鍖�'; + al2.Level2_Code__c = 'CN-9999'; + al2.Level2_Sys_No__c = '9999999'; + al2.Address_Level__c = al.id; + insert al2; + // 鐥呴櫌銈掍綔銈� + Account hospital = new Account(); + + String rid = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Account' and DeveloperName = 'HP'].id; + hospital.Name = 'test hospital'; + hospital.recordtypeId = rid; + hospital.Is_Active__c = '鏈夊姽'; + insert hospital; + + Account accHP = new Account(); + accHP.Name = '鐥呴櫌1'; + accHP.Grade__c = '涓�鑸�'; + accHP.OCM_Category__c = '涓�鑸�'; + accHP.Attribute_Type__c = '淇濋櫤鐪�'; + accHP.Speciality_Type__c = '绶忓悎鐥呴櫌'; + accHP.Is_Active__c = '鏈夊姽'; + accHP.State_Master__c = al.id; + accHP.City_Master__c = al2.id; + accHP.RecordTypeId = rid; + accHP.Valid_To__c = Date.today() + 2; + insert accHP; + // 鎴︾暐绉戝銈掑緱銈� + Account[] strategicDep = [SELECT ID, Name FROM Account WHERE parentId = :hospital.Id AND recordType.DeveloperName = 'Department_Class_OTH']; + // 瑷虹檪绉戙倰浣溿倠 + Account dep = new Account(); + dep.recordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Account' and DeveloperName = 'Department_OTH'].id; + dep.Name = 'test dep'; + dep.AgentCode_Ext__c = '9999998'; + dep.ParentId = strategicDep[0].Id; + dep.Department_Class__c = strategicDep[0].Id; + dep.Hospital__c = hospital.Id; + insert dep; + Account accDepClass = new Account(); + accDepClass.Name = '鎴︾暐绉戝鍒嗛1'; + accDepClass.Department_Class_Label__c = '鑰抽蓟鍠夌'; + accDepClass.Hospital_Department_Class__c = accHP.id; + accDepClass.ParentId = accHP.id; + accDepClass.RecordTypeId = rtDepClass.id; + insert accDepClass; + Account accDep = new Account(); + accDep.Name = '瑷虹檪绉�1'; + accDep.Department_Class_Label__c = '瑷虹檪绉�1'; + accDep.Hospital__c = accHP.id; + accDep.ParentId = accDepClass.id; + accDep.Department_Class__c = accDepClass.id; + accDep.Department_Name__c = '瑷虹檪绉�1'; + accDep.CurrencyIsoCode = 'CNY'; + accDep.RecordTypeId = rtDep.id; + insert accDep; + List<Contact> conList = new List<Contact>(); + Contact con1 = new Contact(); + con1.Firstname='ZZ1'; + con1.LastName = '鍙栧紩鍏堣铂浠昏��1'; + con1.RecordTypeId = rtDoc.id; + con1.AccountId = accDep.Id; + conList.add(con1); + + insert conList; + RecordType Type = [select id from RecordType where DeveloperName='SI_Oppor']; + String TypeID = Type.Id; + Opportunity opp1 = new Opportunity(); + opp1.Name = '寮曞悎1'; + opp1.AccountId = accDep.Id; + opp1.Opportunity_Category__c = 'ENT'; + opp1.Trade__c = '澶栬部'; + opp1.StageName = '寮曞悎'; + opp1.CurrencyIsoCode = 'CNY'; + opp1.Close_Forecasted_Date__c = date.today().addMonths(1); + opp1.CloseDate = date.today().addMonths(1); + opp1.Competitor__c = 'B'; + opp1.Purchase_Type__c ='SI锛堟墜琛撳妗堜欢锛�'; + opp1.Sales_Root__c = 'OCM鐩存帴璨╁2'; + opp1.Hospital__c = accHP.id; + //opp1.Department_Class__c = accDepClass.id; + opp1.StageName = '寮曞悎'; + opp1.RecordTypeid = TypeID; + insert opp1; + + SI_Attachment__c newSac = new SI_Attachment__c(); + newSac.Opportunity_ID__c = opp1.id; + newSac.Type__c = '椤圭洰鏂规涔�'; + newSac.Name__c = '*'; + insert newSac; + + ISO_DemandOperAndDemonsController iso = new ISO_DemandOperAndDemonsController(); + iso.init(); + iso.OpporIdStr = opp1.id; + IS_Opportunity_Demand__c ISOhead = new IS_Opportunity_Demand__c(); + ISOhead.name='*'; + ISOhead.Opportunity_ID__c = opp1.id; + ISOhead.Public_Hospital_TF__c = true; + ISOhead.Preparation_Stage_TF__c = true; + ISOhead.Data_Check_TF__c = true; + ISOhead.Operating_Room_Plane_Graph_TF__c = true; + ISOhead.Demonstration_Area_Plane_Graph_TF__c = true; + insert ISOhead; + + Oly_TriggerHandler.clearAllBypasses(); + + Test.startTest(); + ControllerUtil.ISO_Copy_Func(ISOhead.id); + Test.stopTest(); + + } + + static testMethod void CopyQuoteFromOpporTest() { + Opportunity opp = new Opportunity(); + opp.Name='aiueo'; + opp.StageName='contact'; + opp.Trade__c = '鍐呰部'; + opp.CloseDate=Date.today(); + opp.CurrencyIsoCode = 'CNY'; + opp.Estimation_List_Price__c = 100; + opp.Wholesale_Price__c = 101; + opp.Dealer_Final_Price__c = 102; + opp.OCM_Agent1_Price__c = 103; + opp.Stocking_Price__c = 104; + opp.Estimation_No__c = '105'; + opp.Estimation_Name__c = '106'; + opp.Estimation_Id__c = '107'; + opp.old_Oppo_No__c = '1234567890'; + insert opp; + + Quote q = new Quote( + Name = 'quote', + OpportunityId = opp.Id + ); + insert q; + + Bid_Announcement__c ba = new Bid_Announcement__c( + Opportunity_name__c = opp.Id, + Status__c = '鑽夋涓�' + ); + insert ba; + + ControllerUtil.CopyQuoteFromOppor(opp.Id, '', opp.Id, opp); + List<id> oppidList = new List<id>(); + oppidList.add(opp.Id); + ControllerUtil.ResetQuoteNo(oppidList); + } + + //2021/11/20 update wangweipeng + //2019-06-25鏂板 + /*static testMethod void upsertFutureContactTest(){ + Test.startTest(); + User u = new User(); + Contact c = new Contact(); + Id recordTypeId = [SELECT Id FROM RecordType where id = '01210000000Qtky'].id; + User userList = [select id,Alias,EmailEncodingKey,TimeZoneSidKey,LanguageLocaleKey,LastName,ProfileId,Mobile_Phone__c,Notes_File_Name__c,FirstName,LocaleSidKey,Employee_No__c,Work_Location__c,Stay_or_not__c,Pregnant_Rest__c,Post__c,Job_Category__c,Hire_Date__c,Gender__c,Dept__c from User where id ='00510000007hrK8']; + System.runAs(userlist){ + Profile saleProfile = [ select id from Profile where Name = '绯荤粺绠$悊鍛�']; + // List<User> userList = [select id,Alias,EmailEncodingKey,TimeZoneSidKey,LanguageLocaleKey,LastName,ProfileId,Mobile_Phone__c,Notes_File_Name__c,FirstName,LocaleSidKey,Employee_No__c,Work_Location__c,Stay_or_not__c,Pregnant_Rest__c,Post__c,Job_Category__c,Hire_Date__c,Gender__c,Dept__c from User where id = '00510000000fdZWAAY']; + + u.Notes_File_Name__c = userList.Notes_File_Name__c; + u.FirstName = userList.Firstname; + u.Mobile_Phone__c = userList.Mobile_Phone__c; + u.Employee_No__c = '123456789'; + u.Work_Location__c = userList.Work_Location__c; + u.Post__c = userList.Post__c; + u.Job_Category__c = userList.Job_Category__c; + u.Hire_Date__c = userList.Hire_Date__c; + u.Gender__c = userList.Gender__c; + u.Dept__c = userList.Dept__c; + u.Pregnant_Rest__c = userList.Pregnant_Rest__c; + u.Stay_or_not__c = userList.Stay_or_not__c; + u.Alias=userList.Alias; + u.TimeZoneSidKey=userList.TimeZoneSidKey; + u.LocaleSidKey=userList.LocaleSidKey; + u.LanguageLocaleKey=userList.LanguageLocaleKey; + u.EmailEncodingKey=userList.EmailEncodingKey; + u.Username='supUser@123.com'; + u.LastName='supUser'; + u.Email='supUser@123.com'; + u.ProfileId=saleProfile.Id;//绠�妗� + insert u; + + c.Employee_No_manual__c = '123456789'; + c.RecordTypeId = recordTypeId; + // c.User__c = u.Id; + c.Notes_File_Name__c = 'File'; + c.LastName = 'clastname'; + c.FirstName = 'cFirstName'; + c.Email = 'supUser@123.com'; + c.MobilePhone = '12345643213'; + c.User__c = u.id; + insert c; + + List<String> l = new List<String>(); + l.add('123456789'); + ControllerUtil.upsertFutureContact(l); + ControllerUtil.updateFutureUserByContact(l); + } + Test.stopTest(); + }*/ + //add wangweipeng 2021/11/20 ods鏇存柊user start + static testMethod void odsUpsertUserTest(){ + + ODS__c ods = new ODS__c(); + ods.ALIAS__C = 'om002857666'; + ods.BRANCH__C = ''; + ods.CATEGORY3__C = '鍖荤枟鍗庡寳涓滃寳钀ヤ笟缁熸嫭鏈儴'; + ods.CATEGORY4__C = '鍖荤枟鍗庡寳钀ヤ笟鏈儴'; + ods.CATEGORY5__C = '鍗庡寳钀ヤ笟浜岄儴'; + ods.CATEGORY6__C = '娌冲寳GIR鎺ㄥ箍璇�'; + ods.EMAIL__C = 'chengchao_an@olympus.com.cn'; + ods.EMPLOYEE_NO__C = 'om002857666'; + ods.FIRSTNAME__C = 'Chengchao'; + ods.HIRE_DATE__C = Date.today(); + ods.JOB_CATEGORY__C = '鎺ㄥ箍'; + ods.JOB_TYPE__C = '姝e紡-鏈湴鍛樺伐'; + ods.LASTNAME__C = 'An'; + ods.MOBILEPHONE__C = '13832596948'; + ods.NAME__C = '瀹夋壙瓒�'; + ods.POST__C = '涓�鑸�'; + ods.PRODUCT_SPECIALIST_INCHARGE_PRODUCT__C = ''; + ods.SALES_SPECIALITY__C = ''; + ods.UNIQUEID__C = '11181'; + ods.WORK_LOCATION__C = '鐭冲搴�'; + ods.Stay_or_not__c = '鍦ㄨ亴'; + ods.LeaveDate__c = Date.today(); + + insert ods; + + ods.LeaveDate__c = Date.today(); + ods.JOB_CATEGORY__C = '鏈嶅姟'; + ods.EMPLOYEE_NO__C = 'om002858'; + update ods; + + List<String> l = new List<String>(); + l.add('om002857'); + ControllerUtil.upsertFutureContactInterface(l); + ControllerUtil.updateFutureUserByContact(l); + ControllerUtil.upsertFutureContactInterface(l); + } + //add wangweipeng 2021/11/20 ods鏇存柊user end + //2019-06-25鏂板 + static testMethod void upsEventC2EventTest(){ + Daily_Report__c dr = new Daily_Report__c(); + dr.Reported_Date__c = Date.today(); + dr.Reporter__c = Userinfo.getUserId(); + insert dr; + Event__c ec = new Event__c(Daily_Report__c=dr.Id, StartDateTime__c=System.now(), EndDateTime__c=System.now(), Subject__c='Subject', Location__c='Location', ActivityDate__c=Date.today()); + insert ec; + Event__c ec1 = new Event__c(Daily_Report__c=dr.Id, StartDateTime__c=System.now(), EndDateTime__c=System.now(), Subject__c='Subject', Location__c='Location', ActivityDate__c=Date.today()); + insert ec1; + Map<Id, Event__c> eventCMap = new Map<Id, Event__c>(); + Map<Id, Event__c> eventC_eventMap = new Map<Id, Event__c>(); + eventCMap.put(ec.Id,ec); + eventC_eventMap.put(ec1.Id, ec1); + ControllerUtil.upsEventC2Event(eventCMap,eventC_eventMap); + } + + //2019-7-1 鏂板 + // start + // static testMethod void eventDelInsTest(){ + // Daily_Report__c dr = new Daily_Report__c(); + // dr.Reported_Date__c = Date.today(); + // dr.Reporter__c = Userinfo.getUserId(); + // insert dr; + + // Id recordTypeId = [SELECT Id FROM RecordType where id = '01210000000Qtky'].id; + // Contact c = new Contact(); + // c.Employee_No_manual__c = '123456789'; + // c.RecordTypeId = recordTypeId; + // // c.User__c = u.Id; + // c.Notes_File_Name__c = 'File'; + // c.LastName = 'clastname'; + // c.Email = 'supUser@123.com'; + // insert c; + + // Event__c event = new Event__c(Daily_Report__c=dr.Id, StartDateTime__c=System.now(), EndDateTime__c=System.now(), Subject__c='Subject', Location__c='Location', ActivityDate__c=Date.today()); + // insert event; + // Activity_History_Daily_Report__c ahdr = new Activity_History_Daily_Report__c(); + // ahdr.EventC_ID__c = event.Id; + // ahdr.Contact__c = c.Id; + // ahdr.Daily_Report__c = dr.Id; + // // insert ahdr; + + // Opportunity opp = new Opportunity(); + // opp.Name='aiueo'; + // opp.StageName='contact'; + // opp.Trade__c = '鍐呰部'; + // opp.CloseDate=Date.today(); + // opp.CurrencyIsoCode = 'CNY'; + // opp.Estimation_List_Price__c = 100; + // opp.Wholesale_Price__c = 101; + // opp.Dealer_Final_Price__c = 102; + // opp.OCM_Agent1_Price__c = 103; + // opp.Stocking_Price__c = 104; + // opp.Estimation_No__c = '105'; + // opp.Estimation_Name__c = '106'; + // opp.Estimation_Id__c = '107'; + // opp.old_Oppo_No__c = '1234567890'; + // insert opp; + + // Event_Oppotunity__c eo = new Event_Oppotunity__c(); + // eo.EventC_ID__c = event.Id; + // eo.Daily_Report__c = dr.Id; + // eo.Opportunity__c = opp.Id; + // end + + // insert eo; + +// Address_Level__c al = new Address_Level__c(); +// al.Name = '鏉变含'; +// al.Level1_Code__c = 'CN-99'; +// al.Level1_Sys_No__c = '999999'; +// insert al; +// // 甯� +// Address_Level2__c al2 = new Address_Level2__c(); +// al2.Level1_Code__c = 'CN-99'; +// al2.Level1_Sys_No__c = '999999'; +// al2.Level1_Name__c = '鏉变含'; +// al2.Name = '娓嬭胺鍖�'; +// al2.Level2_Code__c = 'CN-9999'; +// al2.Level2_Sys_No__c = '9999999'; +// al2.Address_Level__c = al.id; +// insert al2; +// Account hospital = new Account(); +// hospital.recordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Account' and DeveloperName = 'HP'].id; +// hospital.Name = 'test hospital'; +// hospital.Is_Active__c = '鏈夊姽'; +// hospital.Attribute_Type__c = '鍗敓閮�'; +// hospital.Speciality_Type__c = '缁煎悎鍖婚櫌'; +// hospital.Grade__c = '涓�绾�'; +// hospital.OCM_Category__c = 'SLTV'; +// hospital.Is_Medical__c = '鍖荤枟鏈烘瀯'; +// hospital.State_Master__c = al.id; +// hospital.City_Master__c = al2.id; +// hospital.Town__c = '涓滀含'; +// insert hospital; + + // Maintenance_Contract__c mc = new Maintenance_Contract__c(); + // mc.Name = 'mc'; + // mc.Service_Contract_Staff__c = getUser().Id; + // mc.Department__c = hospital.Id; + // insert mc; + + //start + // System.test.startTest(); + // 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 = '鎴︾暐绉戝鍒嗛 娑堝寲绉�']; + // if (rectSct.size() == 0) { + // return; + // } + // 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 = 'NFM106TestCompany'; + // insert company; + // Account section = new Account(); + // section.RecordTypeId = rectSct[0].Id; + // section.Name = '*'; + // section.Department_Class_Label__c = '娑堝寲绉�'; + // section.ParentId = company.Id; + // section.Hospital_Department_Class__c = company.Id; + // insert section; + + // Account depart = new Account(); + // depart.RecordTypeId = rectDpt[0].Id; + // depart.Name = '*'; + // depart.Department_Name__c = 'NFM106TestDepart'; + // depart.ParentId = section.Id; + // depart.Department_Class__c = section.Id; + // depart.Hospital__c = company.Id; + // insert depart; + + // // 鍐嶅彇寰� + // List<Account> accList = new List<Account>(); + // company = [select Management_Code__c, Management_Code_Auto__c, Name, Id from Account where Id = :company.Id]; + // accList.add(company); + // section = [select Management_Code__c, Management_Code_Auto__c, Name, Id from Account where Id = :section.Id]; + // accList.add(section); + // depart = [select Management_Code__c, Management_Code_Auto__c, Name, Id from Account where Id = :depart.Id]; + // accList.add(depart); + // System.test.stopTest(); + // // 缁翠慨鍚堝悓銈掍綔鎴愩仚銈� + // Maintenance_Contract__c contract = new Maintenance_Contract__c(); + // contract.Name = 'tect contract'; + // contract.Hospital__c = company.Id; + // contract.Department_Class__c = section.Id; + // contract.Department__c = depart.Id; + // contract.Contract_Start_Date__c = Date.today() - 10; + // contract.Contract_End_Date__c = Date.today() + 10; + // contract.Status__c = '濂戠磩'; + // contract.Maintenance_Contract_No__c = '10001'; + // contract.SalesOfficeCode_selection__c = '鍖椾含RC'; + // contract.Contract_Conclusion_Date__c = Date.today(); + + // // HWAG-BE88UG 銆愬鎵樸�慡FDC-SAP鎼幇鏈夋帴鍙f坊鍔犲悎鍚屸�滀粯娆捐鍒掆�濅俊鎭� by vivek start + // contract.Service_Contract_Staff__c = getUser().Id; + // insert contract; + // Event_Service__c es = new Event_Service__c(); + // es.EventC_ID__c = event.Id; + // es.Daily_Report__c = dr.Id; + // es.Service__c = contract.id; + // // insert es; + + // Set<Id> actDelListForDelIns = new Set<Id>(); + // actDelListForDelIns.add(event.Id); + // List<Activity_History_Daily_Report__c> ahdrUpSertList = new List<Activity_History_Daily_Report__c>(); + // List<Event_Oppotunity__c> eoUpSertList = new List<Event_Oppotunity__c>(); + // List<Event_Service__c> esUpSertList = new List<Event_Service__c>(); + // ahdrUpSertList.add(ahdr); + // eoUpSertList.add(eo); + // esUpSertList.add(es); + + // ControllerUtil.eventDelIns(actDelListForDelIns,ahdrUpSertList,eoUpSertList,esUpSertList); + + // } + //end + } \ No newline at end of file -- Gitblit v1.9.1