@isTest private class AccountTriggerHandlerTest { static testMethod void tsetBusinesslicense() { AccountTriggerHandler.asd(); List dealerIE = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = 'Dealer']; if (dealerIE.size() == 0) { return; } List olyCompany = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = 'OlympusCompany']; if (olyCompany.size() == 0) { return; } List loa_individual = [select Id from RecordType where IsActive = true and SobjectType = 'Asset' and Name = '样机_个体管理']; if (loa_individual.size() == 0) { return; } List loa_number = [select Id from RecordType where IsActive = true and SobjectType = 'Asset' and Name = '样机_数量管理']; if (loa_number.size() == 0) { return; } //代理商用户 List rectDealer = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = 'Dealer']; //Profile prof = [select Id from Profile where Name ='SSBG DEALER IE']; Account dealerParent = new Account(); dealerParent.Name = 'test dealer'; dealerParent.RecordTypeId = rectDealer[0].Id; dealerParent.ProductSegment__c = 'BS'; dealerParent.PostCode__c='000000'; dealerParent.ManagementCode_Ext__c = 'P11111'; insert dealerParent; Account dealer1 = new Account(); dealer1.Name = 'test dealer'; dealer1.RecordTypeId = rectDealer[0].Id; dealer1.ProductSegment__c = 'BS'; dealer1.PostCode__c='000000'; dealer1.ManagementCode_Ext__c = 'C22222'; dealer1.ParentId = dealerParent.Id; insert dealer1; Account dealer2 = new Account(); dealer2.Name = 'test dealer'; dealer2.RecordTypeId = rectDealer[0].Id; dealer2.ProductSegment__c = 'BS'; dealer2.PostCode__c='000000'; dealer2.ManagementCode_Ext__c = 'C33333'; dealer2.ParentId = dealerParent.Id; insert dealer2; dealerParent.Business_license__c = 'Test20191227'; update dealerParent; } static testMethod void myUnitTest() { List rectIE = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = 'Customer IE']; List rectDealer = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = 'Dealer']; Account dealer = new Account(); dealer.Name = 'test dealer'; dealer.RecordTypeId = rectDealer[0].Id; dealer.ProductSegment__c = 'IE'; dealer.PostCode__c='000000'; insert dealer; User user = new User(); user.LastName = 'testAccount'; user.FirstName = 'test'; user.Alias = '2105'; user.Email = 'testAccount@test.com'; user.Username = 'testAccount@test222.com'; user.CommunityNickname = 'testAccount'; user.IsActive = true; user.EmailEncodingKey = 'ISO-2022-JP'; user.TimeZoneSidKey = 'Asia/Tokyo'; user.LocaleSidKey = 'ja_JP'; user.LanguageLocaleKey = 'ja'; user.ProfileId = System.Label.SystemAdmin; insert user; Account acc = new Account(); acc.Name = '*'; acc.Website = 'Website'; acc.Fax = 'Fax'; acc.Phone = 'Phone'; acc.Address1__c = 'Address1__c'; acc.AssetANI4__c = 'AssetANI4__c'; acc.AssetIE7__c = 'AssetIE7__c'; acc.AssetNDT7__c = 'AssetNDT7__c'; acc.Dealer__c = dealer.id; acc.DepartmentName__c = 'DepartmentName__c'; acc.DivisionName__c = 'DivisionName__c'; acc.AssetRVI5__c = 'AssetRVI5__c'; acc.EnglishName__c = 'EnglishName__c'; acc.ExportRegulatedCustomer__c = true; acc.FacilityName__c = 'FacilityName__c'; acc.AssetRVI2__c = 'AssetRVI2__c'; acc.AssetNDT4__c = 'AssetNDT4__c'; acc.IndustryC__c = 'Academic Research'; acc.AssetRVI4__c = 'AssetRVI4__c'; acc.AssetRVI3__c = 'AssetRVI3__c'; acc.KeyAccount__c = 'Large Account'; acc.AssetIE5__c = 'AssetIE5__c'; acc.AssetBS3__c = 'AssetBS3__c'; acc.AssetIE3__c = 'AssetIE3__c'; acc.AssetANI7__c = 'AssetANI7__c'; acc.AssetNDT6__c = 'AssetNDT6__c'; acc.MarketVerticals__c = 'LS Research'; acc.AssetIE6__c = 'AssetIE6__c'; acc.AssetIE2__c = 'AssetIE2__c'; acc.AssetBS2__c = 'AssetBS2__c'; acc.AssetANI3__c = 'AssetANI3__c'; acc.AssetIE1__c = 'AssetIE1__c'; acc.AssetBS1__c = 'AssetBS1__c'; acc.AssetRVI1__c = 'AssetRVI1__c'; acc.AssetNDT1__c = 'AssetNDT1__c'; acc.AssetANI1__c = 'AssetANI1__c'; acc.AssetNDT8__c = 'AssetNDT8__c'; acc.AssetANI8__c = 'AssetANI8__c'; acc.AssetBS5__c = 'AssetBS5__c'; acc.AssetIE8__c = 'AssetIE8__c'; acc.AssetRVI8__c = 'AssetRVI8__c'; acc.AssetANI5__c = 'AssetANI5__c'; acc.Province__c = '北京'; acc.AssetRVI6__c = 'AssetRVI6__c'; acc.AssetANI2__c = 'AssetANI2__c'; acc.AssetNDT3__c = 'AssetNDT3__c'; acc.AssetNDT2__c = 'AssetNDT2__c'; acc.AssetANI6__c = 'AssetANI6__c'; acc.Sub_Use__c = 'LED'; acc.Use__c = '(LS Research) Other'; acc.AssetRVI7__c = 'AssetRVI7__c'; acc.AssetBS4__c = 'AssetBS4__c'; acc.AssetIE4__c = 'AssetIE4__c'; acc.AssetNDT5__c = 'AssetNDT5__c'; acc.AccountStatus__c = 'Active'; acc.CancelReason__c = 'CancelReason__c'; acc.City__c = 'City__c'; acc.PostCode__c = '100111'; acc.serviceCreate__c = true; acc.stautesD__c = 'Pass'; insert acc; acc.Website = 'WebsiteD__c'; acc.Fax = 'FaxD__c'; acc.Phone = 'PhoneD__c'; acc.Address1__c = 'Address1D__c'; acc.AssetANI4__c = 'AssetANI4D__c'; acc.AssetIE7__c = 'AssetIE7D__c'; acc.AssetNDT7__c = 'AssetNDT7D__c'; acc.AssetRVI5__c = 'AssetRVI5D__c'; acc.EnglishName__c = 'EnglishNameD__c'; acc.AssetRVI2__c = 'AssetRVI2D__c'; acc.AssetNDT4__c = 'AssetNDT4D__c'; acc.IndustryC__c = 'Electronics'; acc.AssetRVI4__c = 'AssetRVI4D__c'; acc.AssetRVI3__c = 'AssetRVI3D__c'; acc.AssetIE5__c = 'AssetIE5D__c'; acc.AssetBS3__c = 'AssetBS3D__c'; acc.AssetIE3__c = 'AssetIE3D__c'; acc.AssetANI7__c = 'AssetANI7D__c'; acc.AssetNDT6__c = 'AssetNDT6D__c'; acc.MarketVerticals__c = 'Other'; acc.AssetIE6__c = 'AssetIE6D__c'; acc.AssetIE2__c = 'AssetIE2D__c'; acc.AssetBS2__c = 'AssetBS2D__c'; acc.AssetANI3__c = 'AssetANI3D__c'; acc.AssetIE1__c = 'AssetIE1D__c'; acc.AssetBS1__c = 'AssetBS1D__c'; acc.AssetRVI1__c = 'AssetRVI1D__c'; acc.AssetNDT1__c = 'AssetNDT1D__c'; acc.AssetANI1__c = 'AssetANI1D__c'; acc.AssetNDT8__c = 'AssetNDT8D__c'; acc.AssetANI8__c = 'AssetANI8D__c'; acc.AssetBS5__c = 'AssetBS5D__c'; acc.AssetIE8__c = 'AssetIE8D__c'; acc.AssetRVI8__c = 'AssetRVI8D__c'; acc.AssetANI5__c = 'AssetANI5D__c'; acc.AssetRVI6__c = 'AssetRVI6D__c'; acc.AssetANI2__c = 'AssetANI2D__c'; acc.AssetNDT3__c = 'AssetNDT3D__c'; acc.AssetNDT2__c = 'AssetNDT2D__c'; acc.AssetANI6__c = 'AssetANI6D__c'; acc.Sub_Use__c = 'Compo-FPD'; acc.Use__c = '(Other) Other'; acc.AssetRVI7__c = 'AssetRVI7D__c'; acc.AssetBS4__c = 'AssetBS4D__c'; acc.AssetIE4__c = 'AssetIE4D__c'; acc.AssetNDT5__c = 'AssetNDT5D__c'; acc.AccountStatus__c = 'Cancel'; acc.CancelReason__c = 'CancelReasonD__c'; acc.City__c = 'CityD__c'; acc.PostCode__c = '100222'; acc.OwnerId = user.Id; update acc; acc.WebsiteD__c = 'WebsiteD__c'; acc.FaxD__c = 'FaxD__c'; acc.PhoneD__c = 'PhoneD__c'; acc.Address1D__c = 'Address1D__c'; acc.AssetANI4D__c = 'AssetANI4D__c'; acc.AssetIE7D__c = 'AssetIE7D__c'; acc.AssetNDT7D__c = 'AssetNDT7D__c'; acc.AssetRVI5D__c = 'AssetRVI5D__c'; acc.EnglishNameD__c = 'EnglishNameD__c'; acc.AssetRVI2D__c = 'AssetRVI2D__c'; acc.AssetNDT4D__c = 'AssetNDT4D__c'; acc.IndustryCD__c = 'Mining/Geology'; acc.AssetRVI4D__c = 'AssetRVI4D__c'; acc.AssetRVI3D__c = 'AssetRVI3D__c'; acc.AssetIE5D__c = 'AssetIE5D__c'; acc.AssetBS3D__c = 'AssetBS3D__c'; acc.AssetIE3D__c = 'AssetIE3D__c'; acc.AssetANI7D__c = 'AssetANI7D__c'; acc.AssetNDT6D__c = 'AssetNDT6D__c'; acc.MarketVerticalsD__c = 'Other'; acc.AssetIE6D__c = 'AssetIE6D__c'; acc.AssetIE2D__c = 'AssetIE2D__c'; acc.AssetBS2D__c = 'AssetBS2D__c'; acc.AssetANI3D__c = 'AssetANI3D__c'; acc.AssetIE1D__c = 'AssetIE1D__c'; acc.AssetBS1D__c = 'AssetBS1D__c'; acc.AssetRVI1D__c = 'AssetRVI1D__c'; acc.AssetNDT1D__c = 'AssetNDT1D__c'; acc.AssetANI1D__c = 'AssetANI1D__c'; acc.AssetNDT8D__c = 'AssetNDT8D__c'; acc.AssetANI8D__c = 'AssetANI8D__c'; acc.AssetBS5D__c = 'AssetBS5D__c'; acc.AssetIE8D__c = 'AssetIE8D__c'; acc.AssetRVI8D__c = 'AssetRVI8D__c'; acc.AssetANI5D__c = 'AssetANI5D__c'; acc.AssetRVI6D__c = 'AssetRVI6D__c'; acc.AssetANI2D__c = 'AssetANI2D__c'; acc.AssetNDT3D__c = 'AssetNDT3D__c'; acc.AssetNDT2D__c = 'AssetNDT2D__c'; acc.AssetANI6D__c = 'AssetANI6D__c'; acc.Sub_UseD__c = '石油地质'; acc.UseD__c = 'Geology : Geological Surveys'; acc.AssetRVI7D__c = 'AssetRVI7D__c'; acc.AssetBS4D__c = 'AssetBS4D__c'; acc.AssetIE4D__c = 'AssetIE4D__c'; acc.AssetNDT5D__c = 'AssetNDT5D__c'; acc.AccountStatusD__c = 'Cancel'; acc.CancelReasonD__c = 'CancelReasonD__c'; acc.CityD__c = 'CityD__c'; acc.PostCodeD__c = '100222'; acc.DealerSelectOwner__c = UserInfo.getUserId(); update acc; acc.stautesD__c = 'Completed'; update acc; acc.stautesD__c = 'Submit'; update acc; acc.stautesD__c = 'Pass'; update acc; acc.stautesD__c = 'Reject'; update acc; } static testMethod void testSubUse1() { List rectIE = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = 'Customer IE']; List acclist = new List(); String[] ieSubUse = new String[] {'LED','FPD','半导体','电子部品','电子类_其他','金属','汽车','石油地质','五金模具','重工设备','材料类_其他'}; for (Integer i = 0; i < ieSubUse.size(); i++) { Account acc1 = new Account(); acc1.Name = '*'; acc1.FacilityName__c = 'Account'; acc1.DivisionName__c = ieSubUse[i]; acc1.RecordTypeId = rectIE[0].Id; acc1.ProductSegment__c = 'IE'; acc1.Sub_UseD__c = ieSubUse[i]; acc1.Sub_Use__c = ieSubUse[i]; acc1.PostCode__c = '000000'; acclist.add(acc1); } insert acclist; } static testMethod void testSubUse2() { List rectRVI = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = 'Customer RVI']; List acclist = new List(); String[] rviSubUse = new String[] {'Automotive','Civil Aviation','Security/Defense','Oil,Gas&Chemical','Power','General Manufacturing','Inspection/Service/Rental','Others','Thermal Power','Nuclear Power','Wind Power','Power(other)'}; for (Integer i = 0; i < rviSubUse.size(); i++) { Account acc1 = new Account(); acc1.Name = '*'; acc1.FacilityName__c = 'Account'; acc1.DivisionName__c = rviSubUse[i]; acc1.RecordTypeId = rectRVI[0].Id; acc1.ProductSegment__c = 'RVI'; acc1.Sub_UseD__c = rviSubUse[i]; acc1.Sub_Use__c = rviSubUse[i]; acc1.PostCode__c = '000001'; acclist.add(acc1); } insert acclist; } static testMethod void testSubUse3() { List rectANI = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = 'Customer ANI']; List acclist = new List(); String[] aniSubUse = new String[] {'废旧金属','炼钢厂','PMI-石化行业','PMI-管道制造','PMI-金属制造','PMI-电力','RoHS','ELV','玩具&皮革','贵金属-制造','贵金属-回收','勘探-政府','勘探-矿业公司','Mining-冶炼','Mining-开采','EPA','土壤修复','土壤研究','考古&文物','录井','制药','三元催化剂'}; for (Integer i = 0; i < aniSubUse.size(); i++) { Account acc1 = new Account(); acc1.Name = '*'; acc1.FacilityName__c = 'Account'; acc1.DivisionName__c = aniSubUse[i]; acc1.RecordTypeId = rectANI[0].Id; acc1.ProductSegment__c = 'ANI'; acc1.Sub_UseD__c = aniSubUse[i]; acc1.Sub_Use__c = aniSubUse[i]; acc1.PostCode__c = '000002'; acclist.add(acc1); } insert acclist; } static testMethod void testSubUse5() { List rectBS = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = 'Customer BS']; List acclist = new List(); String[] bSIndu = new String[] {'Biotech',' Food/Feed/Agriculture','Clinic/Hospital','Commercial Diagnostic Laboratories','Education','Government/Security/Defense'}; for (Integer i = 0; i < bSIndu.size(); i++) { Account acc1 = new Account(); acc1.Name = '*'; acc1.FacilityName__c = 'Account'; acc1.DivisionName__c = bSIndu[i]; acc1.RecordTypeId = rectBS[0].Id; acc1.ProductSegment__c = 'BS'; acc1.IndustryBD__c = bSIndu[i]; acc1.IndustryB__c = bSIndu[i]; acc1.PostCode__c = '000002'; acclist.add(acc1); } insert acclist; } static testMethod void testSubUse4() { List rectNDT = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = 'Customer NDT']; List acclist = new List(); String[] rviSubUse = new String[] {'Automotive','Civil Aviation','Security/Defense','Oil,Gas&Chemical','Power','General Manufacturing','Inspection/Service/Rental','Others','Thermal Power','Nuclear Power','Wind Power','Power(other)'}; for (Integer i = 0; i < rviSubUse.size(); i++) { Account acc1 = new Account(); acc1.Name = '*'; acc1.FacilityName__c = 'Account'; acc1.DivisionName__c = rviSubUse[i]; acc1.RecordTypeId = rectNDT[0].Id; acc1.ProductSegment__c = 'NDT'; acc1.Sub_UseD__c = rviSubUse[i]; acc1.Sub_Use__c = rviSubUse[i]; acc1.PostCode__c = '000003'; acclist.add(acc1); } insert acclist; } static testMethod void tsetTriggerAccount() { AccountTriggerHandler.asd(); List dealerIE = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = 'Dealer']; if (dealerIE.size() == 0) { return; } List olyCompany = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = 'OlympusCompany']; if (olyCompany.size() == 0) { return; } List loa_individual = [select Id from RecordType where IsActive = true and SobjectType = 'Asset' and Name = '样机_个体管理']; if (loa_individual.size() == 0) { return; } List loa_number = [select Id from RecordType where IsActive = true and SobjectType = 'Asset' and Name = '样机_数量管理']; if (loa_number.size() == 0) { return; } //代理商用户 List rectDealer = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = 'Dealer']; //Profile prof = [select Id from Profile where Name ='SSBG DEALER IE']; Account dealerParent = new Account(); dealerParent.Name = 'test dealer'; dealerParent.RecordTypeId = rectDealer[0].Id; dealerParent.ProductSegment__c = 'IE'; dealerParent.PostCode__c='000000'; dealerParent.ManagementCode_Ext__c = 'P11111'; dealerParent.Sub_UseA__c = '电子部品'; dealerParent.compo_Acc__c = '非COMPO客户'; insert dealerParent; Account dealer1 = new Account(); dealer1.Name = 'test dealer'; dealer1.RecordTypeId = rectDealer[0].Id; dealer1.ProductSegment__c = 'IE'; dealer1.PostCode__c='000000'; dealer1.ManagementCode_Ext__c = 'C22222'; dealer1.ParentId = dealerParent.Id; dealer1.compo_Acc__c = '非COMPO客户'; insert dealer1; Account dealer2 = new Account(); dealer2.Name = 'test dealer'; dealer2.RecordTypeId = rectDealer[0].Id; dealer2.ProductSegment__c = 'IE'; dealer2.PostCode__c='000000'; dealer2.ManagementCode_Ext__c = 'C33333'; dealer2.ParentId = dealerParent.Id; dealer2.compo_Acc__c = '非COMPO客户'; insert dealer2; dealerParent.Sub_UseA__c = '电子部品'; dealerParent.Sub_Use1__c = '电子部品'; dealerParent.Business_license__c = 'Test20191227'; update dealerParent; } }