@isTest private class NFM105RestTest { @testSetup static void makeTestRepair() { 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'); } List rectSct = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '戦略科室分類 消化科']; if (rectSct.size() == 0) { throw new ControllerUtil.myException('not found 戦略科室分類 呼吸科 recodetype'); } List rectDpt = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '診療科 消化科']; if (rectDpt.size() == 0) { throw new ControllerUtil.myException('not found 診療科 消化科 recodetype'); } // テストデータ Account company = new Account(); company.RecordTypeId = rectCo[0].Id; company.Name = 'NFM105TestCompany'; upsert company; Account section = [Select Management_Code__c, Management_Code_Auto__c, Name, Id from Account where ParentId = :company.Id and RecordTypeId = :rectSct[0].Id]; Account depart = new Account(); depart.RecordTypeId = rectDpt[0].Id; depart.Name = '*'; depart.Department_Name__c = 'NFM105TestDepart'; depart.ParentId = section.Id; depart.Department_Class__c = section.Id; depart.Hospital__c = company.Id; upsert depart; // 再取得 List accList = new List(); company = [select Management_Code__c, Management_Code_Auto__c, Name, Id from Account where Id = :company.Id]; accList.add(company); accList.add(section); depart = [select Management_Code__c, Management_Code_Auto__c, Name, Id from Account where Id = :depart.Id]; accList.add(depart); List prdList = new List(); Product2 prd1 = new Product2(); prd1.ProductCode_Ext__c = 'NFM105Prd1'; prd1.ProductCode = 'NFM105Prd1'; prd1.Repair_Product_Code__c = 'NFM105Prd1_RP'; prd1.Name = 'NFM105Prd1'; prd1.Manual_Entry__c = false; prdList.add(prd1); Product2 prd2 = new Product2(); prd2.ProductCode_Ext__c = 'NFM105Prd2'; prd2.ProductCode = 'NFM105Prd2'; prd2.Repair_Product_Code__c = 'NFM105Prd2_RP'; prd2.Name = 'NFM105Prd2'; prd2.Manual_Entry__c = false; prdList.add(prd2); insert prdList; Asset ast = new Asset(); ast.Name = 'BW-20T:管道清洗刷'; ast.AccountId = depart.Id; ast.Department_Class__c = section.Id; ast.Hospital__c = company.Id; ast.Product2Id = prd1.Id; ast.SerialNumber = '8ZR(FICPX)'; ast.Guarantee_period_for_products__c = Date.today(); ast.InstallDate = Date.today(); //20211109 lt start //集中管理库存(有效库存-上架的附属品有效库存_合计)不可小于0 //有效库存 ast.Quantity = 88; ast.Out_of_wh__c = 1; ast.MaintainCount_For_Processing__c = 1; ast.Frozen_Quantity__c = 1; ast.Abandoned_RealThing__c = 1; ast.Abandoned_Inventory__c = 1; ast.Inventory_Frozen_Quantity__c = 1; ast.Appended_Inventory_Frozen_Quantity__c = 1; ast.TransferFrozenQuantity__c = 1; ast.CountForRepair__c = 1; //20211109 lt end insert ast; //20211109 lt start //上架的附属品有效库存_合计 Fixture_OneToOne_Link__c fol = new Fixture_OneToOne_Link__c(); fol.In_wh_Fu_Shu_Pin_You_Xiao_Ku_Cun__c = 1; fol.Accessory_Asset__c = ast.id; fol.Main_Asset__c = ast.id; insert fol; //count修理 rpr //20211109 lt end ast = [select Id, Name, Product_Serial_No__c, AccountId, Department_Class__c , Department_Class__r.Management_Code_Auto__c, Hospital__c, Product2Id , Product2.ProductCode, Product2.Repair_Product_Code__c, SerialNumber from Asset where Id = :ast.Id]; // User testUser = new User(); // testUser.Job_Category__c = '销售服务'; //add by rentx 2021-3-19 start Profile p = [select Id from Profile where id =: System.Label.ProfileId_SystemAdmin]; User u1 = new User(Test_staff__c = true); u1.LastName = '_サンブリッジ'; u1.FirstName = 'あ'; u1.Alias = 'あ'; u1.Email = 'olympusTest01@sunbridge.com'; u1.Username = 'olympusTest01@sunbridge.com'; u1.CommunityNickname = 'あ'; u1.IsActive = true; u1.EmailEncodingKey = 'ISO-2022-JP'; u1.TimeZoneSidKey = 'Asia/Tokyo'; u1.LocaleSidKey = 'ja_JP'; u1.LanguageLocaleKey = 'ja'; u1.ProfileId = p.Id; u1.Job_Category__c = '销售服务'; u1.Province__c = '東京'; insert u1; // 维修合同を作成する Maintenance_Contract__c contract = new Maintenance_Contract__c(); contract.Name = 'tect contract'; contract.Hospital__c = company.Id; contract.Department_Class__c = section.Id; contract.Department__c = depart.Id; contract.Contract_End_Date__c = Date.today(); contract.Status__c= '契約'; contract.Not_Upper_limit_reason__c = 'test'; contract.Maintenance_Contract_No__c = 'contact1'; contract.RecordTypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Maintenance_Contract__c' and DeveloperName = 'NewMaintenance_Contract'].id; contract.URF_Contract__c = true; //add by rentx 2021-04-27 start contract.agree_Upper_limit__c = true; //add by rentx 2021-04-27 end insert contract; Repair__c rpr = new Repair__c(); rpr.SAPRepairNo__c = 'NFM105Rpr1'; rpr.Account__c = depart.Id; rpr.Department_Class__c = section.Id; rpr.Hospital__c = company.Id; rpr.Delivered_Product__c = ast.Id; rpr.Status__c = '1.受理完毕'; rpr.Incharge_Staff__c = u1.Id; rpr.Repair_Detail__c = 'test'; rpr.Repair_Rank__c = 'A'; rpr.Agreed_Date__c = Date.today(); rpr.Maintenance_Contract__c = contract.Id; insert rpr; // Maintenance_Contract_Asset__c mainAss1 = new Maintenance_Contract_Asset__c(); // mainAss1.Asset__c = ast.Id; // mainAss1.Maintenance_Contract__c = contract.id; // mainAss1.endDateGurantee_Text__c = Date.today().addDays(1); // insert mainAss1; //add by rentx 2021-3-19 end } // そのままreturn @isTest static void testNFM105_void() { // null //NFM105Rest.NFM105(null); NFM105Rest.RepairStatusUpdate RepairStatusUpdate = new NFM105Rest.RepairStatusUpdate(); NFM105Rest.GeneralData GeneralData = new NFM105Rest.GeneralData(); NFM105Rest.InspectionResultInformation InspectionResultInformation = new NFM105Rest.InspectionResultInformation(); NFM105Rest.FailureInformation FailureInformation = new NFM105Rest.FailureInformation(); GeneralData.InspectionResultInformation = new NFM105Rest.InspectionResultInformation[] { InspectionResultInformation }; GeneralData.FailureInformation = new NFM105Rest.FailureInformation[] { FailureInformation }; RepairStatusUpdate.GeneralData = new NFM105Rest.GeneralData[] { GeneralData }; // Monitoringをセットしない //NFM105Rest.NFM105(RepairStatusUpdate); Datetime nowDT = Datetime.now(); String nowStr = nowDT.format('yyyyMMddHHmm'); RepairStatusUpdate.Monitoring = new NFMUtil.Monitoring(); RepairStatusUpdate.Monitoring.MessageGroupNumber = nowStr + '01'; // 必須項目をセットしない //NFM105Rest.NFM105(RepairStatusUpdate); BatchIF_Log__c rowData = NFMUtil.saveRowData(RepairStatusUpdate.Monitoring, 'NFM105', RepairStatusUpdate.GeneralData); if (String.isBlank(rowData.Log__c) == false) NFM105Rest.main(rowData.Id); // 商品コードが存在しない RepairStatusUpdate.Monitoring.MessageGroupNumber = nowStr + '02'; GeneralData.SAPRepairNo = 'NFM105X'; //NFM105Rest.NFM105(RepairStatusUpdate); rowData = NFMUtil.saveRowData(RepairStatusUpdate.Monitoring, 'NFM105', RepairStatusUpdate.GeneralData); if (String.isBlank(rowData.Log__c) == false) NFM105Rest.main(rowData.Id); // 修理受付番号 を受信したけど、SFDC側レコードがない RepairStatusUpdate.Monitoring.MessageGroupNumber = nowStr + '03'; GeneralData.SAPRepairNo = 'NFM105X'; GeneralData.SFDCRepairNo = 'AAAA'; //NFM105Rest.NFM105(RepairStatusUpdate); rowData = NFMUtil.saveRowData(RepairStatusUpdate.Monitoring, 'NFM105', RepairStatusUpdate.GeneralData); if (String.isBlank(rowData.Log__c) == false) NFM105Rest.main(rowData.Id); } //StatusCode = 'B95'; 1件 @isTest static void testNFM105_update_B95_1() { StaticParameter.EventOpportunityPileUpExeFlg = true; // EventC⇒Event処理後、逆更新をスルー用 StaticParameter.NotUpdEventCFlg = true; // 積み上げ処理後、トリガをスルー用 StaticParameter.EscapeNFM001Trigger = true; StaticParameter.EscapeNFM001AgencyContractTrigger = true; StaticParameter.EscapeNFM001AgencyContractTrigger2 = true; StaticParameter.EscapeNFM007Trigger = true; StaticParameter.EscapeOpportunityBefUpdTrigger = true; StaticParameter.EscapeOpportunityHpDeptUpdTrigger = true; StaticParameter.EscapeSyncOpportunityTrigger = true; StaticParameter.EscapeMaintenanceContractAfterUpdateTrigger = true; StaticParameter.EscapeSyncProduct2Trigger = true; // trueのとき、リードのトリガーをスルーする StaticParameter.EscapeLeadTrigger = true; StaticParameter.EscapeAccountTrigger = true; StaticParameter.EscapeConsumableOrderDetail2Trigger = true; StaticParameter.EscapeNFM010UpsertStatuAchievementsTrigger = true; // 直销耗材不直销 ConsumableAssetHander StaticParameter.ConsumableAssetHanderTrigger = true; // 跳过不涉及备品借出的逻辑 StaticParameter.rentalApplyIsRunning = true; // accountdailyUpdate 跳过 更新询价 StaticParameter.EscapeOpportunityownerUpdate = true; Repair__c rpr = [select Id, Name, Delivered_Product__c, SAPRepairNo__c, Repair_Quotation_Id__c from Repair__c limit 1]; Repair_Quotation__c rq1 = new Repair_Quotation__c(); rq1.Name = 'NFM105U1'; rq1.Repair__c = rpr.Id; Repair_Quotation__c rq2 = new Repair_Quotation__c(); rq2.Quotation_agreement__c = true; rq2.Name = 'NFM105U2'; rq2.Repair__c = rpr.Id; insert new Repair_Quotation__c[] {rq1, rq2}; NFM105Rest.RepairStatusUpdate RepairStatusUpdate = new NFM105Rest.RepairStatusUpdate(); NFM105Rest.GeneralData GeneralData = new NFM105Rest.GeneralData(); NFM105Rest.InspectionResultInformation InspectionResultInformation = new NFM105Rest.InspectionResultInformation(); NFM105Rest.FailureInformation FailureInformation = new NFM105Rest.FailureInformation(); GeneralData.InspectionResultInformation = new NFM105Rest.InspectionResultInformation[] { InspectionResultInformation }; GeneralData.FailureInformation = new NFM105Rest.FailureInformation[] { FailureInformation }; RepairStatusUpdate.GeneralData = new NFM105Rest.GeneralData[] { GeneralData }; // Monitoringの設定 Datetime nowDT = Datetime.now(); String nowStr = nowDT.format('yyyyMMddHHmm'); RepairStatusUpdate.Monitoring = new NFMUtil.Monitoring(); // SAPQuotationNo NotExist RepairStatusUpdate.Monitoring.MessageGroupNumber = nowStr + '1'; GeneralData.SFDCRepairNo = rpr.Name; GeneralData.SAPRepairNo = rpr.SAPRepairNo__c; GeneralData.RepairOrderStatusCode = 'B95'; GeneralData.RepairOrderStatusName = '报价同意确认'; GeneralData.StatusUpdateDate = '20150101'; GeneralData.StatusUpdateTime = '101010'; GeneralData.StatusUpdatePersonName = 'John'; GeneralData.CancellationReason = 'R2 到其他公司修理 '; GeneralData.IncorrectDataComment = 'xxxxx'; GeneralData.SAPQuotationNo = 'NFM105UXX'; //NFM105Rest.NFM105(RepairStatusUpdate); System.Test.startTest(); BatchIF_Log__c rowData = NFMUtil.saveRowData(RepairStatusUpdate.Monitoring, 'NFM105', RepairStatusUpdate.GeneralData); if (String.isBlank(rowData.Log__c) == false) NFM105Rest.main(rowData.Id); // NFM105U1 => B95 GeneralData.SAPQuotationNo = 'NFM105U1'; InspectionResultInformation.InspectionResultFlag = 'X'; InspectionResultInformation.InspectionComment = 'CCD线长度: 248MM 把手、S盖脱漆、磨损,旋纽划痕,吸引口、水气口、1号外皮轻磨损。'; InspectionResultInformation.FailureCause = '先端部金属磨损严重,插入部发黄结晶,角度不足,钳子口磨损,2、3号外皮变色,水气不畅,CCD玻璃缺损大于1/10,涂胶后无阴影。B级不修理故障:CCD玻璃缺损大于1/10'; FailureInformation.LocationGroupName = '内镜连接座部'; FailureInformation.LocationName = 'LG导光杆部'; FailureInformation.PhenomenonName = 'IG导光束异常(红裂缝、折损、彩虹斑)'; FailureInformation.CauseName = '劣化, 老化'; FailureInformation.DescriptionName = '由于送气?送水圆筒的刮痕导致气囊送水量不能达到规格值。'; // System.Test.startTest(); //NFM105Rest.NFM105(RepairStatusUpdate); rowData = NFMUtil.saveRowData(RepairStatusUpdate.Monitoring, 'NFM105', RepairStatusUpdate.GeneralData); if (String.isBlank(rowData.Log__c) == false) NFM105Rest.main(rowData.Id); System.Test.stopTest(); // List sapRpairList = [select Id, Name, SAPRepairNo__c, Agreed_Date__c // , RepairOrderStatusName__c, RepairOrderStatusCode__c // , CancellationReason__c, IncorrectDataComment__c // , Repair_Ordered_Date__c, NFM105_MessageGroupNumber__c // , Repair_Quotation_Id__c // from Repair__c // where SAPRepairNo__c = :GeneralData.SAPRepairNo]; // List quotationList = [select Id, Name, Repair_Rank__c, Repair__c, Quotation_agreement__c // , InspectionComment__c, InspectionResultFlag__c // , InspectionFailureCause__c // , LatestQuotationDate__c // , FirstQuotationDate__c, DiscountAmount__c // , TotalPrice__c, DiscountType__c // , CafeteriaFlag__c, MessageGroupNumber__c // from Repair_Quotation__c // where Name = :GeneralData.SAPQuotationNo]; // System.assertEquals(1, sapRpairList.size()); // System.assertEquals(1, quotationList.size()); // if (sapRpairList.size() == 1) { // System.assertEquals(nowStr + 'u1', sapRpairList[0].NFM105_MessageGroupNumber__c); // System.assertEquals(quotationList[0].Id, sapRpairList[0].Repair_Quotation_Id__c); // System.assertEquals(Date.valueOf('2015-01-01'), sapRpairList[0].Agreed_Date__c); // System.assertEquals(GeneralData.SAPRepairNo, sapRpairList[0].SAPRepairNo__c); // System.assertEquals(GeneralData.RepairOrderStatusName, sapRpairList[0].RepairOrderStatusName__c); // System.assertEquals(GeneralData.RepairOrderStatusCode, sapRpairList[0].RepairOrderStatusCode__c); // System.assertEquals(null, sapRpairList[0].CancellationReason__c); // System.assertEquals(null, sapRpairList[0].IncorrectDataComment__c); // } // if (quotationList.size() == 1) { // Repair_Quotation__c qr = [Select Id, Quotation_agreement__c from Repair_Quotation__c where Name <> :GeneralData.SAPQuotationNo]; // System.assertEquals(false, qr.Quotation_agreement__c); // System.assertEquals(GeneralData.SAPQuotationNo, quotationList[0].Name); // System.assertEquals(true, quotationList[0].Quotation_agreement__c); // System.assertEquals('OK', quotationList[0].InspectionResultFlag__c); // System.assertEquals(InspectionResultInformation.InspectionComment, quotationList[0].InspectionComment__c); // System.assertEquals(InspectionResultInformation.FailureCause, quotationList[0].InspectionFailureCause__c); // List qrsnList = [select ActivityDescription__c, Repair_quotation__c, LocationGroupName__c, LocationName__c, PhenomenonName__c, CauseName__c, DescriptionName__c from Repair_quotation_reason__c]; // System.assertEquals(1, qrsnList.size()); // System.assertEquals(quotationList[0].Id, qrsnList[0].Repair_quotation__c); // System.assertEquals(FailureInformation.LocationGroupName, qrsnList[0].LocationGroupName__c); // System.assertEquals(FailureInformation.LocationName, qrsnList[0].LocationName__c); // System.assertEquals(FailureInformation.PhenomenonName, qrsnList[0].PhenomenonName__c); // System.assertEquals(FailureInformation.CauseName, qrsnList[0].CauseName__c); // System.assertEquals(FailureInformation.DescriptionName, qrsnList[0].DescriptionName__c); // List rrsnList = [select Repair__c, Repair_quotation__c, LocationGroupName__c, LocationName__c, PhenomenonName__c, CauseName__c, DescriptionName__c from Repair_reason__c]; // System.assertEquals(1, rrsnList.size()); // System.assertEquals(rpr.Id, rrsnList[0].Repair__c); // System.assertEquals(quotationList[0].Id, rrsnList[0].Repair_quotation__c); // System.assertEquals(FailureInformation.LocationGroupName, rrsnList[0].LocationGroupName__c); // System.assertEquals(FailureInformation.LocationName, rrsnList[0].LocationName__c); // System.assertEquals(FailureInformation.PhenomenonName, rrsnList[0].PhenomenonName__c); // System.assertEquals(FailureInformation.CauseName, rrsnList[0].CauseName__c); // System.assertEquals(FailureInformation.DescriptionName, rrsnList[0].DescriptionName__c); // } } //StatusCode = 'B95'; 同じ修理、2件 @isTest static void testNFM105_update_B95_2() { StaticParameter.EventOpportunityPileUpExeFlg = true; // EventC⇒Event処理後、逆更新をスルー用 StaticParameter.NotUpdEventCFlg = true; // 積み上げ処理後、トリガをスルー用 StaticParameter.EscapeNFM001Trigger = true; StaticParameter.EscapeNFM001AgencyContractTrigger = true; StaticParameter.EscapeNFM001AgencyContractTrigger2 = true; StaticParameter.EscapeNFM007Trigger = true; StaticParameter.EscapeOpportunityBefUpdTrigger = true; StaticParameter.EscapeOpportunityHpDeptUpdTrigger = true; StaticParameter.EscapeSyncOpportunityTrigger = true; StaticParameter.EscapeMaintenanceContractAfterUpdateTrigger = true; StaticParameter.EscapeSyncProduct2Trigger = true; // trueのとき、リードのトリガーをスルーする StaticParameter.EscapeLeadTrigger = true; StaticParameter.EscapeAccountTrigger = true; StaticParameter.EscapeConsumableOrderDetail2Trigger = true; StaticParameter.EscapeNFM010UpsertStatuAchievementsTrigger = true; // 直销耗材不直销 ConsumableAssetHander StaticParameter.ConsumableAssetHanderTrigger = true; // 跳过不涉及备品借出的逻辑 StaticParameter.rentalApplyIsRunning = true; // accountdailyUpdate 跳过 更新询价 StaticParameter.EscapeOpportunityownerUpdate = true; Repair__c rpr = [select Id, Name, Delivered_Product__c, SAPRepairNo__c, Repair_Quotation_Id__c from Repair__c limit 1]; Repair_Quotation__c rq1 = new Repair_Quotation__c(); rq1.Name = 'NFM105U1'; rq1.Repair__c = rpr.Id; Repair_Quotation__c rq2 = new Repair_Quotation__c(); rq2.Name = 'NFM105U2'; rq2.Repair__c = rpr.Id; insert new Repair_Quotation__c[] {rq1, rq2}; NFM105Rest.RepairStatusUpdate RepairStatusUpdate = new NFM105Rest.RepairStatusUpdate(); NFM105Rest.GeneralData GeneralData = new NFM105Rest.GeneralData(); NFM105Rest.GeneralData GeneralData2 = new NFM105Rest.GeneralData(); NFM105Rest.InspectionResultInformation InspectionResultInformation = new NFM105Rest.InspectionResultInformation(); NFM105Rest.InspectionResultInformation InspectionResultInformation2 = new NFM105Rest.InspectionResultInformation(); NFM105Rest.FailureInformation FailureInformation = new NFM105Rest.FailureInformation(); NFM105Rest.FailureInformation FailureInformation1 = new NFM105Rest.FailureInformation(); GeneralData.InspectionResultInformation = new NFM105Rest.InspectionResultInformation[] { InspectionResultInformation }; GeneralData2.InspectionResultInformation = new NFM105Rest.InspectionResultInformation[] { InspectionResultInformation2 }; GeneralData2.FailureInformation = new NFM105Rest.FailureInformation[] { FailureInformation, FailureInformation1 }; RepairStatusUpdate.GeneralData = new NFM105Rest.GeneralData[] { GeneralData, GeneralData2 }; // Monitoringの設定 Datetime nowDT = Datetime.now(); String nowStr = nowDT.format('MMddHHmm'); RepairStatusUpdate.Monitoring = new NFMUtil.Monitoring(); // NFM105U2 => A20 RepairStatusUpdate.Monitoring.MessageGroupNumber = nowStr + '2'; GeneralData.SFDCRepairNo = rpr.Name; GeneralData.SAPRepairNo = rpr.SAPRepairNo__c; GeneralData.RepairOrderStatusCode = 'A20'; GeneralData.RepairOrderStatusName = '报价同意确认'; GeneralData.StatusUpdateDate = '20150101'; GeneralData.StatusUpdateTime = '101010'; GeneralData.StatusUpdatePersonName = 'John'; GeneralData.CancellationReason = 'R2 到其他公司修理 '; GeneralData.IncorrectDataComment = 'xxxxx'; GeneralData.SAPQuotationNo = 'NFM105U2'; InspectionResultInformation.InspectionResultFlag = 'X'; InspectionResultInformation.InspectionComment = 'CCD线长度: 248MM 把手、S盖脱漆、磨损,旋纽划痕,吸引口、水气口、1号外皮轻磨损。'; InspectionResultInformation.FailureCause = '先端部金属磨损严重,插入部发黄结晶,角度不足,钳子口磨损,2、3号外皮变色,水气不畅,CCD玻璃缺损大于1/10,涂胶后无阴影。B级不修理故障:CCD玻璃缺损大于1/10'; // NFM105U2 => B95 GeneralData2.SFDCRepairNo = rpr.Name; GeneralData2.SAPRepairNo = rpr.SAPRepairNo__c; GeneralData2.RepairOrderStatusCode = 'B95'; GeneralData2.RepairOrderStatusName = '报价同意确认'; GeneralData2.StatusUpdateDate = '20150202'; GeneralData2.StatusUpdateTime = '111111'; GeneralData2.StatusUpdatePersonName = 'John'; GeneralData2.CancellationReason = 'R2 到其他公司修理 '; GeneralData2.IncorrectDataComment = 'xxxxx'; GeneralData2.SAPQuotationNo = 'NFM105U2'; InspectionResultInformation2.InspectionResultFlag = ''; InspectionResultInformation2.InspectionComment = 'CCD线长度: 248MM 把手、S盖脱漆、磨损,旋纽划痕,吸引口、水气口、1号外皮轻磨损。'; InspectionResultInformation2.FailureCause = '先端部金属磨损严重,插入部发黄结晶,角度不足,钳子口磨损,2、3号外皮变色,水气不畅,CCD玻璃缺损大于1/10,涂胶后无阴影。B级不修理故障:CCD玻璃缺损大于1/10'; FailureInformation.LocationGroupName = '内镜连接座部'; FailureInformation.LocationName = 'LG导光杆部'; FailureInformation.PhenomenonName = 'IG导光束异常(红裂缝、折损、彩虹斑)'; FailureInformation.CauseName = '劣化, 老化'; FailureInformation.DescriptionName = '由于送气?送水圆筒的刮痕导致气囊送水量不能达到规格值。'; FailureInformation1.LocationGroupName = '1内镜连接座部'; FailureInformation1.LocationName = '1LG导光杆部'; FailureInformation1.PhenomenonName = '1IG导光束异常(红裂缝、折损、彩虹斑)'; FailureInformation1.CauseName = '1劣化, 老化'; FailureInformation1.DescriptionName = '1由于送气?送水圆筒的刮痕导致气囊送水量不能达到规格值。'; GeneralData2.FailureInformation = new NFM105Rest.FailureInformation[] { FailureInformation, FailureInformation1 }; BatchIF_Log__c rowData = NFMUtil.saveRowData(RepairStatusUpdate.Monitoring, 'NFM105', RepairStatusUpdate.GeneralData); System.Test.startTest(); //NFM105Rest.NFM105(RepairStatusUpdate); if (String.isBlank(rowData.Log__c) == false) NFM105Rest.main(rowData.Id); System.Test.stopTest(); } //StatusCode = 'B99'; @isTest static void testNFM105_update_B99() { StaticParameter.EventOpportunityPileUpExeFlg = true; // EventC⇒Event処理後、逆更新をスルー用 StaticParameter.NotUpdEventCFlg = true; // 積み上げ処理後、トリガをスルー用 StaticParameter.EscapeNFM001Trigger = true; StaticParameter.EscapeNFM001AgencyContractTrigger = true; StaticParameter.EscapeNFM001AgencyContractTrigger2 = true; StaticParameter.EscapeNFM007Trigger = true; StaticParameter.EscapeOpportunityBefUpdTrigger = true; StaticParameter.EscapeOpportunityHpDeptUpdTrigger = true; StaticParameter.EscapeSyncOpportunityTrigger = true; StaticParameter.EscapeMaintenanceContractAfterUpdateTrigger = true; StaticParameter.EscapeSyncProduct2Trigger = true; // trueのとき、リードのトリガーをスルーする StaticParameter.EscapeLeadTrigger = true; StaticParameter.EscapeAccountTrigger = true; StaticParameter.EscapeConsumableOrderDetail2Trigger = true; StaticParameter.EscapeNFM010UpsertStatuAchievementsTrigger = true; // 直销耗材不直销 ConsumableAssetHander StaticParameter.ConsumableAssetHanderTrigger = true; // 跳过不涉及备品借出的逻辑 StaticParameter.rentalApplyIsRunning = true; // accountdailyUpdate 跳过 更新询价 StaticParameter.EscapeOpportunityownerUpdate = true; Repair__c rpr = [select Id, Name, Delivered_Product__c, SAPRepairNo__c, Repair_Quotation_Id__c from Repair__c limit 1]; Repair_Quotation__c rq1 = new Repair_Quotation__c(); rq1.Name = 'NFM105U1'; rq1.Repair__c = rpr.Id; Repair_Quotation__c rq2 = new Repair_Quotation__c(); rq2.Name = 'NFM105U2'; rq2.Repair__c = rpr.Id; insert new Repair_Quotation__c[] {rq1, rq2}; NFM105Rest.RepairStatusUpdate RepairStatusUpdate = new NFM105Rest.RepairStatusUpdate(); NFM105Rest.GeneralData GeneralData = new NFM105Rest.GeneralData(); NFM105Rest.GeneralData GeneralData2 = new NFM105Rest.GeneralData(); NFM105Rest.InspectionResultInformation InspectionResultInformation = new NFM105Rest.InspectionResultInformation(); NFM105Rest.InspectionResultInformation InspectionResultInformation2 = new NFM105Rest.InspectionResultInformation(); NFM105Rest.FailureInformation FailureInformation = new NFM105Rest.FailureInformation(); NFM105Rest.FailureInformation FailureInformation1 = new NFM105Rest.FailureInformation(); GeneralData.InspectionResultInformation = new NFM105Rest.InspectionResultInformation[] { InspectionResultInformation }; GeneralData2.InspectionResultInformation = new NFM105Rest.InspectionResultInformation[] { InspectionResultInformation2 }; GeneralData2.FailureInformation = new NFM105Rest.FailureInformation[] { FailureInformation, FailureInformation1 }; RepairStatusUpdate.GeneralData = new NFM105Rest.GeneralData[] { GeneralData, GeneralData2 }; // Monitoringの設定 Datetime nowDT = Datetime.now(); String nowStr = nowDT.format('MMddHHmm'); RepairStatusUpdate.Monitoring = new NFMUtil.Monitoring(); // NFM105U2 => B99 RepairStatusUpdate.Monitoring.MessageGroupNumber = nowStr + '2'; GeneralData.SFDCRepairNo = rpr.Name; GeneralData.SAPRepairNo = rpr.SAPRepairNo__c; GeneralData.RepairOrderStatusCode = 'B99'; GeneralData.RepairOrderStatusName = '报价同意确认'; GeneralData.StatusUpdateDate = '20150101'; GeneralData.StatusUpdateTime = '101010'; GeneralData.StatusUpdatePersonName = 'John'; GeneralData.CancellationReason = 'R2 到其他公司修理 '; GeneralData.IncorrectDataComment = 'xxxxx'; GeneralData.SAPQuotationNo = 'NFM105U2'; InspectionResultInformation.InspectionResultFlag = 'X'; InspectionResultInformation.InspectionComment = 'CCD线长度: 248MM 把手、S盖脱漆、磨损,旋纽划痕,吸引口、水气口、1号外皮轻磨损。'; InspectionResultInformation.FailureCause = '先端部金属磨损严重,插入部发黄结晶,角度不足,钳子口磨损,2、3号外皮变色,水气不畅,CCD玻璃缺损大于1/10,涂胶后无阴影。B级不修理故障:CCD玻璃缺损大于1/10'; // NFM105U2 => B99 GeneralData2.SFDCRepairNo = rpr.Name; GeneralData2.SAPRepairNo = rpr.SAPRepairNo__c; GeneralData2.RepairOrderStatusCode = 'B99'; GeneralData2.RepairOrderStatusName = '报价同意确认'; GeneralData2.StatusUpdateDate = '20150202'; GeneralData2.StatusUpdateTime = '111111'; GeneralData2.StatusUpdatePersonName = 'John'; GeneralData2.CancellationReason = 'R2 到其他公司修理 '; GeneralData2.IncorrectDataComment = 'xxxxx'; GeneralData2.SAPQuotationNo = 'NFM105U2'; InspectionResultInformation2.InspectionResultFlag = ''; InspectionResultInformation2.InspectionComment = 'CCD线长度: 248MM 把手、S盖脱漆、磨损,旋纽划痕,吸引口、水气口、1号外皮轻磨损。'; InspectionResultInformation2.FailureCause = '先端部金属磨损严重,插入部发黄结晶,角度不足,钳子口磨损,2、3号外皮变色,水气不畅,CCD玻璃缺损大于1/10,涂胶后无阴影。B级不修理故障:CCD玻璃缺损大于1/10'; FailureInformation.LocationGroupName = '内镜连接座部'; FailureInformation.LocationName = 'LG导光杆部'; FailureInformation.PhenomenonName = 'IG导光束异常(红裂缝、折损、彩虹斑)'; FailureInformation.CauseName = '劣化, 老化'; FailureInformation.DescriptionName = '由于送气?送水圆筒的刮痕导致气囊送水量不能达到规格值。'; FailureInformation1.LocationGroupName = '1内镜连接座部'; FailureInformation1.LocationName = '1LG导光杆部'; FailureInformation1.PhenomenonName = '1IG导光束异常(红裂缝、折损、彩虹斑)'; FailureInformation1.CauseName = '1劣化, 老化'; FailureInformation1.DescriptionName = '1由于送气?送水圆筒的刮痕导致气囊送水量不能达到规格值。'; GeneralData2.FailureInformation = new NFM105Rest.FailureInformation[] { FailureInformation, FailureInformation1 }; BatchIF_Log__c rowData = NFMUtil.saveRowData(RepairStatusUpdate.Monitoring, 'NFM105', RepairStatusUpdate.GeneralData); System.Test.startTest(); //NFM105Rest.NFM105(RepairStatusUpdate); if (String.isBlank(rowData.Log__c) == false) NFM105Rest.main(rowData.Id); System.Test.stopTest(); System.debug('rowData+++'+rowData.MessageGroupNumber__c); } //StatusCode = 'C90'; @isTest static void testNFM105_update_C90() { StaticParameter.EventOpportunityPileUpExeFlg = true; // EventC⇒Event処理後、逆更新をスルー用 StaticParameter.NotUpdEventCFlg = true; // 積み上げ処理後、トリガをスルー用 StaticParameter.EscapeNFM001Trigger = true; StaticParameter.EscapeNFM001AgencyContractTrigger = true; StaticParameter.EscapeNFM001AgencyContractTrigger2 = true; StaticParameter.EscapeNFM007Trigger = true; StaticParameter.EscapeOpportunityBefUpdTrigger = true; StaticParameter.EscapeOpportunityHpDeptUpdTrigger = true; StaticParameter.EscapeSyncOpportunityTrigger = true; StaticParameter.EscapeMaintenanceContractAfterUpdateTrigger = true; StaticParameter.EscapeSyncProduct2Trigger = true; // trueのとき、リードのトリガーをスルーする StaticParameter.EscapeLeadTrigger = true; StaticParameter.EscapeAccountTrigger = true; StaticParameter.EscapeConsumableOrderDetail2Trigger = true; StaticParameter.EscapeNFM010UpsertStatuAchievementsTrigger = true; // 直销耗材不直销 ConsumableAssetHander StaticParameter.ConsumableAssetHanderTrigger = true; // 跳过不涉及备品借出的逻辑 StaticParameter.rentalApplyIsRunning = true; // accountdailyUpdate 跳过 更新询价 StaticParameter.EscapeOpportunityownerUpdate = true; Repair__c rpr = [select Id, Name, Delivered_Product__c, SAPRepairNo__c, Repair_Quotation_Id__c from Repair__c limit 1]; Repair_Quotation__c rq1 = new Repair_Quotation__c(); rq1.Name = 'NFM105U1'; rq1.Repair__c = rpr.Id; Repair_Quotation__c rq2 = new Repair_Quotation__c(); rq2.Name = 'NFM105U2'; rq2.Repair__c = rpr.Id; insert new Repair_Quotation__c[] {rq1, rq2}; NFM105Rest.RepairStatusUpdate RepairStatusUpdate = new NFM105Rest.RepairStatusUpdate(); NFM105Rest.GeneralData GeneralData = new NFM105Rest.GeneralData(); NFM105Rest.GeneralData GeneralData2 = new NFM105Rest.GeneralData(); NFM105Rest.InspectionResultInformation InspectionResultInformation = new NFM105Rest.InspectionResultInformation(); NFM105Rest.InspectionResultInformation InspectionResultInformation2 = new NFM105Rest.InspectionResultInformation(); NFM105Rest.FailureInformation FailureInformation = new NFM105Rest.FailureInformation(); NFM105Rest.FailureInformation FailureInformation1 = new NFM105Rest.FailureInformation(); GeneralData.InspectionResultInformation = new NFM105Rest.InspectionResultInformation[] { InspectionResultInformation }; GeneralData2.InspectionResultInformation = new NFM105Rest.InspectionResultInformation[] { InspectionResultInformation2 }; GeneralData2.FailureInformation = new NFM105Rest.FailureInformation[] { FailureInformation, FailureInformation1 }; RepairStatusUpdate.GeneralData = new NFM105Rest.GeneralData[] { GeneralData, GeneralData2 }; // Monitoringの設定 Datetime nowDT = Datetime.now(); String nowStr = nowDT.format('MMddHHmm'); RepairStatusUpdate.Monitoring = new NFMUtil.Monitoring(); // NFM105U2 => C90 RepairStatusUpdate.Monitoring.MessageGroupNumber = nowStr + '2'; GeneralData.SFDCRepairNo = rpr.Name; GeneralData.SAPRepairNo = rpr.SAPRepairNo__c; GeneralData.RepairOrderStatusCode = 'C90'; GeneralData.RepairOrderStatusName = '报价同意确认'; GeneralData.StatusUpdateDate = '20150101'; GeneralData.StatusUpdateTime = '101010'; GeneralData.StatusUpdatePersonName = 'John'; GeneralData.CancellationReason = 'R2 到其他公司修理 '; GeneralData.IncorrectDataComment = 'xxxxx'; GeneralData.SAPQuotationNo = 'NFM105U2'; InspectionResultInformation.InspectionResultFlag = 'X'; InspectionResultInformation.InspectionComment = 'CCD线长度: 248MM 把手、S盖脱漆、磨损,旋纽划痕,吸引口、水气口、1号外皮轻磨损。'; InspectionResultInformation.FailureCause = '先端部金属磨损严重,插入部发黄结晶,角度不足,钳子口磨损,2、3号外皮变色,水气不畅,CCD玻璃缺损大于1/10,涂胶后无阴影。B级不修理故障:CCD玻璃缺损大于1/10'; // NFM105U2 => C90 GeneralData2.SFDCRepairNo = rpr.Name; GeneralData2.SAPRepairNo = rpr.SAPRepairNo__c; GeneralData2.RepairOrderStatusCode = 'C90'; GeneralData2.RepairOrderStatusName = '报价同意确认'; GeneralData2.StatusUpdateDate = '20150202'; GeneralData2.StatusUpdateTime = '111111'; GeneralData2.StatusUpdatePersonName = 'John'; GeneralData2.CancellationReason = 'R2 到其他公司修理 '; GeneralData2.IncorrectDataComment = 'xxxxx'; GeneralData2.SAPQuotationNo = 'NFM105U2'; InspectionResultInformation2.InspectionResultFlag = ''; InspectionResultInformation2.InspectionComment = 'CCD线长度: 248MM 把手、S盖脱漆、磨损,旋纽划痕,吸引口、水气口、1号外皮轻磨损。'; InspectionResultInformation2.FailureCause = '先端部金属磨损严重,插入部发黄结晶,角度不足,钳子口磨损,2、3号外皮变色,水气不畅,CCD玻璃缺损大于1/10,涂胶后无阴影。B级不修理故障:CCD玻璃缺损大于1/10'; FailureInformation.LocationGroupName = '内镜连接座部'; FailureInformation.LocationName = 'LG导光杆部'; FailureInformation.PhenomenonName = 'IG导光束异常(红裂缝、折损、彩虹斑)'; FailureInformation.CauseName = '劣化, 老化'; FailureInformation.DescriptionName = '由于送气?送水圆筒的刮痕导致气囊送水量不能达到规格值。'; FailureInformation1.LocationGroupName = '1内镜连接座部'; FailureInformation1.LocationName = '1LG导光杆部'; FailureInformation1.PhenomenonName = '1IG导光束异常(红裂缝、折损、彩虹斑)'; FailureInformation1.CauseName = '1劣化, 老化'; FailureInformation1.DescriptionName = '1由于送气?送水圆筒的刮痕导致气囊送水量不能达到规格值。'; GeneralData2.FailureInformation = new NFM105Rest.FailureInformation[] { FailureInformation, FailureInformation1 }; BatchIF_Log__c rowData = NFMUtil.saveRowData(RepairStatusUpdate.Monitoring, 'NFM105', RepairStatusUpdate.GeneralData); System.Test.startTest(); //NFM105Rest.NFM105(RepairStatusUpdate); if (String.isBlank(rowData.Log__c) == false) NFM105Rest.main(rowData.Id); System.Test.stopTest(); } @isTest static void testNFM105_update_L80() { StaticParameter.EventOpportunityPileUpExeFlg = true; // EventC⇒Event処理後、逆更新をスルー用 StaticParameter.NotUpdEventCFlg = true; // 積み上げ処理後、トリガをスルー用 StaticParameter.EscapeNFM001Trigger = true; StaticParameter.EscapeNFM001AgencyContractTrigger = true; StaticParameter.EscapeNFM001AgencyContractTrigger2 = true; StaticParameter.EscapeNFM007Trigger = true; StaticParameter.EscapeOpportunityBefUpdTrigger = true; StaticParameter.EscapeOpportunityHpDeptUpdTrigger = true; StaticParameter.EscapeSyncOpportunityTrigger = true; StaticParameter.EscapeMaintenanceContractAfterUpdateTrigger = true; StaticParameter.EscapeSyncProduct2Trigger = true; // trueのとき、リードのトリガーをスルーする StaticParameter.EscapeLeadTrigger = true; StaticParameter.EscapeAccountTrigger = true; StaticParameter.EscapeConsumableOrderDetail2Trigger = true; StaticParameter.EscapeNFM010UpsertStatuAchievementsTrigger = true; // 直销耗材不直销 ConsumableAssetHander StaticParameter.ConsumableAssetHanderTrigger = true; // 跳过不涉及备品借出的逻辑 StaticParameter.rentalApplyIsRunning = true; // accountdailyUpdate 跳过 更新询价 StaticParameter.EscapeOpportunityownerUpdate = true; Repair__c rpr = [select Id, Name, Delivered_Product__c, SAPRepairNo__c, Repair_Quotation_Id__c from Repair__c limit 1]; Repair_Quotation__c rq1 = new Repair_Quotation__c(); rq1.Name = 'NFM105U1'; rq1.Repair__c = rpr.Id; Repair_Quotation__c rq2 = new Repair_Quotation__c(); rq2.Name = 'NFM105U2'; rq2.Repair__c = rpr.Id; insert new Repair_Quotation__c[] {rq1, rq2}; NFM105Rest.RepairStatusUpdate RepairStatusUpdate = new NFM105Rest.RepairStatusUpdate(); NFM105Rest.GeneralData GeneralData = new NFM105Rest.GeneralData(); NFM105Rest.GeneralData GeneralData2 = new NFM105Rest.GeneralData(); NFM105Rest.InspectionResultInformation InspectionResultInformation = new NFM105Rest.InspectionResultInformation(); NFM105Rest.InspectionResultInformation InspectionResultInformation2 = new NFM105Rest.InspectionResultInformation(); NFM105Rest.FailureInformation FailureInformation = new NFM105Rest.FailureInformation(); NFM105Rest.FailureInformation FailureInformation1 = new NFM105Rest.FailureInformation(); GeneralData.InspectionResultInformation = new NFM105Rest.InspectionResultInformation[] { InspectionResultInformation }; GeneralData2.InspectionResultInformation = new NFM105Rest.InspectionResultInformation[] { InspectionResultInformation2 }; GeneralData2.FailureInformation = new NFM105Rest.FailureInformation[] { FailureInformation, FailureInformation1 }; RepairStatusUpdate.GeneralData = new NFM105Rest.GeneralData[] { GeneralData, GeneralData2 }; // Monitoringの設定 Datetime nowDT = Datetime.now(); String nowStr = nowDT.format('MMddHHmm'); RepairStatusUpdate.Monitoring = new NFMUtil.Monitoring(); // NFM105U1 => L80 RepairStatusUpdate.Monitoring.MessageGroupNumber = nowStr + '2'; GeneralData.SFDCRepairNo = rpr.Name; GeneralData.SAPRepairNo = rpr.SAPRepairNo__c; GeneralData.RepairOrderStatusCode = 'L80'; GeneralData.RepairOrderStatusName = '报价同意确认'; GeneralData.StatusUpdateDate = '20150101'; GeneralData.StatusUpdateTime = '101010'; GeneralData.StatusUpdatePersonName = 'John'; GeneralData.CancellationReason = 'R2 到其他公司修理 '; GeneralData.IncorrectDataComment = 'xxxxx'; GeneralData.SAPQuotationNo = 'NFM105U1'; GeneralData.ReturnType = 'A20'; InspectionResultInformation.InspectionResultFlag = 'X'; InspectionResultInformation.InspectionComment = 'CCD线长度: 248MM 把手、S盖脱漆、磨损,旋纽划痕,吸引口、水气口、1号外皮轻磨损。'; InspectionResultInformation.FailureCause = '先端部金属磨损严重,插入部发黄结晶,角度不足,钳子口磨损,2、3号外皮变色,水气不畅,CCD玻璃缺损大于1/10,涂胶后无阴影。B级不修理故障:CCD玻璃缺损大于1/10'; // NFM105U2 => L80 GeneralData2.SFDCRepairNo = rpr.Name; GeneralData2.SAPRepairNo = rpr.SAPRepairNo__c; GeneralData2.RepairOrderStatusCode = 'L80'; GeneralData2.RepairOrderStatusName = '报价同意确认'; GeneralData2.StatusUpdateDate = '20150202'; GeneralData2.StatusUpdateTime = '111111'; GeneralData2.StatusUpdatePersonName = 'John'; GeneralData2.CancellationReason = 'R2 到其他公司修理 '; GeneralData2.IncorrectDataComment = 'xxxxx'; GeneralData2.SAPQuotationNo = 'NFM105U2'; GeneralData.ReturnType = 'A20'; InspectionResultInformation2.InspectionResultFlag = ''; InspectionResultInformation2.InspectionComment = 'CCD线长度: 248MM 把手、S盖脱漆、磨损,旋纽划痕,吸引口、水气口、1号外皮轻磨损。'; InspectionResultInformation2.FailureCause = '先端部金属磨损严重,插入部发黄结晶,角度不足,钳子口磨损,2、3号外皮变色,水气不畅,CCD玻璃缺损大于1/10,涂胶后无阴影。B级不修理故障:CCD玻璃缺损大于1/10'; FailureInformation.LocationGroupName = '内镜连接座部'; FailureInformation.LocationName = 'LG导光杆部'; FailureInformation.PhenomenonName = 'IG导光束异常(红裂缝、折损、彩虹斑)'; FailureInformation.CauseName = '劣化, 老化'; FailureInformation.DescriptionName = '由于送气?送水圆筒的刮痕导致气囊送水量不能达到规格值。'; FailureInformation1.LocationGroupName = '1内镜连接座部'; FailureInformation1.LocationName = '1LG导光杆部'; FailureInformation1.PhenomenonName = '1IG导光束异常(红裂缝、折损、彩虹斑)'; FailureInformation1.CauseName = '1劣化, 老化'; FailureInformation1.DescriptionName = '1由于送气?送水圆筒的刮痕导致气囊送水量不能达到规格值。'; GeneralData2.FailureInformation = new NFM105Rest.FailureInformation[] { FailureInformation, FailureInformation1 }; BatchIF_Log__c rowData = NFMUtil.saveRowData(RepairStatusUpdate.Monitoring, 'NFM105', RepairStatusUpdate.GeneralData); System.Test.startTest(); //NFM105Rest.NFM105(RepairStatusUpdate); if (String.isBlank(rowData.Log__c) == false) NFM105Rest.main(rowData.Id); System.Test.stopTest(); } //StatusCode = 'A95'; @isTest static void testNFM105_update_A95() { StaticParameter.EventOpportunityPileUpExeFlg = true; // EventC⇒Event処理後、逆更新をスルー用 StaticParameter.NotUpdEventCFlg = true; // 積み上げ処理後、トリガをスルー用 StaticParameter.EscapeNFM001Trigger = true; StaticParameter.EscapeNFM001AgencyContractTrigger = true; StaticParameter.EscapeNFM001AgencyContractTrigger2 = true; StaticParameter.EscapeNFM007Trigger = true; StaticParameter.EscapeOpportunityBefUpdTrigger = true; StaticParameter.EscapeOpportunityHpDeptUpdTrigger = true; StaticParameter.EscapeSyncOpportunityTrigger = true; StaticParameter.EscapeMaintenanceContractAfterUpdateTrigger = true; StaticParameter.EscapeSyncProduct2Trigger = true; // trueのとき、リードのトリガーをスルーする StaticParameter.EscapeLeadTrigger = true; StaticParameter.EscapeAccountTrigger = true; StaticParameter.EscapeConsumableOrderDetail2Trigger = true; StaticParameter.EscapeNFM010UpsertStatuAchievementsTrigger = true; // 直销耗材不直销 ConsumableAssetHander StaticParameter.ConsumableAssetHanderTrigger = true; // 跳过不涉及备品借出的逻辑 StaticParameter.rentalApplyIsRunning = true; // accountdailyUpdate 跳过 更新询价 StaticParameter.EscapeOpportunityownerUpdate = true; Repair__c rpr = [select Id, Name, Delivered_Product__c, SAPRepairNo__c, Repair_Quotation_Id__c from Repair__c limit 1]; Repair_Quotation__c rq1 = new Repair_Quotation__c(); rq1.Name = 'NFM105U1'; rq1.Repair__c = rpr.Id; Repair_Quotation__c rq2 = new Repair_Quotation__c(); rq2.Name = 'NFM105U2'; rq2.Repair__c = rpr.Id; insert new Repair_Quotation__c[] {rq1, rq2}; NFM105Rest.RepairStatusUpdate RepairStatusUpdate = new NFM105Rest.RepairStatusUpdate(); NFM105Rest.GeneralData GeneralData = new NFM105Rest.GeneralData(); NFM105Rest.InspectionResultInformation InspectionResultInformation = new NFM105Rest.InspectionResultInformation(); NFM105Rest.FailureInformation FailureInformation = new NFM105Rest.FailureInformation(); GeneralData.InspectionResultInformation = new NFM105Rest.InspectionResultInformation[] { InspectionResultInformation }; GeneralData.FailureInformation = new NFM105Rest.FailureInformation[] { FailureInformation }; RepairStatusUpdate.GeneralData = new NFM105Rest.GeneralData[] { GeneralData }; // Monitoringの設定 Datetime nowDT = Datetime.now(); String nowStr = nowDT.format('yyyyMMddHHmm'); RepairStatusUpdate.Monitoring = new NFMUtil.Monitoring(); RepairStatusUpdate.Monitoring.MessageGroupNumber = nowStr + '2'; // update GeneralData.SFDCRepairNo = rpr.Name; GeneralData.SAPRepairNo = rpr.SAPRepairNo__c; GeneralData.RepairOrderStatusCode = 'A95'; GeneralData.RepairOrderStatusName = '报价同意确认'; GeneralData.StatusUpdateDate = '20150101'; GeneralData.StatusUpdateTime = '101010'; GeneralData.StatusUpdatePersonName = 'John'; GeneralData.CancellationReason = 'R2 到其他公司修理'; GeneralData.IncorrectDataComment = 'xxxxx'; GeneralData.SAPQuotationNo = 'NFM105U2'; InspectionResultInformation.InspectionResultFlag = 'X'; InspectionResultInformation.InspectionComment = 'CCD线长度: 248MM 把手、S盖脱漆、磨损,旋纽划痕,吸引口、水气口、1号外皮轻磨损。'; InspectionResultInformation.FailureCause = '先端部金属磨损严重,插入部发黄结晶,角度不足,钳子口磨损,2、3号外皮变色,水气不畅,CCD玻璃缺损大于1/10,涂胶后无阴影。B级不修理故障:CCD玻璃缺损大于1/10'; FailureInformation.LocationGroupName = '内镜连接座部'; FailureInformation.LocationName = 'LG导光杆部'; FailureInformation.PhenomenonName = 'IG导光束异常(红裂缝、折损、彩虹斑)'; FailureInformation.CauseName = '劣化, 老化'; FailureInformation.DescriptionName = '由于送气?送水圆筒的刮痕导致气囊送水量不能达到规格值。'; System.Test.startTest(); //NFM105Rest.NFM105(RepairStatusUpdate); BatchIF_Log__c rowData = NFMUtil.saveRowData(RepairStatusUpdate.Monitoring, 'NFM105', RepairStatusUpdate.GeneralData); if (String.isBlank(rowData.Log__c) == false) NFM105Rest.main(rowData.Id); System.Test.stopTest(); // List sapRpairList = [select Id, Name, SAPRepairNo__c // , RepairOrderStatusName__c, RepairOrderStatusCode__c // , CancellationReason__c, IncorrectDataComment__c // , Repair_Ordered_Date__c, NFM105_MessageGroupNumber__c // , Repair_Quotation_Id__c // from Repair__c // where SAPRepairNo__c = :GeneralData.SAPRepairNo]; // System.assertEquals(1, sapRpairList.size()); // if (sapRpairList.size() == 1) { // System.assertEquals(GeneralData.SAPRepairNo, sapRpairList[0].SAPRepairNo__c); // System.assertEquals(GeneralData.RepairOrderStatusName, sapRpairList[0].RepairOrderStatusName__c); // System.assertEquals(GeneralData.RepairOrderStatusCode, sapRpairList[0].RepairOrderStatusCode__c); // System.assertEquals(GeneralData.CancellationReason, sapRpairList[0].CancellationReason__c); // System.assertEquals(null, sapRpairList[0].IncorrectDataComment__c); // } // List quotationList = [select Id, Name, Repair_Rank__c, Repair__c, Quotation_agreement__c // , InspectionComment__c, InspectionResultFlag__c // , InspectionFailureCause__c, CauseName__c, DescriptionName__c // , LocationName__c, LocationGroupName__c // , PhenomenonName__c, LatestQuotationDate__c // , FirstQuotationDate__c, DiscountAmount__c // , TotalPrice__c, DiscountType__c // , CafeteriaFlag__c, MessageGroupNumber__c // from Repair_Quotation__c // where Name = :GeneralData.SAPQuotationNo // ]; // System.assertEquals(1, quotationList.size()); // if (quotationList.size() == 1) { // System.assertEquals(GeneralData.SAPQuotationNo, quotationList[0].Name); // System.assertEquals(false, quotationList[0].Quotation_agreement__c); // System.assertEquals(null, quotationList[0].InspectionResultFlag__c); // System.assertEquals(null, quotationList[0].InspectionComment__c); // System.assertEquals(null, quotationList[0].InspectionFailureCause__c); // List qrsn0List = [select ActivityDescription__c, Repair_quotation__c, LocationGroupName__c, LocationName__c, PhenomenonName__c, CauseName__c, DescriptionName__c from Repair_quotation_reason__c where Repair_quotation__c <>: quotationList[0].Id]; // System.assertEquals(0, qrsn0List.size()); // List qrsnList = [select ActivityDescription__c, Repair_quotation__c, LocationGroupName__c, LocationName__c, PhenomenonName__c, CauseName__c, DescriptionName__c from Repair_quotation_reason__c where Repair_quotation__c = : quotationList[0].Id]; // System.assertEquals(0, qrsnList.size()); // } } //StatusCode = 'A99'; @isTest static void testNFM105_update_A99() { StaticParameter.EventOpportunityPileUpExeFlg = true; // EventC⇒Event処理後、逆更新をスルー用 StaticParameter.NotUpdEventCFlg = true; // 積み上げ処理後、トリガをスルー用 StaticParameter.EscapeNFM001Trigger = true; StaticParameter.EscapeNFM001AgencyContractTrigger = true; StaticParameter.EscapeNFM001AgencyContractTrigger2 = true; StaticParameter.EscapeNFM007Trigger = true; StaticParameter.EscapeOpportunityBefUpdTrigger = true; StaticParameter.EscapeOpportunityHpDeptUpdTrigger = true; StaticParameter.EscapeSyncOpportunityTrigger = true; StaticParameter.EscapeMaintenanceContractAfterUpdateTrigger = true; StaticParameter.EscapeSyncProduct2Trigger = true; // trueのとき、リードのトリガーをスルーする StaticParameter.EscapeLeadTrigger = true; StaticParameter.EscapeAccountTrigger = true; StaticParameter.EscapeConsumableOrderDetail2Trigger = true; StaticParameter.EscapeNFM010UpsertStatuAchievementsTrigger = true; // 直销耗材不直销 ConsumableAssetHander StaticParameter.ConsumableAssetHanderTrigger = true; // 跳过不涉及备品借出的逻辑 StaticParameter.rentalApplyIsRunning = true; // accountdailyUpdate 跳过 更新询价 StaticParameter.EscapeOpportunityownerUpdate = true; Repair__c rpr = [select Id, Name, Delivered_Product__c, SAPRepairNo__c, Repair_Quotation_Id__c from Repair__c limit 1]; Repair_Quotation__c rq1 = new Repair_Quotation__c(); rq1.Name = 'NFM105U1'; rq1.Repair__c = rpr.Id; Repair_Quotation__c rq2 = new Repair_Quotation__c(); rq2.Name = 'NFM105U2'; rq2.Repair__c = rpr.Id; insert new Repair_Quotation__c[] {rq1, rq2}; NFM105Rest.RepairStatusUpdate RepairStatusUpdate = new NFM105Rest.RepairStatusUpdate(); NFM105Rest.GeneralData GeneralData = new NFM105Rest.GeneralData(); NFM105Rest.InspectionResultInformation InspectionResultInformation = new NFM105Rest.InspectionResultInformation(); NFM105Rest.FailureInformation FailureInformation = new NFM105Rest.FailureInformation(); GeneralData.InspectionResultInformation = new NFM105Rest.InspectionResultInformation[] { InspectionResultInformation }; GeneralData.FailureInformation = new NFM105Rest.FailureInformation[] { FailureInformation }; RepairStatusUpdate.GeneralData = new NFM105Rest.GeneralData[] { GeneralData }; // Monitoringの設定 Datetime nowDT = Datetime.now(); String nowStr = nowDT.format('yyyyMMddHHmm'); RepairStatusUpdate.Monitoring = new NFMUtil.Monitoring(); RepairStatusUpdate.Monitoring.MessageGroupNumber = nowStr + '3'; // update GeneralData.SFDCRepairNo = rpr.Name; GeneralData.SAPRepairNo = rpr.SAPRepairNo__c; GeneralData.RepairOrderStatusCode = 'A99'; GeneralData.RepairOrderStatusName = '报价同意确认'; GeneralData.StatusUpdateDate = '20150101'; GeneralData.StatusUpdateTime = '101010'; GeneralData.StatusUpdatePersonName = 'John'; GeneralData.CancellationReason = 'R2 到其他公司修理 '; GeneralData.IncorrectDataComment = 'xxxxx'; GeneralData.SAPQuotationNo = 'NFM105U2'; InspectionResultInformation.InspectionResultFlag = 'X'; InspectionResultInformation.InspectionComment = 'CCD线长度: 248MM 把手、S盖脱漆、磨损,旋纽划痕,吸引口、水气口、1号外皮轻磨损。'; InspectionResultInformation.FailureCause = '先端部金属磨损严重,插入部发黄结晶,角度不足,钳子口磨损,2、3号外皮变色,水气不畅,CCD玻璃缺损大于1/10,涂胶后无阴影。B级不修理故障:CCD玻璃缺损大于1/10'; FailureInformation.LocationGroupName = '内镜连接座部'; FailureInformation.LocationName = 'LG导光杆部'; FailureInformation.PhenomenonName = 'IG导光束异常(红裂缝、折损、彩虹斑)'; FailureInformation.CauseName = '劣化, 老化'; FailureInformation.DescriptionName = '由于送气?送水圆筒的刮痕导致气囊送水量不能达到规格值。'; System.Test.startTest(); //NFM105Rest.NFM105(RepairStatusUpdate); BatchIF_Log__c rowData = NFMUtil.saveRowData(RepairStatusUpdate.Monitoring, 'NFM105', RepairStatusUpdate.GeneralData); if (String.isBlank(rowData.Log__c) == false) NFM105Rest.main(rowData.Id); System.Test.stopTest(); // List sapRpairList = [select Id, Name, SAPRepairNo__c // , RepairOrderStatusName__c, RepairOrderStatusCode__c // , CancellationReason__c, IncorrectDataComment__c // , Repair_Ordered_Date__c, NFM105_MessageGroupNumber__c // , Repair_Quotation_Id__c // from Repair__c // where SAPRepairNo__c = :GeneralData.SAPRepairNo]; // System.assertEquals(1, sapRpairList.size()); // if (sapRpairList.size() == 1) { // System.assertEquals(GeneralData.SAPRepairNo, sapRpairList[0].SAPRepairNo__c); // System.assertEquals(GeneralData.RepairOrderStatusName, sapRpairList[0].RepairOrderStatusName__c); // System.assertEquals(GeneralData.RepairOrderStatusCode, sapRpairList[0].RepairOrderStatusCode__c); // System.assertEquals(null, sapRpairList[0].CancellationReason__c); // System.assertEquals(GeneralData.IncorrectDataComment, sapRpairList[0].IncorrectDataComment__c); // } // List quotationList = [select Id, Name, Repair_Rank__c, Repair__c, Quotation_agreement__c // , InspectionComment__c, InspectionResultFlag__c // , InspectionFailureCause__c, CauseName__c, DescriptionName__c // , LocationName__c, LocationGroupName__c // , PhenomenonName__c, LatestQuotationDate__c // , FirstQuotationDate__c, DiscountAmount__c // , TotalPrice__c, DiscountType__c // , CafeteriaFlag__c, MessageGroupNumber__c // from Repair_Quotation__c // where Name = :GeneralData.SAPQuotationNo // ]; // System.assertEquals(1, quotationList.size()); // if (quotationList.size() == 1) { // System.assertEquals(GeneralData.SAPQuotationNo, quotationList[0].Name); // System.assertEquals(false, quotationList[0].Quotation_agreement__c); // System.assertEquals(null, quotationList[0].InspectionResultFlag__c); // System.assertEquals(null, quotationList[0].InspectionComment__c); // System.assertEquals(null, quotationList[0].InspectionFailureCause__c); // List qrsn0List = [select ActivityDescription__c, Repair_quotation__c, LocationGroupName__c, LocationName__c, PhenomenonName__c, CauseName__c, DescriptionName__c from Repair_quotation_reason__c where Repair_quotation__c <>: quotationList[0].Id]; // System.assertEquals(0, qrsn0List.size()); // List qrsnList = [select ActivityDescription__c, Repair_quotation__c, LocationGroupName__c, LocationName__c, PhenomenonName__c, CauseName__c, DescriptionName__c from Repair_quotation_reason__c where Repair_quotation__c = : quotationList[0].Id]; // System.assertEquals(0, qrsnList.size()); // } } //StatusCode = 'A30'; @isTest static void testNFM105_update_A30() { StaticParameter.EventOpportunityPileUpExeFlg = true; // EventC⇒Event処理後、逆更新をスルー用 StaticParameter.NotUpdEventCFlg = true; // 積み上げ処理後、トリガをスルー用 StaticParameter.EscapeNFM001Trigger = true; StaticParameter.EscapeNFM001AgencyContractTrigger = true; StaticParameter.EscapeNFM001AgencyContractTrigger2 = true; StaticParameter.EscapeNFM007Trigger = true; StaticParameter.EscapeOpportunityBefUpdTrigger = true; StaticParameter.EscapeOpportunityHpDeptUpdTrigger = true; StaticParameter.EscapeSyncOpportunityTrigger = true; StaticParameter.EscapeMaintenanceContractAfterUpdateTrigger = true; StaticParameter.EscapeSyncProduct2Trigger = true; // trueのとき、リードのトリガーをスルーする StaticParameter.EscapeLeadTrigger = true; StaticParameter.EscapeAccountTrigger = true; StaticParameter.EscapeConsumableOrderDetail2Trigger = true; StaticParameter.EscapeNFM010UpsertStatuAchievementsTrigger = true; // 直销耗材不直销 ConsumableAssetHander StaticParameter.ConsumableAssetHanderTrigger = true; // 跳过不涉及备品借出的逻辑 StaticParameter.rentalApplyIsRunning = true; // accountdailyUpdate 跳过 更新询价 StaticParameter.EscapeOpportunityownerUpdate = true; Repair__c rpr = [select Id, Name, Delivered_Product__c, SAPRepairNo__c, Repair_Quotation_Id__c from Repair__c limit 1]; Repair_Quotation__c rq1 = new Repair_Quotation__c(); rq1.Name = 'NFM105U1'; rq1.Repair__c = rpr.Id; Repair_Quotation__c rq2 = new Repair_Quotation__c(); rq2.Name = 'NFM105U2'; rq2.Repair__c = rpr.Id; insert new Repair_Quotation__c[] {rq1, rq2}; NFM105Rest.RepairStatusUpdate RepairStatusUpdate = new NFM105Rest.RepairStatusUpdate(); NFM105Rest.GeneralData GeneralData = new NFM105Rest.GeneralData(); NFM105Rest.InspectionResultInformation InspectionResultInformation = new NFM105Rest.InspectionResultInformation(); NFM105Rest.FailureInformation FailureInformation = new NFM105Rest.FailureInformation(); GeneralData.InspectionResultInformation = new NFM105Rest.InspectionResultInformation[] { InspectionResultInformation }; GeneralData.FailureInformation = new NFM105Rest.FailureInformation[] { FailureInformation }; RepairStatusUpdate.GeneralData = new NFM105Rest.GeneralData[] { GeneralData }; // Monitoringの設定 Datetime nowDT = Datetime.now(); String nowStr = nowDT.format('yyyyMMddHHmm'); RepairStatusUpdate.Monitoring = new NFMUtil.Monitoring(); RepairStatusUpdate.Monitoring.MessageGroupNumber = nowStr + '3'; // update GeneralData.SFDCRepairNo = rpr.Name; GeneralData.SAPRepairNo = rpr.SAPRepairNo__c; GeneralData.RepairOrderStatusCode = 'A30'; GeneralData.RepairOrderStatusName = '报价同意确认'; GeneralData.StatusUpdateDate = '20150101'; GeneralData.StatusUpdateTime = '101010'; GeneralData.StatusUpdatePersonName = 'John'; GeneralData.CancellationReason = 'R2 到其他公司修理 '; GeneralData.IncorrectDataComment = 'xxxxx'; GeneralData.SAPQuotationNo = 'NFM105U2'; InspectionResultInformation.InspectionResultFlag = 'X'; InspectionResultInformation.InspectionComment = 'CCD线长度: 248MM 把手、S盖脱漆、磨损,旋纽划痕,吸引口、水气口、1号外皮轻磨损。'; InspectionResultInformation.FailureCause = '先端部金属磨损严重,插入部发黄结晶,角度不足,钳子口磨损,2、3号外皮变色,水气不畅,CCD玻璃缺损大于1/10,涂胶后无阴影。B级不修理故障:CCD玻璃缺损大于1/10'; FailureInformation.LocationGroupName = '内镜连接座部'; FailureInformation.LocationName = 'LG导光杆部'; FailureInformation.PhenomenonName = 'IG导光束异常(红裂缝、折损、彩虹斑)'; FailureInformation.CauseName = '劣化, 老化'; FailureInformation.DescriptionName = '由于送气?送水圆筒的刮痕导致气囊送水量不能达到规格值。'; System.Test.startTest(); //NFM105Rest.NFM105(RepairStatusUpdate); BatchIF_Log__c rowData = NFMUtil.saveRowData(RepairStatusUpdate.Monitoring, 'NFM105', RepairStatusUpdate.GeneralData); if (String.isBlank(rowData.Log__c) == false) NFM105Rest.main(rowData.Id); System.Test.stopTest(); } @isTest static void NFM105_Resendtest() { StaticParameter.EventOpportunityPileUpExeFlg = true; // EventC⇒Event処理後、逆更新をスルー用 StaticParameter.NotUpdEventCFlg = true; // 積み上げ処理後、トリガをスルー用 StaticParameter.EscapeNFM001Trigger = true; StaticParameter.EscapeNFM001AgencyContractTrigger = true; StaticParameter.EscapeNFM001AgencyContractTrigger2 = true; StaticParameter.EscapeNFM007Trigger = true; StaticParameter.EscapeOpportunityBefUpdTrigger = true; StaticParameter.EscapeOpportunityHpDeptUpdTrigger = true; StaticParameter.EscapeSyncOpportunityTrigger = true; StaticParameter.EscapeMaintenanceContractAfterUpdateTrigger = true; StaticParameter.EscapeSyncProduct2Trigger = true; // trueのとき、リードのトリガーをスルーする StaticParameter.EscapeLeadTrigger = true; StaticParameter.EscapeAccountTrigger = true; StaticParameter.EscapeConsumableOrderDetail2Trigger = true; StaticParameter.EscapeNFM010UpsertStatuAchievementsTrigger = true; // 直销耗材不直销 ConsumableAssetHander StaticParameter.ConsumableAssetHanderTrigger = true; // 跳过不涉及备品借出的逻辑 StaticParameter.rentalApplyIsRunning = true; // accountdailyUpdate 跳过 更新询价 StaticParameter.EscapeOpportunityownerUpdate = true; Repair__c rpr = [select Id, Name, Delivered_Product__c, SAPRepairNo__c, Repair_Quotation_Id__c from Repair__c limit 1]; Repair_Quotation__c rq1 = new Repair_Quotation__c(); rq1.Name = 'NFM105U1'; rq1.Repair__c = rpr.Id; Repair_Quotation__c rq2 = new Repair_Quotation__c(); rq2.Name = 'NFM105U2'; rq2.Repair__c = rpr.Id; insert new Repair_Quotation__c[] {rq1, rq2}; NFM105Rest.RepairStatusUpdate RepairStatusUpdate = new NFM105Rest.RepairStatusUpdate(); NFM105Rest.GeneralData GeneralData = new NFM105Rest.GeneralData(); NFM105Rest.InspectionResultInformation InspectionResultInformation = new NFM105Rest.InspectionResultInformation(); NFM105Rest.FailureInformation FailureInformation = new NFM105Rest.FailureInformation(); GeneralData.InspectionResultInformation = new NFM105Rest.InspectionResultInformation[] { InspectionResultInformation }; GeneralData.FailureInformation = new NFM105Rest.FailureInformation[] { FailureInformation }; RepairStatusUpdate.GeneralData = new NFM105Rest.GeneralData[] { GeneralData }; // Monitoringの設定 Datetime nowDT = Datetime.now(); String nowStr = nowDT.format('yyyyMMddHHmm'); RepairStatusUpdate.Monitoring = new NFMUtil.Monitoring(); RepairStatusUpdate.Monitoring.MessageGroupNumber = nowStr + '2'; // update GeneralData.SFDCRepairNo = rpr.Name; GeneralData.SAPRepairNo = rpr.SAPRepairNo__c; GeneralData.RepairOrderStatusCode = 'A95'; GeneralData.RepairOrderStatusName = '报价同意确认'; GeneralData.StatusUpdateDate = '20150101'; GeneralData.StatusUpdateTime = '101010'; GeneralData.StatusUpdatePersonName = 'John'; GeneralData.CancellationReason = 'R2 到其他公司修理'; GeneralData.IncorrectDataComment = 'xxxxx'; GeneralData.SAPQuotationNo = 'NFM105U2'; InspectionResultInformation.InspectionResultFlag = 'X'; InspectionResultInformation.InspectionComment = 'CCD线长度: 248MM 把手、S盖脱漆、磨损,旋纽划痕,吸引口、水气口、1号外皮轻磨损。'; InspectionResultInformation.FailureCause = '先端部金属磨损严重,插入部发黄结晶,角度不足,钳子口磨损,2、3号外皮变色,水气不畅,CCD玻璃缺损大于1/10,涂胶后无阴影。B级不修理故障:CCD玻璃缺损大于1/10'; FailureInformation.LocationGroupName = '内镜连接座部'; FailureInformation.LocationName = 'LG导光杆部'; FailureInformation.PhenomenonName = 'IG导光束异常(红裂缝、折损、彩虹斑)'; FailureInformation.CauseName = '劣化, 老化'; FailureInformation.DescriptionName = '由于送气?送水圆筒的刮痕导致气囊送水量不能达到规格值。'; System.Test.startTest(); //NFM105Rest.NFM105(RepairStatusUpdate); BatchIF_Log__c rowData = NFMUtil.saveRowData(RepairStatusUpdate.Monitoring, 'NFM105', RepairStatusUpdate.GeneralData); if (String.isBlank(rowData.Log__c) == false) NFM105Rest.main(rowData.Id); // System.Test.stopTest(); else { List repair = [select Id, Name from Repair__c where Id = :rpr.Id]; System.assertEquals(1, repair.size()); List rowbl = [Select Id, Log__c, ErrorLog__c, retry_cnt__c from BatchIF_Log__c where RowDataFlg__c = true and Type__c = 'NFM105' order by CreatedDate desc]; System.assertEquals(1, rowbl.size()); rowbl[0].retry_cnt__c = 1; update rowbl; NFM105Rest.main(rowbl[0].id); System.Test.stopTest(); List bl = [Select Id, Is_Error__c, Type__c, Log__c, ErrorLog__c, retry_cnt__c from BatchIF_Log__c where Id = :rowbl[0].id]; System.assertEquals(1, bl.size()); } //System.assertEquals(1, bl[0].retry_cnt__c); } // TODO Assetの値のasset、未修理 と 再受付 @isTest static void test_method_execute() { Test.startTest(); RestRequest req = new RestRequest(); RestResponse res = new RestResponse(); String JsonMsg = '{ "RepairStatusUpdate": {"Monitoring":{"TransmissionDateTime":"201812201320","Text":"","Tag":"MSGH","Sender":"SFDC","Receiver":"SPO","NumberOfRecord":"1","MessageType":"NFM105","MessageGroupNumber":"20180001722190"},"GeneralData":[{"StatusUpdateTime":"102449","StatusUpdatePersonName":"董俊龙","StatusUpdateDate":"20190409","SFDCRepairNo":"RS-201904-437259","SAPRepairNo":"000010106343","SAPQuotationNo":"","ReturnType":"","ReRepairObject":"","RepairOrderStatusName":"RC受理完成","RepairOrderStatusCode":"A20","PlannedRepairFinishDate":"","InspectType":"","InspectionResultInformation":null,"IncorrectDataComment":"","FailureInformation":null,"CancellationReason":""}]}}'; req.requestURI = 'services/apexrest/NFM105/execute'; req.httpMethod = 'POST'; req.requestBody = Blob.valueof(JsonMsg); RestContext.request = req; RestContext.response = res; NFM105Rest.execute(); Test.stopTest(); } //add by rentx 2021-04-28 start //StatusCode = 'B99'; @isTest static void testNFM105_update_L99() { StaticParameter.EventOpportunityPileUpExeFlg = true; // EventC⇒Event処理後、逆更新をスルー用 StaticParameter.NotUpdEventCFlg = true; // 積み上げ処理後、トリガをスルー用 StaticParameter.EscapeNFM001Trigger = true; StaticParameter.EscapeNFM001AgencyContractTrigger = true; StaticParameter.EscapeNFM001AgencyContractTrigger2 = true; StaticParameter.EscapeNFM007Trigger = true; StaticParameter.EscapeOpportunityBefUpdTrigger = true; StaticParameter.EscapeOpportunityHpDeptUpdTrigger = true; StaticParameter.EscapeSyncOpportunityTrigger = true; StaticParameter.EscapeMaintenanceContractAfterUpdateTrigger = true; StaticParameter.EscapeSyncProduct2Trigger = true; // trueのとき、リードのトリガーをスルーする StaticParameter.EscapeLeadTrigger = true; StaticParameter.EscapeAccountTrigger = true; StaticParameter.EscapeConsumableOrderDetail2Trigger = true; StaticParameter.EscapeNFM010UpsertStatuAchievementsTrigger = true; // 直销耗材不直销 ConsumableAssetHander StaticParameter.ConsumableAssetHanderTrigger = true; // 跳过不涉及备品借出的逻辑 StaticParameter.rentalApplyIsRunning = true; // accountdailyUpdate 跳过 更新询价 StaticParameter.EscapeOpportunityownerUpdate = true; Repair__c rpr = [select Id, Name, Delivered_Product__c, SAPRepairNo__c, Repair_Quotation_Id__c from Repair__c limit 1]; Repair_Quotation__c rq1 = new Repair_Quotation__c(); rq1.Name = 'NFM105U1'; rq1.Repair__c = rpr.Id; Repair_Quotation__c rq2 = new Repair_Quotation__c(); rq2.Name = 'NFM105U2'; rq2.Repair__c = rpr.Id; Repair_Quotation__c rq3 = new Repair_Quotation__c(); rq3.Name = 'NFM105U3'; rq3.Repair__c = rpr.Id; Repair_Quotation__c rq4 = new Repair_Quotation__c(); rq4.Name = 'NFM105U4'; rq4.Repair__c = rpr.Id; Repair_Quotation__c rq5 = new Repair_Quotation__c(); rq5.Name = 'NFM105U5'; rq5.Repair__c = rpr.Id; Repair_Quotation__c rq6 = new Repair_Quotation__c(); rq6.Name = 'NFM105U6'; rq6.Repair__c = rpr.Id; Repair_Quotation__c rq7 = new Repair_Quotation__c(); rq7.Name = 'NFM105U7'; rq7.Repair__c = rpr.Id; Repair_Quotation__c rq8 = new Repair_Quotation__c(); rq8.Name = 'NFM105U8'; rq8.Repair__c = rpr.Id; Repair_Quotation__c rq9 = new Repair_Quotation__c(); rq9.Name = 'NFM105U9'; rq9.Repair__c = rpr.Id; Repair_Quotation__c rq10 = new Repair_Quotation__c(); rq10.Name = 'NFM105U10'; rq10.Repair__c = rpr.Id; insert new Repair_Quotation__c[] {rq1, rq2, rq3, rq4, rq5, rq6, rq7, rq8, rq9, rq10}; NFM105Rest.RepairStatusUpdate RepairStatusUpdate = new NFM105Rest.RepairStatusUpdate(); NFM105Rest.GeneralData GeneralData = new NFM105Rest.GeneralData(); NFM105Rest.GeneralData GeneralData2 = new NFM105Rest.GeneralData(); NFM105Rest.GeneralData GeneralData3 = new NFM105Rest.GeneralData(); NFM105Rest.GeneralData GeneralData4 = new NFM105Rest.GeneralData(); NFM105Rest.GeneralData GeneralData5 = new NFM105Rest.GeneralData(); NFM105Rest.GeneralData GeneralData6 = new NFM105Rest.GeneralData(); NFM105Rest.GeneralData GeneralData7 = new NFM105Rest.GeneralData(); NFM105Rest.GeneralData GeneralData8 = new NFM105Rest.GeneralData(); NFM105Rest.GeneralData GeneralData9 = new NFM105Rest.GeneralData(); NFM105Rest.GeneralData GeneralData10 = new NFM105Rest.GeneralData(); NFM105Rest.InspectionResultInformation InspectionResultInformation = new NFM105Rest.InspectionResultInformation(); NFM105Rest.InspectionResultInformation InspectionResultInformation2 = new NFM105Rest.InspectionResultInformation(); NFM105Rest.FailureInformation FailureInformation = new NFM105Rest.FailureInformation(); NFM105Rest.FailureInformation FailureInformation1 = new NFM105Rest.FailureInformation(); GeneralData.InspectionResultInformation = new NFM105Rest.InspectionResultInformation[] { InspectionResultInformation }; GeneralData2.InspectionResultInformation = new NFM105Rest.InspectionResultInformation[] { InspectionResultInformation2 }; GeneralData2.FailureInformation = new NFM105Rest.FailureInformation[] { FailureInformation, FailureInformation1 }; RepairStatusUpdate.GeneralData = new NFM105Rest.GeneralData[] { GeneralData, GeneralData2, GeneralData3,GeneralData4,GeneralData5,GeneralData6,GeneralData7,GeneralData8,GeneralData9,GeneralData10}; // Monitoringの設定 Datetime nowDT = Datetime.now(); String nowStr = nowDT.format('MMddHHmm'); RepairStatusUpdate.Monitoring = new NFMUtil.Monitoring(); // NFM105U1 => X30 RepairStatusUpdate.Monitoring.MessageGroupNumber = nowStr + '2'; GeneralData.SFDCRepairNo = rpr.Name; GeneralData.SAPRepairNo = rpr.SAPRepairNo__c; GeneralData.RepairOrderStatusCode = 'X30'; GeneralData.RepairOrderStatusName = '报价同意确认'; GeneralData.StatusUpdateDate = '20150101'; GeneralData.StatusUpdateTime = '101010'; GeneralData.StatusUpdatePersonName = 'John'; GeneralData.CancellationReason = 'R2 到其他公司修理 '; GeneralData.IncorrectDataComment = 'xxxxx'; GeneralData.SAPQuotationNo = 'NFM105U1'; // NFM105U2 => C50 GeneralData2.SFDCRepairNo = rpr.Name; GeneralData2.SAPRepairNo = rpr.SAPRepairNo__c; GeneralData2.RepairOrderStatusCode = 'C50'; GeneralData2.RepairOrderStatusName = '报价同意确认'; GeneralData2.StatusUpdateDate = '20150202'; GeneralData2.StatusUpdateTime = '111111'; GeneralData2.StatusUpdatePersonName = 'John'; GeneralData2.CancellationReason = 'R2 到其他公司修理 '; GeneralData2.IncorrectDataComment = 'xxxxx'; GeneralData2.SAPQuotationNo = 'NFM105U2'; InspectionResultInformation2.InspectionResultFlag = ''; // NFM105U3 => C70 GeneralData3.SFDCRepairNo = rpr.Name; GeneralData3.SAPRepairNo = rpr.SAPRepairNo__c; GeneralData3.RepairOrderStatusCode = 'C70'; GeneralData3.RepairOrderStatusName = '报价同意确认'; GeneralData3.StatusUpdateDate = '20150203'; GeneralData3.StatusUpdateTime = '111111'; GeneralData3.StatusUpdatePersonName = 'John'; GeneralData3.CancellationReason = 'R2 到其他公司修理 '; GeneralData3.IncorrectDataComment = 'xxxxx'; GeneralData3.SAPQuotationNo = 'NFM105U3'; InspectionResultInformation2.InspectionResultFlag = ''; // NFM105U4 => L99 GeneralData4.SFDCRepairNo = rpr.Name; GeneralData4.SAPRepairNo = rpr.SAPRepairNo__c; GeneralData4.RepairOrderStatusCode = 'L99'; GeneralData4.RepairOrderStatusName = '报价同意确认'; GeneralData4.StatusUpdateDate = '20150203'; GeneralData4.StatusUpdateTime = '111111'; GeneralData4.StatusUpdatePersonName = 'John'; GeneralData4.CancellationReason = 'R2 到其他公司修理 '; GeneralData4.IncorrectDataComment = 'xxxxx'; GeneralData4.SAPQuotationNo = 'NFM105U4'; GeneralData4.InspectType = '1'; InspectionResultInformation2.InspectionResultFlag = ''; // NFM105U5 => E10 GeneralData5.SFDCRepairNo = rpr.Name; GeneralData5.SAPRepairNo = rpr.SAPRepairNo__c; GeneralData5.RepairOrderStatusCode = 'E10'; GeneralData5.RepairOrderStatusName = '报价同意确认'; GeneralData5.StatusUpdateDate = '20150202'; GeneralData5.StatusUpdateTime = '111111'; GeneralData5.StatusUpdatePersonName = 'John'; GeneralData5.CancellationReason = 'R2 到其他公司修理 '; GeneralData5.IncorrectDataComment = 'xxxxx'; GeneralData5.SAPQuotationNo = 'NFM105U5'; InspectionResultInformation2.InspectionResultFlag = ''; // NFM105U6 => L20 GeneralData6.SFDCRepairNo = rpr.Name; GeneralData6.SAPRepairNo = rpr.SAPRepairNo__c; GeneralData6.RepairOrderStatusCode = 'L20'; GeneralData6.RepairOrderStatusName = '报价同意确认'; GeneralData6.StatusUpdateDate = '20150202'; GeneralData6.StatusUpdateTime = '111111'; GeneralData6.StatusUpdatePersonName = 'John'; GeneralData6.CancellationReason = 'R2 到其他公司修理 '; GeneralData6.IncorrectDataComment = 'xxxxx'; GeneralData6.SAPQuotationNo = 'NFM105U6'; InspectionResultInformation2.InspectionResultFlag = ''; // NFM105U7 => L25 GeneralData7.SFDCRepairNo = rpr.Name; GeneralData7.SAPRepairNo = rpr.SAPRepairNo__c; GeneralData7.RepairOrderStatusCode = 'L25'; GeneralData7.RepairOrderStatusName = '报价同意确认'; GeneralData7.StatusUpdateDate = '20150202'; GeneralData7.StatusUpdateTime = '111111'; GeneralData7.StatusUpdatePersonName = 'John'; GeneralData7.CancellationReason = 'R2 到其他公司修理 '; GeneralData7.IncorrectDataComment = 'xxxxx'; GeneralData7.SAPQuotationNo = 'NFM105U7'; InspectionResultInformation2.InspectionResultFlag = ''; // NFM105U8 => L30 GeneralData8.SFDCRepairNo = rpr.Name; GeneralData8.SAPRepairNo = rpr.SAPRepairNo__c; GeneralData8.RepairOrderStatusCode = 'L30'; GeneralData8.RepairOrderStatusName = '报价同意确认'; GeneralData8.StatusUpdateDate = '20150202'; GeneralData8.StatusUpdateTime = '111111'; GeneralData8.StatusUpdatePersonName = 'John'; GeneralData8.CancellationReason = 'R2 到其他公司修理 '; GeneralData8.IncorrectDataComment = 'xxxxx'; GeneralData8.SAPQuotationNo = 'NFM105U8'; InspectionResultInformation2.InspectionResultFlag = ''; // NFM105U9 => L40 GeneralData9.SFDCRepairNo = rpr.Name; GeneralData9.SAPRepairNo = rpr.SAPRepairNo__c; GeneralData9.RepairOrderStatusCode = 'L40'; GeneralData9.RepairOrderStatusName = '报价同意确认'; GeneralData9.StatusUpdateDate = '20150202'; GeneralData9.StatusUpdateTime = '111111'; GeneralData9.StatusUpdatePersonName = 'John'; GeneralData9.CancellationReason = 'R2 到其他公司修理 '; GeneralData9.IncorrectDataComment = 'xxxxx'; GeneralData9.SAPQuotationNo = 'NFM105U9'; InspectionResultInformation2.InspectionResultFlag = ''; // NFM105U10 => L45 GeneralData10.SFDCRepairNo = rpr.Name; GeneralData10.SAPRepairNo = rpr.SAPRepairNo__c; GeneralData10.RepairOrderStatusCode = 'L45'; GeneralData10.RepairOrderStatusName = '报价同意确认'; GeneralData10.StatusUpdateDate = '20150202'; GeneralData10.StatusUpdateTime = '111111'; GeneralData10.StatusUpdatePersonName = 'John'; GeneralData10.CancellationReason = 'R2 到其他公司修理 '; GeneralData10.IncorrectDataComment = 'xxxxx'; GeneralData10.SAPQuotationNo = 'NFM105U10'; InspectionResultInformation2.InspectionResultFlag = ''; GeneralData2.FailureInformation = new NFM105Rest.FailureInformation[] { FailureInformation, FailureInformation1 }; BatchIF_Log__c rowData = NFMUtil.saveRowData(RepairStatusUpdate.Monitoring, 'NFM105', RepairStatusUpdate.GeneralData); System.Test.startTest(); //NFM105Rest.NFM105(RepairStatusUpdate); if (String.isBlank(rowData.Log__c) == false) { NFM105Rest.main(rowData.Id); } System.Test.stopTest(); System.debug('rowData+++'+rowData.MessageGroupNumber__c); } //add by rentx 2021-04-28 end }