@isTest public class MDMITMRestTest { @isTest static void testMDMITM_void() { Id pricebookId = ControllerUtil.getStandardPricebook().Id; MDMITMRest.ItemMaster ItemMaster = new MDMITMRest.ItemMaster(); MDMITMRest.ItemMasters ItemMasters = new MDMITMRest.ItemMasters(); ItemMasters.ItemMaster = new MDMITMRest.ItemMaster[] { ItemMaster }; MDMITMRest.Record Record = new MDMITMRest.Record(); ItemMaster.Record = new MDMITMRest.Record[] { Record }; MDMITMRest.MaterialDescription MaterialDescription = new MDMITMRest.MaterialDescription(); Record.MaterialDescription = new MDMITMRest.MaterialDescription[] { MaterialDescription }; MDMITMRest.ProductLotSerialNoTraceability ProductLotSerialNoTraceability = new MDMITMRest.ProductLotSerialNoTraceability(); Record.ProductLotSerialNoTraceability = new MDMITMRest.ProductLotSerialNoTraceability[] { ProductLotSerialNoTraceability }; Record.BusinessSegmentName = new MDMITMRest.BusinessSegmentName(); // OCNではない Datetime nowDT = Datetime.now(); String nowStr = nowDT.format('yyyyMMddHHmm'); ItemMasters.Monitoring = new NFMUtil.Monitoring(); ItemMasters.Monitoring.MessageGroupNumber = nowStr + '01'; Record.To = 'MMM'; Record.MaterialNumber = 'MDMITMTst1'; // 必須項目をセットしない ItemMasters.Monitoring.MessageGroupNumber = nowStr + '02'; Record.To = 'OCN'; Record.MaterialNumber = ''; NFMUtil.Monitoring Monitoring = ItemMasters.Monitoring; if (Monitoring == null) { return; } BatchIF_Log__c rowData = NFMUtil.saveRowData(Monitoring, 'MDMITM', ItemMasters.ItemMaster); MDMITMRest.execute(rowData.id); // ZHではない ItemMasters.Monitoring.MessageGroupNumber = nowStr + '03'; Record.MaterialNumber = 'MDMITMTst1'; MaterialDescription.LanguageKey = 'EN'; MaterialDescription.Description = 'GIF-X0261:stop2012.8::Gastroscopy'; Monitoring = ItemMasters.Monitoring; rowData = NFMUtil.saveRowData(Monitoring, 'MDMITM', ItemMasters.ItemMaster); MDMITMRest.execute(rowData.id); Product2[] rslts = [select Id from Product2 where ProductCode_Ext__c = :Record.MaterialNumber]; System.assertEquals(0, rslts.size()); } // insert時、SFDA_Status__cが 準備中 になる @isTest static void testMDMITM_insert() { Id pricebookId = ControllerUtil.getStandardPricebook().Id; MDMITMRest.ItemMaster ItemMaster = new MDMITMRest.ItemMaster(); MDMITMRest.ItemMasters ItemMasters = new MDMITMRest.ItemMasters(); ItemMasters.ItemMaster = new MDMITMRest.ItemMaster[] { ItemMaster }; MDMITMRest.Record Record = new MDMITMRest.Record(); MDMITMRest.Record Record2 = new MDMITMRest.Record(); ItemMaster.Record = new MDMITMRest.Record[] { Record, Record2 }; MDMITMRest.MaterialDescription MaterialDescription = new MDMITMRest.MaterialDescription(); MDMITMRest.MaterialDescription MaterialDescription2 = new MDMITMRest.MaterialDescription(); Record.MaterialDescription = new MDMITMRest.MaterialDescription[] { MaterialDescription }; Record2.MaterialDescription = new MDMITMRest.MaterialDescription[] { MaterialDescription2 }; MDMITMRest.ProductLotSerialNoTraceability ProductLotSerialNoTraceability = new MDMITMRest.ProductLotSerialNoTraceability(); MDMITMRest.ProductLotSerialNoTraceability ProductLotSerialNoTraceability2 = new MDMITMRest.ProductLotSerialNoTraceability(); Record.ProductLotSerialNoTraceability = new MDMITMRest.ProductLotSerialNoTraceability[] { ProductLotSerialNoTraceability }; Record2.ProductLotSerialNoTraceability = new MDMITMRest.ProductLotSerialNoTraceability[] { ProductLotSerialNoTraceability2 }; Record.BusinessSegmentName = new MDMITMRest.BusinessSegmentName(); Record2.BusinessSegmentName = new MDMITMRest.BusinessSegmentName(); MDMITMRest.EANUPC EANUPC = new MDMITMRest.EANUPC(); Record.EANUPC = new MDMITMRest.EANUPC[] { EANUPC }; MDMITMRest.QuantityPerSalesPackagingUnit QuantityPerSalesPackagingUnit = new MDMITMRest.QuantityPerSalesPackagingUnit(); Record.QuantityPerSalesPackagingUnit = new MDMITMRest.QuantityPerSalesPackagingUnit[] { QuantityPerSalesPackagingUnit }; Record.MaterialClassificationCode = new MDMITMRest.MaterialClassificationCode(); Record2.MaterialClassificationCode = new MDMITMRest.MaterialClassificationCode(); // Monitoringの設定 Datetime nowDT = Datetime.now(); String nowStr = nowDT.format('yyyyMMddHHmm'); ItemMasters.Monitoring = new NFMUtil.Monitoring(); ItemMasters.Monitoring.MessageGroupNumber = nowStr + '11'; List transfers = new List(); BatchIF_Transfer__c transfer = new BatchIF_Transfer__c(); transfer.Table__c = 'Product2'; transfer.Column__c = 'SalesPackagingUnit_Chinese__c'; transfer.External_Value__c = 'PCS'; transfer.Internal_Value__c = '把'; transfers.add(transfer); insert transfers; List eng = new List(); eng.add('ENG'); //HHOA-BLZCYF MDM:新增字段传输 精琢技术 2020/03/11 start List cn_String_FW = new List(); cn_String_FW.add('服务'); List cn_String_SC = new List(); cn_String_SC.add('市场'); List cn_Dec1 = new List(); cn_Dec1.add('3'); List cn_Dec2 = new List(); cn_Dec2.add('2'); //HHOA-BLZCYF MDM:新增字段传输 精琢技术 2020/03/11 end // insert Record.MaterialNumber = 'MDMITMTst1'; MaterialDescription.LanguageKey = 'ZH'; MaterialDescription.Description = ' GIF-X0260 : 停止2012.8 :: 胃鏡 '; Record.ModelForSales = 'ABCD1234'; Record.RepairCode = 'RC12345'; Record.Layer1st = 'GI'; Record.Layer2nd = 'L2'; Record.Layer3rd = 'L3'; Record.Layer4th = 'L4'; Record.Layer5th = 'L5'; ProductLotSerialNoTraceability.Value = 'No tracing'; Record.LifeTime = 3; Record.MCompany = '製造会社名'; Record.BaseUnitOfMeasure = 'PC'; Record.BusinessSegmentName.Value = 'G&R'; Record.To = 'OCN'; Record.MaterialClassificationCode.Value = '103410909020'; Record.CN_String1 = eng; //HHOA-BLZCYF MDM:新增字段传输 精琢技术 2020/03/11 start //保修期(年) Record.CN_String2 = cn_String_FW; Record.CN_Dec1 = cn_Dec2; //HHOA-BLZCYF MDM:新增字段传输 精琢技术 2020/03/11 end QuantityPerSalesPackagingUnit.Value = '12'; EANUPC.Category = 'G1'; EANUPC.Value = '4042761051835'; Record.CN_SalesPackagingUnit = 'PCS'; Record.GrossWeight = '1'; Record.WeightUnit = 'KG'; Record.CN_LonerType = '消耗品'; // insert2 Record2.MaterialNumber = 'MDMITMTst2'; MaterialDescription2.LanguageKey = 'ZH'; MaterialDescription2.Description = ' :: 胃鏡2 '; Record2.ModelForSales = 'ABCD2234'; Record2.RepairCode = 'RC22345'; Record2.Layer1st = 'GI2'; Record2.Layer2nd = 'L22'; Record2.Layer3rd = 'L32'; Record2.Layer4th = 'L42'; Record2.Layer5th = 'L52'; ProductLotSerialNoTraceability2.Value = 'No tracing'; Record2.LifeTime = 3; Record2.MCompany = '製造会社名'; Record2.BaseUnitOfMeasure = 'PC'; Record2.BusinessSegmentName.Value = 'G&R'; Record2.To = 'OCN'; Record2.CN_String1 = eng; //HHOA-BLZCYF MDM:新增字段传输 精琢技术 2020/03/11 start //保修期(年) Record2.CN_String2 = cn_String_FW; Record2.CN_Dec1 = cn_Dec1; //HHOA-BLZCYF MDM:新增字段传输 精琢技术 2020/03/11 end Record2.MaterialClassificationCode.Value = '103410909020'; QuantityPerSalesPackagingUnit.Value = '12'; EANUPC.Category = 'G1'; EANUPC.Value = '4042761051835'; Record2.CN_SalesPackagingUnit = 'PCS'; Record2.GrossWeight = '1'; Record2.WeightUnit = 'KG'; Record2.CN_LonerType = '消耗品'; NFMUtil.Monitoring Monitoring = ItemMasters.Monitoring; if (Monitoring == null) { return; } BatchIF_Log__c rowData = NFMUtil.saveRowData(Monitoring, 'MDMITM', ItemMasters.ItemMaster); System.Test.startTest(); MDMITMRest.executefuture(rowData.Id); System.Test.stopTest(); Product2[] rslts = [select Id, ProductCode, ProductCode_Ext__c, MDM_Name__c, MDM_Model_No__c, Alternative_Products__c, Name, Asset_Model_No__c, Repair_Product_Code__c, BSSCategory__c, Family, Category2__c, Category3__c, Category4__c, Category5__c, Serial_Lot_No__c, Durable_Years__c, Brand_Name__c, Qty_Unit__c from Product2 where ProductCode_Ext__c = :Record.MaterialNumber]; System.assertEquals(1, rslts.size()); if (rslts.size() == 1) { System.assertEquals('MDMITMTst1', rslts[0].ProductCode); System.assertEquals('MDMITMTst1', rslts[0].ProductCode_Ext__c); System.assertEquals('GIF-X0260:胃鏡', rslts[0].Name); System.assertEquals('GIF-X0260 : 停止2012.8 :: 胃鏡', rslts[0].MDM_Name__c); System.assertEquals('GIF-X0260', rslts[0].MDM_Model_No__c); System.assertEquals('停止2012.8', rslts[0].Alternative_Products__c); System.assertEquals('ABCD1234', rslts[0].Asset_Model_No__c); System.assertEquals('RC12345', rslts[0].Repair_Product_Code__c); System.assertEquals('GI', rslts[0].Family); System.assertEquals('L2', rslts[0].Category2__c); System.assertEquals('L3', rslts[0].Category3__c); System.assertEquals('L4', rslts[0].Category4__c); System.assertEquals('L5', rslts[0].Category5__c); System.assertEquals('No tracing', rslts[0].Serial_Lot_No__c); System.assertEquals(3, rslts[0].Durable_Years__c); System.assertEquals('製造会社名', rslts[0].Brand_Name__c); System.assertEquals('PC', rslts[0].Qty_Unit__c); System.assertEquals('G&R', rslts[0].BSSCategory__c); } rslts = [select Id, ProductCode, ProductCode_Ext__c, MDM_Name__c, MDM_Model_No__c, Alternative_Products__c, Name, Asset_Model_No__c, Repair_Product_Code__c, BSSCategory__c, Family, Category2__c, Category3__c, Category4__c, Category5__c, Serial_Lot_No__c, Durable_Years__c, Brand_Name__c, Qty_Unit__c from Product2 where ProductCode_Ext__c = :Record2.MaterialNumber]; System.assertEquals(1, rslts.size()); if (rslts.size() == 1) { System.assertEquals('MDMITMTst2', rslts[0].ProductCode); System.assertEquals('MDMITMTst2', rslts[0].ProductCode_Ext__c); System.assertEquals('胃鏡2', rslts[0].Name); System.assertEquals(':: 胃鏡2', rslts[0].MDM_Name__c); System.assertEquals(null, rslts[0].MDM_Model_No__c); System.assertEquals(null, rslts[0].Alternative_Products__c); } } @isTest static void testMDMITM_insert2() { Id pricebookId = ControllerUtil.getStandardPricebook().Id; MDMITMRest.ItemMaster ItemMaster = new MDMITMRest.ItemMaster(); MDMITMRest.ItemMasters ItemMasters = new MDMITMRest.ItemMasters(); ItemMasters.ItemMaster = new MDMITMRest.ItemMaster[] { ItemMaster }; MDMITMRest.Record Record = new MDMITMRest.Record(); MDMITMRest.Record Record2 = new MDMITMRest.Record(); ItemMaster.Record = new MDMITMRest.Record[] { Record, Record2 }; MDMITMRest.MaterialDescription MaterialDescription = new MDMITMRest.MaterialDescription(); MDMITMRest.MaterialDescription MaterialDescription2 = new MDMITMRest.MaterialDescription(); Record.MaterialDescription = new MDMITMRest.MaterialDescription[] { MaterialDescription }; Record2.MaterialDescription = new MDMITMRest.MaterialDescription[] { MaterialDescription2 }; MDMITMRest.ProductLotSerialNoTraceability ProductLotSerialNoTraceability = new MDMITMRest.ProductLotSerialNoTraceability(); MDMITMRest.ProductLotSerialNoTraceability ProductLotSerialNoTraceability2 = new MDMITMRest.ProductLotSerialNoTraceability(); Record.ProductLotSerialNoTraceability = new MDMITMRest.ProductLotSerialNoTraceability[] { ProductLotSerialNoTraceability }; Record2.ProductLotSerialNoTraceability = new MDMITMRest.ProductLotSerialNoTraceability[] { ProductLotSerialNoTraceability2 }; Record.BusinessSegmentName = new MDMITMRest.BusinessSegmentName(); Record2.BusinessSegmentName = new MDMITMRest.BusinessSegmentName(); Record2.USRatio_US = new MDMITMRest.USRatio_US(); //zzm 2023-12-04 贸易合规2期 MDMITMRest.EANUPC EANUPC = new MDMITMRest.EANUPC(); Record.EANUPC = new MDMITMRest.EANUPC[] { EANUPC }; MDMITMRest.QuantityPerSalesPackagingUnit QuantityPerSalesPackagingUnit = new MDMITMRest.QuantityPerSalesPackagingUnit(); Record.QuantityPerSalesPackagingUnit = new MDMITMRest.QuantityPerSalesPackagingUnit[] { QuantityPerSalesPackagingUnit }; Record.MaterialClassificationCode = new MDMITMRest.MaterialClassificationCode(); Record2.MaterialClassificationCode = new MDMITMRest.MaterialClassificationCode(); // Monitoringの設定 Datetime nowDT = Datetime.now(); String nowStr = nowDT.format('yyyyMMddHHmm'); ItemMasters.Monitoring = new NFMUtil.Monitoring(); ItemMasters.Monitoring.MessageGroupNumber = nowStr + '11'; List transfers = new List(); BatchIF_Transfer__c transfer = new BatchIF_Transfer__c(); transfer.Table__c = 'Product2'; transfer.Column__c = 'SalesPackagingUnit_Chinese__c'; transfer.External_Value__c = 'PCS'; transfer.Internal_Value__c = '把'; transfers.add(transfer); //zzm 20231122 贸易合规2期 start BatchIF_Transfer__c transfer2 = new BatchIF_Transfer__c(); transfer2.Table__c = 'Product2'; transfer2.Column__c = 'USRatio_US__c'; transfer2.External_Value__c = '<25'; transfer2.Internal_Value__c = '<25'; transfers.add(transfer2); //zzm 20231122 贸易合规2期 end insert transfers; List eng = new List(); eng.add('ENG'); //HHOA-BLZCYF MDM:新增字段传输 精琢技术 2020/03/11 start List cn_String_FW = new List(); cn_String_FW.add('服务'); List cn_String_SC = new List(); cn_String_SC.add('市场'); List cn_Dec1 = new List(); cn_Dec1.add('4'); List cn_Dec2 = new List(); cn_Dec2.add('5'); //HHOA-BLZCYF MDM:新增字段传输 精琢技术 2020/03/11 end // insert Record.MaterialNumber = 'MDMITMTst1'; MaterialDescription.LanguageKey = 'ZH'; MaterialDescription.Description = ' GIF-X0260 : 停止2012.8 :: 胃鏡 '; Record.ModelForSales = 'ABCD1234'; Record.RepairCode = 'RC12345'; Record.Layer1st = 'GI'; Record.Layer2nd = 'L2'; Record.Layer3rd = 'L3'; Record.Layer4th = 'L4'; Record.Layer5th = 'L5'; ProductLotSerialNoTraceability.Value = 'No tracing'; Record.LifeTime = 3; Record.MCompany = '製造会社名'; Record.BaseUnitOfMeasure = 'PC'; Record.BusinessSegmentName.Value = 'G&R'; Record.To = 'OCN'; Record.MaterialClassificationCode.Value = '103410909020'; Record.CN_String1 = eng; //HHOA-BLZCYF MDM:新增字段传输 精琢技术 2020/03/11 start //保修期(年) Record.CN_String2 = cn_String_FW; Record.CN_Dec1 = cn_Dec2; //HHOA-BLZCYF MDM:新增字段传输 精琢技术 2020/03/11 end QuantityPerSalesPackagingUnit.Value = '12'; EANUPC.Category = 'G1'; EANUPC.Value = '4042761051835'; Record.CN_SalesPackagingUnit = 'PCS'; Record.GrossWeight = '1'; Record.WeightUnit = 'KG'; Record.CN_LonerType = '消耗品'; //zzm 20231122 贸易合规2期 start List countryOfOriginTmp = new List(); countryOfOriginTmp.add('US'); //zzm 20231122 贸易合规2期 end // insert2 Record2.MaterialNumber = 'MDMITMTst2'; MaterialDescription2.LanguageKey = 'ZH'; MaterialDescription2.Description = ' :: 胃鏡2 '; Record2.ModelForSales = 'ABCD2234'; Record2.RepairCode = 'RC22345'; Record2.Layer1st = 'GI2'; Record2.Layer2nd = 'L22'; Record2.Layer3rd = 'L32'; Record2.Layer4th = 'L42'; Record2.Layer5th = 'L52'; ProductLotSerialNoTraceability2.Value = 'No tracing'; Record2.LifeTime = 3; Record2.MCompany = '製造会社名'; Record2.BaseUnitOfMeasure = 'PC'; Record2.BusinessSegmentName.Value = 'G&R'; //zzm 20231122 贸易合规2期 start Record2.USRatio_US.Value = '<25'; Record2.CountryOfOrigin = countryOfOriginTmp; //zzm 20231122 贸易合规2期 end Record2.To = 'OCN'; Record2.CN_String1 = eng; //HHOA-BLZCYF MDM:新增字段传输 精琢技术 2020/03/11 start //保修期(年) Record2.CN_String2 = cn_String_SC; Record2.CN_Dec1 = cn_Dec1; //HHOA-BLZCYF MDM:新增字段传输 精琢技术 2020/03/11 end Record2.MaterialClassificationCode.Value = '103410909020'; QuantityPerSalesPackagingUnit.Value = '12'; EANUPC.Category = 'G1'; EANUPC.Value = '4042761051835'; Record2.CN_SalesPackagingUnit = 'PCS'; Record2.GrossWeight = '1'; Record2.WeightUnit = 'KG'; Record2.CN_LonerType = '消耗品'; NFMUtil.Monitoring Monitoring = ItemMasters.Monitoring; if (Monitoring == null) { return; } BatchIF_Log__c rowData = NFMUtil.saveRowData(Monitoring, 'MDMITM', ItemMasters.ItemMaster); System.Test.startTest(); MDMITMRest.executefuture(rowData.Id); System.Test.stopTest(); Product2[] rslts = [select Id, ProductCode, ProductCode_Ext__c, MDM_Name__c, MDM_Model_No__c, Alternative_Products__c, Name, Asset_Model_No__c, Repair_Product_Code__c, BSSCategory__c, Family, Category2__c, Category3__c, Category4__c, Category5__c, Serial_Lot_No__c, Durable_Years__c, Brand_Name__c, Qty_Unit__c from Product2 where ProductCode_Ext__c = :Record.MaterialNumber]; System.assertEquals(1, rslts.size()); if (rslts.size() == 1) { System.assertEquals('MDMITMTst1', rslts[0].ProductCode); System.assertEquals('MDMITMTst1', rslts[0].ProductCode_Ext__c); System.assertEquals('GIF-X0260:胃鏡', rslts[0].Name); System.assertEquals('GIF-X0260 : 停止2012.8 :: 胃鏡', rslts[0].MDM_Name__c); System.assertEquals('GIF-X0260', rslts[0].MDM_Model_No__c); System.assertEquals('停止2012.8', rslts[0].Alternative_Products__c); System.assertEquals('ABCD1234', rslts[0].Asset_Model_No__c); System.assertEquals('RC12345', rslts[0].Repair_Product_Code__c); System.assertEquals('GI', rslts[0].Family); System.assertEquals('L2', rslts[0].Category2__c); System.assertEquals('L3', rslts[0].Category3__c); System.assertEquals('L4', rslts[0].Category4__c); System.assertEquals('L5', rslts[0].Category5__c); System.assertEquals('No tracing', rslts[0].Serial_Lot_No__c); System.assertEquals(3, rslts[0].Durable_Years__c); System.assertEquals('製造会社名', rslts[0].Brand_Name__c); System.assertEquals('PC', rslts[0].Qty_Unit__c); System.assertEquals('G&R', rslts[0].BSSCategory__c); } rslts = [select Id, ProductCode, ProductCode_Ext__c, MDM_Name__c, MDM_Model_No__c, Alternative_Products__c, Name, Asset_Model_No__c, Repair_Product_Code__c, BSSCategory__c, Family, Category2__c, Category3__c, Category4__c, Category5__c, Serial_Lot_No__c, Durable_Years__c, Brand_Name__c, //zzm 20231122 贸易合规2期 start CountryOfOrigin__c, USRatio_US__c, //zzm 20231122 贸易合规2期 end Qty_Unit__c from Product2 where ProductCode_Ext__c = :Record2.MaterialNumber]; System.assertEquals(1, rslts.size()); if (rslts.size() == 1) { System.assertEquals('MDMITMTst2', rslts[0].ProductCode); System.assertEquals('MDMITMTst2', rslts[0].ProductCode_Ext__c); System.assertEquals('胃鏡2', rslts[0].Name); System.assertEquals(':: 胃鏡2', rslts[0].MDM_Name__c); System.assertEquals(null, rslts[0].MDM_Model_No__c); System.assertEquals(null, rslts[0].Alternative_Products__c); //zzm 20231122 贸易合规2期 start System.assertEquals('US', rslts[0].CountryOfOrigin__c); System.assertEquals('<25', rslts[0].USRatio_US__c); //zzm 20231122 贸易合规2期 end } } @isTest static void testMDMITM_insert3() { Id pricebookId = ControllerUtil.getStandardPricebook().Id; MDMITMRest.ItemMaster ItemMaster = new MDMITMRest.ItemMaster(); MDMITMRest.ItemMasters ItemMasters = new MDMITMRest.ItemMasters(); ItemMasters.ItemMaster = new MDMITMRest.ItemMaster[] { ItemMaster }; MDMITMRest.Record Record = new MDMITMRest.Record(); MDMITMRest.Record Record2 = new MDMITMRest.Record(); ItemMaster.Record = new MDMITMRest.Record[] { Record, Record2 }; MDMITMRest.MaterialDescription MaterialDescription = new MDMITMRest.MaterialDescription(); MDMITMRest.MaterialDescription MaterialDescription2 = new MDMITMRest.MaterialDescription(); Record.MaterialDescription = new MDMITMRest.MaterialDescription[] { MaterialDescription }; Record2.MaterialDescription = new MDMITMRest.MaterialDescription[] { MaterialDescription2 }; MDMITMRest.ProductLotSerialNoTraceability ProductLotSerialNoTraceability = new MDMITMRest.ProductLotSerialNoTraceability(); MDMITMRest.ProductLotSerialNoTraceability ProductLotSerialNoTraceability2 = new MDMITMRest.ProductLotSerialNoTraceability(); Record.ProductLotSerialNoTraceability = new MDMITMRest.ProductLotSerialNoTraceability[] { ProductLotSerialNoTraceability }; Record2.ProductLotSerialNoTraceability = new MDMITMRest.ProductLotSerialNoTraceability[] { ProductLotSerialNoTraceability2 }; Record.BusinessSegmentName = new MDMITMRest.BusinessSegmentName(); Record2.BusinessSegmentName = new MDMITMRest.BusinessSegmentName(); MDMITMRest.EANUPC EANUPC = new MDMITMRest.EANUPC(); Record.EANUPC = new MDMITMRest.EANUPC[] { EANUPC }; MDMITMRest.QuantityPerSalesPackagingUnit QuantityPerSalesPackagingUnit = new MDMITMRest.QuantityPerSalesPackagingUnit(); Record.QuantityPerSalesPackagingUnit = new MDMITMRest.QuantityPerSalesPackagingUnit[] { QuantityPerSalesPackagingUnit }; Record.MaterialClassificationCode = new MDMITMRest.MaterialClassificationCode(); Record2.MaterialClassificationCode = new MDMITMRest.MaterialClassificationCode(); // Monitoringの設定 Datetime nowDT = Datetime.now(); String nowStr = nowDT.format('yyyyMMddHHmm'); ItemMasters.Monitoring = new NFMUtil.Monitoring(); ItemMasters.Monitoring.MessageGroupNumber = nowStr + '11'; List transfers = new List(); BatchIF_Transfer__c transfer = new BatchIF_Transfer__c(); transfer.Table__c = 'Product2'; transfer.Column__c = 'SalesPackagingUnit_Chinese__c'; transfer.External_Value__c = 'PCS'; transfer.Internal_Value__c = '把'; transfers.add(transfer); insert transfers; List eng = new List(); eng.add('ENG'); //HHOA-BLZCYF MDM:新增字段传输 精琢技术 2020/03/11 start List cn_String_FW = new List(); cn_String_FW.add('服务'); List cn_String_SC = new List(); cn_String_SC.add('市场'); List cn_Dec1 = new List(); cn_Dec1.add('4'); List cn_Dec2 = new List(); cn_Dec2.add('5'); //HHOA-BLZCYF MDM:新增字段传输 精琢技术 2020/03/11 end // insert Record.MaterialNumber = 'MDMITMTst1'; MaterialDescription.LanguageKey = 'ZH'; MaterialDescription.Description = ' GIF-X0260 : 停止2012.8 :: 胃鏡 '; Record.ModelForSales = 'ABCD1234'; Record.RepairCode = 'RC12345'; Record.Layer1st = 'GI'; Record.Layer2nd = 'L2'; Record.Layer3rd = 'L3'; Record.Layer4th = 'L4'; Record.Layer5th = 'L5'; ProductLotSerialNoTraceability.Value = 'No tracing'; Record.LifeTime = 3; Record.MCompany = '製造会社名'; Record.BaseUnitOfMeasure = 'PC'; Record.BusinessSegmentName.Value = 'G&R'; Record.To = 'OCN'; Record.MaterialClassificationCode.Value = '103410909020'; Record.CN_String1 = eng; //HHOA-BLZCYF MDM:新增字段传输 精琢技术 2020/03/11 start //保修期(年) Record.CN_String2 = cn_String_FW; Record.CN_Dec1 = cn_Dec1; //HHOA-BLZCYF MDM:新增字段传输 精琢技术 2020/03/11 end QuantityPerSalesPackagingUnit.Value = '12'; EANUPC.Category = 'G1'; EANUPC.Value = '4042761051835'; Record.CN_SalesPackagingUnit = 'PCS'; Record.GrossWeight = '1'; Record.WeightUnit = 'KG'; Record.CN_LonerType = '消耗品'; // insert2 Record2.MaterialNumber = 'MDMITMTst2'; MaterialDescription2.LanguageKey = 'ZH'; MaterialDescription2.Description = ' :: 胃鏡2 '; Record2.ModelForSales = 'ABCD2234'; Record2.RepairCode = 'RC22345'; Record2.Layer1st = 'GI2'; Record2.Layer2nd = 'L22'; Record2.Layer3rd = 'L32'; Record2.Layer4th = 'L42'; Record2.Layer5th = 'L52'; ProductLotSerialNoTraceability2.Value = 'No tracing'; Record2.LifeTime = 3; Record2.MCompany = '製造会社名'; Record2.BaseUnitOfMeasure = 'PC'; Record2.BusinessSegmentName.Value = 'G&R'; Record2.To = 'OCN'; Record2.CN_String1 = eng; //HHOA-BLZCYF MDM:新增字段传输 精琢技术 2020/03/11 start //保修期(年) Record2.CN_String2 = cn_String_SC; Record2.CN_Dec1 = cn_Dec2; //HHOA-BLZCYF MDM:新增字段传输 精琢技术 2020/03/11 end Record2.MaterialClassificationCode.Value = '103410909020'; QuantityPerSalesPackagingUnit.Value = '12'; EANUPC.Category = 'G1'; EANUPC.Value = '4042761051835'; Record2.CN_SalesPackagingUnit = 'PCS'; Record2.GrossWeight = '1'; Record2.WeightUnit = 'KG'; Record2.CN_LonerType = '消耗品'; NFMUtil.Monitoring Monitoring = ItemMasters.Monitoring; if (Monitoring == null) { return; } BatchIF_Log__c rowData = NFMUtil.saveRowData(Monitoring, 'MDMITM', ItemMasters.ItemMaster); System.Test.startTest(); MDMITMRest.executefuture(rowData.Id); System.Test.stopTest(); Product2[] rslts = [select Id, ProductCode, ProductCode_Ext__c, MDM_Name__c, MDM_Model_No__c, Alternative_Products__c, Name, Asset_Model_No__c, Repair_Product_Code__c, BSSCategory__c, Family, Category2__c, Category3__c, Category4__c, Category5__c, Serial_Lot_No__c, Durable_Years__c, Brand_Name__c, Qty_Unit__c from Product2 where ProductCode_Ext__c = :Record.MaterialNumber]; System.assertEquals(1, rslts.size()); if (rslts.size() == 1) { System.assertEquals('MDMITMTst1', rslts[0].ProductCode); System.assertEquals('MDMITMTst1', rslts[0].ProductCode_Ext__c); System.assertEquals('GIF-X0260:胃鏡', rslts[0].Name); System.assertEquals('GIF-X0260 : 停止2012.8 :: 胃鏡', rslts[0].MDM_Name__c); System.assertEquals('GIF-X0260', rslts[0].MDM_Model_No__c); System.assertEquals('停止2012.8', rslts[0].Alternative_Products__c); System.assertEquals('ABCD1234', rslts[0].Asset_Model_No__c); System.assertEquals('RC12345', rslts[0].Repair_Product_Code__c); System.assertEquals('GI', rslts[0].Family); System.assertEquals('L2', rslts[0].Category2__c); System.assertEquals('L3', rslts[0].Category3__c); System.assertEquals('L4', rslts[0].Category4__c); System.assertEquals('L5', rslts[0].Category5__c); System.assertEquals('No tracing', rslts[0].Serial_Lot_No__c); System.assertEquals(3, rslts[0].Durable_Years__c); System.assertEquals('製造会社名', rslts[0].Brand_Name__c); System.assertEquals('PC', rslts[0].Qty_Unit__c); System.assertEquals('G&R', rslts[0].BSSCategory__c); } rslts = [select Id, ProductCode, ProductCode_Ext__c, MDM_Name__c, MDM_Model_No__c, Alternative_Products__c, Name, Asset_Model_No__c, Repair_Product_Code__c, BSSCategory__c, Family, Category2__c, Category3__c, Category4__c, Category5__c, Serial_Lot_No__c, Durable_Years__c, Brand_Name__c, Qty_Unit__c from Product2 where ProductCode_Ext__c = :Record2.MaterialNumber]; System.assertEquals(1, rslts.size()); if (rslts.size() == 1) { System.assertEquals('MDMITMTst2', rslts[0].ProductCode); System.assertEquals('MDMITMTst2', rslts[0].ProductCode_Ext__c); System.assertEquals('胃鏡2', rslts[0].Name); System.assertEquals(':: 胃鏡2', rslts[0].MDM_Name__c); System.assertEquals(null, rslts[0].MDM_Model_No__c); System.assertEquals(null, rslts[0].Alternative_Products__c); } } @isTest static void testMDMITM_insert4() { Id pricebookId = ControllerUtil.getStandardPricebook().Id; MDMITMRest.ItemMaster ItemMaster = new MDMITMRest.ItemMaster(); MDMITMRest.ItemMasters ItemMasters = new MDMITMRest.ItemMasters(); ItemMasters.ItemMaster = new MDMITMRest.ItemMaster[] { ItemMaster }; MDMITMRest.Record Record = new MDMITMRest.Record(); MDMITMRest.Record Record2 = new MDMITMRest.Record(); ItemMaster.Record = new MDMITMRest.Record[] { Record, Record2 }; MDMITMRest.MaterialDescription MaterialDescription = new MDMITMRest.MaterialDescription(); MDMITMRest.MaterialDescription MaterialDescription2 = new MDMITMRest.MaterialDescription(); Record.MaterialDescription = new MDMITMRest.MaterialDescription[] { MaterialDescription }; Record2.MaterialDescription = new MDMITMRest.MaterialDescription[] { MaterialDescription2 }; MDMITMRest.ProductLotSerialNoTraceability ProductLotSerialNoTraceability = new MDMITMRest.ProductLotSerialNoTraceability(); MDMITMRest.ProductLotSerialNoTraceability ProductLotSerialNoTraceability2 = new MDMITMRest.ProductLotSerialNoTraceability(); Record.ProductLotSerialNoTraceability = new MDMITMRest.ProductLotSerialNoTraceability[] { ProductLotSerialNoTraceability }; Record2.ProductLotSerialNoTraceability = new MDMITMRest.ProductLotSerialNoTraceability[] { ProductLotSerialNoTraceability2 }; Record.BusinessSegmentName = new MDMITMRest.BusinessSegmentName(); Record2.BusinessSegmentName = new MDMITMRest.BusinessSegmentName(); MDMITMRest.EANUPC EANUPC = new MDMITMRest.EANUPC(); Record.EANUPC = new MDMITMRest.EANUPC[] { EANUPC }; MDMITMRest.QuantityPerSalesPackagingUnit QuantityPerSalesPackagingUnit = new MDMITMRest.QuantityPerSalesPackagingUnit(); Record.QuantityPerSalesPackagingUnit = new MDMITMRest.QuantityPerSalesPackagingUnit[] { QuantityPerSalesPackagingUnit }; Record.MaterialClassificationCode = new MDMITMRest.MaterialClassificationCode(); Record2.MaterialClassificationCode = new MDMITMRest.MaterialClassificationCode(); // Monitoringの設定 Datetime nowDT = Datetime.now(); String nowStr = nowDT.format('yyyyMMddHHmm'); ItemMasters.Monitoring = new NFMUtil.Monitoring(); ItemMasters.Monitoring.MessageGroupNumber = nowStr + '11'; List transfers = new List(); BatchIF_Transfer__c transfer = new BatchIF_Transfer__c(); transfer.Table__c = 'Product2'; transfer.Column__c = 'SalesPackagingUnit_Chinese__c'; transfer.External_Value__c = 'PCS'; transfer.Internal_Value__c = '把'; transfers.add(transfer); insert transfers; List eng = new List(); eng.add('ENG'); //HHOA-BLZCYF MDM:新增字段传输 精琢技术 2020/03/11 start List cn_String_FW = new List(); cn_String_FW.add('服务'); List cn_String_SC = new List(); cn_String_SC.add('市场'); List cn_Dec1 = new List(); cn_Dec1.add('3'); List cn_Dec2 = new List(); cn_Dec2.add('2'); //HHOA-BLZCYF MDM:新增字段传输 精琢技术 2020/03/11 end // insert Record.MaterialNumber = 'MDMITMTst1'; MaterialDescription.LanguageKey = 'ZH'; MaterialDescription.Description = ' GIF-X0260 : 停止2012.8 :: 胃鏡 '; Record.ModelForSales = 'ABCD1234'; Record.RepairCode = 'RC12345'; Record.Layer1st = 'GI'; Record.Layer2nd = 'L2'; Record.Layer3rd = 'L3'; Record.Layer4th = 'L4'; Record.Layer5th = 'L5'; ProductLotSerialNoTraceability.Value = 'No tracing'; Record.LifeTime = 3; Record.MCompany = '製造会社名'; Record.BaseUnitOfMeasure = 'PC'; Record.BusinessSegmentName.Value = 'G&R'; Record.To = 'OCN'; Record.MaterialClassificationCode.Value = '103410909020'; Record.CN_String1 = eng; //HHOA-BLZCYF MDM:新增字段传输 精琢技术 2020/03/11 start //保修期(年) Record.CN_String2 = cn_String_FW; Record.CN_Dec1 = cn_Dec1; //HHOA-BLZCYF MDM:新增字段传输 精琢技术 2020/03/11 end QuantityPerSalesPackagingUnit.Value = '12'; EANUPC.Category = 'G1'; EANUPC.Value = '4042761051835'; Record.CN_SalesPackagingUnit = 'PCS'; Record.GrossWeight = '1'; Record.WeightUnit = 'KG'; Record.CN_LonerType = '消耗品'; // insert2 Record2.MaterialNumber = 'MDMITMTst2'; MaterialDescription2.LanguageKey = 'ZH'; MaterialDescription2.Description = ' :: 胃鏡2 '; Record2.ModelForSales = 'ABCD2234'; Record2.RepairCode = 'RC22345'; Record2.Layer1st = 'GI2'; Record2.Layer2nd = 'L22'; Record2.Layer3rd = 'L32'; Record2.Layer4th = 'L42'; Record2.Layer5th = 'L52'; ProductLotSerialNoTraceability2.Value = 'No tracing'; Record2.LifeTime = 3; Record2.MCompany = '製造会社名'; Record2.BaseUnitOfMeasure = 'PC'; Record2.BusinessSegmentName.Value = 'G&R'; Record2.To = 'OCN'; Record2.CN_String1 = eng; //HHOA-BLZCYF MDM:新增字段传输 精琢技术 2020/03/11 start //保修期(年) Record2.CN_String2 = cn_String_SC; Record2.CN_Dec1 = cn_Dec2; //HHOA-BLZCYF MDM:新增字段传输 精琢技术 2020/03/11 end Record2.MaterialClassificationCode.Value = '103410909020'; QuantityPerSalesPackagingUnit.Value = '12'; EANUPC.Category = 'G1'; EANUPC.Value = '4042761051835'; Record2.CN_SalesPackagingUnit = 'PCS'; Record2.GrossWeight = '1'; Record2.WeightUnit = 'KG'; Record2.CN_LonerType = '消耗品'; NFMUtil.Monitoring Monitoring = ItemMasters.Monitoring; if (Monitoring == null) { return; } BatchIF_Log__c rowData = NFMUtil.saveRowData(Monitoring, 'MDMITM', ItemMasters.ItemMaster); System.Test.startTest(); MDMITMRest.executefuture(rowData.Id); System.Test.stopTest(); Product2[] rslts = [select Id, ProductCode, ProductCode_Ext__c, MDM_Name__c, MDM_Model_No__c, Alternative_Products__c, Name, Asset_Model_No__c, Repair_Product_Code__c, BSSCategory__c, Family, Category2__c, Category3__c, Category4__c, Category5__c, Serial_Lot_No__c, Durable_Years__c, Brand_Name__c, Qty_Unit__c from Product2 where ProductCode_Ext__c = :Record.MaterialNumber]; System.assertEquals(1, rslts.size()); if (rslts.size() == 1) { System.assertEquals('MDMITMTst1', rslts[0].ProductCode); System.assertEquals('MDMITMTst1', rslts[0].ProductCode_Ext__c); System.assertEquals('GIF-X0260:胃鏡', rslts[0].Name); System.assertEquals('GIF-X0260 : 停止2012.8 :: 胃鏡', rslts[0].MDM_Name__c); System.assertEquals('GIF-X0260', rslts[0].MDM_Model_No__c); System.assertEquals('停止2012.8', rslts[0].Alternative_Products__c); System.assertEquals('ABCD1234', rslts[0].Asset_Model_No__c); System.assertEquals('RC12345', rslts[0].Repair_Product_Code__c); System.assertEquals('GI', rslts[0].Family); System.assertEquals('L2', rslts[0].Category2__c); System.assertEquals('L3', rslts[0].Category3__c); System.assertEquals('L4', rslts[0].Category4__c); System.assertEquals('L5', rslts[0].Category5__c); System.assertEquals('No tracing', rslts[0].Serial_Lot_No__c); System.assertEquals(3, rslts[0].Durable_Years__c); System.assertEquals('製造会社名', rslts[0].Brand_Name__c); System.assertEquals('PC', rslts[0].Qty_Unit__c); System.assertEquals('G&R', rslts[0].BSSCategory__c); } rslts = [select Id, ProductCode, ProductCode_Ext__c, MDM_Name__c, MDM_Model_No__c, Alternative_Products__c, Name, Asset_Model_No__c, Repair_Product_Code__c, BSSCategory__c, Family, Category2__c, Category3__c, Category4__c, Category5__c, Serial_Lot_No__c, Durable_Years__c, Brand_Name__c, Qty_Unit__c from Product2 where ProductCode_Ext__c = :Record2.MaterialNumber]; System.assertEquals(1, rslts.size()); if (rslts.size() == 1) { System.assertEquals('MDMITMTst2', rslts[0].ProductCode); System.assertEquals('MDMITMTst2', rslts[0].ProductCode_Ext__c); System.assertEquals('胃鏡2', rslts[0].Name); System.assertEquals(':: 胃鏡2', rslts[0].MDM_Name__c); System.assertEquals(null, rslts[0].MDM_Model_No__c); System.assertEquals(null, rslts[0].Alternative_Products__c); } } @isTest static void testMDMITM_update() { Id pricebookId = ControllerUtil.getStandardPricebook().Id; Product2 pro1 = new Product2(Name = 'MDMITMTst1', IsActive = true, Family = 'GI', Asset_Model_No__c = 'ABCD1234', Serial_Lot_No__c = 'No tracing', Manual_Entry__c = false); insert pro1; // null 更新、値の変更がない MDMITMRest.ItemMaster ItemMaster = new MDMITMRest.ItemMaster(); MDMITMRest.ItemMasters ItemMasters = new MDMITMRest.ItemMasters(); ItemMasters.ItemMaster = new MDMITMRest.ItemMaster[] { ItemMaster }; MDMITMRest.Record Record = new MDMITMRest.Record(); ItemMaster.Record = new MDMITMRest.Record[] { Record }; MDMITMRest.MaterialDescription MaterialDescription = new MDMITMRest.MaterialDescription(); Record.MaterialDescription = new MDMITMRest.MaterialDescription[] { MaterialDescription }; MDMITMRest.ProductLotSerialNoTraceability ProductLotSerialNoTraceability = new MDMITMRest.ProductLotSerialNoTraceability(); Record.ProductLotSerialNoTraceability = new MDMITMRest.ProductLotSerialNoTraceability[] { ProductLotSerialNoTraceability }; Record.BusinessSegmentName = new MDMITMRest.BusinessSegmentName(); // Monitoringの設定 Datetime nowDT = Datetime.now(); String nowStr = nowDT.format('yyyyMMddHHmm'); ItemMasters.Monitoring = new NFMUtil.Monitoring(); ItemMasters.Monitoring.MessageGroupNumber = nowStr + '21'; List eng = new List(); eng.add('ENG'); //HHOA-BLZCYF MDM:新增字段传输 精琢技术 2020/03/11 start List cn_String_FW = new List(); cn_String_FW.add('服务'); List cn_String_SC = new List(); cn_String_SC.add('市场'); List cn_Dec1 = new List(); cn_Dec1.add('3'); List cn_Dec2 = new List(); cn_Dec2.add('2'); //HHOA-BLZCYF MDM:新增字段传输 精琢技术 2020/03/11 end // 品名以外全部 null Record.MaterialNumber = 'MDMITMTst1'; MaterialDescription.LanguageKey = 'ZH'; MaterialDescription.Description = ' GIF-X0261 : 胃鏡 '; Record.ModelForSales = 'ABCD1234'; Record.RepairCode = 'RC12345'; Record.Layer1st = 'GI'; Record.Layer2nd = 'L2'; Record.Layer3rd = 'L3'; Record.Layer4th = 'L4'; Record.Layer5th = 'L5'; ProductLotSerialNoTraceability.Value = 'No tracing'; Record.LifeTime = 3; Record.MCompany = '製造会社名'; Record.BaseUnitOfMeasure = 'PC'; Record.BusinessSegmentName.Value = 'G&R'; Record.To = 'OCN'; Record.CN_String1 = eng; //HHOA-BLZCYF MDM:新增字段传输 精琢技术 2020/03/11 start //保修期(年) Record.CN_String2 = cn_String_SC; Record.CN_Dec1 = cn_Dec2; //HHOA-BLZCYF MDM:新增字段传输 精琢技术 2020/03/11 end NFMUtil.Monitoring Monitoring = ItemMasters.Monitoring; if (Monitoring == null) { return; } BatchIF_Log__c rowData = NFMUtil.saveRowData(Monitoring, 'MDMITM', ItemMasters.ItemMaster); System.Test.startTest(); MDMITMRest.executefuture(rowData.Id); System.Test.stopTest(); Product2[] rslts = [select Id, ProductCode, ProductCode_Ext__c, MDM_Name__c, MDM_Model_No__c, Alternative_Products__c, Name, Asset_Model_No__c, Repair_Product_Code__c, BSSCategory__c, Family, Category2__c, Category3__c, Category4__c, Category5__c, Serial_Lot_No__c, Durable_Years__c, Brand_Name__c, Qty_Unit__c from Product2 where ProductCode_Ext__c = :Record.MaterialNumber]; System.assertEquals(1, rslts.size()); if (rslts.size() == 1) { System.assertEquals('MDMITMTst1', rslts[0].ProductCode); System.assertEquals('MDMITMTst1', rslts[0].ProductCode_Ext__c); System.assertEquals('GIF-X0261:胃鏡', rslts[0].Name); System.assertEquals('GIF-X0261 : 胃鏡', rslts[0].MDM_Name__c); System.assertEquals('GIF-X0261', rslts[0].MDM_Model_No__c); System.assertEquals(null, rslts[0].Alternative_Products__c); System.assertEquals('ABCD1234', rslts[0].Asset_Model_No__c); System.assertEquals('RC12345', rslts[0].Repair_Product_Code__c); System.assertEquals('GI', rslts[0].Family); System.assertEquals('L2', rslts[0].Category2__c); System.assertEquals('L3', rslts[0].Category3__c); System.assertEquals('L4', rslts[0].Category4__c); System.assertEquals('L5', rslts[0].Category5__c); System.assertEquals('No tracing', rslts[0].Serial_Lot_No__c); System.assertEquals(3, rslts[0].Durable_Years__c); System.assertEquals('製造会社名', rslts[0].Brand_Name__c); System.assertEquals('PC', rslts[0].Qty_Unit__c); System.assertEquals('G&R', rslts[0].BSSCategory__c); } } @isTest static void testMDMITM_resend() { Id pricebookId = ControllerUtil.getStandardPricebook().Id; Product2 pro1 = new Product2(Name = 'MDMITMTst1', IsActive = true, Family = 'GI', Asset_Model_No__c = 'ABCD1234', Serial_Lot_No__c = 'No tracing', Manual_Entry__c = false); insert pro1; // null 更新、値の変更がない MDMITMRest.ItemMaster ItemMaster = new MDMITMRest.ItemMaster(); MDMITMRest.ItemMasters ItemMasters = new MDMITMRest.ItemMasters(); ItemMasters.ItemMaster = new MDMITMRest.ItemMaster[] { ItemMaster }; MDMITMRest.Record Record = new MDMITMRest.Record(); ItemMaster.Record = new MDMITMRest.Record[] { Record }; MDMITMRest.MaterialDescription MaterialDescription = new MDMITMRest.MaterialDescription(); Record.MaterialDescription = new MDMITMRest.MaterialDescription[] { MaterialDescription }; MDMITMRest.ProductLotSerialNoTraceability ProductLotSerialNoTraceability = new MDMITMRest.ProductLotSerialNoTraceability(); Record.ProductLotSerialNoTraceability = new MDMITMRest.ProductLotSerialNoTraceability[] { ProductLotSerialNoTraceability }; Record.BusinessSegmentName = new MDMITMRest.BusinessSegmentName(); // Monitoringの設定 Datetime nowDT = Datetime.now(); String nowStr = nowDT.format('yyyyMMddHHmm'); ItemMasters.Monitoring = new NFMUtil.Monitoring(); ItemMasters.Monitoring.MessageGroupNumber = nowStr + '21'; List eng = new List(); eng.add('ENG'); // 品名以外全部 null //HHOA-BLZCYF MDM:新增字段传输 精琢技术 2020/03/11 start List cn_String_FW = new List(); cn_String_FW.add('服务'); List cn_String_SC = new List(); cn_String_SC.add('市场'); List cn_Dec1 = new List(); cn_Dec1.add('3'); List cn_Dec2 = new List(); cn_Dec2.add('2'); //HHOA-BLZCYF MDM:新增字段传输 精琢技术 2020/03/11 end Record.MaterialNumber = 'MDMITMTst1'; MaterialDescription.LanguageKey = 'ZH'; MaterialDescription.Description = ' GIF-X0261 : 胃鏡 '; Record.ModelForSales = 'ABCD1234'; Record.RepairCode = 'RC12345'; Record.Layer1st = 'GI'; Record.Layer2nd = 'L2'; Record.Layer3rd = 'L3'; Record.Layer4th = 'L4'; Record.Layer5th = 'L5'; ProductLotSerialNoTraceability.Value = 'No tracing'; Record.LifeTime = 3; Record.MCompany = '製造会社名'; Record.BaseUnitOfMeasure = 'PC'; Record.BusinessSegmentName.Value = 'G&R'; Record.To = 'OCN'; Record.CN_String1 = eng; //HHOA-BLZCYF MDM:新增字段传输 精琢技术 2020/03/11 start //保修期(年) Record.CN_String2 = cn_String_SC; Record.CN_Dec1 = cn_Dec2; //HHOA-BLZCYF MDM:新增字段传输 精琢技术 2020/03/11 end NFMUtil.Monitoring Monitoring = ItemMasters.Monitoring; if (Monitoring == null) { return; } BatchIF_Log__c rowData = NFMUtil.saveRowData(Monitoring, 'MDMITM', ItemMasters.ItemMaster); System.Test.startTest(); MDMITMRest.executefuture(rowData.Id); System.Test.stopTest(); Product2[] rslts = [select Id, ProductCode, ProductCode_Ext__c, MDM_Name__c, MDM_Model_No__c, Alternative_Products__c, Name, Asset_Model_No__c, Repair_Product_Code__c, BSSCategory__c, Family, Category2__c, Category3__c, Category4__c, Category5__c, Serial_Lot_No__c, Durable_Years__c, Brand_Name__c, Qty_Unit__c from Product2 where ProductCode_Ext__c = :Record.MaterialNumber]; System.assertEquals(1, rslts.size()); if (rslts.size() == 1) { System.assertEquals('MDMITMTst1', rslts[0].ProductCode); System.assertEquals('MDMITMTst1', rslts[0].ProductCode_Ext__c); System.assertEquals('GIF-X0261:胃鏡', rslts[0].Name); System.assertEquals('GIF-X0261 : 胃鏡', rslts[0].MDM_Name__c); System.assertEquals('GIF-X0261', rslts[0].MDM_Model_No__c); System.assertEquals(null, rslts[0].Alternative_Products__c); System.assertEquals('ABCD1234', rslts[0].Asset_Model_No__c); System.assertEquals('RC12345', rslts[0].Repair_Product_Code__c); System.assertEquals('GI', rslts[0].Family); System.assertEquals('L2', rslts[0].Category2__c); System.assertEquals('L3', rslts[0].Category3__c); System.assertEquals('L4', rslts[0].Category4__c); System.assertEquals('L5', rslts[0].Category5__c); System.assertEquals('No tracing', rslts[0].Serial_Lot_No__c); System.assertEquals(3, rslts[0].Durable_Years__c); System.assertEquals('製造会社名', rslts[0].Brand_Name__c); System.assertEquals('PC', rslts[0].Qty_Unit__c); System.assertEquals('G&R', rslts[0].BSSCategory__c); } List rowbl = [Select Id, Log__c, ErrorLog__c from BatchIF_Log__c where RowDataFlg__c = true and Type__c = 'MDMITM' order by CreatedDate desc]; System.assertEquals(1, rowbl.size()); rowbl[0].retry_cnt__c = 1; update rowbl; MDMITMRest.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(0, bl[0].retry_cnt__c); } }