@isTest // TODO Inspection_Report__c 草案中 private class RollupToHPBatchTest { static Date targetToday = RollupToHPBatch.getTargetDay().addDays(1); static Datetime targetNow = Datetime.newInstance(targetToday, Time.newInstance(6, 0, 0, 0)); static testMethod void testExecute() { ControllerUtil.EscapeNFM001Trigger = true; Oly_TriggerHandler.bypass('PowerBIBaseHandler'); Profile p = [select Id from Profile where id = :System.Label.ProfileId_SystemAdmin]; // ユーザー作成 User hpOwner = new User(Test_staff__c = true, LastName = 'hp', FirstName = 'owner', Alias = 'hp', CommunityNickname = 'hpOwner', Email = 'olympus_hpowner@sunbridge.com', Username = 'olympus_hpowner@sunbridge.com', IsActive = true, EmailEncodingKey = 'ISO-2022-JP', TimeZoneSidKey = 'Asia/Tokyo', LocaleSidKey = 'ja_JP', LanguageLocaleKey = 'ja', ProfileId = p.id); insert hpOwner; // 取引先作成 List rectHp = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '病院']; if (rectHp.size() == 0) { return; } List rectDpt = [select Id, Name from RecordType where IsActive = true and SobjectType = 'Account' and Name IN ('診療科 消化科', '診療科 呼吸科', '診療科 普外科') order by Name desc]; if (rectDpt.size() == 0) { return; } Account hp1 = new Account(RecordTypeId = rectHp[0].Id, Name = 'SoakupTestHp1', OwnerId = hpOwner.Id, FSE_GI_Main_Leader__c = UserInfo.getUserId(), FSE_SP_Main_Leader__c = UserInfo.getUserId()); Account hp2 = new Account(RecordTypeId = rectHp[0].Id, Name = 'SoakupTestHp2', OwnerId = hpOwner.Id, FSE_GI_Main_Leader__c = UserInfo.getUserId(), FSE_SP_Main_Leader__c = UserInfo.getUserId()); insert new Account[] {hp1, hp2}; List dc1s = [Select Id, Name, Department_Class_Label__c from Account where Parent.Id = :hp1.Id and Department_Class_Label__c in ('消化科', '呼吸科') order by Department_Class_Label__c]; List dc2s = [Select Id, Name, Department_Class_Label__c from Account where Parent.Id = :hp2.Id and Department_Class_Label__c in ('消化科', '呼吸科') order by Department_Class_Label__c]; List cv_other1 = [Select Id, Name, Department_Class_Label__c from Account where Parent.Id = :hp1.Id and Department_Class_Label__c = '普外科' order by Department_Class_Label__c]; List cv_other2 = [Select Id, Name, Department_Class_Label__c from Account where Parent.Id = :hp2.Id and Department_Class_Label__c = '普外科' order by Department_Class_Label__c]; Account depart1 = new Account(); depart1.RecordTypeId = rectDpt[1].Id; depart1.Name = '*'; depart1.Department_Name__c = '診療科1'; depart1.ParentId = dc1s[0].Id; depart1.Department_Class__c = dc1s[0].Id; depart1.Hospital__c = hp1.Id; Account depart2 = new Account(); depart2.RecordTypeId = rectDpt[2].Id; depart2.Name = '*'; depart2.Department_Name__c = '診療科2'; depart2.ParentId = dc2s[1].Id; depart2.Department_Class__c = dc2s[1].Id; depart2.Hospital__c = hp2.Id; Account depart3 = new Account(); depart3.RecordTypeId = rectDpt[0].Id; depart3.Name = '*'; depart3.Department_Name__c = '診療科3'; depart3.ParentId = cv_other1[0].Id; depart3.Department_Class__c = cv_other1[0].Id; depart3.Hospital__c = hp1.Id; insert new Account[] {depart1, depart2, depart3}; Product2 prd1 = new Product2(); prd1.ProductCode_Ext__c = 'Prd1'; prd1.ProductCode = 'Prd1'; prd1.Repair_Product_Code__c = 'Prd1_RP'; prd1.Name = 'Prd1'; prd1.Manual_Entry__c = false; prd1.Category3__c = ''; prd1.Category4__c = 'CV'; Product2 prd2 = new Product2(); prd2.ProductCode_Ext__c = 'Prd2'; prd2.ProductCode = 'Prd2'; prd2.Repair_Product_Code__c = 'Prd2_RP'; prd2.Name = 'Prd2'; prd2.Manual_Entry__c = false; prd2.Category3__c = ''; prd2.Category4__c = 'CV'; Product2 prd_ov_other = new Product2(); prd_ov_other.ProductCode_Ext__c = 'prd_ov_other'; prd_ov_other.ProductCode = 'prd_ov_other'; prd_ov_other.Repair_Product_Code__c = 'prd_ov_other_RP'; prd_ov_other.Name = 'prd_ov_other'; prd_ov_other.Manual_Entry__c = false; prd_ov_other.Category3__c = ''; prd_ov_other.Category4__c = 'CV'; Product2 prd3 = new Product2(); prd3.ProductCode_Ext__c = 'Prd3'; prd3.ProductCode = 'Prd3'; prd3.Repair_Product_Code__c = 'Prd3_RP'; prd3.Name = 'Prd3'; prd3.Manual_Entry__c = false; prd3.Category3__c = '电子镜'; prd3.Category4__c = 'GIF'; Product2 prd3_2 = new Product2(); prd3_2.ProductCode_Ext__c = 'prd3_2'; prd3_2.ProductCode = 'prd3_2'; prd3_2.Repair_Product_Code__c = 'prd3_2_RP'; prd3_2.Name = 'prd3_2'; prd3_2.Manual_Entry__c = false; prd3_2.Category3__c = '纤维镜'; prd3_2.Category4__c = ''; Product2 prd4 = new Product2(); prd4.ProductCode_Ext__c = 'Prd4'; prd4.ProductCode = 'Prd4'; prd4.Repair_Product_Code__c = 'Prd4_RP'; prd4.Name = 'Prd4'; prd4.Manual_Entry__c = false; prd4.Category3__c = ''; prd4.Category4__c = 'CV'; Product2 prd5 = new Product2(); prd5.ProductCode_Ext__c = 'Prd5'; prd5.ProductCode = 'Prd5'; prd5.Repair_Product_Code__c = 'Prd5_RP'; prd5.Name = 'Prd5'; prd5.Manual_Entry__c = false; prd5.Category3__c = '电子镜'; prd5.Category4__c = 'GIF'; Product2 prd6 = new Product2(); prd6.ProductCode_Ext__c = 'Prd6'; prd6.ProductCode = 'Prd6'; prd6.Repair_Product_Code__c = 'Prd6_RP'; prd6.Name = 'Prd6'; prd6.Manual_Entry__c = false; prd6.Category3__c = '电子镜'; prd6.Category4__c = 'GIF'; Product2 prd7 = new Product2(); prd7.ProductCode_Ext__c = 'Prd7'; prd7.ProductCode = 'Prd7'; prd7.Repair_Product_Code__c = 'Prd7_RP'; prd7.Name = 'Prd7'; prd7.Manual_Entry__c = false; prd7.Category3__c = ''; prd7.Category4__c = 'OTV'; Product2 prd8 = new Product2(); prd8.ProductCode_Ext__c = 'Prd8'; prd8.ProductCode = 'Prd8'; prd8.Repair_Product_Code__c = 'Prd8_RP'; prd8.Name = 'Prd8'; prd8.Manual_Entry__c = false; prd8.Category3__c = ''; prd8.Category4__c = 'OTV'; Product2 prd9 = new Product2(); prd9.ProductCode_Ext__c = 'Prd9'; prd9.ProductCode = 'Prd9'; prd9.Repair_Product_Code__c = 'Prd9_RP'; prd9.Name = 'Prd9'; prd9.Manual_Entry__c = false; prd9.Category3__c = ''; prd9.Category4__c = 'OTV'; insert new Product2[] {prd1, prd2, prd3, prd3_2, prd_ov_other, prd4, prd5, prd6, prd7, prd8, prd9}; Product2 pNew1 = new Product2(); pNew1.ProductCode_Ext__c = 'pNew1'; pNew1.ProductCode = 'pNew1'; pNew1.Repair_Product_Code__c = 'pNew1_RP'; pNew1.Name = 'pNew1'; pNew1.Manual_Entry__c = false; pNew1.Category3__c = ''; pNew1.Category4__c = 'CV'; pNew1.Category5__c = '290系列'; Product2 pNew2 = new Product2(); pNew2.ProductCode_Ext__c = 'pNew2'; pNew2.ProductCode = 'pNew2'; pNew2.Repair_Product_Code__c = 'pNew2_RP'; pNew2.Name = 'pNew2'; pNew2.Manual_Entry__c = false; pNew2.Category3__c = ''; pNew2.Category4__c = 'CV'; pNew2.Category5__c = '260SL系列'; Product2 pNew3 = new Product2(); pNew3.ProductCode_Ext__c = 'pNew3'; pNew3.ProductCode = 'pNew3'; pNew3.Repair_Product_Code__c = 'pNew3_RP'; pNew3.Name = 'pNew3'; pNew3.Manual_Entry__c = false; pNew3.Category3__c = ''; pNew3.Category4__c = 'CV'; pNew3.Category5__c = '260系列'; Product2 pNew4 = new Product2(); pNew4.ProductCode_Ext__c = 'pNew4'; pNew4.ProductCode = 'pNew4'; pNew4.Repair_Product_Code__c = 'pNew4_RP'; pNew4.Name = 'pNew4'; pNew4.Manual_Entry__c = false; pNew4.Category3__c = ''; pNew4.Category4__c = 'CV'; pNew4.Category5__c = '240系列'; Product2 pNew6 = new Product2(); pNew6.ProductCode_Ext__c = 'pNew6'; pNew6.ProductCode = 'N4491360'; pNew6.Repair_Product_Code__c = 'pNew6_RP'; pNew6.Name = 'pNew6'; pNew6.Manual_Entry__c = false; pNew6.Category3__c = ''; pNew6.Category4__c = ''; pNew6.Category5__c = ''; Product2 pNew7 = new Product2(); pNew7.ProductCode_Ext__c = 'pNew7'; pNew7.ProductCode = 'pNew7'; pNew7.Repair_Product_Code__c = 'pNew7_RP'; pNew7.Name = 'pNew7'; pNew7.Manual_Entry__c = false; pNew7.Category3__c = ''; pNew7.Category4__c = 'CV'; pNew7.Category5__c = '190系列'; Product2 pNew8 = new Product2(); pNew8.ProductCode_Ext__c = 'pNew8'; pNew8.ProductCode = 'pNew8'; pNew8.Repair_Product_Code__c = 'pNew8_RP'; pNew8.Name = 'pNew8'; pNew8.Manual_Entry__c = false; pNew8.Category3__c = ''; pNew8.Category4__c = 'OTV'; pNew8.Category5__c = 'OTV-S190系列'; Product2 pNew9 = new Product2(); pNew9.ProductCode_Ext__c = 'pNew9'; pNew9.ProductCode = 'pNew9'; pNew9.Repair_Product_Code__c = 'pNew9_RP'; pNew9.Name = 'pNew9'; pNew9.Manual_Entry__c = false; pNew9.Category3__c = ''; pNew9.Category4__c = 'OTV'; pNew9.Category5__c = 'OTV-S7Pro系列'; Product2 pNew10 = new Product2(); pNew10.ProductCode_Ext__c = 'pNew10'; pNew10.ProductCode = 'pNew10'; pNew10.Repair_Product_Code__c = 'pNew10_RP'; pNew10.Name = 'pNew10'; pNew10.Manual_Entry__c = false; pNew10.Category3__c = ''; pNew10.Category4__c = 'CV'; pNew10.Category5__c = '180系列'; Product2 pNew11 = new Product2(); pNew11.ProductCode_Ext__c = 'pNew11'; pNew11.ProductCode = 'pNew11'; pNew11.Repair_Product_Code__c = 'pNew11_RP'; pNew11.Name = 'pNew11'; pNew11.Manual_Entry__c = false; pNew11.Category3__c = ''; pNew11.Category4__c = 'OTV'; pNew11.Category5__c = 'OTV-S7系列'; Product2 pNew12 = new Product2(); pNew12.ProductCode_Ext__c = 'pNew12'; pNew12.ProductCode = 'pNew12'; pNew12.Repair_Product_Code__c = 'pNew12_RP'; pNew12.Name = 'pNew12'; pNew12.Manual_Entry__c = false; pNew12.Category3__c = ''; pNew12.Category4__c = 'OTV'; pNew12.Category5__c = 'OTV-S6系列'; Product2 pNew13 = new Product2(); pNew13.ProductCode_Ext__c = 'pNew13'; pNew13.ProductCode = 'pNew13'; pNew13.Repair_Product_Code__c = 'pNew13_RP'; pNew13.Name = 'pNew13'; pNew13.Manual_Entry__c = false; pNew13.Category3__c = ''; pNew13.Category4__c = 'OTV'; pNew13.Category5__c = ''; Product2 pNew14 = new Product2(); pNew14.ProductCode_Ext__c = 'pNew14'; pNew14.ProductCode = 'pNew14'; pNew14.Repair_Product_Code__c = 'pNew14_RP'; pNew14.Name = 'pNew14'; pNew14.Manual_Entry__c = false; pNew14.Category3__c = '能量主机'; pNew14.Category4__c = ''; pNew14.Category5__c = 'G2'; Product2 pNew15 = new Product2(); pNew15.ProductCode_Ext__c = 'pNew15'; pNew15.ProductCode = 'WB91051C'; pNew15.Repair_Product_Code__c = 'pNew15_RP'; pNew15.Name = 'pNew15'; pNew15.Manual_Entry__c = false; pNew15.Category3__c = ''; pNew15.Category4__c = ''; pNew15.Category5__c = ''; Product2 pNew16 = new Product2(); pNew16.ProductCode_Ext__c = 'pNew16'; pNew16.ProductCode = 'pNew16'; pNew16.Repair_Product_Code__c = 'pNew16_RP'; pNew16.Name = 'pNew16'; pNew16.Manual_Entry__c = false; pNew16.Category3__c = '能量主机'; pNew16.Category4__c = ''; pNew16.Category5__c = 'G400'; Product2 pNew17 = new Product2(); pNew17.ProductCode_Ext__c = 'pNew17'; pNew17.ProductCode = 'pNew17'; pNew17.Repair_Product_Code__c = 'pNew17_RP'; pNew17.Name = 'pNew17'; pNew17.Manual_Entry__c = false; pNew17.Category3__c = '电子腹腔镜'; pNew17.Category4__c = ''; pNew17.Category5__c = 'HD EndoEYE'; Product2 pNew18 = new Product2(); pNew18.ProductCode_Ext__c = 'pNew18'; pNew18.ProductCode = 'pNew18'; pNew18.Repair_Product_Code__c = 'pNew18_RP'; pNew18.Name = 'pNew18'; pNew18.Manual_Entry__c = false; pNew18.Category3__c = '电子腹腔镜'; pNew18.Category4__c = ''; pNew18.Category5__c = 'SD EndoEYE'; Product2 pNew19 = new Product2(); pNew19.ProductCode_Ext__c = 'pNew19'; pNew19.ProductCode = 'pNew19'; pNew19.Repair_Product_Code__c = 'pNew19_RP'; pNew19.Name = 'pNew19'; pNew19.Manual_Entry__c = false; pNew19.Category3__c = '电子镜'; pNew19.Category4__c = 'URF'; pNew19.Category5__c = ''; Product2 pNew20 = new Product2(); pNew20.ProductCode_Ext__c = 'pNew20'; pNew20.ProductCode = 'pNew20'; pNew20.Repair_Product_Code__c = 'pNew20_RP'; pNew20.Name = 'pNew20'; pNew20.Manual_Entry__c = false; pNew20.Category3__c = '电子镜'; pNew20.Category4__c = 'CYF'; pNew20.Category5__c = ''; Product2 pNew21 = new Product2(); pNew21.ProductCode_Ext__c = 'pNew21'; pNew21.ProductCode = 'pNew21'; pNew21.Repair_Product_Code__c = 'pNew21_RP'; pNew21.Name = 'pNew21'; pNew21.Manual_Entry__c = false; pNew21.Category3__c = '电子镜'; pNew21.Category4__c = 'ENF'; pNew21.Category5__c = ''; Product2 pNew22 = new Product2(); pNew22.ProductCode_Ext__c = 'pNew22'; pNew22.ProductCode = 'pNew22'; pNew22.Repair_Product_Code__c = 'pNew22_RP'; pNew22.Name = 'pNew22'; pNew22.Manual_Entry__c = false; pNew22.Category3__c = '主机'; pNew22.Category4__c = ''; pNew22.Category5__c = '竞争对手'; Product2 pNew23 = new Product2(); pNew23.ProductCode_Ext__c = 'pNew23'; pNew23.ProductCode = 'pNew23'; pNew23.Repair_Product_Code__c = 'pNew23_RP'; pNew23.Name = 'pNew23'; pNew23.Manual_Entry__c = false; pNew23.Category3__c = '主机'; pNew23.Category4__c = ''; pNew23.Category5__c = '竞争对手'; Product2 pNew24 = new Product2(); pNew24.ProductCode_Ext__c = 'pNew24'; pNew24.ProductCode = 'pNew24'; pNew24.Repair_Product_Code__c = 'pNew24_RP'; pNew24.Name = 'pNew24'; pNew24.Manual_Entry__c = false; pNew24.Category3__c = '能量主机'; pNew24.Category4__c = ''; pNew24.Category5__c = '竞争对手'; Product2 pNew25 = new Product2(); pNew25.ProductCode_Ext__c = 'pNew25'; pNew25.ProductCode = 'pNew25'; pNew25.Repair_Product_Code__c = 'pNew25_RP'; pNew25.Name = 'pNew25'; pNew25.Manual_Entry__c = false; pNew25.Category3__c = '能量主机'; pNew25.Category4__c = ''; pNew25.Category5__c = '竞争对手'; Product2 pNew26 = new Product2(); pNew26.ProductCode_Ext__c = 'pNew26'; pNew26.ProductCode = 'pNew26'; pNew26.Repair_Product_Code__c = 'pNew26_RP'; pNew26.Name = 'pNew26'; pNew26.Manual_Entry__c = false; pNew26.Category3__c = 'Not能量主机'; pNew26.Category4__c = ''; pNew26.Category5__c = '竞争对手'; insert new Product2[] {pNew1, pNew2, pNew3, pNew4, pNew6, pNew7, pNew8, pNew9, pNew10, pNew11, pNew12, pNew13, pNew14, pNew15, pNew16, pNew17, pNew18, pNew19, pNew20, pNew21, pNew22, pNew23, pNew24, pNew25, pNew26 }; Asset ast1 = new Asset(); ast1.Name = '保有設備1'; ast1.Hospital__c = hp1.Id; ast1.Department_Class__c = dc1s[0].Id; ast1.AccountId = depart1.Id; ast1.Product2Id = prd1.Id; ast1.SerialNumber = 'SerialNumber1'; ast1.Guarantee_period_for_products__c = Date.today(); ast1.InstallDate = Date.today(); Asset ast2 = new Asset(); ast2.Name = '保有設備2'; ast2.Hospital__c = hp1.Id; ast2.Department_Class__c = dc1s[0].Id; ast2.AccountId = depart1.Id; ast2.Product2Id = prd2.Id; ast2.SerialNumber = 'SerialNumber2'; ast2.Guarantee_period_for_products__c = Date.today(); ast2.InstallDate = Date.today(); Asset ast_ov_other = new Asset(); ast_ov_other.Name = '保有設備_ov_other'; ast_ov_other.Hospital__c = hp1.Id; ast_ov_other.Department_Class__c = cv_other1[0].Id; ast_ov_other.AccountId = depart3.Id; ast_ov_other.Product2Id = prd_ov_other.Id; ast_ov_other.SerialNumber = 'SerialNumber_ov_other'; ast_ov_other.Guarantee_period_for_products__c = Date.today(); ast_ov_other.InstallDate = Date.today(); Asset ast3 = new Asset(); ast3.Name = '保有設備3'; ast3.Hospital__c = hp1.Id; ast3.Department_Class__c = dc1s[0].Id; ast3.AccountId = depart1.Id; ast3.Product2Id = prd3.Id; ast3.SerialNumber = 'SerialNumber3'; ast3.Guarantee_period_for_products__c = Date.today(); ast3.InstallDate = Date.today(); Asset ast3_2 = new Asset(); ast3_2.Name = '保有設備3_2'; ast3_2.Hospital__c = hp1.Id; ast3_2.Department_Class__c = dc1s[0].Id; ast3_2.AccountId = depart1.Id; ast3_2.Product2Id = prd3_2.Id; ast3_2.SerialNumber = 'SerialNumber3_2'; ast3_2.Guarantee_period_for_products__c = Date.today(); ast3_2.InstallDate = Date.today(); Asset ast4 = new Asset(); ast4.Name = '保有設備4'; ast4.Hospital__c = hp2.Id; ast4.Department_Class__c = dc2s[1].Id; ast4.AccountId = depart2.Id; ast4.Product2Id = prd4.Id; ast4.SerialNumber = 'SerialNumber4'; ast4.Guarantee_period_for_products__c = Date.today(); ast4.InstallDate = Date.today(); Asset ast5 = new Asset(); ast5.Name = '保有設備5'; ast5.Hospital__c = hp2.Id; ast5.Department_Class__c = dc2s[1].Id; ast5.AccountId = depart2.Id; ast5.Product2Id = prd5.Id; ast5.SerialNumber = 'SerialNumber5'; ast5.Guarantee_period_for_products__c = Date.today(); ast5.InstallDate = Date.today(); Asset ast6 = new Asset(); ast6.Name = '保有設備6'; ast6.Hospital__c = hp2.Id; ast6.Department_Class__c = dc2s[1].Id; ast6.AccountId = depart2.Id; ast6.Product2Id = prd6.Id; ast6.SerialNumber = 'SerialNumber6'; ast6.Guarantee_period_for_products__c = Date.today(); ast6.InstallDate = Date.today(); Asset ast7 = new Asset(); ast7.Name = '保有設備7'; ast7.Hospital__c = hp2.Id; ast7.Department_Class__c = dc2s[1].Id; ast7.AccountId = depart2.Id; ast7.Product2Id = prd7.Id; ast7.SerialNumber = 'SerialNumber7'; ast7.Guarantee_period_for_products__c = Date.today(); ast7.InstallDate = Date.today(); Asset ast8 = new Asset(); ast8.Name = '保有設備8'; ast8.Hospital__c = hp2.Id; ast8.Department_Class__c = dc2s[1].Id; ast8.AccountId = depart2.Id; ast8.Product2Id = prd8.Id; ast8.SerialNumber = 'SerialNumber8'; ast8.Guarantee_period_for_products__c = Date.today(); ast8.InstallDate = Date.today(); Asset ast9 = new Asset(); ast9.Name = '保有設備9'; ast9.Hospital__c = hp2.Id; ast9.Department_Class__c = dc2s[1].Id; ast9.AccountId = depart2.Id; ast9.Product2Id = prd9.Id; ast9.SerialNumber = 'SerialNumber9'; ast9.Guarantee_period_for_products__c = Date.today(); ast9.InstallDate = Date.today(); insert new Asset[] {ast1, ast2, ast_ov_other, ast3, ast3_2, ast4, ast5, ast6, ast7, ast8, ast9}; Asset aNew1 = new Asset(); aNew1.Name = 'aNew1'; aNew1.Hospital__c = hp1.Id; aNew1.Department_Class__c = dc1s[0].Id; aNew1.AccountId = depart1.Id; aNew1.Product2Id = pNew1.Id; aNew1.SerialNumber = 'aNew1'; aNew1.Guarantee_period_for_products__c = Date.today(); aNew1.InstallDate = Date.today(); Asset aNew2 = new Asset(); aNew2.Name = 'aNew2'; aNew2.Hospital__c = hp1.Id; aNew2.Department_Class__c = dc1s[0].Id; aNew2.AccountId = depart1.Id; aNew2.Product2Id = pNew2.Id; aNew2.SerialNumber = 'aNew2'; aNew2.Guarantee_period_for_products__c = Date.today(); aNew2.InstallDate = Date.today(); Asset aNew3 = new Asset(); aNew3.Name = 'aNew3'; aNew3.Hospital__c = hp1.Id; aNew3.Department_Class__c = dc1s[0].Id; aNew3.AccountId = depart1.Id; aNew3.Product2Id = pNew3.Id; aNew3.SerialNumber = 'aNew3'; aNew3.Guarantee_period_for_products__c = Date.today(); aNew3.InstallDate = Date.today(); Asset aNew4 = new Asset(); aNew4.Name = 'aNew4'; aNew4.Hospital__c = hp1.Id; aNew4.Department_Class__c = dc1s[0].Id; aNew4.AccountId = depart1.Id; aNew4.Product2Id = pNew4.Id; aNew4.SerialNumber = 'aNew4'; aNew4.Guarantee_period_for_products__c = Date.today(); aNew4.InstallDate = Date.today(); Asset aNew6 = new Asset(); aNew6.Name = 'aNew6'; aNew6.Hospital__c = hp1.Id; aNew6.Department_Class__c = dc1s[0].Id; aNew6.AccountId = depart1.Id; aNew6.Product2Id = pNew6.Id; aNew6.SerialNumber = 'aNew6'; aNew6.Guarantee_period_for_products__c = Date.today(); aNew6.InstallDate = Date.today(); Asset aNew7 = new Asset(); aNew7.Name = 'aNew7'; aNew7.Hospital__c = hp1.Id; aNew7.Department_Class__c = dc1s[0].Id; aNew7.AccountId = depart1.Id; aNew7.Product2Id = pNew7.Id; aNew7.SerialNumber = 'aNew7'; aNew7.Guarantee_period_for_products__c = Date.today(); aNew7.InstallDate = Date.today(); Asset aNew8 = new Asset(); aNew8.Name = 'aNew8'; aNew8.Hospital__c = hp1.Id; aNew8.Department_Class__c = dc1s[0].Id; aNew8.AccountId = depart1.Id; aNew8.Product2Id = pNew8.Id; aNew8.SerialNumber = 'aNew8'; aNew8.Guarantee_period_for_products__c = Date.today(); aNew8.InstallDate = Date.today(); Asset aNew9 = new Asset(); aNew9.Name = 'aNew9'; aNew9.Hospital__c = hp1.Id; aNew9.Department_Class__c = dc1s[0].Id; aNew9.AccountId = depart1.Id; aNew9.Product2Id = pNew9.Id; aNew9.SerialNumber = 'aNew9'; aNew9.Guarantee_period_for_products__c = Date.today(); aNew9.InstallDate = Date.today(); Asset aNew10 = new Asset(); aNew10.Name = 'aNew10'; aNew10.Hospital__c = hp1.Id; aNew10.Department_Class__c = dc1s[0].Id; aNew10.AccountId = depart1.Id; aNew10.Product2Id = pNew10.Id; aNew10.SerialNumber = 'aNew10'; aNew10.Guarantee_period_for_products__c = Date.today(); aNew10.InstallDate = Date.today(); Asset aNew11 = new Asset(); aNew11.Name = 'aNew11'; aNew11.Hospital__c = hp1.Id; aNew11.Department_Class__c = dc1s[0].Id; aNew11.AccountId = depart1.Id; aNew11.Product2Id = pNew11.Id; aNew11.SerialNumber = 'aNew11'; aNew11.Guarantee_period_for_products__c = Date.today(); aNew11.InstallDate = Date.today(); Asset aNew12 = new Asset(); aNew12.Name = 'aNew12'; aNew12.Hospital__c = hp1.Id; aNew12.Department_Class__c = dc1s[0].Id; aNew12.AccountId = depart1.Id; aNew12.Product2Id = pNew12.Id; aNew12.SerialNumber = 'aNew12'; aNew12.Guarantee_period_for_products__c = Date.today(); aNew12.InstallDate = Date.today(); Asset aNew13 = new Asset(); aNew13.Name = 'aNew13'; aNew13.Hospital__c = hp1.Id; aNew13.Department_Class__c = dc1s[0].Id; aNew13.AccountId = depart1.Id; aNew13.Product2Id = pNew13.Id; aNew13.SerialNumber = 'aNew13'; aNew13.Guarantee_period_for_products__c = Date.today(); aNew13.InstallDate = Date.today(); Asset aNew14 = new Asset(); aNew14.Name = 'aNew14'; aNew14.Hospital__c = hp1.Id; aNew14.Department_Class__c = dc1s[0].Id; aNew14.AccountId = depart1.Id; aNew14.Product2Id = pNew14.Id; aNew14.SerialNumber = 'aNew14'; aNew14.Guarantee_period_for_products__c = Date.today(); aNew14.InstallDate = Date.today(); Asset aNew15 = new Asset(); aNew15.Name = 'aNew15'; aNew15.Hospital__c = hp1.Id; aNew15.Department_Class__c = dc1s[0].Id; aNew15.AccountId = depart1.Id; aNew15.Product2Id = pNew15.Id; aNew15.SerialNumber = 'aNew15'; aNew15.Guarantee_period_for_products__c = Date.today(); aNew15.InstallDate = Date.today(); Asset aNew16 = new Asset(); aNew16.Name = 'aNew16'; aNew16.Hospital__c = hp1.Id; aNew16.Department_Class__c = dc1s[0].Id; aNew16.AccountId = depart1.Id; aNew16.Product2Id = pNew16.Id; aNew16.SerialNumber = 'aNew16'; aNew16.Guarantee_period_for_products__c = Date.today(); aNew16.InstallDate = Date.today(); Asset aNew17 = new Asset(); aNew17.Name = 'aNew17'; aNew17.Hospital__c = hp1.Id; aNew17.Department_Class__c = dc1s[0].Id; aNew17.AccountId = depart1.Id; aNew17.Product2Id = pNew17.Id; aNew17.SerialNumber = 'aNew17'; aNew17.Guarantee_period_for_products__c = Date.today(); aNew17.InstallDate = Date.today(); Asset aNew18 = new Asset(); aNew18.Name = 'aNew18'; aNew18.Hospital__c = hp1.Id; aNew18.Department_Class__c = dc1s[0].Id; aNew18.AccountId = depart1.Id; aNew18.Product2Id = pNew18.Id; aNew18.SerialNumber = 'aNew18'; aNew18.Guarantee_period_for_products__c = Date.today(); aNew18.InstallDate = Date.today(); Asset aNew19 = new Asset(); aNew19.Name = 'aNew19'; aNew19.Hospital__c = hp1.Id; aNew19.Department_Class__c = dc1s[0].Id; aNew19.AccountId = depart1.Id; aNew19.Product2Id = pNew19.Id; aNew19.SerialNumber = 'aNew19'; aNew19.Guarantee_period_for_products__c = Date.today(); aNew19.InstallDate = Date.today(); Asset aNew20 = new Asset(); aNew20.Name = 'aNew20'; aNew20.Hospital__c = hp1.Id; aNew20.Department_Class__c = dc1s[0].Id; aNew20.AccountId = depart1.Id; aNew20.Product2Id = pNew20.Id; aNew20.SerialNumber = 'aNew20'; aNew20.Guarantee_period_for_products__c = Date.today(); aNew20.InstallDate = Date.today(); Asset aNew21 = new Asset(); aNew21.Name = 'aNew21'; aNew21.Hospital__c = hp1.Id; aNew21.Department_Class__c = dc1s[0].Id; aNew21.AccountId = depart1.Id; aNew21.Product2Id = pNew21.Id; aNew21.SerialNumber = 'aNew21'; aNew21.Guarantee_period_for_products__c = Date.today(); aNew21.InstallDate = Date.today(); Asset aNew22 = new Asset(); aNew22.Name = 'aNew22'; aNew22.Hospital__c = hp1.Id; aNew22.Department_Class__c = dc1s[0].Id; aNew22.AccountId = depart1.Id; aNew22.Product2Id = pNew22.Id; aNew22.SerialNumber = 'aNew22'; aNew22.Guarantee_period_for_products__c = Date.today(); aNew22.InstallDate = Date.today(); Asset aNew23 = new Asset(); aNew23.Name = 'aNew23'; aNew23.Hospital__c = hp1.Id; aNew23.Department_Class__c = cv_other1[0].Id; aNew23.AccountId = depart3.Id; aNew23.Product2Id = pNew23.Id; aNew23.SerialNumber = 'aNew23'; aNew23.Guarantee_period_for_products__c = Date.today(); aNew23.InstallDate = Date.today(); Asset aNew24 = new Asset(); aNew24.Name = 'aNew24'; aNew24.Hospital__c = hp1.Id; aNew24.Department_Class__c = dc1s[0].Id; aNew24.AccountId = depart1.Id; aNew24.Product2Id = pNew24.Id; aNew24.SerialNumber = 'aNew24'; aNew24.Guarantee_period_for_products__c = Date.today(); aNew24.InstallDate = Date.today(); Asset aNew25 = new Asset(); aNew25.Name = 'aNew25'; aNew25.Hospital__c = hp1.Id; aNew25.Department_Class__c = cv_other1[0].Id; aNew25.AccountId = depart3.Id; aNew25.Product2Id = pNew25.Id; aNew25.SerialNumber = 'aNew25'; aNew25.Guarantee_period_for_products__c = Date.today(); aNew25.InstallDate = Date.today(); Asset aNew26 = new Asset(); aNew26.Name = 'aNew26'; aNew26.Hospital__c = hp1.Id; aNew26.Department_Class__c = cv_other1[0].Id; aNew26.AccountId = depart3.Id; aNew26.Product2Id = pNew26.Id; aNew26.SerialNumber = 'aNew26'; aNew26.Guarantee_period_for_products__c = Date.today(); aNew26.InstallDate = Date.today(); insert new Asset[] {aNew1, aNew2, aNew3, aNew4, aNew6, aNew7, aNew8, aNew9, aNew10, aNew11, aNew12, aNew13, aNew14, aNew15, aNew16, aNew17, aNew18, aNew19, aNew20, aNew21, aNew22, aNew23, aNew24, aNew25, aNew26 }; AssetHistory__c astH1 = new AssetHistory__c(); astH1.CurrencyIsoCode = 'CNY'; astH1.Asset_Inspection_ExtID__c = 'astH1'; astH1.Field_Api_Name__c = 'astH1'; astH1.Field_Lable_Name__c = 'astH1'; astH1.Inspection_Times__c = 1; astH1.Examination_Date__c = targetToday.addDays(-1); astH1.AssetId__c = ast8.Id; astH1.Field_Api_Name__c = 'Inspection_report_number__c'; astH1.NewValue__c = 'NewValue'; AssetHistory__c astH2 = new AssetHistory__c(); astH2.CurrencyIsoCode = 'CNY'; astH2.Asset_Inspection_ExtID__c = 'astH2'; astH2.Field_Api_Name__c = 'astH2'; astH2.Field_Lable_Name__c = 'astH2'; astH2.Inspection_Times__c = 0; astH2.Examination_Date__c = targetToday.addDays(-1); astH2.AssetId__c = ast9.Id; astH2.Field_Api_Name__c = 'Inspection_report_number__c'; astH2.NewValue__c = 'NewValue'; AssetHistory__c astH3 = new AssetHistory__c(); astH3.CurrencyIsoCode = 'CNY'; astH3.Asset_Inspection_ExtID__c = 'astH3'; astH3.Field_Api_Name__c = 'astH3'; astH3.Field_Lable_Name__c = 'astH3'; astH3.Inspection_Times__c = 1; astH3.Examination_Date__c = targetToday.addDays(-1); astH3.AssetId__c = ast9.Id; astH3.Field_Api_Name__c = 'Inspection_report_number__c'; astH3.NewValue__c = 'NewValue2'; AssetHistory__c astH4 = new AssetHistory__c(); astH4.CurrencyIsoCode = 'CNY'; astH4.Asset_Inspection_ExtID__c = 'astH4'; astH4.Field_Api_Name__c = 'astH3'; astH4.Field_Lable_Name__c = 'astH3'; astH4.Inspection_Times__c = 1; astH4.Examination_Date__c = targetToday.addDays(-1); astH4.AssetId__c = ast9.Id; astH4.Field_Api_Name__c = 'Inspection_report_number__c'; astH4.NewValue__c = ''; // <== 対象外 insert new AssetHistory__c[] {astH1, astH2, astH3, astH4}; Repair__c repair1 = new Repair__c(); repair1.Service_Repair_No__c = 'repair1'; repair1.Hospital__c = hp1.Id; repair1.Department_Class__c = dc1s[0].Id; repair1.Account__c = depart1.Id; repair1.Delivered_Product__c = ast1.Id; repair1.Repair_List_Price__c = 100; repair1.Billing_Amount__c = 10; repair1.Paid_Amount__c = 1; repair1.SAP_Transfer_time__c = targetToday; repair1.Repair_Final_Inspection_Date__c = targetToday; repair1.Failure_Occurrence_Date__c = targetToday.addDays(-1); repair1.Repair_Returned_To_HP_Date__c = targetToday.addDays(3); repair1.Repair_Shipped_Date__c = targetToday.addDays(1); Repair__c repair2 = new Repair__c(); repair2.Service_Repair_No__c = 'repair2'; repair2.Hospital__c = hp1.Id; repair2.Department_Class__c = dc1s[0].Id; repair2.Account__c = depart1.Id; repair2.Delivered_Product__c = ast1.Id; repair2.Repair_List_Price__c = 200; repair2.Billing_Amount__c = 20; repair2.Paid_Amount__c = 2; repair2.SAP_Transfer_time__c = targetToday; repair2.Repair_Final_Inspection_Date__c = targetToday; repair2.Failure_Occurrence_Date__c = targetToday.addDays(-1); repair2.Repair_Returned_To_HP_Date__c = targetToday.addDays(5); repair2.Repair_Shipped_Date__c = targetToday.addDays(3); Repair__c repair3 = new Repair__c(); repair3.Service_Repair_No__c = 'repair3'; repair3.Hospital__c = hp1.Id; repair3.Department_Class__c = dc1s[0].Id; repair3.Account__c = depart1.Id; repair3.Delivered_Product__c = ast1.Id; repair3.Repair_List_Price__c = 150; repair3.Billing_Amount__c = 15; repair3.Paid_Amount__c = 1; repair3.SAP_Transfer_time__c = targetToday; repair3.Repair_Final_Inspection_Date__c = targetToday; repair3.Failure_Occurrence_Date__c = targetToday.addYears(-1).addDays(-1); repair3.Repair_Returned_To_HP_Date__c = targetToday.addYears(-1).addDays(5); repair3.Repair_Shipped_Date__c = targetToday.addYears(-1).addDays(3); insert new Repair__c[] {repair1, repair2, repair3}; Integer targetmonth = targetToday.addDays(-1).month(); Account2__c[] hps = [select id, Name, SpecialAsset_CV_Count__c, SpecialAsset_CV_Other_Count__c, SpecialAsset_GIF_Count__c, SpecialAsset_OTV_Count__c, SUM_Repair_List_Price__c, SUM_Repair_Billing_Amount__c, AVG_Elapsed_day_from_Repair__c, AVG_Elapsed_day_from_Repair2__c, SUM_Unpaid_Amount__c, This_year_inspection_times1__c, This_year_inspection_times2__c, This_year_inspection_times3__c, This_year_inspection_times4__c, This_year_inspection_times5__c, This_year_inspection_times6__c, This_year_inspection_times7__c, This_year_inspection_times8__c, This_year_inspection_times9__c, This_year_inspection_times10__c, This_year_inspection_times11__c, This_year_inspection_times12__c, This_year_inspection_count1__c, This_year_inspection_count2__c, This_year_inspection_count3__c, This_year_inspection_count4__c, This_year_inspection_count5__c, This_year_inspection_count6__c, This_year_inspection_count7__c, This_year_inspection_count8__c, This_year_inspection_count9__c, This_year_inspection_count10__c, This_year_inspection_count11__c, This_year_inspection_count12__c from Account2__c where Account_Org__r.RecordType.Name = '病院' order by Name]; System.assertEquals('SoakupTestHp1', hps[0].Name); System.assertEquals(null, hps[0].SpecialAsset_CV_Count__c); System.assertEquals(null, hps[0].SpecialAsset_CV_Other_Count__c); System.assertEquals(null, hps[0].SpecialAsset_GIF_Count__c); System.assertEquals(null, hps[0].SpecialAsset_OTV_Count__c); System.assertEquals(null, hps[0].SUM_Repair_List_Price__c); System.assertEquals(null, hps[0].SUM_Repair_Billing_Amount__c); System.assertEquals(null, hps[0].AVG_Elapsed_day_from_Repair__c); System.assertEquals(null, hps[0].AVG_Elapsed_day_from_Repair2__c); System.assertEquals(null, hps[0].SUM_Unpaid_Amount__c); if (targetmonth == 1) { System.assertEquals(null, hps[0].This_year_inspection_times1__c); } else if (targetmonth == 2) { System.assertEquals(null, hps[0].This_year_inspection_times2__c); } else if (targetmonth == 3) { System.assertEquals(null, hps[0].This_year_inspection_times3__c); } else if (targetmonth == 4) { System.assertEquals(null, hps[0].This_year_inspection_times4__c); } else if (targetmonth == 5) { System.assertEquals(null, hps[0].This_year_inspection_times5__c); } else if (targetmonth == 6) { System.assertEquals(null, hps[0].This_year_inspection_times6__c); } else if (targetmonth == 7) { System.assertEquals(null, hps[0].This_year_inspection_times7__c); } else if (targetmonth == 8) { System.assertEquals(null, hps[0].This_year_inspection_times8__c); } else if (targetmonth == 9) { System.assertEquals(null, hps[0].This_year_inspection_times9__c); } else if (targetmonth == 10) { System.assertEquals(null, hps[0].This_year_inspection_times10__c); } else if (targetmonth == 11) { System.assertEquals(null, hps[0].This_year_inspection_times11__c); } else if (targetmonth == 12) { System.assertEquals(null, hps[0].This_year_inspection_times12__c); } if (targetmonth == 1) { System.assertEquals(null, hps[0].This_year_inspection_count1__c); } else if (targetmonth == 2) { System.assertEquals(null, hps[0].This_year_inspection_count2__c); } else if (targetmonth == 3) { System.assertEquals(null, hps[0].This_year_inspection_count3__c); } else if (targetmonth == 4) { System.assertEquals(null, hps[0].This_year_inspection_count4__c); } else if (targetmonth == 5) { System.assertEquals(null, hps[0].This_year_inspection_count5__c); } else if (targetmonth == 6) { System.assertEquals(null, hps[0].This_year_inspection_count6__c); } else if (targetmonth == 7) { System.assertEquals(null, hps[0].This_year_inspection_count7__c); } else if (targetmonth == 8) { System.assertEquals(null, hps[0].This_year_inspection_count8__c); } else if (targetmonth == 9) { System.assertEquals(null, hps[0].This_year_inspection_count9__c); } else if (targetmonth == 10) { System.assertEquals(null, hps[0].This_year_inspection_count10__c); } else if (targetmonth == 11) { System.assertEquals(null, hps[0].This_year_inspection_count11__c); } else if (targetmonth == 12) { System.assertEquals(null, hps[0].This_year_inspection_count12__c); } System.assertEquals('SoakupTestHp2', hps[1].Name); System.assertEquals(null, hps[1].SpecialAsset_CV_Count__c); System.assertEquals(null, hps[1].SpecialAsset_CV_Other_Count__c); System.assertEquals(null, hps[1].SpecialAsset_GIF_Count__c); System.assertEquals(null, hps[1].SpecialAsset_OTV_Count__c); System.assertEquals(null, hps[1].SUM_Repair_List_Price__c); System.assertEquals(null, hps[1].SUM_Repair_Billing_Amount__c); System.assertEquals(null, hps[1].AVG_Elapsed_day_from_Repair__c); System.assertEquals(null, hps[1].AVG_Elapsed_day_from_Repair2__c); System.assertEquals(null, hps[1].SUM_Unpaid_Amount__c); if (targetmonth == 1) { System.assertEquals(null, hps[1].This_year_inspection_times1__c); } else if (targetmonth == 2) { System.assertEquals(null, hps[1].This_year_inspection_times2__c); } else if (targetmonth == 3) { System.assertEquals(null, hps[1].This_year_inspection_times3__c); } else if (targetmonth == 4) { System.assertEquals(null, hps[1].This_year_inspection_times4__c); } else if (targetmonth == 5) { System.assertEquals(null, hps[1].This_year_inspection_times5__c); } else if (targetmonth == 6) { System.assertEquals(null, hps[1].This_year_inspection_times6__c); } else if (targetmonth == 7) { System.assertEquals(null, hps[1].This_year_inspection_times7__c); } else if (targetmonth == 8) { System.assertEquals(null, hps[1].This_year_inspection_times8__c); } else if (targetmonth == 9) { System.assertEquals(null, hps[1].This_year_inspection_times9__c); } else if (targetmonth == 10) { System.assertEquals(null, hps[1].This_year_inspection_times10__c); } else if (targetmonth == 11) { System.assertEquals(null, hps[1].This_year_inspection_times11__c); } else if (targetmonth == 12) { System.assertEquals(null, hps[1].This_year_inspection_times12__c); } if (targetmonth == 1) { System.assertEquals(null, hps[1].This_year_inspection_count1__c); } else if (targetmonth == 2) { System.assertEquals(null, hps[1].This_year_inspection_count2__c); } else if (targetmonth == 3) { System.assertEquals(null, hps[1].This_year_inspection_count3__c); } else if (targetmonth == 4) { System.assertEquals(null, hps[1].This_year_inspection_count4__c); } else if (targetmonth == 5) { System.assertEquals(null, hps[1].This_year_inspection_count5__c); } else if (targetmonth == 6) { System.assertEquals(null, hps[1].This_year_inspection_count6__c); } else if (targetmonth == 7) { System.assertEquals(null, hps[1].This_year_inspection_count7__c); } else if (targetmonth == 8) { System.assertEquals(null, hps[1].This_year_inspection_count8__c); } else if (targetmonth == 9) { System.assertEquals(null, hps[1].This_year_inspection_count9__c); } else if (targetmonth == 10) { System.assertEquals(null, hps[1].This_year_inspection_count10__c); } else if (targetmonth == 11) { System.assertEquals(null, hps[1].This_year_inspection_count11__c); } else if (targetmonth == 12) { System.assertEquals(null, hps[1].This_year_inspection_count12__c); } System.Test.StartTest(); Id execBTId = Database.executeBatch(new RollupToHPBatch(null, null), 5); System.Test.StopTest(); Account2__c[] hps2 = [select id, Name, SpecialAsset_CV_Count__c, SpecialAsset_CV_Other_Count__c, SpecialAsset_GIF_Count__c, SpecialAsset_C3_Electronic_Mirror__c, SpecialAsset_C3_Fiber_Mirror__c, SpecialAsset_OTV_Count__c, SUM_Repair_List_Price__c, SUM_Repair_Billing_Amount__c, AVG_Elapsed_day_from_Repair__c, AVG_Elapsed_day_from_Repair2__c, SUM_Unpaid_Amount__c, SUM_Repair_List_Price_Lastyear__c, SUM_Repair_Billing_Amount_Lastyear__c, AVG_Elapsed_day_from_Repair_Lastyear__c, AVG_Elapsed_day_from_Repair2_Lastyear__c, This_year_inspection_times1__c, This_year_inspection_times2__c, This_year_inspection_times3__c, This_year_inspection_times4__c, This_year_inspection_times5__c, This_year_inspection_times6__c, This_year_inspection_times7__c, This_year_inspection_times8__c, This_year_inspection_times9__c, This_year_inspection_times10__c, This_year_inspection_times11__c, This_year_inspection_times12__c, This_year_inspection_count1__c, This_year_inspection_count2__c, This_year_inspection_count3__c, This_year_inspection_count4__c, This_year_inspection_count5__c, This_year_inspection_count6__c, This_year_inspection_count7__c, This_year_inspection_count8__c, This_year_inspection_count9__c, This_year_inspection_count10__c, This_year_inspection_count11__c, This_year_inspection_count12__c from Account2__c where Account_Org__r.RecordType.Name = '病院' order by Name]; System.assertEquals('SoakupTestHp1', hps2[0].Name); System.assertEquals(8, hps2[0].SpecialAsset_CV_Count__c); System.assertEquals(1, hps2[0].SpecialAsset_CV_Other_Count__c); System.assertEquals(1, hps2[0].SpecialAsset_GIF_Count__c); System.assertEquals(4, hps2[0].SpecialAsset_C3_Electronic_Mirror__c); System.assertEquals(1, hps2[0].SpecialAsset_C3_Fiber_Mirror__c); System.assertEquals(5, hps2[0].SpecialAsset_OTV_Count__c); System.assertEquals(300, hps2[0].SUM_Repair_List_Price__c); System.assertEquals(30, hps2[0].SUM_Repair_Billing_Amount__c); System.assertEquals(5, hps2[0].AVG_Elapsed_day_from_Repair__c); System.assertEquals(3, hps2[0].AVG_Elapsed_day_from_Repair2__c); System.assertEquals(150, hps2[0].SUM_Repair_List_Price_Lastyear__c); System.assertEquals(15, hps2[0].SUM_Repair_Billing_Amount_Lastyear__c); System.assertEquals(6, hps2[0].AVG_Elapsed_day_from_Repair_Lastyear__c); System.assertEquals(4, hps2[0].AVG_Elapsed_day_from_Repair2_Lastyear__c); System.assertEquals(41, hps2[0].SUM_Unpaid_Amount__c); if (targetmonth == 1) { System.assertEquals(0, hps2[0].This_year_inspection_times1__c); } else if (targetmonth == 2) { System.assertEquals(0, hps2[0].This_year_inspection_times2__c); } else if (targetmonth == 3) { System.assertEquals(0, hps2[0].This_year_inspection_times3__c); } else if (targetmonth == 4) { System.assertEquals(0, hps2[0].This_year_inspection_times4__c); } else if (targetmonth == 5) { System.assertEquals(0, hps2[0].This_year_inspection_times5__c); } else if (targetmonth == 6) { System.assertEquals(0, hps2[0].This_year_inspection_times6__c); } else if (targetmonth == 7) { System.assertEquals(0, hps2[0].This_year_inspection_times7__c); } else if (targetmonth == 8) { System.assertEquals(0, hps2[0].This_year_inspection_times8__c); } else if (targetmonth == 9) { System.assertEquals(0, hps2[0].This_year_inspection_times9__c); } else if (targetmonth == 10) { System.assertEquals(0, hps2[0].This_year_inspection_times10__c); } else if (targetmonth == 11) { System.assertEquals(0, hps2[0].This_year_inspection_times11__c); } else if (targetmonth == 12) { System.assertEquals(0, hps2[0].This_year_inspection_times12__c); } if (targetmonth == 1) { System.assertEquals(0, hps2[0].This_year_inspection_count1__c); } else if (targetmonth == 2) { System.assertEquals(0, hps2[0].This_year_inspection_count2__c); } else if (targetmonth == 3) { System.assertEquals(0, hps2[0].This_year_inspection_count3__c); } else if (targetmonth == 4) { System.assertEquals(0, hps2[0].This_year_inspection_count4__c); } else if (targetmonth == 5) { System.assertEquals(0, hps2[0].This_year_inspection_count5__c); } else if (targetmonth == 6) { System.assertEquals(0, hps2[0].This_year_inspection_count6__c); } else if (targetmonth == 7) { System.assertEquals(0, hps2[0].This_year_inspection_count7__c); } else if (targetmonth == 8) { System.assertEquals(0, hps2[0].This_year_inspection_count8__c); } else if (targetmonth == 9) { System.assertEquals(0, hps2[0].This_year_inspection_count9__c); } else if (targetmonth == 10) { System.assertEquals(0, hps2[0].This_year_inspection_count10__c); } else if (targetmonth == 11) { System.assertEquals(0, hps2[0].This_year_inspection_count11__c); } else if (targetmonth == 12) { System.assertEquals(0, hps2[0].This_year_inspection_count12__c); } System.assertEquals('SoakupTestHp2', hps2[1].Name); System.assertEquals(1, hps2[1].SpecialAsset_CV_Count__c); System.assertEquals(0, hps2[1].SpecialAsset_CV_Other_Count__c); System.assertEquals(2, hps2[1].SpecialAsset_GIF_Count__c); System.assertEquals(3, hps2[1].SpecialAsset_OTV_Count__c); System.assertEquals(0, hps2[1].SUM_Repair_List_Price__c); System.assertEquals(0, hps2[1].SUM_Repair_Billing_Amount__c); System.assertEquals(0, hps2[1].AVG_Elapsed_day_from_Repair__c); System.assertEquals(0, hps2[1].AVG_Elapsed_day_from_Repair2__c); System.assertEquals(0, hps2[1].SUM_Unpaid_Amount__c); if (targetmonth == 1) { System.assertEquals(2, hps2[1].This_year_inspection_times1__c); } else if (targetmonth == 2) { System.assertEquals(2, hps2[1].This_year_inspection_times2__c); } else if (targetmonth == 3) { System.assertEquals(2, hps2[1].This_year_inspection_times3__c); } else if (targetmonth == 4) { System.assertEquals(2, hps2[1].This_year_inspection_times4__c); } else if (targetmonth == 5) { System.assertEquals(2, hps2[1].This_year_inspection_times5__c); } else if (targetmonth == 6) { System.assertEquals(2, hps2[1].This_year_inspection_times6__c); } else if (targetmonth == 7) { System.assertEquals(2, hps2[1].This_year_inspection_times7__c); } else if (targetmonth == 8) { System.assertEquals(2, hps2[1].This_year_inspection_times8__c); } else if (targetmonth == 9) { System.assertEquals(2, hps2[1].This_year_inspection_times9__c); } else if (targetmonth == 10) { System.assertEquals(2, hps2[1].This_year_inspection_times10__c); } else if (targetmonth == 11) { System.assertEquals(2, hps2[1].This_year_inspection_times11__c); } else if (targetmonth == 12) { System.assertEquals(2, hps2[1].This_year_inspection_times12__c); } if (targetmonth == 1) { System.assertEquals(3, hps2[1].This_year_inspection_count1__c); } else if (targetmonth == 2) { System.assertEquals(3, hps2[1].This_year_inspection_count2__c); } else if (targetmonth == 3) { System.assertEquals(3, hps2[1].This_year_inspection_count3__c); } else if (targetmonth == 4) { System.assertEquals(3, hps2[1].This_year_inspection_count4__c); } else if (targetmonth == 5) { System.assertEquals(3, hps2[1].This_year_inspection_count5__c); } else if (targetmonth == 6) { System.assertEquals(3, hps2[1].This_year_inspection_count6__c); } else if (targetmonth == 7) { System.assertEquals(3, hps2[1].This_year_inspection_count7__c); } else if (targetmonth == 8) { System.assertEquals(3, hps2[1].This_year_inspection_count8__c); } else if (targetmonth == 9) { System.assertEquals(3, hps2[1].This_year_inspection_count9__c); } else if (targetmonth == 10) { System.assertEquals(3, hps2[1].This_year_inspection_count10__c); } else if (targetmonth == 11) { System.assertEquals(3, hps2[1].This_year_inspection_count11__c); } else if (targetmonth == 12) { System.assertEquals(3, hps2[1].This_year_inspection_count12__c); } // 戦略科室 List dccheck1 = [Select id, Name, SpecialAsset_CV_Count__c, SpecialAsset_CV_Other_Count__c, SpecialAsset_GIF_Count__c, SpecialAsset_C3_Electronic_Mirror__c, SpecialAsset_C3_Fiber_Mirror__c, SpecialAsset_OTV_Count__c, SUM_Repair_List_Price__c, SUM_Repair_Billing_Amount__c, AVG_Elapsed_day_from_Repair__c, AVG_Elapsed_day_from_Repair2__c, SUM_Unpaid_Amount__c, SUM_Repair_List_Price_Lastyear__c, SUM_Repair_Billing_Amount_Lastyear__c, AVG_Elapsed_day_from_Repair_Lastyear__c, AVG_Elapsed_day_from_Repair2_Lastyear__c from Account2__c where Account_Org__r.ParentId = :hp1.Id and Account_Org__r.Department_Class_Label__c in ('消化科', '呼吸科') order by Account_Org__r.Department_Class_Label__c]; System.assertEquals(8, dccheck1[0].SpecialAsset_CV_Count__c); System.assertEquals(0, dccheck1[0].SpecialAsset_CV_Other_Count__c); System.assertEquals(1, dccheck1[0].SpecialAsset_GIF_Count__c); System.assertEquals(4, dccheck1[0].SpecialAsset_C3_Electronic_Mirror__c); System.assertEquals(1, dccheck1[0].SpecialAsset_C3_Fiber_Mirror__c); System.assertEquals(5, dccheck1[0].SpecialAsset_OTV_Count__c); System.assertEquals(300, dccheck1[0].SUM_Repair_List_Price__c); System.assertEquals(30, dccheck1[0].SUM_Repair_Billing_Amount__c); System.assertEquals(5, dccheck1[0].AVG_Elapsed_day_from_Repair__c); System.assertEquals(3, dccheck1[0].AVG_Elapsed_day_from_Repair2__c); System.assertEquals(150, dccheck1[0].SUM_Repair_List_Price_Lastyear__c); System.assertEquals(15, dccheck1[0].SUM_Repair_Billing_Amount_Lastyear__c); System.assertEquals(6, dccheck1[0].AVG_Elapsed_day_from_Repair_Lastyear__c); System.assertEquals(4, dccheck1[0].AVG_Elapsed_day_from_Repair2_Lastyear__c); System.assertEquals(41, dccheck1[0].SUM_Unpaid_Amount__c); List dccheck2 = [Select id, Name, SpecialAsset_CV_Count__c, SpecialAsset_CV_Other_Count__c, SpecialAsset_GIF_Count__c, SpecialAsset_OTV_Count__c, SUM_Repair_List_Price__c, SUM_Repair_Billing_Amount__c, AVG_Elapsed_day_from_Repair__c, AVG_Elapsed_day_from_Repair2__c, SUM_Unpaid_Amount__c from Account2__c where Account_Org__r.ParentId = :hp2.Id and Account_Org__r.Department_Class_Label__c in ('消化科', '呼吸科') order by Account_Org__r.Department_Class_Label__c]; System.assertEquals(1, dccheck2[1].SpecialAsset_CV_Count__c); System.assertEquals(0, dccheck2[1].SpecialAsset_CV_Other_Count__c); System.assertEquals(2, dccheck2[1].SpecialAsset_GIF_Count__c); System.assertEquals(3, dccheck2[1].SpecialAsset_OTV_Count__c); System.assertEquals(0, dccheck2[1].SUM_Repair_List_Price__c); System.assertEquals(0, dccheck2[1].SUM_Repair_Billing_Amount__c); System.assertEquals(0, dccheck2[1].AVG_Elapsed_day_from_Repair__c); System.assertEquals(0, dccheck2[1].AVG_Elapsed_day_from_Repair2__c); System.assertEquals(0, dccheck2[1].SUM_Unpaid_Amount__c); List dccheck3 = [Select id, Name, SpecialAsset_CV_Count__c, SpecialAsset_CV_Other_Count__c, SpecialAsset_GIF_Count__c, SpecialAsset_OTV_Count__c, SUM_Repair_List_Price__c, SUM_Repair_Billing_Amount__c, AVG_Elapsed_day_from_Repair__c, AVG_Elapsed_day_from_Repair2__c, SUM_Unpaid_Amount__c from Account2__c where Account_Org__r.ParentId = :hp1.Id and Account_Org__r.Department_Class_Label__c = '普外科' order by Account_Org__r.Department_Class_Label__c]; System.assertEquals(0, dccheck3[0].SpecialAsset_CV_Count__c); System.assertEquals(1, dccheck3[0].SpecialAsset_CV_Other_Count__c); System.assertEquals(0, dccheck3[0].SpecialAsset_GIF_Count__c); System.assertEquals(0, dccheck3[0].SpecialAsset_OTV_Count__c); System.assertEquals(0, dccheck3[0].SUM_Repair_List_Price__c); System.assertEquals(0, dccheck3[0].SUM_Repair_Billing_Amount__c); System.assertEquals(0, dccheck3[0].AVG_Elapsed_day_from_Repair__c); System.assertEquals(0, dccheck3[0].AVG_Elapsed_day_from_Repair2__c); System.assertEquals(0, dccheck3[0].SUM_Unpaid_Amount__c); Account2__c[] hps3 = [select id, Name, CV_290_Count__c, CV_260SL_Count__c, CV_260_Count__c, CV_240_Other_Count__c, CV_Other_Count__c, D3_System_Count__c, CV_190_Count__c, OTV_S190_Count__c, OTV_S7Pro_Count__c, CV_180_Count__c, OTV_S7_Count__c, OTV_S6_Count__c, OTV_Other_Count__c, SSG2_Count__c, ESG_400_Count__c, G400_Count__c, HD_EndoEYE_Count__c, SD_EndoEYE_Count__c, Video_URF_Count__c, Video_CYF_Count__c, Video_ENF_Count__c, Competitor_Count__c, Competitor_Count_SP__c, Energy_Processor_Count__c, Energy_Processor_Count_SP__c, Other_Competitor_Product_Count__c from Account2__c where Account_Org__r.RecordType.Name = '病院' order by Name]; System.assertEquals(1, hps3[0].CV_290_Count__c); System.assertEquals(1, hps3[0].CV_260SL_Count__c); System.assertEquals(1, hps3[0].CV_260_Count__c); System.assertEquals(1, hps3[0].CV_240_Other_Count__c); System.assertEquals(5, hps3[0].CV_Other_Count__c); System.assertEquals(1, hps3[0].D3_System_Count__c); System.assertEquals(1, hps3[0].CV_190_Count__c); System.assertEquals(1, hps3[0].OTV_S190_Count__c); System.assertEquals(1, hps3[0].OTV_S7Pro_Count__c); System.assertEquals(1, hps3[0].CV_180_Count__c); System.assertEquals(1, hps3[0].OTV_S7_Count__c); System.assertEquals(1, hps3[0].OTV_S6_Count__c); System.assertEquals(1, hps3[0].OTV_Other_Count__c); System.assertEquals(1, hps3[0].SSG2_Count__c); System.assertEquals(1, hps3[0].ESG_400_Count__c); System.assertEquals(1, hps3[0].G400_Count__c); System.assertEquals(1, hps3[0].HD_EndoEYE_Count__c); System.assertEquals(1, hps3[0].SD_EndoEYE_Count__c); System.assertEquals(1, hps3[0].Video_URF_Count__c); System.assertEquals(1, hps3[0].Video_CYF_Count__c); System.assertEquals(1, hps3[0].Video_ENF_Count__c); System.assertEquals(1, hps3[0].Competitor_Count__c); System.assertEquals(1, hps3[0].Competitor_Count_SP__c); System.assertEquals(1, hps3[0].Energy_Processor_Count__c); System.assertEquals(1, hps3[0].Energy_Processor_Count_SP__c); System.assertEquals(1, hps3[0].Other_Competitor_Product_Count__c); Account2__c[] dccheck4 = [select id, Name, CV_290_Count__c, CV_260SL_Count__c, CV_260_Count__c, CV_240_Other_Count__c, CV_Other_Count__c, D3_System_Count__c, CV_190_Count__c, OTV_S190_Count__c, OTV_S7Pro_Count__c, CV_180_Count__c, OTV_S7_Count__c, OTV_S6_Count__c, OTV_Other_Count__c, SSG2_Count__c, ESG_400_Count__c, G400_Count__c, HD_EndoEYE_Count__c, SD_EndoEYE_Count__c, Video_URF_Count__c, Video_CYF_Count__c, Video_ENF_Count__c, Competitor_Count__c, Competitor_Count_SP__c, Energy_Processor_Count__c, Energy_Processor_Count_SP__c, Other_Competitor_Product_Count__c from Account2__c where Account_Org__r.ParentId = :hp1.Id and Account_Org__r.Department_Class_Label__c in ('消化科', '呼吸科') order by Account_Org__r.Department_Class_Label__c]; System.assertEquals(1, dccheck4[0].CV_290_Count__c); System.assertEquals(1, dccheck4[0].CV_260SL_Count__c); System.assertEquals(1, dccheck4[0].CV_260_Count__c); System.assertEquals(1, dccheck4[0].CV_240_Other_Count__c); System.assertEquals(4, dccheck4[0].CV_Other_Count__c); System.assertEquals(1, dccheck4[0].D3_System_Count__c); System.assertEquals(1, dccheck4[0].CV_190_Count__c); System.assertEquals(1, dccheck4[0].OTV_S190_Count__c); System.assertEquals(1, dccheck4[0].OTV_S7Pro_Count__c); System.assertEquals(1, dccheck4[0].CV_180_Count__c); System.assertEquals(1, dccheck4[0].OTV_S7_Count__c); System.assertEquals(1, dccheck4[0].OTV_S6_Count__c); System.assertEquals(1, dccheck4[0].OTV_Other_Count__c); System.assertEquals(1, dccheck4[0].SSG2_Count__c); System.assertEquals(1, dccheck4[0].ESG_400_Count__c); System.assertEquals(1, dccheck4[0].G400_Count__c); System.assertEquals(1, dccheck4[0].HD_EndoEYE_Count__c); System.assertEquals(1, dccheck4[0].SD_EndoEYE_Count__c); System.assertEquals(1, dccheck4[0].Video_URF_Count__c); System.assertEquals(1, dccheck4[0].Video_CYF_Count__c); System.assertEquals(1, dccheck4[0].Video_ENF_Count__c); System.assertEquals(1, dccheck4[0].Competitor_Count__c); System.assertEquals(0, dccheck4[0].Competitor_Count_SP__c); System.assertEquals(1, dccheck4[0].Energy_Processor_Count__c); System.assertEquals(0, dccheck4[0].Energy_Processor_Count_SP__c); System.assertEquals(0, dccheck4[0].Other_Competitor_Product_Count__c); Account2__c[] dccheck5 = [select id, Name, CV_290_Count__c, CV_260SL_Count__c, CV_260_Count__c, CV_240_Other_Count__c, CV_Other_Count__c, D3_System_Count__c, CV_190_Count__c, OTV_S190_Count__c, OTV_S7Pro_Count__c, CV_180_Count__c, OTV_S7_Count__c, OTV_S6_Count__c, OTV_Other_Count__c, SSG2_Count__c, ESG_400_Count__c, G400_Count__c, HD_EndoEYE_Count__c, SD_EndoEYE_Count__c, Video_URF_Count__c, Video_CYF_Count__c, Video_ENF_Count__c, Competitor_Count__c, Competitor_Count_SP__c, Energy_Processor_Count__c, Energy_Processor_Count_SP__c, Other_Competitor_Product_Count__c from Account2__c where Account_Org__r.ParentId = :hp1.Id and Account_Org__r.Department_Class_Label__c = '普外科' order by Account_Org__r.Department_Class_Label__c]; System.assertEquals(0, dccheck5[0].CV_290_Count__c); System.assertEquals(0, dccheck5[0].CV_260SL_Count__c); System.assertEquals(0, dccheck5[0].CV_260_Count__c); System.assertEquals(0, dccheck5[0].CV_240_Other_Count__c); System.assertEquals(1, dccheck5[0].CV_Other_Count__c); System.assertEquals(0, dccheck5[0].D3_System_Count__c); System.assertEquals(0, dccheck5[0].CV_190_Count__c); System.assertEquals(0, dccheck5[0].OTV_S190_Count__c); System.assertEquals(0, dccheck5[0].OTV_S7Pro_Count__c); System.assertEquals(0, dccheck5[0].CV_180_Count__c); System.assertEquals(0, dccheck5[0].OTV_S7_Count__c); System.assertEquals(0, dccheck5[0].OTV_S6_Count__c); System.assertEquals(0, dccheck5[0].OTV_Other_Count__c); System.assertEquals(0, dccheck5[0].SSG2_Count__c); System.assertEquals(0, dccheck5[0].ESG_400_Count__c); System.assertEquals(0, dccheck5[0].G400_Count__c); System.assertEquals(0, dccheck5[0].HD_EndoEYE_Count__c); System.assertEquals(0, dccheck5[0].SD_EndoEYE_Count__c); System.assertEquals(0, dccheck5[0].Video_URF_Count__c); System.assertEquals(0, dccheck5[0].Video_CYF_Count__c); System.assertEquals(0, dccheck5[0].Video_ENF_Count__c); System.assertEquals(0, dccheck5[0].Competitor_Count__c); System.assertEquals(1, dccheck5[0].Competitor_Count_SP__c); System.assertEquals(0, dccheck5[0].Energy_Processor_Count__c); System.assertEquals(1, dccheck5[0].Energy_Processor_Count_SP__c); System.assertEquals(1, dccheck5[0].Other_Competitor_Product_Count__c); } static testMethod void SoakupHPOppRanktaxTest() { ControllerUtil.EscapeNFM001Trigger = true; //病院 List rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '病院'] ; //戦略科室分類 RecordType rectSct1 = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '戦略科室分類 普外科']; RecordType rectSct2 = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '戦略科室分類 呼吸科']; //科室分類 RecordType rectDpt1 = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '診療科 普外科']; RecordType rectDpt2 = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '診療科 呼吸科']; //商談のレコードタイプ RecordType rectOpp = [select id from RecordType where IsActive = true and SobjectType = 'Opportunity' and DeveloperName = 'Opportunity' ]; // insert Account company1 = new Account(); //Account company2 = new Account(); company1.RecordTypeId = rectCo[0].Id; company1.Name = 'HPテスト1'; insert company1; Account dc1 = [Select Id, Name, Department_Class_Label__c, Sys_Dept_Name_Change_Chk__c from Account where Parent.Id = :company1.Id and RecordTypeId = : rectSct1.Id] ; Account dc2 = [Select Id, Name, Department_Class_Label__c, Sys_Dept_Name_Change_Chk__c from Account where Parent.Id = :company1.Id and RecordTypeId = : rectSct2.Id] ; Account depart1 = new Account(); depart1.RecordTypeId = rectDpt1.Id; depart1.Name = '*'; depart1.Department_Name__c = '診療科1'; depart1.ParentId = dc1.Id; depart1.Department_Class__c = dc1.Id; depart1.Hospital__c = company1.Id; Account depart2 = new Account(); depart2.RecordTypeId = rectDpt2.Id; depart2.Name = '*'; depart2.Department_Name__c = '診療科2'; depart2.ParentId = dc2.Id; depart2.Department_Class__c = dc2.Id; depart2.Hospital__c = company1.Id; StaticParameter.EscapeNFM001Trigger = true; insert new Account[] {depart1, depart2}; Opportunity opp1 = new Opportunity( Name = 'testOpp1', StageName = '引合', CloseDate = Date.today(), AccountId = depart1.Id, Competitor__c = 'A', Trade__c = '内貿', Wholesale_Price__c = 1000, RecordType = rectOpp ); Opportunity opp2 = new Opportunity( Name = 'testOpp2', StageName = '引合', CloseDate = Date.today(), AccountId = depart1.Id, Competitor__c = 'B', Trade__c = '内貿', Wholesale_Price__c = 100, RecordType = rectOpp ); Opportunity opp3 = new Opportunity( Name = 'testOpp3', StageName = '引合', CloseDate = Date.today(), AccountId = depart2.Id, Competitor__c = 'C', Trade__c = '内貿', Wholesale_Price__c = 2000, RecordType = rectOpp ); Opportunity opp4 = new Opportunity( Name = 'testOpp4', StageName = '引合', CloseDate = Date.today(), AccountId = depart2.Id, Competitor__c = 'D', Trade__c = '外貿', Wholesale_Price__c = 200, RecordType = rectOpp ); Opportunity opp5 = new Opportunity( Name = 'testOpp5', StageName = '引合', CloseDate = Date.today(), AccountId = depart2.Id, Competitor__c = 'E', Trade__c = '外貿', Wholesale_Price__c = 300, RecordType = rectOpp ); Opportunity opp6 = new Opportunity( Name = 'testOpp6', StageName = '引合', CloseDate = Date.today(), AccountId = depart2.Id, Competitor__c = 'A', Trade__c = '内貿', Wholesale_Price__c = 100, RecordType = rectOpp ); StaticParameter.EscapeNFM007Trigger = true; insert new Opportunity[] {opp1, opp2, opp3, opp4, opp5, opp6}; System.Test.StartTest(); Id execBTId = Database.executeBatch(new RollupToHPBatch(null, null), 5); System.Test.StopTest(); Account2__c acc2dc1 = [select RANK_A_tax_HP__c, RANK_B_tax_HP__c, RANK_C_tax_HP__c, RANK_D_tax_HP__c, RANK_E_tax_HP__c, Forecast_Amount_HP__c, ShippedAmount_HP__c from Account2__c where Account_Org__c = :dc1.Id]; //System.assertEquals(1000, acc2dc1.RANK_A_tax_HP__c); //System.assertEquals(100, acc2dc1.RANK_B_tax_HP__c); Account2__c acc2dc2 = [select RANK_A_tax_HP__c, RANK_B_tax_HP__c, RANK_C_tax_HP__c, RANK_D_tax_HP__c, RANK_E_tax_HP__c, Forecast_Amount_HP__c, ShippedAmount_HP__c from Account2__c where Account_Org__c = :dc2.Id]; //System.assertEquals(2000, acc2dc2.RANK_C_tax_HP__c); //System.assertEquals(200, acc2dc2.RANK_D_tax_HP__c); //System.assertNotEquals(300, acc2dc2.RANK_E_tax_HP__c); Account2__c acc2company1 = [select RANK_A_tax_HP__c, RANK_B_tax_HP__c, RANK_C_tax_HP__c, RANK_D_tax_HP__c, RANK_E_tax_HP__c, Forecast_Amount_HP__c, ShippedAmount_HP__c from Account2__c where Account_Org__c = :company1.Id]; //System.assertEquals(1100, acc2company1.RANK_A_tax_HP__c); //System.assertEquals(100, acc2company1.RANK_B_tax_HP__c); //System.assertEquals(2000, acc2company1.RANK_C_tax_HP__c); //System.assertNotEquals(200, acc2company1.RANK_D_tax_HP__c); //System.assertNotEquals(300, acc2company1.RANK_E_tax_HP__c); } static testMethod void soakupNewTest() { ControllerUtil.EscapeNFM001Trigger = true; System.Test.StartTest(); Oly_TriggerHandler.bypass('PowerBIBaseHandler'); Profile p = [select Id from Profile where id = :System.Label.ProfileId_SystemAdmin]; // ユーザー作成 User hpOwner = new User(Test_staff__c = true, LastName = 'hp', FirstName = 'owner', Alias = 'hp', CommunityNickname = 'hpOwner', Email = 'olympus_hpowner@sunbridge.com', Username = 'olympus_hpowner@sunbridge.com', IsActive = true, EmailEncodingKey = 'ISO-2022-JP', TimeZoneSidKey = 'Asia/Tokyo', LocaleSidKey = 'ja_JP', LanguageLocaleKey = 'ja', ProfileId = p.id); insert hpOwner; // 取引先作成 List rectHp = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '病院']; if (rectHp.size() == 0) { return; } List rectDpt = [select Id, Name from RecordType where IsActive = true and SobjectType = 'Account' and Name IN ('診療科 消化科', '診療科 呼吸科') order by Name desc]; if (rectDpt.size() == 0) { return; } Address_Level__c addr1 = new Address_Level__c(); addr1.Name = '北京市'; addr1.OwnerId = hpOwner.Id; addr1.Level1_Code__c = 'CN-01'; Address_Level__c addr2 = new Address_Level__c(); addr2.Name = '河南省'; addr2.OwnerId = hpOwner.Id; addr2.Level1_Code__c = 'CN-03'; insert new Address_Level__c[] {addr1, addr2}; Account hp = new Account(RecordTypeId = rectHp[0].Id, Name = 'SoakupTestHp1', OwnerId = hpOwner.Id, State_Master__c = addr1.Id , FSE_GI_Main_Leader__c = UserInfo.getUserId(), FSE_SP_Main_Leader__c = UserInfo.getUserId()); //Account hp2 = new Account(RecordTypeId = rectHp[0].Id, Name = 'SoakupTestHp2', OwnerId = hpOwner.Id, State_Master__c = addr2.Id); //insert new Account[] {hp,hp2}; insert hp; List dcs = [Select Id, Name, Department_Class_Label__c from Account where Parent.Id = :hp.Id and Department_Class_Label__c in ('消化科', '呼吸科') order by Department_Class_Label__c]; Account depart1 = new Account(); depart1.RecordTypeId = rectDpt[0].Id; depart1.Name = '*'; depart1.Department_Name__c = '診療科1'; depart1.ParentId = dcs[0].Id; depart1.Department_Class__c = dcs[0].Id; depart1.Hospital__c = hp.Id; Account depart2 = new Account(); depart2.RecordTypeId = rectDpt[1].Id; depart2.Name = '*'; depart2.Department_Name__c = '診療科2'; depart2.ParentId = dcs[1].Id; depart2.Department_Class__c = dcs[1].Id; depart2.Hospital__c = hp.Id; insert new Account[] {depart1, depart2}; Product2 prd1 = new Product2(); prd1.ProductCode_Ext__c = 'Prd1'; prd1.ProductCode = 'Prd1'; prd1.Repair_Product_Code__c = 'Prd1_RP'; prd1.Name = 'Prd1'; prd1.Manual_Entry__c = false; prd1.Important_Rroduct_1GI__c = true; Product2 prd2 = new Product2(); prd2.ProductCode_Ext__c = 'prd2'; prd2.ProductCode = 'prd2'; prd2.Repair_Product_Code__c = 'prd2_RP'; prd2.Name = 'prd2'; prd2.Manual_Entry__c = false; prd2.Important_Rroduct_2GI__c = true; Product2 prd3 = new Product2(); prd3.ProductCode_Ext__c = 'prd3'; prd3.ProductCode = 'prd3'; prd3.Repair_Product_Code__c = 'prd3_RP'; prd3.Name = 'prd3'; prd3.Manual_Entry__c = false; prd3.Important_Rroduct_3GI__c = true; Product2 prd4 = new Product2(); prd4.ProductCode_Ext__c = 'prd4'; prd4.ProductCode = 'prd4'; prd4.Repair_Product_Code__c = 'prd4_RP'; prd4.Name = 'prd4'; prd4.Manual_Entry__c = false; prd4.Important_Rroduct_4GI__c = true; Product2 prd5 = new Product2(); prd5.ProductCode_Ext__c = 'prd5'; prd5.ProductCode = 'prd5'; prd5.Repair_Product_Code__c = 'prd5_RP'; prd5.Name = 'prd5'; prd5.Manual_Entry__c = false; prd5.Important_Rroduct_5GI__c = true; Product2 prd6 = new Product2(); prd6.ProductCode_Ext__c = 'prd6'; prd6.ProductCode = 'prd6'; prd6.Repair_Product_Code__c = 'prd6_RP'; prd6.Name = 'prd6'; prd6.Manual_Entry__c = false; prd6.Important_Rroduct_6GI__c = true; Product2 prd7 = new Product2(); prd7.ProductCode_Ext__c = 'prd7'; prd7.ProductCode = 'prd7'; prd7.Repair_Product_Code__c = 'prd7_RP'; prd7.Name = 'prd7'; prd7.Manual_Entry__c = false; prd7.Important_Rroduct_7GI__c = true; Product2 prd8 = new Product2(); prd8.ProductCode_Ext__c = 'prd8'; prd8.ProductCode = 'prd8'; prd8.Repair_Product_Code__c = 'prd8_RP'; prd8.Name = 'pprd8rd5'; prd8.Manual_Entry__c = false; prd8.Important_Rroduct_8GI__c = true; Product2 prd9 = new Product2(); prd9.ProductCode_Ext__c = 'prd9'; prd9.ProductCode = 'prd9'; prd9.Repair_Product_Code__c = 'prd9_RP'; prd9.Name = 'prd9'; prd9.Manual_Entry__c = false; prd9.Important_Rroduct_9GI__c = true; Product2 prd10 = new Product2(); prd10.ProductCode_Ext__c = 'prd10'; prd10.ProductCode = 'prd10'; prd10.Repair_Product_Code__c = 'prd10_RP'; prd10.Name = 'prd10'; prd10.Manual_Entry__c = false; prd10.Important_Rroduct_10GI__c = true; Product2 prd11 = new Product2(); prd11.ProductCode_Ext__c = 'prd11'; prd11.ProductCode = 'prd11'; prd11.Repair_Product_Code__c = 'prd11_RP'; prd11.Name = 'prd11'; prd11.Manual_Entry__c = false; prd11.Important_Rroduct_11GI__c = true; Product2 prd12 = new Product2(); prd12.ProductCode_Ext__c = 'prd12'; prd12.ProductCode = 'prd12'; prd12.Repair_Product_Code__c = 'prd12_RP'; prd12.Name = 'prd12'; prd12.Manual_Entry__c = false; prd12.Important_Rroduct_12GI__c = true; Product2 prd13 = new Product2(); prd13.ProductCode_Ext__c = 'prd13'; prd13.ProductCode = 'prd13'; prd13.Repair_Product_Code__c = 'prd13_RP'; prd13.Name = 'prd13'; prd13.Manual_Entry__c = false; prd13.Important_Rroduct_13GI__c = true; Product2 prd14 = new Product2(); prd14.ProductCode_Ext__c = 'prd14'; prd14.ProductCode = 'prd14'; prd14.Repair_Product_Code__c = 'prd14_RP'; prd14.Name = 'prd14'; prd14.Manual_Entry__c = false; prd14.Important_Rroduct_14GI__c = true; Product2 prd15 = new Product2(); prd15.ProductCode_Ext__c = 'prd15'; prd15.ProductCode = 'prd15'; prd15.Repair_Product_Code__c = 'prd15_RP'; prd15.Name = 'prd15'; prd15.Manual_Entry__c = false; prd15.Important_Rroduct_15GI__c = true; Product2 prd16 = new Product2(); prd16.ProductCode_Ext__c = 'prd16'; prd16.ProductCode = 'prd16'; prd16.Repair_Product_Code__c = 'prd16_RP'; prd16.Name = 'prd16'; prd16.Manual_Entry__c = false; prd16.Important_Rroduct_16GI__c = true; Product2 prd17 = new Product2(); prd17.ProductCode_Ext__c = 'prd17'; prd17.ProductCode = 'prd17'; prd17.Repair_Product_Code__c = 'prd17_RP'; prd17.Name = 'prd17'; prd17.Manual_Entry__c = false; prd17.Important_Rroduct_17GI__c = true; Product2 prd18 = new Product2(); prd18.ProductCode_Ext__c = 'prd18'; prd18.ProductCode = 'prd18'; prd18.Repair_Product_Code__c = 'prd18_RP'; prd18.Name = 'prd18'; prd18.Manual_Entry__c = false; prd18.Important_Rroduct_18GI__c = true; Product2 prd19 = new Product2(); prd19.ProductCode_Ext__c = 'prd19'; prd19.ProductCode = 'prd19'; prd19.Repair_Product_Code__c = 'prd19_RP'; prd19.Name = 'prd19'; prd19.Manual_Entry__c = false; prd19.Important_Rroduct_19GI__c = true; Product2 prd20 = new Product2(); prd20.ProductCode_Ext__c = 'prd20'; prd20.ProductCode = 'prd20'; prd20.Repair_Product_Code__c = 'prd20_RP'; prd20.Name = 'prd20'; prd20.Manual_Entry__c = false; prd20.Important_Rroduct_20GI__c = true; insert new Product2[] {prd1, prd2, prd3, prd4, prd5, prd6, prd7, prd8, prd9, prd10, prd11, prd12, prd13, prd14, prd15, prd16, prd17, prd18, prd19, prd20 }; System.Test.StopTest(); Daily_Report__c dr1 = new Daily_Report__c(); dr1.Reporter__c = UserInfo.getUserId(); dr1.Reported_Date__c = date.today(); dr1.Status__c = '申請中'; Daily_Report__c dr2 = new Daily_Report__c(); dr2.Reporter__c = UserInfo.getUserId(); dr2.Reported_Date__c = date.today().addDays(-1); dr2.Status__c = '申請中'; Daily_Report__c dr3 = new Daily_Report__c(); dr3.Reporter__c = UserInfo.getUserId(); dr3.Reported_Date__c = date.today().addDays(-2); dr3.Status__c = '申請中'; Daily_Report__c dr4 = new Daily_Report__c(); dr4.Reporter__c = UserInfo.getUserId(); dr4.Reported_Date__c = date.today().addDays(-3); dr4.Status__c = '申請中'; insert new Daily_Report__c[] {dr1, dr2, dr3, dr4}; Report__c rep1 = new Report__c(); rep1.CurrencyIsoCode = 'CNY'; rep1.RecordTypeId = '01210000000QekjAAC'; rep1.Status__c = '批准'; rep1.Daily_Report__c = dr1.Id; rep1.Purpose1__c = 'OPD'; rep1.Purpose2__c = '引合追及活動'; rep1.Reason__c = '実施背景'; rep1.Appeal_Point__c = '実施目的・訴求点'; rep1.Strategic_Department_Class__c = '1.消化科'; rep1.Technical_Category1__c = '消化道检查'; rep1.Technical_Category2__c = '普通胃镜检查'; rep1.Patient_Status__c = '患者状況'; rep1.OPD_ProductCategory1__c = '3D System'; rep1.OPD_ProductCategory2__c = 'NBI-170'; rep1.Operation_Process__c = '手術プロセス'; rep1.Operation_Task__c = '手術上の課題'; rep1.Product_Evaluation_Advantage__c = '製品評価利点'; rep1.Product_Evaluation_Faults__c = '製品評価欠点'; rep1.OPD_Summarize__c = 'OPD実施総括'; rep1.Activity_Plan__c = '今後の活動計画'; rep1.Opportunity_Situation__c = '引合無'; rep1.Hospital_Reference__c = hp.Id; rep1.Department_Class_Ref__c = dcs[0].Id; rep1.Hospital_Department__c = depart1.Id; rep1.Product1__c = prd1.Id; rep1.Product2__c = prd2.Id; rep1.Product3__c = prd3.Id; rep1.Product4__c = prd4.Id; rep1.Product5__c = prd5.Id; rep1.Date__c = targetToday.addDays(-1); Report__c rep2 = new Report__c(); rep2.CurrencyIsoCode = 'CNY'; rep2.RecordTypeId = '01210000000QekjAAC'; rep2.Status__c = '批准'; rep2.Daily_Report__c = dr2.Id; rep2.Purpose1__c = 'OPD'; rep2.OPD_ProductCategory1__c = 'NBI-290'; rep2.OPD_ProductCategory2__c = 'OR Imaging Products'; rep2.Purpose2__c = '引合追及活動'; rep2.Reason__c = '実施背景'; rep2.Appeal_Point__c = '実施目的・訴求点'; rep2.Strategic_Department_Class__c = '1.消化科'; rep2.Technical_Category1__c = '消化道检查'; rep2.Technical_Category2__c = '普通胃镜检查'; rep2.Patient_Status__c = '患者状況'; rep2.Operation_Process__c = '手術プロセス'; rep2.Operation_Task__c = '手術上の課題'; rep2.Product_Evaluation_Advantage__c = '製品評価利点'; rep2.Product_Evaluation_Faults__c = '製品評価欠点'; rep2.OPD_Summarize__c = 'OPD実施総括'; rep2.Activity_Plan__c = '今後の活動計画'; rep2.Opportunity_Situation__c = '引合無'; rep2.Hospital_Reference__c = hp.Id; rep2.Department_Class_Ref__c = dcs[0].Id; rep2.Hospital_Department__c = depart1.Id; rep2.Product1__c = prd6.Id; rep2.Product2__c = prd7.Id; rep2.Product3__c = prd8.Id; rep2.Product4__c = prd9.Id; rep2.Product5__c = prd10.Id; rep2.Date__c = targetToday.addDays(-1); Report__c rep3 = new Report__c(); rep3.CurrencyIsoCode = 'CNY'; rep3.RecordTypeId = '01210000000QekjAAC'; rep3.Status__c = '提交'; rep3.Daily_Report__c = dr3.Id; rep3.Purpose1__c = 'OPD'; rep3.Purpose2__c = '引合追及活動'; rep3.Reason__c = '実施背景'; rep3.Appeal_Point__c = '実施目的・訴求点'; rep3.Strategic_Department_Class__c = '1.消化科'; rep3.Technical_Category1__c = '消化道检查'; rep3.Technical_Category2__c = '普通胃镜检查'; rep3.OPD_ProductCategory1__c = 'EUS'; rep3.OPD_ProductCategory2__c = 'EBUS'; rep3.Patient_Status__c = '患者状況'; rep3.Operation_Process__c = '手術プロセス'; rep3.Operation_Task__c = '手術上の課題'; rep3.Product_Evaluation_Advantage__c = '製品評価利点'; rep3.Product_Evaluation_Faults__c = '製品評価欠点'; rep3.OPD_Summarize__c = 'OPD実施総括'; rep3.Activity_Plan__c = '今後の活動計画'; rep3.Opportunity_Situation__c = '引合無'; rep3.Hospital_Reference__c = hp.Id; rep3.Department_Class_Ref__c = dcs[0].Id; rep3.Hospital_Department__c = depart1.Id; rep3.Product1__c = prd11.Id; rep3.Product2__c = prd12.Id; rep3.Product3__c = prd13.Id; rep3.Product4__c = prd14.Id; rep3.Product5__c = prd15.Id; rep3.Date__c = targetToday.addDays(-1); Report__c rep4 = new Report__c(); rep4.CurrencyIsoCode = 'CNY'; rep4.RecordTypeId = '01210000000QekjAAC'; rep4.Status__c = '提交'; rep4.Daily_Report__c = dr4.Id; rep4.Purpose1__c = 'OPD'; rep4.Purpose2__c = '引合追及活動'; rep4.Reason__c = '実施背景'; rep4.Appeal_Point__c = '実施目的・訴求点'; rep4.Strategic_Department_Class__c = '1.消化科'; rep4.Technical_Category1__c = '消化道检查'; rep4.Technical_Category2__c = '普通胃镜检查'; rep4.Patient_Status__c = '患者状況'; rep4.OPD_ProductCategory1__c = 'OTV-S190'; rep4.OPD_ProductCategory2__c = 'STMS'; rep4.Operation_Process__c = '手術プロセス'; rep4.Operation_Task__c = '手術上の課題'; rep4.Product_Evaluation_Advantage__c = '製品評価利点'; rep4.Product_Evaluation_Faults__c = '製品評価欠点'; rep4.OPD_Summarize__c = 'OPD実施総括'; rep4.Activity_Plan__c = '今後の活動計画'; rep4.Opportunity_Situation__c = '引合無'; rep4.Hospital_Reference__c = hp.Id; rep4.Department_Class_Ref__c = dcs[1].Id; rep4.Hospital_Department__c = depart2.Id; rep4.Product1__c = prd16.Id; rep4.Product2__c = prd17.Id; rep4.Product3__c = prd18.Id; rep4.Product4__c = prd19.Id; rep4.Product5__c = prd20.Id; rep4.Date__c = targetToday.addDays(-1); Report__c rep6 = new Report__c(); rep6.CurrencyIsoCode = 'CNY'; rep6.RecordTypeId = '01210000000QekjAAC'; rep6.Status__c = '提交'; rep6.Daily_Report__c = dr4.Id; rep6.Purpose1__c = 'OPD'; rep6.Purpose2__c = '引合追及活動'; rep6.Reason__c = '実施背景'; rep6.Appeal_Point__c = '実施目的・訴求点'; rep6.Strategic_Department_Class__c = '1.消化科'; rep6.Technical_Category1__c = '消化道检查'; rep6.Technical_Category2__c = '普通胃镜检查'; rep6.Patient_Status__c = '患者状況'; rep6.OPD_ProductCategory1__c = 'CYF'; rep6.OPD_ProductCategory2__c = 'ERCP(含导丝)'; rep6.Operation_Process__c = '手術プロセス'; rep6.Operation_Task__c = '手術上の課題'; rep6.Product_Evaluation_Advantage__c = '製品評価利点'; rep6.Product_Evaluation_Faults__c = '製品評価欠点'; rep6.OPD_Summarize__c = 'OPD実施総括'; rep6.Activity_Plan__c = '今後の活動計画'; rep6.Opportunity_Situation__c = '引合無'; rep6.Hospital_Reference__c = hp.Id; rep6.Department_Class_Ref__c = dcs[1].Id; rep6.Hospital_Department__c = depart2.Id; rep6.Product1__c = prd16.Id; rep6.Product2__c = prd17.Id; rep6.Product3__c = prd18.Id; rep6.Product4__c = prd19.Id; rep6.Product5__c = prd20.Id; rep6.Date__c = targetToday.addDays(-2); Report__c rep5 = new Report__c(); rep5.Daily_Report__c = dr1.Id; rep5.RecordTypeId = '01210000000QekoAAC'; rep5.Manual_Name__c = 'test hospital3'; rep5.Status__c = '提交'; rep5.Hospital_Reference__c = hp.Id; rep5.Department_Class_Ref__c = dcs[0].Id; rep5.Hospital_Department__c = depart1.Id; rep5.Date__c = targetToday.addDays(-1); rep5.From__c = targetToday; rep5.OPD_ProductCategory1__c = '3D System'; rep5.OPD_ProductCategory2__c = 'OR Imaging Products'; rep5.To__c = targetToday.addDays(1); rep5.Caller_phone_c__c = '123456789'; rep5.Content__c = '①使用方法'; rep5.Detailed_Report__c = 'test'; rep5.Location__c = 'test'; rep5.NTC_TTC_Select__c = 'NTC'; rep5.Product_Category_for_NTC__c = 'test'; rep5.Purpose_Of_Implementation__c = 'test'; rep5.Reason__c = 'test'; rep5.Responsible_Person_HP_c__c = 'test'; rep5.Use_Materials__c = 'test'; rep5.Date__c = targetToday.addYears(-1).addDays(-1); insert new Report__c[] {rep1, rep2, rep3, rep4, rep5, rep6}; Daily_Report__c dr = new Daily_Report__c(); dr.Reporter__c = UserInfo.getUserId(); dr.Daily_Report_Key__c = 'key'; dr.Reported_Date__c = date.today().addDays(-1); dr.Reporter__c = hpOwner.id; dr.Status__c = '申請中'; insert dr; Event__c event1 = new Event__c(); event1.Account_ID__c = depart1.Id; event1.ActivityDate__c = targetToday.addDays(-1); event1.Daily_Report__c = dr.Id; event1.StartDateTime__c = targetNow.addHours(-5); event1.EndDateTime__c = targetNow.addHours(-4); Event__c event2 = new Event__c(); event2.Account_ID__c = depart1.Id; event2.ActivityDate__c = targetToday.addDays(-1); event2.Daily_Report__c = dr.Id; event2.StartDateTime__c = targetNow.addHours(-4); event2.EndDateTime__c = targetNow.addHours(-3); Event__c event3 = new Event__c(); event3.Account_ID__c = depart1.Id; event3.ActivityDate__c = targetToday.addDays(-1); event3.Daily_Report__c = dr.Id; event3.StartDateTime__c = targetNow.addHours(-4); event3.EndDateTime__c = targetNow.addHours(-2); Event__c event4 = new Event__c(); event4.Account_ID__c = depart2.Id; event4.ActivityDate__c = targetToday.addDays(-1); event4.Daily_Report__c = dr.Id; event4.StartDateTime__c = targetNow.addHours(-2); event4.EndDateTime__c = targetNow.addHours(-1); Event__c event5 = new Event__c(); event5.Account_ID__c = depart2.Id; event5.ActivityDate__c = targetToday.addDays(-1); event5.Daily_Report__c = dr.Id; event5.StartDateTime__c = targetNow.addHours(-1); event5.EndDateTime__c = targetNow; insert new Event__c[] {event1, event2, event3, event4, event5}; Maintenance_Contract__c mc1 = new Maintenance_Contract__c(); mc1.Name = 'mc1'; mc1.Past_update_contract__c = true; mc1.RecordTypeId = '01210000000QjeFAAS'; mc1.CurrencyIsoCode = 'CNY'; mc1.Status__c = '契約'; mc1.Hospital__c = hp.Id; mc1.Department_Class__c = dcs[0].Id; mc1.Department__c = depart1.Id; mc1.Maintenance_Contract_No__c = 'mc1'; mc1.Contract_Conclusion_Date__c = Date.today(); mc1.Contract_End_Date__c = Date.today().addDays(1); mc1.SalesOfficeCode_selection__c = '北京RC'; Maintenance_Contract__c mc2 = new Maintenance_Contract__c(); mc2.Name = 'mc2'; mc2.Past_update_contract__c = true; mc2.RecordTypeId = '01210000000QjeFAAS'; mc2.CurrencyIsoCode = 'CNY'; mc2.Status__c = '契約'; mc2.Hospital__c = hp.Id; mc2.Department_Class__c = dcs[0].Id; mc2.Department__c = depart1.Id; mc2.Maintenance_Contract_No__c = 'mc2'; mc2.Contract_Conclusion_Date__c = Date.today(); mc2.Contract_End_Date__c = Date.today().addDays(1); mc2.SalesOfficeCode_selection__c = '北京RC'; Maintenance_Contract__c mc3 = new Maintenance_Contract__c(); mc3.Name = 'mc3'; mc3.Past_update_contract__c = true; mc3.RecordTypeId = '01210000000QjeFAAS'; mc3.CurrencyIsoCode = 'CNY'; mc3.Status__c = '契約'; mc3.Hospital__c = hp.Id; mc3.Department_Class__c = dcs[1].Id; mc3.Department__c = depart2.Id; mc3.Maintenance_Contract_No__c = 'mc3'; mc3.Contract_Conclusion_Date__c = Date.today(); mc3.Contract_End_Date__c = Date.today().addDays(1); mc3.SalesOfficeCode_selection__c = '北京RC'; insert new Maintenance_Contract__c[] {mc1, mc2, mc3}; Contact cont1 = new Contact(); cont1.FirstName = 'FirstName1'; cont1.LastName = 'LastName1'; cont1.Number_of_participant_for_TTC__c = 1; cont1.HCP__c = '学術HCP'; cont1.Strategic_dept_Class__c = dcs[0].Id; Contact cont2 = new Contact(); cont2.FirstName = 'FirstName2'; cont2.LastName = 'LastName2'; cont2.Number_of_participant_for_TTC__c = 2; cont2.HCP__c = '製品HCP'; cont2.Strategic_dept_Class__c = dcs[0].Id; Contact cont3 = new Contact(); cont3.FirstName = 'FirstName3'; cont3.LastName = 'LastName3'; cont3.Number_of_participant_for_TTC__c = 4; cont3.HCP__c = '一般HCP'; cont3.Strategic_dept_Class__c = dcs[1].Id; insert new Contact[] {cont1, cont2, cont3}; Integer targetmonth = targetToday.addDays(-1).month(); //System.Test.StartTest(); Id execBTId = Database.executeBatch(new RollupToHPBatch('1.华北', '2.东北'), 1); /* Account2__c[] hps = [select id,Name,Service_contract_active_number_HP__c,Sum_Number_of_participant_for_TTC__c,Academic_HCP_Count__c,Product_HCP_Count__c,General_HCP_Count__c, Important_product1__c,Important_product2__c,Important_product3__c,Important_product4__c,Important_product5__c, Important_product6__c,Important_product7__c,Important_product8__c,Important_product9__c,Important_product10__c, Important_product11__c,Important_product12__c,Important_product13__c,Important_product14__c,Important_product15__c, Important_product16__c,Important_product17__c,Important_product18__c,Important_product19__c,Important_product20__c, ThisYear1__c,ThisYear2__c,ThisYear3__c,ThisYear4__c,ThisYear5__c,ThisYear6__c, ThisYear7__c,ThisYear8__c,ThisYear9__c,ThisYear10__c,ThisYear11__c,ThisYear12__c, DoNTCHospital_ThisYear1__c,DoNTCHospital_ThisYear2__c,DoNTCHospital_ThisYear3__c,DoNTCHospital_ThisYear4__c,DoNTCHospital_ThisYear5__c,DoNTCHospital_ThisYear6__c, DoNTCHospital_ThisYear7__c,DoNTCHospital_ThisYear8__c,DoNTCHospital_ThisYear9__c,DoNTCHospital_ThisYear10__c,DoNTCHospital_ThisYear11__c,DoNTCHospital_ThisYear12__c, DoOPDHospital_ThisYear1__c,DoOPDHospital_ThisYear2__c,DoOPDHospital_ThisYear3__c,DoOPDHospital_ThisYear4__c,DoOPDHospital_ThisYear5__c,DoOPDHospital_ThisYear6__c, DoOPDHospital_ThisYear7__c,DoOPDHospital_ThisYear8__c,DoOPDHospital_ThisYear9__c,DoOPDHospital_ThisYear10__c,DoOPDHospital_ThisYear11__c,DoOPDHospital_ThisYear12__c from Account2__c where Account_Org__c = :hp.Id and Account_Org__r.RecordType.Name = '病院' order by Name]; System.assertEquals(1, hps[0].Important_product1__c); System.assertEquals(1, hps[0].Important_product2__c); System.assertEquals(1, hps[0].Important_product3__c); System.assertEquals(1, hps[0].Important_product4__c); System.assertEquals(1, hps[0].Important_product5__c); System.assertEquals(1, hps[0].Important_product6__c); System.assertEquals(1, hps[0].Important_product7__c); System.assertEquals(1, hps[0].Important_product8__c); System.assertEquals(1, hps[0].Important_product9__c); System.assertEquals(1, hps[0].Important_product10__c); System.assertEquals(1, hps[0].Important_product11__c); System.assertEquals(1, hps[0].Important_product12__c); System.assertEquals(1, hps[0].Important_product13__c); System.assertEquals(1, hps[0].Important_product14__c); System.assertEquals(1, hps[0].Important_product15__c); System.assertEquals(1, hps[0].Important_product16__c); System.assertEquals(1, hps[0].Important_product17__c); System.assertEquals(1, hps[0].Important_product18__c); System.assertEquals(1, hps[0].Important_product19__c); System.assertEquals(1, hps[0].Important_product20__c); System.assertEquals(3, hps[0].Service_contract_active_number_HP__c); System.assertEquals(7, hps[0].Sum_Number_of_participant_for_TTC__c); System.assertEquals(1, hps[0].Academic_HCP_Count__c); System.assertEquals(1, hps[0].Product_HCP_Count__c); System.assertEquals(1, hps[0].General_HCP_Count__c); if (targetmonth == 1) { System.assertEquals(5, hps[0].ThisYear1__c); System.assertEquals(1, hps[0].DoNTCHospital_ThisYear1__c); System.assertEquals(4, hps[0].DoOPDHospital_ThisYear1__c); } if (targetmonth == 2) { System.assertEquals(5, hps[0].ThisYear2__c); System.assertEquals(1, hps[0].DoNTCHospital_ThisYear2__c); System.assertEquals(4, hps[0].DoOPDHospital_ThisYear2__c); } if (targetmonth == 3) { System.assertEquals(5, hps[0].ThisYear3__c); System.assertEquals(1, hps[0].DoNTCHospital_ThisYear3__c); System.assertEquals(4, hps[0].DoOPDHospital_ThisYear3__c); } if (targetmonth == 4) { System.assertEquals(5, hps[0].ThisYear4__c); System.assertEquals(1, hps[0].DoNTCHospital_ThisYear4__c); System.assertEquals(4, hps[0].DoOPDHospital_ThisYear4__c); } if (targetmonth == 5) { System.assertEquals(5, hps[0].ThisYear5__c); System.assertEquals(1, hps[0].DoNTCHospital_ThisYear5__c); System.assertEquals(4, hps[0].DoOPDHospital_ThisYear5__c); } if (targetmonth == 6) { System.assertEquals(5, hps[0].ThisYear6__c); System.assertEquals(1, hps[0].DoNTCHospital_ThisYear6__c); System.assertEquals(4, hps[0].DoOPDHospital_ThisYear6__c); } if (targetmonth == 7) { System.assertEquals(5, hps[0].ThisYear7__c); System.assertEquals(1, hps[0].DoNTCHospital_ThisYear7__c); System.assertEquals(4, hps[0].DoOPDHospital_ThisYear7__c); } if (targetmonth == 8) { System.assertEquals(5, hps[0].ThisYear8__c); System.assertEquals(1, hps[0].DoNTCHospital_ThisYear8__c); System.assertEquals(4, hps[0].DoOPDHospital_ThisYear8__c); } if (targetmonth == 9) { System.assertEquals(5, hps[0].ThisYear9__c); System.assertEquals(1, hps[0].DoNTCHospital_ThisYear9__c); System.assertEquals(4, hps[0].DoOPDHospital_ThisYear9__c); } if (targetmonth == 10) { System.assertEquals(5, hps[0].ThisYear10__c); System.assertEquals(1, hps[0].DoNTCHospital_ThisYear10__c); System.assertEquals(4, hps[0].DoOPDHospital_ThisYear10__c); } if (targetmonth == 11) { System.assertEquals(5, hps[0].ThisYear11__c); System.assertEquals(1, hps[0].DoNTCHospital_ThisYear11__c); System.assertEquals(4, hps[0].DoOPDHospital_ThisYear11__c); } if (targetmonth == 12) { System.assertEquals(5, hps[0].ThisYear12__c); System.assertEquals(1, hps[0].DoNTCHospital_ThisYear12__c); System.assertEquals(4, hps[0].DoOPDHospital_ThisYear12__c); } Account2__c[] dcs1 = [select id,Name,Service_contract_active_number_HP__c,Sum_Number_of_participant_for_TTC__c,Academic_HCP_Count__c,Product_HCP_Count__c,General_HCP_Count__c, Important_product1__c,Important_product2__c,Important_product3__c,Important_product4__c,Important_product5__c, Important_product6__c,Important_product7__c,Important_product8__c,Important_product9__c,Important_product10__c, Important_product11__c,Important_product12__c,Important_product13__c,Important_product14__c,Important_product15__c, Important_product16__c,Important_product17__c,Important_product18__c,Important_product19__c,Important_product20__c, ThisYear1__c,ThisYear2__c,ThisYear3__c,ThisYear4__c,ThisYear5__c,ThisYear6__c, ThisYear7__c,ThisYear8__c,ThisYear9__c,ThisYear10__c,ThisYear11__c,ThisYear12__c, DoNTCHospital_ThisYear1__c,DoNTCHospital_ThisYear2__c,DoNTCHospital_ThisYear3__c,DoNTCHospital_ThisYear4__c,DoNTCHospital_ThisYear5__c,DoNTCHospital_ThisYear6__c, DoNTCHospital_ThisYear7__c,DoNTCHospital_ThisYear8__c,DoNTCHospital_ThisYear9__c,DoNTCHospital_ThisYear10__c,DoNTCHospital_ThisYear11__c,DoNTCHospital_ThisYear12__c, DoOPDHospital_ThisYear1__c,DoOPDHospital_ThisYear2__c,DoOPDHospital_ThisYear3__c,DoOPDHospital_ThisYear4__c,DoOPDHospital_ThisYear5__c,DoOPDHospital_ThisYear6__c, DoOPDHospital_ThisYear7__c,DoOPDHospital_ThisYear8__c,DoOPDHospital_ThisYear9__c,DoOPDHospital_ThisYear10__c,DoOPDHospital_ThisYear11__c,DoOPDHospital_ThisYear12__c from Account2__c where Account_Org__r.ParentId = :hp.Id and Account_Org__r.Department_Class_Label__c in ('消化科', '呼吸科') order by Account_Org__r.Department_Class_Label__c]; System.assertEquals(1, dcs1[0].Important_product1__c); System.assertEquals(1, dcs1[0].Important_product2__c); System.assertEquals(1, dcs1[0].Important_product3__c); System.assertEquals(1, dcs1[0].Important_product4__c); System.assertEquals(1, dcs1[0].Important_product5__c); System.assertEquals(1, dcs1[0].Important_product6__c); System.assertEquals(1, dcs1[0].Important_product7__c); System.assertEquals(1, dcs1[0].Important_product8__c); System.assertEquals(1, dcs1[0].Important_product9__c); System.assertEquals(1, dcs1[0].Important_product10__c); System.assertEquals(1, dcs1[0].Important_product11__c); System.assertEquals(1, dcs1[0].Important_product12__c); System.assertEquals(1, dcs1[0].Important_product13__c); System.assertEquals(1, dcs1[0].Important_product14__c); System.assertEquals(1, dcs1[0].Important_product15__c); System.assertEquals(0, dcs1[0].Important_product16__c); System.assertEquals(0, dcs1[0].Important_product17__c); System.assertEquals(0, dcs1[0].Important_product18__c); System.assertEquals(0, dcs1[0].Important_product19__c); System.assertEquals(0, dcs1[0].Important_product20__c); System.assertEquals(2, dcs1[0].Service_contract_active_number_HP__c); System.assertEquals(3, dcs1[0].Sum_Number_of_participant_for_TTC__c); System.assertEquals(1, dcs1[0].Academic_HCP_Count__c); System.assertEquals(1, dcs1[0].Product_HCP_Count__c); System.assertEquals(0, dcs1[0].General_HCP_Count__c); if (targetmonth == 1) { System.assertEquals(3, dcs1[0].ThisYear1__c); System.assertEquals(1, dcs1[0].DoNTCHospital_ThisYear1__c); System.assertEquals(3, dcs1[0].DoOPDHospital_ThisYear1__c); } if (targetmonth == 2) { System.assertEquals(3, dcs1[0].ThisYear2__c); System.assertEquals(1, dcs1[0].DoNTCHospital_ThisYear2__c); System.assertEquals(3, dcs1[0].DoOPDHospital_ThisYear2__c); } if (targetmonth == 3) { System.assertEquals(3, dcs1[0].ThisYear3__c); System.assertEquals(1, dcs1[0].DoNTCHospital_ThisYear3__c); System.assertEquals(3, dcs1[0].DoOPDHospital_ThisYear3__c); } if (targetmonth == 4) { System.assertEquals(3, dcs1[0].ThisYear4__c); System.assertEquals(1, dcs1[0].DoNTCHospital_ThisYear4__c); System.assertEquals(3, dcs1[0].DoOPDHospital_ThisYear4__c); } if (targetmonth == 5) { System.assertEquals(3, dcs1[0].ThisYear5__c); System.assertEquals(1, dcs1[0].DoNTCHospital_ThisYear5__c); System.assertEquals(3, dcs1[0].DoOPDHospital_ThisYear5__c); } if (targetmonth == 6) { System.assertEquals(3, dcs1[0].ThisYear6__c); System.assertEquals(1, dcs1[0].DoNTCHospital_ThisYear6__c); System.assertEquals(3, dcs1[0].DoOPDHospital_ThisYear6__c); } if (targetmonth == 7) { System.assertEquals(3, dcs1[0].ThisYear7__c); System.assertEquals(1, dcs1[0].DoNTCHospital_ThisYear7__c); System.assertEquals(3, dcs1[0].DoOPDHospital_ThisYear7__c); } if (targetmonth == 8) { System.assertEquals(3, dcs1[0].ThisYear8__c); System.assertEquals(1, dcs1[0].DoNTCHospital_ThisYear8__c); System.assertEquals(3, dcs1[0].DoOPDHospital_ThisYear8__c); } if (targetmonth == 9) { System.assertEquals(3, dcs1[0].ThisYear9__c); System.assertEquals(1, dcs1[0].DoNTCHospital_ThisYear9__c); System.assertEquals(3, dcs1[0].DoOPDHospital_ThisYear9__c); } if (targetmonth == 10) { System.assertEquals(3, dcs1[0].ThisYear10__c); System.assertEquals(1, dcs1[0].DoNTCHospital_ThisYear10__c); System.assertEquals(3, dcs1[0].DoOPDHospital_ThisYear10__c); } if (targetmonth == 11) { System.assertEquals(3, dcs1[0].ThisYear11__c); System.assertEquals(1, dcs1[0].DoNTCHospital_ThisYear11__c); System.assertEquals(3, dcs1[0].DoOPDHospital_ThisYear11__c); } if (targetmonth == 12) { System.assertEquals(3, dcs1[0].ThisYear12__c); System.assertEquals(1, dcs1[0].DoNTCHospital_ThisYear12__c); System.assertEquals(3, dcs1[0].DoOPDHospital_ThisYear12__c); } System.assertEquals(0, dcs1[1].Important_product1__c); System.assertEquals(0, dcs1[1].Important_product2__c); System.assertEquals(0, dcs1[1].Important_product3__c); System.assertEquals(0, dcs1[1].Important_product4__c); System.assertEquals(0, dcs1[1].Important_product5__c); System.assertEquals(0, dcs1[1].Important_product6__c); System.assertEquals(0, dcs1[1].Important_product7__c); System.assertEquals(0, dcs1[1].Important_product8__c); System.assertEquals(0, dcs1[1].Important_product9__c); System.assertEquals(0, dcs1[1].Important_product10__c); System.assertEquals(0, dcs1[1].Important_product11__c); System.assertEquals(0, dcs1[1].Important_product12__c); System.assertEquals(0, dcs1[1].Important_product13__c); System.assertEquals(0, dcs1[1].Important_product14__c); System.assertEquals(0, dcs1[1].Important_product15__c); System.assertEquals(1, dcs1[1].Important_product16__c); System.assertEquals(1, dcs1[1].Important_product17__c); System.assertEquals(1, dcs1[1].Important_product18__c); System.assertEquals(1, dcs1[1].Important_product19__c); System.assertEquals(1, dcs1[1].Important_product20__c); System.assertEquals(1, dcs1[1].Service_contract_active_number_HP__c); System.assertEquals(4, dcs1[1].Sum_Number_of_participant_for_TTC__c); System.assertEquals(0, dcs1[1].Academic_HCP_Count__c); System.assertEquals(0, dcs1[1].Product_HCP_Count__c); System.assertEquals(1, dcs1[1].General_HCP_Count__c); if (targetmonth == 1) { System.assertEquals(2, dcs1[1].ThisYear1__c); System.assertEquals(0, dcs1[1].DoNTCHospital_ThisYear1__c); System.assertEquals(1, dcs1[1].DoOPDHospital_ThisYear1__c); } if (targetmonth == 2) { System.assertEquals(2, dcs1[1].ThisYear2__c); System.assertEquals(0, dcs1[1].DoNTCHospital_ThisYear2__c); System.assertEquals(1, dcs1[1].DoOPDHospital_ThisYear2__c); } if (targetmonth == 3) { System.assertEquals(2, dcs1[1].ThisYear3__c); System.assertEquals(0, dcs1[1].DoNTCHospital_ThisYear3__c); System.assertEquals(1, dcs1[1].DoOPDHospital_ThisYear3__c); } if (targetmonth == 4) { System.assertEquals(2, dcs1[1].ThisYear4__c); System.assertEquals(0, dcs1[1].DoNTCHospital_ThisYear4__c); System.assertEquals(1, dcs1[1].DoOPDHospital_ThisYear4__c); } if (targetmonth == 5) { System.assertEquals(2, dcs1[1].ThisYear5__c); System.assertEquals(0, dcs1[1].DoNTCHospital_ThisYear5__c); System.assertEquals(1, dcs1[1].DoOPDHospital_ThisYear5__c); } if (targetmonth == 6) { System.assertEquals(2, dcs1[1].ThisYear6__c); System.assertEquals(0, dcs1[1].DoNTCHospital_ThisYear6__c); System.assertEquals(1, dcs1[1].DoOPDHospital_ThisYear6__c); } if (targetmonth == 7) { System.assertEquals(2, dcs1[1].ThisYear7__c); System.assertEquals(0, dcs1[1].DoNTCHospital_ThisYear7__c); System.assertEquals(1, dcs1[1].DoOPDHospital_ThisYear7__c); } if (targetmonth == 8) { System.assertEquals(2, dcs1[1].ThisYear8__c); System.assertEquals(0, dcs1[1].DoNTCHospital_ThisYear8__c); System.assertEquals(1, dcs1[1].DoOPDHospital_ThisYear8__c); } if (targetmonth == 9) { System.assertEquals(2, dcs1[1].ThisYear9__c); System.assertEquals(0, dcs1[1].DoNTCHospital_ThisYear9__c); System.assertEquals(1, dcs1[1].DoOPDHospital_ThisYear9__c); } if (targetmonth == 10) { System.assertEquals(2, dcs1[1].ThisYear10__c); System.assertEquals(0, dcs1[1].DoNTCHospital_ThisYear10__c); System.assertEquals(1, dcs1[1].DoOPDHospital_ThisYear10__c); } if (targetmonth == 11) { System.assertEquals(2, dcs1[1].ThisYear11__c); System.assertEquals(0, dcs1[1].DoNTCHospital_ThisYear11__c); System.assertEquals(1, dcs1[1].DoOPDHospital_ThisYear11__c); } if (targetmonth == 12) { System.assertEquals(2, dcs1[1].ThisYear12__c); System.assertEquals(0, dcs1[1].DoNTCHospital_ThisYear12__c); System.assertEquals(1, dcs1[1].DoOPDHospital_ThisYear12__c); } Account2__c[] hp2s = [select id,Name,Service_contract_active_number_HP__c, Important_product1__c,Important_product2__c,Important_product3__c,Important_product4__c,Important_product5__c, Important_product6__c,Important_product7__c,Important_product8__c,Important_product9__c,Important_product10__c, Important_product11__c,Important_product12__c,Important_product13__c,Important_product14__c,Important_product15__c, Important_product16__c,Important_product17__c,Important_product18__c,Important_product19__c,Important_product20__c, ThisYear1__c,ThisYear2__c,ThisYear3__c,ThisYear4__c,ThisYear5__c,ThisYear6__c, ThisYear7__c,ThisYear8__c,ThisYear9__c,ThisYear10__c,ThisYear11__c,ThisYear12__c from Account2__c where Account_Org__c = :hp2.Id and Account_Org__r.RecordType.Name = '病院' order by Name]; System.assertEquals('SoakupTestHp2', hp2s[0].Name); System.assertEquals(null, hp2s[0].Important_product1__c); System.assertEquals(null, hp2s[0].Important_product2__c); System.assertEquals(null, hp2s[0].Important_product3__c); System.assertEquals(null, hp2s[0].Important_product4__c); System.assertEquals(null, hp2s[0].Important_product5__c); System.assertEquals(null, hp2s[0].Important_product6__c); System.assertEquals(null, hp2s[0].Important_product7__c); System.assertEquals(null, hp2s[0].Important_product8__c); System.assertEquals(null, hp2s[0].Important_product9__c); System.assertEquals(null, hp2s[0].Important_product10__c); System.assertEquals(null, hp2s[0].Important_product11__c); System.assertEquals(null, hp2s[0].Important_product12__c); System.assertEquals(null, hp2s[0].Important_product13__c); System.assertEquals(null, hp2s[0].Important_product14__c); System.assertEquals(null, hp2s[0].Important_product15__c); System.assertEquals(null, hp2s[0].Important_product16__c); System.assertEquals(null, hp2s[0].Important_product17__c); System.assertEquals(null, hp2s[0].Important_product18__c); System.assertEquals(null, hp2s[0].Important_product19__c); System.assertEquals(null, hp2s[0].Important_product20__c); System.assertEquals(0, hp2s[0].Service_contract_active_number_HP__c);*/ } // 提案书、提出後 static testMethod void soakupTemporaryFileBoxTest() { // recode type を取得 ControllerUtil.EscapeNFM001Trigger = true; List rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '病院']; if (rectCo.size() == 0) { throw new ControllerUtil.myException('not found 病院 recodetype'); } // insert Account company = new Account( RecordTypeId = rectCo[0].Id, Name = 'Katsu テスト' ); Account company2 = new Account( RecordTypeId = rectCo[0].Id, Name = 'Katsu テスト2' ); insert new Account[] {company, company2}; // 提案書 TemporaryFileBox__c tfb1 = new TemporaryFileBox__c( Hospital__c = company.Id ); TemporaryFileBox__c tfb2 = new TemporaryFileBox__c( Hospital__c = company.Id ); insert new TemporaryFileBox__c[] {tfb1, tfb2}; // 添付してから、已申请 に更新 Attachment attach1 = new Attachment( Name = 'Unit Test Attachment', body = Blob.valueOf('Unit Test Attachment Body'), parentId = tfb1.id ); Attachment attach2 = new Attachment( Name = 'Unit Test Attachment', body = Blob.valueOf('Unit Test Attachment Body'), parentId = tfb2.id ); insert new Attachment[] {attach1, attach2}; // 提案書 submit tfb1.Status__c = '已申请'; tfb2.Status__c = '已申请'; tfb1.Attached_category__c = '季报'; tfb2.Attached_category__c = '季报'; update new TemporaryFileBox__c[] {tfb1, tfb2}; tfb1.Customer_submit_day__c = System.today().addDays(-1); tfb2.Customer_submit_day__c = System.today().addDays(-2); update new TemporaryFileBox__c[] {tfb1, tfb2}; System.Test.StartTest(); Id execBTId = Database.executeBatch(new RollupToHPBatch(null, null), 5); System.Test.StopTest(); Account2__c acc2company = [Select Id, Latest_Proposal_document_Submit_day__c, Proposal_Submit_Status__c from Account2__c where Account_Org__c = :company.Id]; System.assertEquals(null, acc2company.Latest_Proposal_document_Submit_day__c); System.assertEquals(null, acc2company.Proposal_Submit_Status__c); Account2__c acc2company2 = [Select Id, Latest_Proposal_document_Submit_day__c, Proposal_Submit_Status__c from Account2__c where Account_Org__c = :company2.Id]; System.assertEquals(null, acc2company2.Latest_Proposal_document_Submit_day__c); System.assertEquals(null, acc2company2.Proposal_Submit_Status__c); } // 提案书、提出後,批准 static testMethod void soakupTemporaryFileBoxTest2() { // recode type を取得 ControllerUtil.EscapeNFM001Trigger = true; List rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '病院']; if (rectCo.size() == 0) { throw new ControllerUtil.myException('not found 病院 recodetype'); } System.Test.StartTest(); // insert Account company = new Account( RecordTypeId = rectCo[0].Id, Name = 'Katsu テスト' ); Account company2 = new Account( RecordTypeId = rectCo[0].Id, Name = 'Katsu テスト2' ); insert new Account[] {company, company2}; // 提案書 TemporaryFileBox__c tfb1 = new TemporaryFileBox__c( Hospital__c = company.Id ); TemporaryFileBox__c tfb2 = new TemporaryFileBox__c( Hospital__c = company.Id ); insert new TemporaryFileBox__c[] {tfb1, tfb2}; // 添付してから、已申请 に更新 Attachment attach1 = new Attachment( Name = 'Unit Test Attachment', body = Blob.valueOf('Unit Test Attachment Body'), parentId = tfb1.id ); Attachment attach2 = new Attachment( Name = 'Unit Test Attachment', body = Blob.valueOf('Unit Test Attachment Body'), parentId = tfb2.id ); insert new Attachment[] {attach1, attach2}; System.Test.StopTest(); // 提案書 submit tfb1.Status__c = '已申请'; tfb2.Status__c = '已申请'; tfb1.Attached_category__c = '季报'; tfb2.Attached_category__c = '季报'; update new TemporaryFileBox__c[] {tfb1, tfb2}; tfb1.Customer_submit_day__c = System.today().addDays(-1); tfb2.Customer_submit_day__c = System.today().addDays(-2); update new TemporaryFileBox__c[] {tfb1, tfb2}; // 提案書 更新 tfb1.Status__c = '已批准'; tfb2.Status__c = '已批准'; tfb1.Customer_submit_day__c = System.today().addDays(-3); tfb1.Attached_category__c = '季报'; tfb2.Attached_category__c = '季报'; update new TemporaryFileBox__c[] {tfb1, tfb2}; Id execBTId = Database.executeBatch(new RollupToHPBatch(null, null), 5); Account2__c acc2company = [Select Id, Latest_Proposal_document_Submit_day__c, Proposal_Submit_Status__c from Account2__c where Account_Org__c = :company.Id]; System.assertEquals(null, acc2company.Latest_Proposal_document_Submit_day__c); System.assertEquals(null, acc2company.Proposal_Submit_Status__c); Account2__c acc2company2 = [Select Id, Latest_Proposal_document_Submit_day__c, Proposal_Submit_Status__c from Account2__c where Account_Org__c = :company2.Id]; System.assertEquals(null, acc2company2.Latest_Proposal_document_Submit_day__c); System.assertEquals(null, acc2company2.Proposal_Submit_Status__c); } // SWAG-BQ75WE update by vivek 2020/06/11 start static testMethod void test01(){ RollupToHPBatch rollHPBatch = new RollupToHPBatch(null); rollHPBatch.getImportantProductModel('1','2'); } // SWAG-BQ75WE update by vivek 2020/06/11 end }