@isTest //TODO resend unit test private class NFM105WebServiceTest { static Repair__c 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 = 'NFM105Ast1'; ast.AccountId = depart.Id; ast.Department_Class__c = section.Id; ast.Hospital__c = company.Id; ast.Product2Id = prd1.Id; ast.SerialNumber = 'NFM105SerialNumber'; ast.Guarantee_period_for_products__c = Date.today(); ast.InstallDate = Date.today(); insert ast; 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]; 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 = Userinfo.getUserId(); rpr.Repair_Detail__c = 'test'; insert rpr; rpr = [select Id, Name, Delivered_Product__c, SAPRepairNo__c, Repair_Quotation_Id__c from Repair__c where Id =: rpr.Id]; return rpr; } // そのままreturn @isTest static void testNFM105_void() { // null NFM105WebService.NFM105(null); NFM105WebService.RepairStatusUpdate RepairStatusUpdate = new NFM105WebService.RepairStatusUpdate(); NFM105WebService.GeneralData GeneralData = new NFM105WebService.GeneralData(); NFM105WebService.InspectionResultInformation InspectionResultInformation = new NFM105WebService.InspectionResultInformation(); NFM105WebService.FailureInformation FailureInformation = new NFM105WebService.FailureInformation(); GeneralData.InspectionResultInformation = new NFM105WebService.InspectionResultInformation[] { InspectionResultInformation }; GeneralData.FailureInformation = new NFM105WebService.FailureInformation[] { FailureInformation }; RepairStatusUpdate.GeneralData = new NFM105WebService.GeneralData[] { GeneralData }; // Monitoringをセットしない NFM105WebService.NFM105(RepairStatusUpdate); Datetime nowDT = Datetime.now(); String nowStr = nowDT.format('yyyyMMddHHmm'); RepairStatusUpdate.Monitoring = new NFMUtil.Monitoring(); RepairStatusUpdate.Monitoring.MessageGroupNumber = nowStr + '01'; // 必須項目をセットしない NFM105WebService.NFM105(RepairStatusUpdate); // 商品コードが存在しない RepairStatusUpdate.Monitoring.MessageGroupNumber = nowStr + '02'; GeneralData.SAPRepairNo = 'NFM105X'; NFM105WebService.NFM105(RepairStatusUpdate); // 修理受付番号 を受信したけど、SFDC側レコードがない RepairStatusUpdate.Monitoring.MessageGroupNumber = nowStr + '03'; GeneralData.SAPRepairNo = 'NFM105X'; GeneralData.SFDCRepairNo = 'AAAA'; NFM105WebService.NFM105(RepairStatusUpdate); } //StatusCode = 'B95'; 1件 // @isTest // static void testNFM105_update_B95_1() { // Repair__c rpr = makeTestRepair(); // 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}; // NFM105WebService.RepairStatusUpdate RepairStatusUpdate = new NFM105WebService.RepairStatusUpdate(); // NFM105WebService.GeneralData GeneralData = new NFM105WebService.GeneralData(); // NFM105WebService.InspectionResultInformation InspectionResultInformation = new NFM105WebService.InspectionResultInformation(); // NFM105WebService.FailureInformation FailureInformation = new NFM105WebService.FailureInformation(); // GeneralData.InspectionResultInformation = new NFM105WebService.InspectionResultInformation[] { InspectionResultInformation }; // GeneralData.FailureInformation = new NFM105WebService.FailureInformation[] { FailureInformation }; // RepairStatusUpdate.GeneralData = new NFM105WebService.GeneralData[] { GeneralData }; // // Monitoringの設定 // Datetime nowDT = Datetime.now(); // String nowStr = nowDT.format('yyyyMMddHHmm'); // RepairStatusUpdate.Monitoring = new NFMUtil.Monitoring(); // // SAPQuotationNo NotExist // RepairStatusUpdate.Monitoring.MessageGroupNumber = nowStr + 'u1'; // 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'; // NFM105WebService.NFM105(RepairStatusUpdate); // // 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(); // NFM105WebService.NFM105(RepairStatusUpdate); // 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() { // Repair__c rpr = makeTestRepair(); // 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}; // NFM105WebService.RepairStatusUpdate RepairStatusUpdate = new NFM105WebService.RepairStatusUpdate(); // NFM105WebService.GeneralData GeneralData = new NFM105WebService.GeneralData(); // NFM105WebService.GeneralData GeneralData2 = new NFM105WebService.GeneralData(); // NFM105WebService.InspectionResultInformation InspectionResultInformation = new NFM105WebService.InspectionResultInformation(); // NFM105WebService.InspectionResultInformation InspectionResultInformation2 = new NFM105WebService.InspectionResultInformation(); // NFM105WebService.FailureInformation FailureInformation = new NFM105WebService.FailureInformation(); // NFM105WebService.FailureInformation FailureInformation1 = new NFM105WebService.FailureInformation(); // GeneralData.InspectionResultInformation = new NFM105WebService.InspectionResultInformation[] { InspectionResultInformation }; // GeneralData2.InspectionResultInformation = new NFM105WebService.InspectionResultInformation[] { InspectionResultInformation2 }; // GeneralData2.FailureInformation = new NFM105WebService.FailureInformation[] { FailureInformation, FailureInformation1 }; // RepairStatusUpdate.GeneralData = new NFM105WebService.GeneralData[] { GeneralData, GeneralData2 }; // // Monitoringの設定 // Datetime nowDT = Datetime.now(); // String nowStr = nowDT.format('yyyyMMddHHmm'); // RepairStatusUpdate.Monitoring = new NFMUtil.Monitoring(); // // NFM105U2 => A20 // RepairStatusUpdate.Monitoring.MessageGroupNumber = nowStr + 'u2'; // 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 NFM105WebService.FailureInformation[] { FailureInformation, FailureInformation1 }; // System.Test.startTest(); // NFM105WebService.NFM105(RepairStatusUpdate); // 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(quotationList[0].Id, sapRpairList[0].Repair_Quotation_Id__c); // //System.assertEquals(Date.valueOf('2015-02-02'), sapRpairList[0].Agreed_Date__c); //// System.assertEquals(GeneralData2.SAPRepairNo, sapRpairList[0].SAPRepairNo__c); // //System.assertEquals(GeneralData2.RepairOrderStatusName, sapRpairList[0].RepairOrderStatusName__c); // //System.assertEquals(GeneralData2.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('NG', quotationList[0].InspectionResultFlag__c); // System.assertEquals(InspectionResultInformation2.InspectionComment, quotationList[0].InspectionComment__c); // System.assertEquals(InspectionResultInformation2.FailureCause, 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(2, qrsnList.size()); // 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); // System.assertEquals(FailureInformation1.LocationGroupName, qrsnList[1].LocationGroupName__c); // System.assertEquals(FailureInformation1.LocationName, qrsnList[1].LocationName__c); // System.assertEquals(FailureInformation1.PhenomenonName, qrsnList[1].PhenomenonName__c); // System.assertEquals(FailureInformation1.CauseName, qrsnList[1].CauseName__c); // System.assertEquals(FailureInformation1.DescriptionName, qrsnList[1].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(2, 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); // System.assertEquals(rpr.Id, rrsnList[1].Repair__c); // System.assertEquals(quotationList[0].Id, rrsnList[1].Repair_quotation__c); // System.assertEquals(FailureInformation1.LocationGroupName, rrsnList[1].LocationGroupName__c); // System.assertEquals(FailureInformation1.LocationName, rrsnList[1].LocationName__c); // System.assertEquals(FailureInformation1.PhenomenonName, rrsnList[1].PhenomenonName__c); // System.assertEquals(FailureInformation1.CauseName, rrsnList[1].CauseName__c); // System.assertEquals(FailureInformation1.DescriptionName, rrsnList[1].DescriptionName__c); // } // } // //StatusCode = 'A95'; // @isTest // static void testNFM105_update_A95() { // Repair__c rpr = makeTestRepair(); // 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}; // NFM105WebService.RepairStatusUpdate RepairStatusUpdate = new NFM105WebService.RepairStatusUpdate(); // NFM105WebService.GeneralData GeneralData = new NFM105WebService.GeneralData(); // NFM105WebService.InspectionResultInformation InspectionResultInformation = new NFM105WebService.InspectionResultInformation(); // NFM105WebService.FailureInformation FailureInformation = new NFM105WebService.FailureInformation(); // GeneralData.InspectionResultInformation = new NFM105WebService.InspectionResultInformation[] { InspectionResultInformation }; // GeneralData.FailureInformation = new NFM105WebService.FailureInformation[] { FailureInformation }; // RepairStatusUpdate.GeneralData = new NFM105WebService.GeneralData[] { GeneralData }; // // Monitoringの設定 // Datetime nowDT = Datetime.now(); // String nowStr = nowDT.format('yyyyMMddHHmm'); // RepairStatusUpdate.Monitoring = new NFMUtil.Monitoring(); // RepairStatusUpdate.Monitoring.MessageGroupNumber = nowStr + 'u2'; // // 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(); // NFM105WebService.NFM105(RepairStatusUpdate); // 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() { // Repair__c rpr = makeTestRepair(); // 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}; // NFM105WebService.RepairStatusUpdate RepairStatusUpdate = new NFM105WebService.RepairStatusUpdate(); // NFM105WebService.GeneralData GeneralData = new NFM105WebService.GeneralData(); // NFM105WebService.InspectionResultInformation InspectionResultInformation = new NFM105WebService.InspectionResultInformation(); // NFM105WebService.FailureInformation FailureInformation = new NFM105WebService.FailureInformation(); // GeneralData.InspectionResultInformation = new NFM105WebService.InspectionResultInformation[] { InspectionResultInformation }; // GeneralData.FailureInformation = new NFM105WebService.FailureInformation[] { FailureInformation }; // RepairStatusUpdate.GeneralData = new NFM105WebService.GeneralData[] { GeneralData }; // // Monitoringの設定 // Datetime nowDT = Datetime.now(); // String nowStr = nowDT.format('yyyyMMddHHmm'); // RepairStatusUpdate.Monitoring = new NFMUtil.Monitoring(); // RepairStatusUpdate.Monitoring.MessageGroupNumber = nowStr + 'u3'; // // 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(); // NFM105WebService.NFM105(RepairStatusUpdate); // 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()); // } // } // @isTest // static void NFM105_Resendtest() { // Repair__c rpr = makeTestRepair(); // 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}; // NFM105WebService.RepairStatusUpdate RepairStatusUpdate = new NFM105WebService.RepairStatusUpdate(); // NFM105WebService.GeneralData GeneralData = new NFM105WebService.GeneralData(); // NFM105WebService.InspectionResultInformation InspectionResultInformation = new NFM105WebService.InspectionResultInformation(); // NFM105WebService.FailureInformation FailureInformation = new NFM105WebService.FailureInformation(); // GeneralData.InspectionResultInformation = new NFM105WebService.InspectionResultInformation[] { InspectionResultInformation }; // GeneralData.FailureInformation = new NFM105WebService.FailureInformation[] { FailureInformation }; // RepairStatusUpdate.GeneralData = new NFM105WebService.GeneralData[] { GeneralData }; // // Monitoringの設定 // Datetime nowDT = Datetime.now(); // String nowStr = nowDT.format('yyyyMMddHHmm'); // RepairStatusUpdate.Monitoring = new NFMUtil.Monitoring(); // RepairStatusUpdate.Monitoring.MessageGroupNumber = nowStr + 'u2'; // // 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(); // NFM105WebService.NFM105(RepairStatusUpdate); // System.Test.stopTest(); // 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; // NFM105WebService.execute(rowbl[0].id); // 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、未修理 と 再受付 }