From ae3dbaacd49b295337c5c53dbf5cf732898ed6f8 Mon Sep 17 00:00:00 2001 From: GWY <guweiyiscp096@foxmail.com> Date: 星期四, 17 三月 2022 09:49:00 +0800 Subject: [PATCH] PJ1降类修复 --- force-app/main/default/classes/AttachmentTriggerTest.cls | 868 ++++++++++++++++++++++++--------------------------------- 1 files changed, 366 insertions(+), 502 deletions(-) diff --git a/force-app/main/default/classes/AttachmentTriggerTest.cls b/force-app/main/default/classes/AttachmentTriggerTest.cls index 9312c10..21503a0 100644 --- a/force-app/main/default/classes/AttachmentTriggerTest.cls +++ b/force-app/main/default/classes/AttachmentTriggerTest.cls @@ -1,530 +1,394 @@ @isTest private class AttachmentTriggerTest { - - @isTest - static void test_method_one() { + static void setupTestData() { + 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); + OlympusCalendar__c oc13 = new OlympusCalendar__c(Date__c = Date.today().addDays(-1), ChangeToHoliday__c=true, ChangeToWorkday__c=false); + OlympusCalendar__c oc14 = new OlympusCalendar__c(Date__c = Date.today().addDays(-2), ChangeToHoliday__c=true, ChangeToWorkday__c=false); + OlympusCalendar__c oc15 = new OlympusCalendar__c(Date__c = Date.today().addDays(-3), ChangeToHoliday__c=false, ChangeToWorkday__c=true); + OlympusCalendar__c oc16 = new OlympusCalendar__c(Date__c = Date.today().addDays(-4), ChangeToHoliday__c=false, ChangeToWorkday__c=true); + OlympusCalendar__c oc17 = new OlympusCalendar__c(Date__c = Date.today().addDays(-5), ChangeToHoliday__c=false, ChangeToWorkday__c=true); - 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; - } - ControllerUtil.EscapeNFM001Trigger = true; - StaticParameter.EscapeOpportunityBefUpdTrigger = true; - StaticParameter.EscapeSyncOpportunityTrigger = true; - StaticParameter.EscapeNFM007Trigger = true; - StaticParameter.EscapeOpportunityHpDeptUpdTrigger = true; - StaticParameter.EscapeSyncOpportunityTrigger = true; - - // 銉嗐偣銉堛儑銉笺偪 - Account company = new Account(); - company.RecordTypeId = rectCo[0].Id; - company.Name = 'NFM007TestCompany'; - upsert 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; - upsert section; - Account depart = new Account(); - depart.RecordTypeId = rectDpt[0].Id; - depart.Name = '*'; - depart.Department_Name__c = 'NFM007TestDepart'; - depart.ParentId = section.Id; - depart.Department_Class__c = section.Id; - depart.Hospital__c = company.Id; - upsert depart; - - Opportunity opp = new Opportunity(); - 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.Stock_apply_status__c = '鐢宠涓�'; - insert opp; - - Opportunity_File__c ofile = new Opportunity_File__c(); - ofile.Name = 'test file'; - ofile.Opportunity__c = opp.Id; - ofile.Oppor_File_Stage__c = 'G'; - insert ofile; - Attachment att1 = new Attachment( - Name = 'test', - ParentId = ofile.Id, - Body = EncodingUtil.base64Decode('test') - ); - System.Test.startTest(); - insert att1; - Attachment att = new Attachment( - Name = 'test', - ParentId = ofile.Id, - Body = EncodingUtil.base64Decode('test') - ); - insert att; - - //delete att1; - System.Test.stopTest(); - } - - //@isTest - static void test_method_two() { - ControllerUtil.EscapeNFM001Trigger = true; - // 鐪� - 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; - - // 鎴︾暐绉戝銈掑緱銈� - 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; - - Contact contact2 = new Contact(); - contact2.AccountId = dep.Id; - contact2.FirstName = '璨换鑰�'; - contact2.LastName = 'test1缁忛攢鍟�'; - insert contact2; - - // 浜у搧 - Product2 pro5 = new Product2(Name='name05',IsActive=true,Family='SP', - Fixture_Model_No__c='n05',Serial_Lot_No__c='S/N tracing', - Fixture_Model_No_T__c = 'n05', - ProductCode_Ext__c='pc05',Manual_Entry__c=false); - insert pro5; - - //澶囧搧鍊熷嚭鐢宠 - Rental_Apply__c raObj = new Rental_Apply__c(); - raObj.Name = 'testra'; - raObj.Product_category__c = 'GI'; - raObj.Demo_purpose1__c = '浜у搧璇曠敤'; - raObj.demo_purpose2__c = FixtureUtil.raDemo_purpose2MAP.get('shiyongwuxunjia'); - raObj.direct_send__c = '鍖荤枟鏈烘瀯'; - raObj.Loaner_received_staff__c = '鐜嬩簲'; - raObj.Loaner_received_staff_phone__c = '110'; - raObj.direct_shippment_address__c = '鍖椾含甯�'; - raObj.Hospital__c = hospital.Id; - raObj.Strategic_dept__c = strategicDep[0].Id; - raObj.Account__c = dep.Id; - raObj.Request_shipping_day__c = Date.toDay(); - raObj.Request_return_day__c = Date.toDay(); - raObj.Phone_number__c = '1234567890'; - raObj.Loaner_medical_Staff__c = contact2.Id; - insert raObj; - - } - - - @isTest - static void test_method_3() { - ControllerUtil.EscapeNFM001Trigger = true; - // 鐪� - 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; - - // 鎴︾暐绉戝銈掑緱銈� - 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; - - Contact contact2 = new Contact(); - contact2.AccountId = dep.Id; - contact2.FirstName = '璨换鑰�'; - contact2.LastName = 'test1缁忛攢鍟�'; - insert contact2; - - System.Test.startTest(); - //insert att1; - Attachment att = new Attachment( - Name = 'test', - ParentId = hospital.Id, - Body = EncodingUtil.base64Decode('test') - ); - insert att; - - delete att; - System.Test.stopTest(); - - } - - @isTest - static void test_method_4() { - - 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; - } - ControllerUtil.EscapeNFM001Trigger = true; - StaticParameter.EscapeOpportunityBefUpdTrigger = true; - StaticParameter.EscapeSyncOpportunityTrigger = true; - StaticParameter.EscapeNFM007Trigger = true; - StaticParameter.EscapeOpportunityHpDeptUpdTrigger = true; - StaticParameter.EscapeSyncOpportunityTrigger = true; - - // 銉嗐偣銉堛儑銉笺偪 - Account company = new Account(); - company.RecordTypeId = rectCo[0].Id; - company.Name = 'NFM007TestCompany'; - upsert 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; - upsert section; - Account depart = new Account(); - depart.RecordTypeId = rectDpt[0].Id; - depart.Name = '*'; - depart.Department_Name__c = 'NFM007TestDepart'; - depart.ParentId = section.Id; - depart.Department_Class__c = section.Id; - depart.Hospital__c = company.Id; - upsert depart; - - Opportunity opp = new Opportunity(); - 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.Stock_apply_status__c = '鐢宠涓�'; - insert opp; - - OpportunitySpecialApply__c osa = new OpportunitySpecialApply__c(); - osa.Opportunity__c = opp.Id; - System.Test.startTest(); - insert osa; - - Attachment att = new Attachment( - Name = 'test', - ParentId = osa.Id, - Body = EncodingUtil.base64Decode('test') - ); - insert att; - - delete att; - System.Test.stopTest(); - - } - - // MZY SWAG-BXXBKA 2021-02-19 start - @isTest - static void test_method_5() { - OPDPlan__c opd = new OPDPlan__c(); - opd.Status__c = '鑽夋涓�'; - opd.OPDPlan_ImplementDate__c = Date.today().addDays(5); - opd.NoOpp_Reason__c = 'HCP瀵瑰簲'; - opd.OPDType__c = '绉戝'; - - insert opd; - System.Test.startTest(); - - Attachment att = new Attachment( - Name = 'test', - ParentId = opd.Id, - Body = EncodingUtil.base64Decode('test') - ); - - insert att; - System.Test.stopTest(); - + insert new OlympusCalendar__c[] {oc1,oc2,oc3,oc4,oc5,oc6,oc7,oc8,oc9,oc10,oc11,oc12,oc13,oc14,oc15,oc16,oc17}; } - @isTest - static void test_method_6() { - List<RecordType> rectC = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '鐥呴櫌']; - if (rectC.size() == 0) { - return; - } - Account act1 = new Account(); - act1.Name = 'TestAccount01'; - act1.RecordTypeId = rectC[0].Id; - - upsert act1; - - List<RecordType> rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '濂戠磩']; - if (rectCo.size() == 0) { - return; - } - Account act2 = new Account(); - act2.Name = 'TestAccount02'; - act2.Business_Assistant__c = getUser().id; - act2.RecordTypeId = rectCo[0].Id; - act2.ParentId = act1.Id; - - upsert act2; - - Consumable_order__c co = new Consumable_order__c(); - co.Name = 'TestCo'; - co.Order_status__c = '鑽夋涓�'; - co.Order_effective_contact__c = act2.id; - - insert co; - System.Test.startTest(); - - Attachment att = new Attachment( - Name = 'test', - ParentId = co.Id, - Body = EncodingUtil.base64Decode('test') + static testMethod void myTest1() { + List<RecordType> rectIE = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = 'Customer IE']; + Account accIE = new Account( + Name = '*', + RecordTypeId = rectIE[0].Id, + OwnerId = UserInfo.getUserId(), + DivisionName__c='Customer IE', + FacilityName__c='abc', + PostCode__c='000000' ); - - insert att; - - delete att; - - System.Test.stopTest(); - - } - - @isTest - static void test_method_7() { - 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 = 'TestCompany'; - upsert 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; - upsert section; - Account depart = new Account(); - depart.RecordTypeId = rectDpt[0].Id; - depart.Name = '*'; - depart.Department_Name__c = 'TestDepart'; - depart.ParentId = section.Id; - depart.Department_Class__c = section.Id; - depart.Hospital__c = company.Id; - upsert depart; - - - RecordType rectOpp = [select id from RecordType where IsActive = true and SobjectType = 'Opportunity' and DeveloperName = 'Opportunity' ]; + insert accIE; + Contact con = new Contact(); + con.LastName = 'test'; + con.AccountId = accIE.Id; + con.MobilePhone = 'MobilePhoneD__c'; + con.OtherPhone = 'OtherPhoneD__c'; + con.Fax = 'FaxD__c'; + con.Email = 'EmailD__c@test.com'; + con.Phone = 'PhoneD__c'; + con.Title = 'TitleD__c'; + con.Address1__c = 'Address1D__c'; + con.Address2__c = 'Address2D__c'; + con.Address3__c = 'Address3D__c'; + con.Postcode__c = '100111'; + con.ContactStatus__c = 'ContactStatusD__c'; + con.CancelReason__c = 'CancelReasonD__c'; + con.StatusD__c = 'Pass'; + insert con; + PriceBook2 pricebook =new PriceBook2( + Name = 'IE' + ); + insert pricebook; + + List<RecordType> rectOpp = [select id from RecordType where IsActive = true and SobjectType = 'Opportunity']; + // 鏈夐瀹氫笅鍗曟棩 Opportunity opp = new Opportunity( - Name='testOpp1', - StageName='寮曞悎', - CloseDate=Date.today(), - AccountId=depart.Id, - Sales_Root__c = '璨╁2搴�', - Competitor__c ='A', - Click_Close_Date__c = null, - RecordType = rectOpp + Name = 'test opp', + AccountId = accIE.Id, + RecordTypeId = rectOpp[0].Id, + OwnerId = UserInfo.getUserId(), + StageName = 'Phase3', + CurrencyIsoCode = 'CNY', + ProductSegment__c = 'IE', + CloseDate = Date.today(), + NewInquiryDate__c = Date.today().addDays(-2), + ExpectedOrderDate__c = Date.today().addDays(2), + SalesChannel__c = 'direct' ); insert opp; - - //娉ㄦ畫 - Statu_Achievements__c Sac = new Statu_Achievements__c( - name = 'zhucan_one', - Opportunity__c = opp.id, - DeliveryDate__c = Date.today(), - ContractNO__c = 'ContractNO1', - ContractAmount__c = 1000 + OpportunityContactRole role = new OpportunityContactRole( + Role = 'End user', + IsPrimary = true, + OpportunityId = opp.Id, + ContactId = con.Id + ); + insert role; + Order odr = new Order( + Name = '', + Status = 'Draft', + AccountId = accIE.Id, + ApproveStatus__c = 'Draft', + OpportunityId = opp.Id, + EffectiveDate = Date.today(), + EndUser__c = con.Id ); - insert Sac; - - eSignForm__c es = new eSignForm__c(); - es.Statu_Achievements__c = Sac.id; - - insert es; - System.Test.startTest(); + insert odr; Attachment att = new Attachment( - Name = 'test', - ParentId = es.Id, + Name = 'ORDER-123456.pdf', + parentId = odr.Id, Body = EncodingUtil.base64Decode('test') ); - insert att; - System.Test.stopTest(); + Attachment att2 = new Attachment( + Name = 'not-ORDER-123456.pdf', + parentId = odr.Id, + Body = EncodingUtil.base64Decode('test') + ); + insert att2; + + delete att; } - @isTest - static void test_method_8() { - List<RecordType> rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '鐥呴櫌']; - if (rectCo.size() == 0) { - return; + + static testMethod void myTest2() { + setupTestData(); + // Implement test code + List<RecordType> rectLo = [select Id from RecordType where IsActive = true and SobjectType = 'loaner_application__c' and Name = 'IE']; + + List<RecordType> rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = 'Customer IE']; + + // 鏂板缓澶囧搧鍊熷嚭鐢宠 + loaner_application__c loaner = new loaner_application__c(); + loaner.Name = 'TEST'; + loaner.RecordTypeId = rectLo[0].id; + loaner.EC_CODE_1__C = 'DV2-CAMELEONS-CUBE'; + loaner.DEMO_PURPOSE__C = '婕旂ず'; + loaner.Request_shipping_Date__c = Date.today(); + loaner.Request_return_Date__c = Date.today(); + loaner.Status__c = '宸插嚭搴撴寚绀�'; + loaner.Return_Track_Company__c = '鐗╂祦鍏徃'; + //loaner.Return_Trake_Staff__c = '杩斿搧浜�'; + insert loaner; + Attachment att = new Attachment( + Name = '鍊熺敤鍗忚-123456.pdf', + parentId = loaner.Id, + Body = EncodingUtil.base64Decode('test') + ); + insert att; + Attachment att2 = new Attachment( + Name = '瑁呮満纭-123456.pdf', + parentId = loaner.Id, + Body = EncodingUtil.base64Decode('test') + ); + insert att2; + + Attachment att3 = new Attachment( + Name = '鏀惰揣纭-123456.pdf', + parentId = loaner.Id, + Body = EncodingUtil.base64Decode('test') + ); + insert att3; + + try{ + Attachment att4 = new Attachment( + Name = '鍊熺敤鍗忚-123456.pdf', + parentId = loaner.Id, + Body = EncodingUtil.base64Decode('test') + ); + insert att4; + }catch(Exception ex){ + try{ + Attachment att21 = new Attachment( + Name = '瑁呮満纭-123456.pdf', + parentId = loaner.Id, + Body = EncodingUtil.base64Decode('test') + ); + insert att21; + }catch(Exception ex1){ + try{ + Attachment att31 = new Attachment( + Name = '鏀惰揣纭-123456.pdf', + parentId = loaner.Id, + Body = EncodingUtil.base64Decode('test') + ); + insert att31; + }catch(Exception ex2){ + return; + } + } + } + } + + + static testMethod void myTest3() { + setupTestData(); + // Implement test code + List<RecordType> rectLo = [select Id from RecordType where IsActive = true and SobjectType = 'loaner_application__c' and Name = 'IE']; + + List<RecordType> rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = 'Customer IE']; + + // 鏂板缓澶囧搧鍊熷嚭鐢宠 + loaner_application__c loaner = new loaner_application__c(); + loaner.Name = 'TEST'; + loaner.RecordTypeId = rectLo[0].id; + loaner.EC_CODE_1__C = 'DV2-CAMELEONS-CUBE'; + loaner.DEMO_PURPOSE__C = '婕旂ず'; + loaner.Request_shipping_Date__c = Date.today(); + loaner.Request_return_Date__c = Date.today(); + loaner.Status__c = '宸插嚭搴撴寚绀�'; + loaner.Return_Track_Company__c = '鐗╂祦鍏徃'; + //loaner.Return_Trake_Staff__c = '杩斿搧浜�'; + insert loaner; + Attachment att = new Attachment( + Name = '鍊熺敤鍗忚-123456.pdf', + parentId = loaner.Id, + Body = EncodingUtil.base64Decode('test') + ); + insert att; + Attachment att2 = new Attachment( + Name = '瑁呮満纭-123456.pdf', + parentId = loaner.Id, + Body = EncodingUtil.base64Decode('test') + ); + insert att2; + + Attachment att3 = new Attachment( + Name = '鏀惰揣纭-123456.pdf', + parentId = loaner.Id, + Body = EncodingUtil.base64Decode('test') + ); + insert att3; + + delete att; + delete att2; + delete att3; + } + static testMethod void myTest4() { + setupTestData(); + // Implement test code + List<RecordType> rectLo = [select Id from RecordType where IsActive = true and SobjectType = 'loaner_application__c' and Name = 'IE']; + + List<RecordType> rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = 'Customer IE']; + + // 鏂板缓澶囧搧鍊熷嚭鐢宠 + loaner_application__c loaner = new loaner_application__c(); + loaner.Name = 'TEST'; + loaner.RecordTypeId = rectLo[0].id; + loaner.EC_CODE_1__C = 'DV2-CAMELEONS-CUBE'; + loaner.DEMO_PURPOSE__C = '婕旂ず'; + loaner.Request_shipping_Date__c = Date.today(); + loaner.Request_return_Date__c = Date.today(); + loaner.Status__c = '宸插嚭搴撴寚绀�'; + loaner.Return_Track_Company__c = '鐗╂祦鍏徃'; + //loaner.Return_Trake_Staff__c = '杩斿搧浜�'; + loaner.HP_Received_Sign_Date__c = Date.today(); + loaner.Bollow_Date__c = Date.today(); + insert loaner; + Attachment att = new Attachment( + Name = '鍊熺敤鍗忚-123456.pdf', + parentId = loaner.Id, + Body = EncodingUtil.base64Decode('test') + ); + insert att; + Attachment att2 = new Attachment( + Name = '瑁呮満纭-123456.pdf', + parentId = loaner.Id, + Body = EncodingUtil.base64Decode('test') + ); + insert att2; + try{ + delete att; + }catch(Exception ex){ + try{ + delete att2; + }catch(Exception ex1){ + 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; - } + } + // 涓氬姟娲诲姩 闄勪欢涓婁紶 + static testMethod void myTest5() { - Account company = new Account(); - company.RecordTypeId = rectCo[0].Id; - company.Name = 'TestCompany'; - upsert 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; - upsert section; - Account depart = new Account(); - depart.RecordTypeId = rectDpt[0].Id; - depart.Name = '*'; - depart.Department_Name__c = 'TestDepart'; - depart.ParentId = section.Id; - depart.Department_Class__c = section.Id; - depart.Hospital__c = company.Id; - upsert depart; + TS_Repair__c tsr = new TS_Repair__c(); + tsr.TSReportDate__c = Date.today(); + insert tsr; - - OPDPlan__c opd = new OPDPlan__c(); - opd.Status__c = '璁″垝涓�'; - opd.OPDPlan_ImplementDate__c = Date.today().addDays(5); - opd.NoOpp_Reason__c = 'HCP瀵瑰簲'; - opd.OPDType__c = '绉戝'; - - insert opd; - - - Rental_Apply__c rap = new Rental_Apply__c(); - rap.Name = 'testra'; - rap.Product_category__c = 'GI'; - rap.Hospital__c = company.Id; - rap.Strategic_dept__c = section .Id; - rap.Account__c = depart.Id; - rap.demo_purpose2__c = '璇曠敤锛堟棤璇环锛�'; - rap.Request_shipping_day__c = Date.toDay(); - rap.Request_return_day__c = Date.toDay(); - rap.OPDPlan__c = opd.id; - - insert rap; - - System.Test.startTest(); + User_FaultInfo__c uf1 = new User_FaultInfo__c(); + insert uf1; + FailureAsset__c fa1 = new FailureAsset__c(); + fa1.model__c = 'test1'; + fa1.FAUserFaultInfo__c = uf1.Id; + insert fa1; + Attachment att3 = new Attachment( + Name = 'not-ORDER-123456.pdf', + parentId = uf1.Id, + Body = EncodingUtil.base64Decode('test') + ); + insert att3; + + BusinessActivity__c ba1 = new BusinessActivity__c(); + ba1.BusinessATS__c = tsr.Id; + ba1.User_FaultInfo__c = uf1.Id; + insert ba1; Attachment att = new Attachment( - Name = 'test', - ParentId = rap.Id, + Name = 'ORDER-123456.pdf', + parentId = ba1.Id, Body = EncodingUtil.base64Decode('test') ); - insert att; - System.Test.stopTest(); + + Attachment att2 = new Attachment( + Name = 'not-ORDER-123456.pdf', + parentId = ba1.Id, + Body = EncodingUtil.base64Decode('test') + ); + insert att2; + + } - - private static User getUser() { - String timenow = Datetime.now().format('yyyyMMddHHmmss'); - User usr = new User(Test_staff__c = true, LastName = 'TestZY', FirstName = 'TestZY', - Alias = 'zy', CommunityNickname = 'TestMiao', Email = 'TestZY@test.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, - Province__c = '鍖椾含甯�'); - insert usr; - return usr; + static testMethod void myTest6() { + List<RecordType> rectIE = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = 'Customer IE']; + Account accIE = new Account( + Name = '*', + RecordTypeId = rectIE[0].Id, + OwnerId = UserInfo.getUserId(), + DivisionName__c='Customer IE', + FacilityName__c='abc', + PostCode__c='000000' + ); + insert accIE; + Contact con = new Contact(); + con.LastName = 'test'; + con.AccountId = accIE.Id; + con.MobilePhone = 'MobilePhoneD__c'; + con.OtherPhone = 'OtherPhoneD__c'; + con.Fax = 'FaxD__c'; + con.Email = 'EmailD__c@test.com'; + con.Phone = 'PhoneD__c'; + con.Title = 'TitleD__c'; + con.Address1__c = 'Address1D__c'; + con.Address2__c = 'Address2D__c'; + con.Address3__c = 'Address3D__c'; + con.Postcode__c = '100111'; + con.ContactStatus__c = 'ContactStatusD__c'; + con.CancelReason__c = 'CancelReasonD__c'; + con.StatusD__c = 'Pass'; + insert con; + PriceBook2 pricebook =new PriceBook2( + Name = 'IE' + ); + insert pricebook; + + List<RecordType> rectOpp = [select id from RecordType where IsActive = true and SobjectType = 'Opportunity']; + // 鏈夐瀹氫笅鍗曟棩 + Opportunity opp = new Opportunity( + Name = 'test opp', + AccountId = accIE.Id, + RecordTypeId = rectOpp[0].Id, + OwnerId = UserInfo.getUserId(), + StageName = 'Phase3', + CurrencyIsoCode = 'CNY', + ProductSegment__c = 'IE', + CloseDate = Date.today(), + NewInquiryDate__c = Date.today().addDays(-2), + ExpectedOrderDate__c = Date.today().addDays(2), + SalesChannel__c = 'direct', + customerType__c = 'B' + ); + insert opp; + OpportunityContactRole role = new OpportunityContactRole( + Role = 'End user', + IsPrimary = true, + OpportunityId = opp.Id, + ContactId = con.Id + ); + insert role; + Order odr = new Order( + Name = '', + Status = 'Draft', + AccountId = accIE.Id, + ApproveStatus__c = 'Draft', + OpportunityId = opp.Id, + EffectiveDate = Date.today(), + EndUser__c = con.Id + ); + insert odr; + TradeCustomerManager__c tra = new TradeCustomerManager__c( + OrderIdSave__c = odr.Id, + order__c = odr.Id + ); + insert tra; + Attachment att1 = new Attachment( + Name = '鍐涗簨.pdf', + parentId = tra.Id, + Body = EncodingUtil.base64Decode('test') + ); + insert att1; + Attachment att2 = new Attachment( + Name = '涓汉淇℃伅.pdf', + parentId = tra.Id, + Body = EncodingUtil.base64Decode('test') + ); + insert att2; + att1.Name = 'test.pdf'; + update att1; + delete att1; } - - // MZY SWAG-BXXBKA 2021-02-19 end - } \ No newline at end of file -- Gitblit v1.9.1