@isTest private class NFM005RestTest { static Product2 testNFM005Init() { // テストデータ Product2 prd = new Product2(); prd.ProductCode_Ext__c = 'testNFM005'; prd.ProductCode = 'testNFM005'; prd.Name = 'testNFM005'; prd.Manual_Entry__c = false; insert prd; return prd; } @isTest static void testNFM005_void1() { testNFM005Init(); NFM005Rest.SalesPrice SalesPrice = new NFM005Rest.SalesPrice(); NFM005Rest.SalesPrices SalesPrices = new NFM005Rest.SalesPrices(); //SalesPrices.SalesPrice = new NFM005Rest.SalesPrice[] { SalesPrice }; Datetime nowDT = Datetime.now(); String nowStr = nowDT.format('yyyyMMddHHmm'); SalesPrices.Monitoring = new NFMUtil.Monitoring(); SalesPrices.Monitoring.MessageGroupNumber = nowStr + '01'; BatchIF_Log__c rowData = NFMUtil.saveRowData(SalesPrices.Monitoring, 'NFM005', SalesPrices.SalesPrice); NFM005Rest u = new NFM005Rest(rowData.Id, 0, 1); System.Test.startTest(); Database.executeBatch(u, 1); System.Test.stopTest(); } // そのままreturn @isTest static void testNFM005_void() { testNFM005Init(); NFM005Rest.SalesPrice SalesPrice = new NFM005Rest.SalesPrice(); NFM005Rest.SalesPrices SalesPrices = new NFM005Rest.SalesPrices(); SalesPrices.SalesPrice = new NFM005Rest.SalesPrice[] { SalesPrice }; Datetime nowDT = Datetime.now(); String nowStr = nowDT.format('yyyyMMddHHmm'); SalesPrices.Monitoring = new NFMUtil.Monitoring(); SalesPrices.Monitoring.MessageGroupNumber = nowStr + '01'; BatchIF_Log__c rowData = NFMUtil.saveRowData(SalesPrices.Monitoring, 'NFM005', SalesPrices.SalesPrice); NFM005Rest u = new NFM005Rest(rowData.Id, 0, SalesPrices.SalesPrice.size()); System.Test.startTest(); Database.executeBatch(u, 1); System.Test.stopTest(); } @isTest static void testNFM005_update_RMB_1() { testNFM005Init(); NFM005Rest.SalesPrice SalesPrice = new NFM005Rest.SalesPrice(); NFM005Rest.SalesPrices SalesPrices = new NFM005Rest.SalesPrices(); SalesPrices.SalesPrice = new NFM005Rest.SalesPrice[] { SalesPrice }; // Monitoringの設定 Datetime nowDT = Datetime.now(); String nowStr = nowDT.format('yyyyMMddHHmm'); SalesPrices.Monitoring = new NFMUtil.Monitoring(); SalesPrices.Monitoring.MessageGroupNumber = nowStr + '11'; // update RMB 内貿 1回目 SalesPrice.SuppliersItemCode = 'testNFM005'; SalesPrice.PriceType = 'OCM-001S'; SalesPrice.Currency_x = 'RMB'; SalesPrice.SalesPrice_x = 1.12; SalesPrice.EffectiveDateFrom = '20121101'; SalesPrice.EffectiveDateTo = '29121103'; SalesPrice.PurposeOfAdvice = '3'; BatchIF_Log__c rowData = NFMUtil.saveRowData(SalesPrices.Monitoring, 'NFM005', SalesPrices.SalesPrice); NFM005Rest u = new NFM005Rest(rowData.Id, 0, SalesPrices.SalesPrice.size()); System.Test.startTest(); Database.executeBatch(u, 1); System.Test.stopTest(); List rslts = [select Id, ProductCode, ProductCode_Ext__c, Intra_Trade_List_RMB_1__c, Intra_Trade_List_RMB_Date1__c, Intra_Trade_List_RMB_End_Date1__c, Intra_Trade_List_RMB_2__c, Intra_Trade_List_RMB_Date2__c, Intra_Trade_List_RMB_End_Date2__c, Foreign_Trade_List_US_1__c, Foreign_Trade_List_US_Date1__c, Foreign_Trade_List_US_End_Date1__c, Foreign_Trade_List_US_2__c, Foreign_Trade_List_US_Date2__c, Foreign_Trade_List_US_End_Date2__c, Intra_Trade_List_US__c, Intra_Trade_List_US_Date__c, Intra_Trade_List_US_End_Date__c, Foreign_Trade_List_RMB__c, Foreign_Trade_List_RMB_Date__c, Foreign_Trade_List_RMB_End_Date__c from Product2 where ProductCode_Ext__c = :SalesPrice.SuppliersItemCode]; System.assertEquals(1, rslts.size()); if (rslts.size() == 1) { System.assertEquals('testNFM005', rslts[0].ProductCode); System.assertEquals(1.12, rslts[0].Intra_Trade_List_RMB_1__c); System.assertEquals(date.newinstance(2012, 11, 1), rslts[0].Intra_Trade_List_RMB_Date1__c); System.assertEquals(date.newinstance(2912, 11, 3), rslts[0].Intra_Trade_List_RMB_End_Date1__c); System.assertEquals(null, rslts[0].Intra_Trade_List_RMB_2__c); System.assertEquals(null, rslts[0].Intra_Trade_List_RMB_Date2__c); System.assertEquals(null, rslts[0].Intra_Trade_List_RMB_End_Date2__c); System.assertEquals(null, rslts[0].Foreign_Trade_List_US_1__c); System.assertEquals(null, rslts[0].Foreign_Trade_List_US_Date1__c); System.assertEquals(null, rslts[0].Foreign_Trade_List_US_End_Date1__c); System.assertEquals(null, rslts[0].Foreign_Trade_List_US_2__c); System.assertEquals(null, rslts[0].Foreign_Trade_List_US_Date2__c); System.assertEquals(null, rslts[0].Foreign_Trade_List_US_End_Date2__c); System.assertEquals(null, rslts[0].Intra_Trade_List_US__c); System.assertEquals(null, rslts[0].Intra_Trade_List_US_Date__c); System.assertEquals(null, rslts[0].Intra_Trade_List_US_End_Date__c); System.assertEquals(null, rslts[0].Foreign_Trade_List_RMB__c); System.assertEquals(null, rslts[0].Foreign_Trade_List_RMB_Date__c); System.assertEquals(null, rslts[0].Foreign_Trade_List_RMB_End_Date__c); } } @isTest static void testNFM005_update_RMB_2() { Product2 prd = testNFM005Init(); prd.Intra_Trade_List_RMB_1__c = 1.12; prd.Intra_Trade_List_RMB_Date1__c = date.newinstance(2012, 11, 1); prd.Intra_Trade_List_RMB_End_Date1__c = date.newinstance(2912, 11, 3); update prd; NFM005Rest.SalesPrice SalesPrice = new NFM005Rest.SalesPrice(); NFM005Rest.SalesPrices SalesPrices = new NFM005Rest.SalesPrices(); SalesPrices.SalesPrice = new NFM005Rest.SalesPrice[] { SalesPrice }; // Monitoringの設定 Datetime nowDT = Datetime.now(); String nowStr = nowDT.format('yyyyMMddHHmm'); SalesPrices.Monitoring = new NFMUtil.Monitoring(); // update RMB 内貿 2回目 SalesPrices.Monitoring.MessageGroupNumber = nowStr + '12'; SalesPrice.SuppliersItemCode = 'testNFM005'; SalesPrice.PriceType = 'OCM-001S'; SalesPrice.Currency_x = 'RMB'; SalesPrice.SalesPrice_x = 1.34; SalesPrice.EffectiveDateFrom = '20121111'; SalesPrice.EffectiveDateTo = '29121113'; SalesPrice.PurposeOfAdvice = '3'; BatchIF_Log__c rowData = NFMUtil.saveRowData(SalesPrices.Monitoring, 'NFM005', SalesPrices.SalesPrice); NFM005Rest u = new NFM005Rest(rowData.Id, 0, SalesPrices.SalesPrice.size()); System.Test.startTest(); Database.executeBatch(u, 1); System.Test.stopTest(); List rslts = [select Id, ProductCode, ProductCode_Ext__c, Intra_Trade_List_RMB_1__c, Intra_Trade_List_RMB_Date1__c, Intra_Trade_List_RMB_End_Date1__c, Intra_Trade_List_RMB_2__c, Intra_Trade_List_RMB_Date2__c, Intra_Trade_List_RMB_End_Date2__c, Foreign_Trade_List_US_1__c, Foreign_Trade_List_US_Date1__c, Foreign_Trade_List_US_End_Date1__c, Foreign_Trade_List_US_2__c, Foreign_Trade_List_US_Date2__c, Foreign_Trade_List_US_End_Date2__c, Intra_Trade_List_US__c, Intra_Trade_List_US_Date__c, Intra_Trade_List_US_End_Date__c, Foreign_Trade_List_RMB__c, Foreign_Trade_List_RMB_Date__c, Foreign_Trade_List_RMB_End_Date__c from Product2 where ProductCode_Ext__c = :SalesPrice.SuppliersItemCode]; System.assertEquals(1, rslts.size()); if (rslts.size() == 1) { System.assertEquals('testNFM005', rslts[0].ProductCode); System.assertEquals(1.12, rslts[0].Intra_Trade_List_RMB_1__c); System.assertEquals(date.newinstance(2012, 11, 1), rslts[0].Intra_Trade_List_RMB_Date1__c); System.assertEquals(date.newinstance(2912, 11, 3), rslts[0].Intra_Trade_List_RMB_End_Date1__c); System.assertEquals(1.34, rslts[0].Intra_Trade_List_RMB_2__c); System.assertEquals(date.newinstance(2012, 11, 11), rslts[0].Intra_Trade_List_RMB_Date2__c); System.assertEquals(date.newinstance(2912, 11, 13), rslts[0].Intra_Trade_List_RMB_End_Date2__c); System.assertEquals(null, rslts[0].Foreign_Trade_List_US_1__c); System.assertEquals(null, rslts[0].Foreign_Trade_List_US_Date1__c); System.assertEquals(null, rslts[0].Foreign_Trade_List_US_End_Date1__c); System.assertEquals(null, rslts[0].Foreign_Trade_List_US_2__c); System.assertEquals(null, rslts[0].Foreign_Trade_List_US_Date2__c); System.assertEquals(null, rslts[0].Foreign_Trade_List_US_End_Date2__c); System.assertEquals(null, rslts[0].Intra_Trade_List_US__c); System.assertEquals(null, rslts[0].Intra_Trade_List_US_Date__c); System.assertEquals(null, rslts[0].Intra_Trade_List_US_End_Date__c); System.assertEquals(null, rslts[0].Foreign_Trade_List_RMB__c); System.assertEquals(null, rslts[0].Foreign_Trade_List_RMB_Date__c); System.assertEquals(null, rslts[0].Foreign_Trade_List_RMB_End_Date__c); } } @isTest static void testNFM005_update_RMB_3() { Product2 prd = testNFM005Init(); prd.Intra_Trade_List_RMB_1__c = 1.12; prd.Intra_Trade_List_RMB_Date1__c = date.newinstance(2012, 11, 1); prd.Intra_Trade_List_RMB_End_Date1__c = date.newinstance(2912, 11, 3); prd.Intra_Trade_List_RMB_2__c = 1.34; prd.Intra_Trade_List_RMB_Date2__c = date.newinstance(2012, 11, 11); prd.Intra_Trade_List_RMB_End_Date2__c = date.newinstance(2912, 11, 13); update prd; NFM005Rest.SalesPrice SalesPrice = new NFM005Rest.SalesPrice(); NFM005Rest.SalesPrices SalesPrices = new NFM005Rest.SalesPrices(); SalesPrices.SalesPrice = new NFM005Rest.SalesPrice[] { SalesPrice }; // Monitoringの設定 Datetime nowDT = Datetime.now(); String nowStr = nowDT.format('yyyyMMddHHmm'); SalesPrices.Monitoring = new NFMUtil.Monitoring(); // update RMB 内貿 3回目 SalesPrices.Monitoring.MessageGroupNumber = nowStr + '13'; SalesPrice.SuppliersItemCode = 'testNFM005'; SalesPrice.PriceType = 'OCM-001S'; SalesPrice.Currency_x = 'RMB'; SalesPrice.SalesPrice_x = 1.56; SalesPrice.EffectiveDateFrom = '20121121'; SalesPrice.EffectiveDateTo = '29121123'; SalesPrice.PurposeOfAdvice = '3'; BatchIF_Log__c rowData = NFMUtil.saveRowData(SalesPrices.Monitoring, 'NFM005', SalesPrices.SalesPrice); NFM005Rest u = new NFM005Rest(rowData.Id, 0, SalesPrices.SalesPrice.size()); System.Test.startTest(); Database.executeBatch(u, 1); System.Test.stopTest(); List rslts = [select Id, ProductCode, ProductCode_Ext__c, Intra_Trade_List_RMB_1__c, Intra_Trade_List_RMB_Date1__c, Intra_Trade_List_RMB_End_Date1__c, Intra_Trade_List_RMB_2__c, Intra_Trade_List_RMB_Date2__c, Intra_Trade_List_RMB_End_Date2__c, Foreign_Trade_List_US_1__c, Foreign_Trade_List_US_Date1__c, Foreign_Trade_List_US_End_Date1__c, Foreign_Trade_List_US_2__c, Foreign_Trade_List_US_Date2__c, Foreign_Trade_List_US_End_Date2__c, Intra_Trade_List_US__c, Intra_Trade_List_US_Date__c, Intra_Trade_List_US_End_Date__c, Foreign_Trade_List_RMB__c, Foreign_Trade_List_RMB_Date__c, Foreign_Trade_List_RMB_End_Date__c from Product2 where ProductCode_Ext__c = :SalesPrice.SuppliersItemCode]; System.assertEquals(1, rslts.size()); if (rslts.size() == 1) { System.assertEquals('testNFM005', rslts[0].ProductCode); System.assertEquals(1.56, rslts[0].Intra_Trade_List_RMB_1__c); System.assertEquals(date.newinstance(2012, 11, 21), rslts[0].Intra_Trade_List_RMB_Date1__c); System.assertEquals(date.newinstance(2912, 11, 23), rslts[0].Intra_Trade_List_RMB_End_Date1__c); System.assertEquals(1.34, rslts[0].Intra_Trade_List_RMB_2__c); System.assertEquals(date.newinstance(2012, 11, 11), rslts[0].Intra_Trade_List_RMB_Date2__c); System.assertEquals(date.newinstance(2912, 11, 13), rslts[0].Intra_Trade_List_RMB_End_Date2__c); System.assertEquals(null, rslts[0].Foreign_Trade_List_US_1__c); System.assertEquals(null, rslts[0].Foreign_Trade_List_US_Date1__c); System.assertEquals(null, rslts[0].Foreign_Trade_List_US_End_Date1__c); System.assertEquals(null, rslts[0].Foreign_Trade_List_US_2__c); System.assertEquals(null, rslts[0].Foreign_Trade_List_US_Date2__c); System.assertEquals(null, rslts[0].Foreign_Trade_List_US_End_Date2__c); System.assertEquals(null, rslts[0].Intra_Trade_List_US__c); System.assertEquals(null, rslts[0].Intra_Trade_List_US_Date__c); System.assertEquals(null, rslts[0].Intra_Trade_List_US_End_Date__c); System.assertEquals(null, rslts[0].Foreign_Trade_List_RMB__c); System.assertEquals(null, rslts[0].Foreign_Trade_List_RMB_Date__c); System.assertEquals(null, rslts[0].Foreign_Trade_List_RMB_End_Date__c); } } @isTest static void testNFM005_update_RMB_4() { Product2 prd = testNFM005Init(); prd.Intra_Trade_List_RMB_1__c = 1.56; prd.Intra_Trade_List_RMB_Date1__c = date.newinstance(2012, 11, 21); prd.Intra_Trade_List_RMB_End_Date1__c = date.newinstance(2912, 11, 23); prd.Intra_Trade_List_RMB_2__c = 1.34; prd.Intra_Trade_List_RMB_Date2__c = date.newinstance(2012, 11, 11); prd.Intra_Trade_List_RMB_End_Date2__c = date.newinstance(2912, 11, 13); update prd; NFM005Rest.SalesPrice SalesPrice = new NFM005Rest.SalesPrice(); NFM005Rest.SalesPrice SalesPrice2 = new NFM005Rest.SalesPrice(); NFM005Rest.SalesPrices SalesPrices = new NFM005Rest.SalesPrices(); SalesPrices.SalesPrice = new NFM005Rest.SalesPrice[] { SalesPrice, SalesPrice2 }; // Monitoringの設定 Datetime nowDT = Datetime.now(); String nowStr = nowDT.format('yyyyMMddHHmm'); SalesPrices.Monitoring = new NFMUtil.Monitoring(); // update RMB 内貿 4回目 SalesPrices.Monitoring.MessageGroupNumber = nowStr + '14'; SalesPrice.SuppliersItemCode = 'testNFM005'; SalesPrice.PriceType = 'OCM-001S'; SalesPrice.Currency_x = 'RMB'; SalesPrice.SalesPrice_x = 1.78; SalesPrice.EffectiveDateFrom = '20121201'; SalesPrice.EffectiveDateTo = '29121203'; SalesPrice.PurposeOfAdvice = '3'; // update US 内貿 SalesPrice2.SuppliersItemCode = 'testNFM005'; SalesPrice2.PriceType = 'OCM-001S'; SalesPrice2.Currency_x = 'USD'; SalesPrice2.SalesPrice_x = 101.12; SalesPrice2.EffectiveDateFrom = '20121112'; SalesPrice2.EffectiveDateTo = '29121123'; SalesPrice2.PurposeOfAdvice = '3'; BatchIF_Log__c rowData = NFMUtil.saveRowData(SalesPrices.Monitoring, 'NFM005', SalesPrices.SalesPrice); NFM005Rest u = new NFM005Rest(rowData.Id, 0, SalesPrices.SalesPrice.size()); System.Test.startTest(); Database.executeBatch(u, 1); System.Test.stopTest(); List rslts = [select Id, ProductCode, ProductCode_Ext__c, Intra_Trade_List_RMB_1__c, Intra_Trade_List_RMB_Date1__c, Intra_Trade_List_RMB_End_Date1__c, Intra_Trade_List_RMB_2__c, Intra_Trade_List_RMB_Date2__c, Intra_Trade_List_RMB_End_Date2__c, Foreign_Trade_List_US_1__c, Foreign_Trade_List_US_Date1__c, Foreign_Trade_List_US_End_Date1__c, Foreign_Trade_List_US_2__c, Foreign_Trade_List_US_Date2__c, Foreign_Trade_List_US_End_Date2__c, Intra_Trade_List_US__c, Intra_Trade_List_US_Date__c, Intra_Trade_List_US_End_Date__c, Foreign_Trade_List_RMB__c, Foreign_Trade_List_RMB_Date__c, Foreign_Trade_List_RMB_End_Date__c from Product2 where ProductCode_Ext__c = :SalesPrice.SuppliersItemCode]; System.assertEquals(1, rslts.size()); if (rslts.size() == 1) { System.assertEquals('testNFM005', rslts[0].ProductCode); System.assertEquals(1.56, rslts[0].Intra_Trade_List_RMB_1__c); System.assertEquals(date.newinstance(2012, 11, 21), rslts[0].Intra_Trade_List_RMB_Date1__c); System.assertEquals(date.newinstance(2912, 11, 23), rslts[0].Intra_Trade_List_RMB_End_Date1__c); System.assertEquals(1.78, rslts[0].Intra_Trade_List_RMB_2__c); System.assertEquals(date.newinstance(2012, 12, 01), rslts[0].Intra_Trade_List_RMB_Date2__c); System.assertEquals(date.newinstance(2912, 12, 03), rslts[0].Intra_Trade_List_RMB_End_Date2__c); System.assertEquals(null, rslts[0].Foreign_Trade_List_US_1__c); System.assertEquals(null, rslts[0].Foreign_Trade_List_US_Date1__c); System.assertEquals(null, rslts[0].Foreign_Trade_List_US_End_Date1__c); System.assertEquals(null, rslts[0].Foreign_Trade_List_US_2__c); System.assertEquals(null, rslts[0].Foreign_Trade_List_US_Date2__c); System.assertEquals(null, rslts[0].Foreign_Trade_List_US_End_Date2__c); System.assertEquals(101.12, rslts[0].Intra_Trade_List_US__c); System.assertEquals(date.newinstance(2012, 11, 12), rslts[0].Intra_Trade_List_US_Date__c); System.assertEquals(date.newinstance(2912, 11, 23), rslts[0].Intra_Trade_List_US_End_Date__c); System.assertEquals(null, rslts[0].Foreign_Trade_List_RMB__c); System.assertEquals(null, rslts[0].Foreign_Trade_List_RMB_Date__c); System.assertEquals(null, rslts[0].Foreign_Trade_List_RMB_End_Date__c); } } @isTest static void testNFM005_update_RMB_5() { testNFM005Init(); NFM005Rest.SalesPrice SalesPrice = new NFM005Rest.SalesPrice(); NFM005Rest.SalesPrices SalesPrices = new NFM005Rest.SalesPrices(); SalesPrices.SalesPrice = new NFM005Rest.SalesPrice[] { SalesPrice }; // Monitoringの設定 Datetime nowDT = Datetime.now(); String nowStr = nowDT.format('yyyyMMddHHmm'); SalesPrices.Monitoring = new NFMUtil.Monitoring(); SalesPrices.Monitoring.MessageGroupNumber = nowStr + '11'; // update RMB 内貿 1回目 SalesPrice.SuppliersItemCode = 'testNFM005'; SalesPrice.PriceType = ''; SalesPrice.Currency_x = 'RMB'; SalesPrice.SalesPrice_x = 1.12; SalesPrice.EffectiveDateFrom = '20121101'; SalesPrice.EffectiveDateTo = '29121103'; SalesPrice.PurposeOfAdvice = '3'; BatchIF_Log__c rowData = NFMUtil.saveRowData(SalesPrices.Monitoring, 'NFM005', SalesPrices.SalesPrice); NFM005Rest u = new NFM005Rest(rowData.Id, 0, SalesPrices.SalesPrice.size()); System.Test.startTest(); Database.executeBatch(u, 1); System.Test.stopTest(); } @isTest static void testNFM005_update_RMB_6() { testNFM005Init(); NFM005Rest.SalesPrice SalesPrice = new NFM005Rest.SalesPrice(); NFM005Rest.SalesPrices SalesPrices = new NFM005Rest.SalesPrices(); SalesPrices.SalesPrice = new NFM005Rest.SalesPrice[] { SalesPrice }; // Monitoringの設定 Datetime nowDT = Datetime.now(); String nowStr = nowDT.format('yyyyMMddHHmm'); SalesPrices.Monitoring = new NFMUtil.Monitoring(); SalesPrices.Monitoring.MessageGroupNumber = nowStr + '11'; // update RMB 内貿 1回目 SalesPrice.SuppliersItemCode = 'testNFM005'; SalesPrice.PriceType = 'OCM-001S'; SalesPrice.Currency_x = 'RMB'; SalesPrice.SalesPrice_x = null; SalesPrice.EffectiveDateFrom = '20121101'; SalesPrice.EffectiveDateTo = '29121103'; SalesPrice.PurposeOfAdvice = '3'; BatchIF_Log__c rowData = NFMUtil.saveRowData(SalesPrices.Monitoring, 'NFM005', SalesPrices.SalesPrice); NFM005Rest u = new NFM005Rest(rowData.Id, 0, SalesPrices.SalesPrice.size()); System.Test.startTest(); Database.executeBatch(u, 1); System.Test.stopTest(); } @isTest static void testNFM005_update_RMB_7() { testNFM005Init(); NFM005Rest.SalesPrice SalesPrice = new NFM005Rest.SalesPrice(); NFM005Rest.SalesPrices SalesPrices = new NFM005Rest.SalesPrices(); SalesPrices.SalesPrice = new NFM005Rest.SalesPrice[] { SalesPrice }; // Monitoringの設定 Datetime nowDT = Datetime.now(); String nowStr = nowDT.format('yyyyMMddHHmm'); SalesPrices.Monitoring = new NFMUtil.Monitoring(); SalesPrices.Monitoring.MessageGroupNumber = nowStr + '11'; // update RMB 内貿 1回目 SalesPrice.SuppliersItemCode = 'testNFM005'; SalesPrice.PriceType = 'OCM-001S'; SalesPrice.Currency_x = ''; SalesPrice.SalesPrice_x = 1.12; SalesPrice.EffectiveDateFrom = '20121101'; SalesPrice.EffectiveDateTo = '29121103'; SalesPrice.PurposeOfAdvice = '3'; BatchIF_Log__c rowData = NFMUtil.saveRowData(SalesPrices.Monitoring, 'NFM005', SalesPrices.SalesPrice); NFM005Rest u = new NFM005Rest(rowData.Id, 0, SalesPrices.SalesPrice.size()); System.Test.startTest(); Database.executeBatch(u, 1); System.Test.stopTest(); } @isTest static void testNFM005_update_RMB_8() { testNFM005Init(); NFM005Rest.SalesPrice SalesPrice = new NFM005Rest.SalesPrice(); NFM005Rest.SalesPrices SalesPrices = new NFM005Rest.SalesPrices(); SalesPrices.SalesPrice = new NFM005Rest.SalesPrice[] { SalesPrice }; // Monitoringの設定 Datetime nowDT = Datetime.now(); String nowStr = nowDT.format('yyyyMMddHHmm'); SalesPrices.Monitoring = new NFMUtil.Monitoring(); SalesPrices.Monitoring.MessageGroupNumber = nowStr + '11'; // update RMB 内貿 1回目 SalesPrice.SuppliersItemCode = 'testNFM005'; SalesPrice.PriceType = 'OCM-001S'; SalesPrice.Currency_x = 'RMB'; SalesPrice.SalesPrice_x = 1.12; SalesPrice.EffectiveDateFrom = ''; SalesPrice.EffectiveDateTo = '29121103'; SalesPrice.PurposeOfAdvice = '3'; BatchIF_Log__c rowData = NFMUtil.saveRowData(SalesPrices.Monitoring, 'NFM005', SalesPrices.SalesPrice); NFM005Rest u = new NFM005Rest(rowData.Id, 0, SalesPrices.SalesPrice.size()); System.Test.startTest(); Database.executeBatch(u, 1); System.Test.stopTest(); } @isTest static void testNFM005_update_RMB_9() { testNFM005Init(); NFM005Rest.SalesPrice SalesPrice = new NFM005Rest.SalesPrice(); NFM005Rest.SalesPrices SalesPrices = new NFM005Rest.SalesPrices(); SalesPrices.SalesPrice = new NFM005Rest.SalesPrice[] { SalesPrice }; // Monitoringの設定 Datetime nowDT = Datetime.now(); String nowStr = nowDT.format('yyyyMMddHHmm'); SalesPrices.Monitoring = new NFMUtil.Monitoring(); SalesPrices.Monitoring.MessageGroupNumber = nowStr + '11'; // update RMB 内貿 1回目 SalesPrice.SuppliersItemCode = 'testNFM005'; SalesPrice.PriceType = 'OCM-001S'; SalesPrice.Currency_x = 'RMB'; SalesPrice.SalesPrice_x = 1.12; SalesPrice.EffectiveDateFrom = '20121101'; SalesPrice.EffectiveDateTo = ''; SalesPrice.PurposeOfAdvice = '3'; BatchIF_Log__c rowData = NFMUtil.saveRowData(SalesPrices.Monitoring, 'NFM005', SalesPrices.SalesPrice); NFM005Rest u = new NFM005Rest(rowData.Id, 0, SalesPrices.SalesPrice.size()); System.Test.startTest(); Database.executeBatch(u, 1); System.Test.stopTest(); } @isTest static void testNFM005_update_RMB_10() { testNFM005Init(); NFM005Rest.SalesPrice SalesPrice = new NFM005Rest.SalesPrice(); NFM005Rest.SalesPrices SalesPrices = new NFM005Rest.SalesPrices(); SalesPrices.SalesPrice = new NFM005Rest.SalesPrice[] { SalesPrice }; // Monitoringの設定 Datetime nowDT = Datetime.now(); String nowStr = nowDT.format('yyyyMMddHHmm'); SalesPrices.Monitoring = new NFMUtil.Monitoring(); SalesPrices.Monitoring.MessageGroupNumber = nowStr + '11'; // update RMB 内貿 1回目 SalesPrice.SuppliersItemCode = 'testNFM115'; SalesPrice.PriceType = 'OCM-001S'; SalesPrice.Currency_x = 'RMB'; SalesPrice.SalesPrice_x = 1.12; SalesPrice.EffectiveDateFrom = '20121101'; SalesPrice.EffectiveDateTo = '20121101'; SalesPrice.PurposeOfAdvice = '3'; BatchIF_Log__c rowData = NFMUtil.saveRowData(SalesPrices.Monitoring, 'NFM005', SalesPrices.SalesPrice); NFM005Rest u = new NFM005Rest(rowData.Id, 0, SalesPrices.SalesPrice.size()); System.Test.startTest(); Database.executeBatch(u, 1); System.Test.stopTest(); } @isTest static void testNFM005_update_USD_1() { Product2 prd = testNFM005Init(); prd.Intra_Trade_List_RMB_1__c = 1.56; prd.Intra_Trade_List_RMB_Date1__c = date.newinstance(2012, 11, 21); prd.Intra_Trade_List_RMB_End_Date1__c = date.newinstance(2912, 11, 23); prd.Intra_Trade_List_RMB_2__c = 1.78; prd.Intra_Trade_List_RMB_Date2__c = date.newinstance(2012, 12, 1); prd.Intra_Trade_List_RMB_End_Date2__c = date.newinstance(2912, 12, 3); prd.Intra_Trade_List_US__c = 101.12; prd.Intra_Trade_List_US_Date__c = date.newinstance(2012, 11, 12); prd.Intra_Trade_List_US_End_Date__c = date.newinstance(2912, 11, 23); update prd; NFM005Rest.SalesPrice SalesPrice = new NFM005Rest.SalesPrice(); NFM005Rest.SalesPrices SalesPrices = new NFM005Rest.SalesPrices(); SalesPrices.SalesPrice = new NFM005Rest.SalesPrice[] { SalesPrice }; // Monitoringの設定 Datetime nowDT = Datetime.now(); String nowStr = nowDT.format('yyyyMMddHHmm'); SalesPrices.Monitoring = new NFMUtil.Monitoring(); // update USD 外貿 1回目 SalesPrices.Monitoring.MessageGroupNumber = nowStr + '21'; SalesPrice.SuppliersItemCode = 'testNFM005'; SalesPrice.PriceType = 'OHC-001S'; SalesPrice.Currency_x = 'USD'; SalesPrice.SalesPrice_x = 201.21; SalesPrice.EffectiveDateFrom = '20121102'; SalesPrice.EffectiveDateTo = '29121104'; SalesPrice.PurposeOfAdvice = '3'; BatchIF_Log__c rowData = NFMUtil.saveRowData(SalesPrices.Monitoring, 'NFM005', SalesPrices.SalesPrice); NFM005Rest u = new NFM005Rest(rowData.Id, 0, SalesPrices.SalesPrice.size()); System.Test.startTest(); Database.executeBatch(u, 1); System.Test.stopTest(); List rslts = [select Id, ProductCode, ProductCode_Ext__c, Intra_Trade_List_RMB_1__c, Intra_Trade_List_RMB_Date1__c, Intra_Trade_List_RMB_End_Date1__c, Intra_Trade_List_RMB_2__c, Intra_Trade_List_RMB_Date2__c, Intra_Trade_List_RMB_End_Date2__c, Foreign_Trade_List_US_1__c, Foreign_Trade_List_US_Date1__c, Foreign_Trade_List_US_End_Date1__c, Foreign_Trade_List_US_2__c, Foreign_Trade_List_US_Date2__c, Foreign_Trade_List_US_End_Date2__c, Intra_Trade_List_US__c, Intra_Trade_List_US_Date__c, Intra_Trade_List_US_End_Date__c, Foreign_Trade_List_RMB__c, Foreign_Trade_List_RMB_Date__c, Foreign_Trade_List_RMB_End_Date__c from Product2 where ProductCode_Ext__c = :SalesPrice.SuppliersItemCode]; System.assertEquals(1, rslts.size()); if (rslts.size() == 1) { System.assertEquals('testNFM005', rslts[0].ProductCode); System.assertEquals(1.56, rslts[0].Intra_Trade_List_RMB_1__c); System.assertEquals(date.newinstance(2012, 11, 21), rslts[0].Intra_Trade_List_RMB_Date1__c); System.assertEquals(date.newinstance(2912, 11, 23), rslts[0].Intra_Trade_List_RMB_End_Date1__c); System.assertEquals(1.78, rslts[0].Intra_Trade_List_RMB_2__c); System.assertEquals(date.newinstance(2012, 12, 01), rslts[0].Intra_Trade_List_RMB_Date2__c); System.assertEquals(date.newinstance(2912, 12, 03), rslts[0].Intra_Trade_List_RMB_End_Date2__c); System.assertEquals(201.21, rslts[0].Foreign_Trade_List_US_1__c); System.assertEquals(date.newinstance(2012, 11, 02), rslts[0].Foreign_Trade_List_US_Date1__c); System.assertEquals(date.newinstance(2912, 11, 04), rslts[0].Foreign_Trade_List_US_End_Date1__c); System.assertEquals(null, rslts[0].Foreign_Trade_List_US_2__c); System.assertEquals(null, rslts[0].Foreign_Trade_List_US_Date2__c); System.assertEquals(null, rslts[0].Foreign_Trade_List_US_End_Date2__c); System.assertEquals(101.12, rslts[0].Intra_Trade_List_US__c); System.assertEquals(date.newinstance(2012, 11, 12), rslts[0].Intra_Trade_List_US_Date__c); System.assertEquals(date.newinstance(2912, 11, 23), rslts[0].Intra_Trade_List_US_End_Date__c); System.assertEquals(null, rslts[0].Foreign_Trade_List_RMB__c); System.assertEquals(null, rslts[0].Foreign_Trade_List_RMB_Date__c); System.assertEquals(null, rslts[0].Foreign_Trade_List_RMB_End_Date__c); } } @isTest static void testNFM005_update_USD_2() { Product2 prd = testNFM005Init(); prd.Intra_Trade_List_RMB_1__c = 1.56; prd.Intra_Trade_List_RMB_Date1__c = date.newinstance(2012, 11, 21); prd.Intra_Trade_List_RMB_End_Date1__c = date.newinstance(2912, 11, 23); prd.Intra_Trade_List_RMB_2__c = 1.78; prd.Intra_Trade_List_RMB_Date2__c = date.newinstance(2012, 12, 1); prd.Intra_Trade_List_RMB_End_Date2__c = date.newinstance(2912, 12, 3); prd.Intra_Trade_List_US__c = 101.12; prd.Intra_Trade_List_US_Date__c = date.newinstance(2012, 11, 12); prd.Intra_Trade_List_US_End_Date__c = date.newinstance(2912, 11, 23); prd.Foreign_Trade_List_US_1__c = 201.21; prd.Foreign_Trade_List_US_Date1__c = date.newinstance(2012, 11, 02); prd.Foreign_Trade_List_US_End_Date1__c = date.newinstance(2912, 11, 04); update prd; NFM005Rest.SalesPrice SalesPrice = new NFM005Rest.SalesPrice(); NFM005Rest.SalesPrices SalesPrices = new NFM005Rest.SalesPrices(); SalesPrices.SalesPrice = new NFM005Rest.SalesPrice[] { SalesPrice }; // Monitoringの設定 Datetime nowDT = Datetime.now(); String nowStr = nowDT.format('yyyyMMddHHmm'); SalesPrices.Monitoring = new NFMUtil.Monitoring(); // update USD 外貿 2回目 SalesPrices.Monitoring.MessageGroupNumber = nowStr + '22'; SalesPrice.SuppliersItemCode = 'testNFM005'; SalesPrice.PriceType = 'OHC-001S'; SalesPrice.Currency_x = 'USD'; SalesPrice.SalesPrice_x = 201.43; SalesPrice.EffectiveDateFrom = '20121112'; SalesPrice.EffectiveDateTo = '29121114'; SalesPrice.PurposeOfAdvice = '3'; BatchIF_Log__c rowData = NFMUtil.saveRowData(SalesPrices.Monitoring, 'NFM005', SalesPrices.SalesPrice); NFM005Rest u = new NFM005Rest(rowData.Id, 0, SalesPrices.SalesPrice.size()); System.Test.startTest(); Database.executeBatch(u, 1); System.Test.stopTest(); List rslts = [select Id, ProductCode, ProductCode_Ext__c, Intra_Trade_List_RMB_1__c, Intra_Trade_List_RMB_Date1__c, Intra_Trade_List_RMB_End_Date1__c, Intra_Trade_List_RMB_2__c, Intra_Trade_List_RMB_Date2__c, Intra_Trade_List_RMB_End_Date2__c, Foreign_Trade_List_US_1__c, Foreign_Trade_List_US_Date1__c, Foreign_Trade_List_US_End_Date1__c, Foreign_Trade_List_US_2__c, Foreign_Trade_List_US_Date2__c, Foreign_Trade_List_US_End_Date2__c, Intra_Trade_List_US__c, Intra_Trade_List_US_Date__c, Intra_Trade_List_US_End_Date__c, Foreign_Trade_List_RMB__c, Foreign_Trade_List_RMB_Date__c, Foreign_Trade_List_RMB_End_Date__c from Product2 where ProductCode_Ext__c = :SalesPrice.SuppliersItemCode]; System.assertEquals(1, rslts.size()); if (rslts.size() == 1) { System.assertEquals('testNFM005', rslts[0].ProductCode); System.assertEquals(1.56, rslts[0].Intra_Trade_List_RMB_1__c); System.assertEquals(date.newinstance(2012, 11, 21), rslts[0].Intra_Trade_List_RMB_Date1__c); System.assertEquals(date.newinstance(2912, 11, 23), rslts[0].Intra_Trade_List_RMB_End_Date1__c); System.assertEquals(1.78, rslts[0].Intra_Trade_List_RMB_2__c); System.assertEquals(date.newinstance(2012, 12, 01), rslts[0].Intra_Trade_List_RMB_Date2__c); System.assertEquals(date.newinstance(2912, 12, 03), rslts[0].Intra_Trade_List_RMB_End_Date2__c); System.assertEquals(201.21, rslts[0].Foreign_Trade_List_US_1__c); System.assertEquals(date.newinstance(2012, 11, 02), rslts[0].Foreign_Trade_List_US_Date1__c); System.assertEquals(date.newinstance(2912, 11, 04), rslts[0].Foreign_Trade_List_US_End_Date1__c); System.assertEquals(201.43, rslts[0].Foreign_Trade_List_US_2__c); System.assertEquals(date.newinstance(2012, 11, 12), rslts[0].Foreign_Trade_List_US_Date2__c); System.assertEquals(date.newinstance(2912, 11, 14), rslts[0].Foreign_Trade_List_US_End_Date2__c); System.assertEquals(101.12, rslts[0].Intra_Trade_List_US__c); System.assertEquals(date.newinstance(2012, 11, 12), rslts[0].Intra_Trade_List_US_Date__c); System.assertEquals(date.newinstance(2912, 11, 23), rslts[0].Intra_Trade_List_US_End_Date__c); System.assertEquals(null, rslts[0].Foreign_Trade_List_RMB__c); System.assertEquals(null, rslts[0].Foreign_Trade_List_RMB_Date__c); System.assertEquals(null, rslts[0].Foreign_Trade_List_RMB_End_Date__c); } } @isTest static void testNFM005_update_USD_3() { Product2 prd = testNFM005Init(); prd.Intra_Trade_List_RMB_1__c = 1.56; prd.Intra_Trade_List_RMB_Date1__c = date.newinstance(2012, 11, 21); prd.Intra_Trade_List_RMB_End_Date1__c = date.newinstance(2912, 11, 23); prd.Intra_Trade_List_RMB_2__c = 1.78; prd.Intra_Trade_List_RMB_Date2__c = date.newinstance(2012, 12, 1); prd.Intra_Trade_List_RMB_End_Date2__c = date.newinstance(2912, 12, 3); prd.Intra_Trade_List_US__c = 101.12; prd.Intra_Trade_List_US_Date__c = date.newinstance(2012, 11, 12); prd.Intra_Trade_List_US_End_Date__c = date.newinstance(2912, 11, 23); prd.Foreign_Trade_List_US_1__c = 201.21; prd.Foreign_Trade_List_US_Date1__c = date.newinstance(2012, 11, 2); prd.Foreign_Trade_List_US_End_Date1__c = date.newinstance(2912, 11, 4); prd.Foreign_Trade_List_US_2__c = 201.43; prd.Foreign_Trade_List_US_Date2__c = date.newinstance(2012, 11, 12); prd.Foreign_Trade_List_US_End_Date2__c = date.newinstance(2912, 11, 14); update prd; NFM005Rest.SalesPrice SalesPrice = new NFM005Rest.SalesPrice(); NFM005Rest.SalesPrices SalesPrices = new NFM005Rest.SalesPrices(); SalesPrices.SalesPrice = new NFM005Rest.SalesPrice[] { SalesPrice }; // Monitoringの設定 Datetime nowDT = Datetime.now(); String nowStr = nowDT.format('yyyyMMddHHmm'); SalesPrices.Monitoring = new NFMUtil.Monitoring(); // update USD 外貿 3回目 SalesPrices.Monitoring.MessageGroupNumber = nowStr + '23'; SalesPrice.SuppliersItemCode = 'testNFM005'; SalesPrice.PriceType = 'OHC-001S'; SalesPrice.Currency_x = 'USD'; SalesPrice.SalesPrice_x = 201.65; SalesPrice.EffectiveDateFrom = '20121122'; SalesPrice.EffectiveDateTo = '29121124'; SalesPrice.PurposeOfAdvice = '3'; BatchIF_Log__c rowData = NFMUtil.saveRowData(SalesPrices.Monitoring, 'NFM005', SalesPrices.SalesPrice); NFM005Rest u = new NFM005Rest(rowData.Id, 0, SalesPrices.SalesPrice.size()); System.Test.startTest(); Database.executeBatch(u, 1); System.Test.stopTest(); List rslts = [select Id, ProductCode, ProductCode_Ext__c, Intra_Trade_List_RMB_1__c, Intra_Trade_List_RMB_Date1__c, Intra_Trade_List_RMB_End_Date1__c, Intra_Trade_List_RMB_2__c, Intra_Trade_List_RMB_Date2__c, Intra_Trade_List_RMB_End_Date2__c, Foreign_Trade_List_US_1__c, Foreign_Trade_List_US_Date1__c, Foreign_Trade_List_US_End_Date1__c, Foreign_Trade_List_US_2__c, Foreign_Trade_List_US_Date2__c, Foreign_Trade_List_US_End_Date2__c, Intra_Trade_List_US__c, Intra_Trade_List_US_Date__c, Intra_Trade_List_US_End_Date__c, Foreign_Trade_List_RMB__c, Foreign_Trade_List_RMB_Date__c, Foreign_Trade_List_RMB_End_Date__c from Product2 where ProductCode_Ext__c = :SalesPrice.SuppliersItemCode]; System.assertEquals(1, rslts.size()); if (rslts.size() == 1) { System.assertEquals('testNFM005', rslts[0].ProductCode); System.assertEquals(1.56, rslts[0].Intra_Trade_List_RMB_1__c); System.assertEquals(date.newinstance(2012, 11, 21), rslts[0].Intra_Trade_List_RMB_Date1__c); System.assertEquals(date.newinstance(2912, 11, 23), rslts[0].Intra_Trade_List_RMB_End_Date1__c); System.assertEquals(1.78, rslts[0].Intra_Trade_List_RMB_2__c); System.assertEquals(date.newinstance(2012, 12, 01), rslts[0].Intra_Trade_List_RMB_Date2__c); System.assertEquals(date.newinstance(2912, 12, 03), rslts[0].Intra_Trade_List_RMB_End_Date2__c); System.assertEquals(201.65, rslts[0].Foreign_Trade_List_US_1__c); System.assertEquals(date.newinstance(2012, 11, 22), rslts[0].Foreign_Trade_List_US_Date1__c); System.assertEquals(date.newinstance(2912, 11, 24), rslts[0].Foreign_Trade_List_US_End_Date1__c); System.assertEquals(201.43, rslts[0].Foreign_Trade_List_US_2__c); System.assertEquals(date.newinstance(2012, 11, 12), rslts[0].Foreign_Trade_List_US_Date2__c); System.assertEquals(date.newinstance(2912, 11, 14), rslts[0].Foreign_Trade_List_US_End_Date2__c); System.assertEquals(101.12, rslts[0].Intra_Trade_List_US__c); System.assertEquals(date.newinstance(2012, 11, 12), rslts[0].Intra_Trade_List_US_Date__c); System.assertEquals(date.newinstance(2912, 11, 23), rslts[0].Intra_Trade_List_US_End_Date__c); System.assertEquals(null, rslts[0].Foreign_Trade_List_RMB__c); System.assertEquals(null, rslts[0].Foreign_Trade_List_RMB_Date__c); System.assertEquals(null, rslts[0].Foreign_Trade_List_RMB_End_Date__c); } } @isTest static void testNFM005_update_USD_4() { Product2 prd = testNFM005Init(); prd.Intra_Trade_List_RMB_1__c = 1.56; prd.Intra_Trade_List_RMB_Date1__c = date.newinstance(2012, 11, 21); prd.Intra_Trade_List_RMB_End_Date1__c = date.newinstance(2912, 11, 23); prd.Intra_Trade_List_RMB_2__c = 1.78; prd.Intra_Trade_List_RMB_Date2__c = date.newinstance(2012, 12, 1); prd.Intra_Trade_List_RMB_End_Date2__c = date.newinstance(2912, 12, 3); prd.Intra_Trade_List_US__c = 101.12; prd.Intra_Trade_List_US_Date__c = date.newinstance(2012, 11, 12); prd.Intra_Trade_List_US_End_Date__c = date.newinstance(2912, 11, 23); prd.Foreign_Trade_List_US_1__c = 201.65; prd.Foreign_Trade_List_US_Date1__c = date.newinstance(2012, 11, 22); prd.Foreign_Trade_List_US_End_Date1__c = date.newinstance(2912, 11, 24); prd.Foreign_Trade_List_US_2__c = 201.43; prd.Foreign_Trade_List_US_Date2__c = date.newinstance(2012, 11, 12); prd.Foreign_Trade_List_US_End_Date2__c = date.newinstance(2912, 11, 14); update prd; NFM005Rest.SalesPrice SalesPrice = new NFM005Rest.SalesPrice(); NFM005Rest.SalesPrice SalesPrice2 = new NFM005Rest.SalesPrice(); NFM005Rest.SalesPrices SalesPrices = new NFM005Rest.SalesPrices(); SalesPrices.SalesPrice = new NFM005Rest.SalesPrice[] { SalesPrice, SalesPrice2 }; // Monitoringの設定 Datetime nowDT = Datetime.now(); String nowStr = nowDT.format('yyyyMMddHHmm'); SalesPrices.Monitoring = new NFMUtil.Monitoring(); // update USD 外貿 4回目 SalesPrices.Monitoring.MessageGroupNumber = nowStr + '24'; SalesPrice.SuppliersItemCode = 'testNFM005'; SalesPrice.PriceType = 'OHC-001S'; SalesPrice.Currency_x = 'USD'; SalesPrice.SalesPrice_x = 201.87; SalesPrice.EffectiveDateFrom = '20121202'; SalesPrice.EffectiveDateTo = '29121204'; SalesPrice.PurposeOfAdvice = '3'; // update RMB 外貿 SalesPrice2.SuppliersItemCode = 'testNFM005'; SalesPrice2.PriceType = 'OHC-001S'; SalesPrice2.Currency_x = 'RMB'; SalesPrice2.SalesPrice_x = 222.12; SalesPrice2.EffectiveDateFrom = '20121212'; SalesPrice2.EffectiveDateTo = '29121214'; SalesPrice2.PurposeOfAdvice = '3'; BatchIF_Log__c rowData = NFMUtil.saveRowData(SalesPrices.Monitoring, 'NFM005', SalesPrices.SalesPrice); NFM005Rest u = new NFM005Rest(rowData.Id, 0, SalesPrices.SalesPrice.size()); System.Test.startTest(); Database.executeBatch(u, 1); System.Test.stopTest(); List rslts = [select Id, ProductCode, ProductCode_Ext__c, Intra_Trade_List_RMB_1__c, Intra_Trade_List_RMB_Date1__c, Intra_Trade_List_RMB_End_Date1__c, Intra_Trade_List_RMB_2__c, Intra_Trade_List_RMB_Date2__c, Intra_Trade_List_RMB_End_Date2__c, Foreign_Trade_List_US_1__c, Foreign_Trade_List_US_Date1__c, Foreign_Trade_List_US_End_Date1__c, Foreign_Trade_List_US_2__c, Foreign_Trade_List_US_Date2__c, Foreign_Trade_List_US_End_Date2__c, Intra_Trade_List_US__c, Intra_Trade_List_US_Date__c, Intra_Trade_List_US_End_Date__c, Foreign_Trade_List_RMB__c, Foreign_Trade_List_RMB_Date__c, Foreign_Trade_List_RMB_End_Date__c from Product2 where ProductCode_Ext__c = :SalesPrice.SuppliersItemCode]; System.assertEquals(1, rslts.size()); if (rslts.size() == 1) { System.assertEquals('testNFM005', rslts[0].ProductCode); System.assertEquals(1.56, rslts[0].Intra_Trade_List_RMB_1__c); System.assertEquals(date.newinstance(2012, 11, 21), rslts[0].Intra_Trade_List_RMB_Date1__c); System.assertEquals(date.newinstance(2912, 11, 23), rslts[0].Intra_Trade_List_RMB_End_Date1__c); System.assertEquals(1.78, rslts[0].Intra_Trade_List_RMB_2__c); System.assertEquals(date.newinstance(2012, 12, 01), rslts[0].Intra_Trade_List_RMB_Date2__c); System.assertEquals(date.newinstance(2912, 12, 03), rslts[0].Intra_Trade_List_RMB_End_Date2__c); System.assertEquals(201.65, rslts[0].Foreign_Trade_List_US_1__c); System.assertEquals(date.newinstance(2012, 11, 22), rslts[0].Foreign_Trade_List_US_Date1__c); System.assertEquals(date.newinstance(2912, 11, 24), rslts[0].Foreign_Trade_List_US_End_Date1__c); System.assertEquals(201.87, rslts[0].Foreign_Trade_List_US_2__c); System.assertEquals(date.newinstance(2012, 12, 02), rslts[0].Foreign_Trade_List_US_Date2__c); System.assertEquals(date.newinstance(2912, 12, 04), rslts[0].Foreign_Trade_List_US_End_Date2__c); System.assertEquals(101.12, rslts[0].Intra_Trade_List_US__c); System.assertEquals(date.newinstance(2012, 11, 12), rslts[0].Intra_Trade_List_US_Date__c); System.assertEquals(date.newinstance(2912, 11, 23), rslts[0].Intra_Trade_List_US_End_Date__c); System.assertEquals(222.12, rslts[0].Foreign_Trade_List_RMB__c); System.assertEquals(date.newinstance(2012, 12, 12), rslts[0].Foreign_Trade_List_RMB_Date__c); System.assertEquals(date.newinstance(2912, 12, 14), rslts[0].Foreign_Trade_List_RMB_End_Date__c); } } @isTest static void testNFM005_delete_1() { Product2 prd = testNFM005Init(); prd.Intra_Trade_List_RMB_1__c = 1.56; prd.Intra_Trade_List_RMB_Date1__c = date.newinstance(2012, 11, 21); prd.Intra_Trade_List_RMB_End_Date1__c = date.newinstance(2912, 11, 23); prd.Intra_Trade_List_RMB_2__c = 1.78; prd.Intra_Trade_List_RMB_Date2__c = date.newinstance(2012, 12, 1); prd.Intra_Trade_List_RMB_End_Date2__c = date.newinstance(2912, 12, 3); prd.Intra_Trade_List_US__c = 101.12; prd.Intra_Trade_List_US_Date__c = date.newinstance(2012, 11, 12); prd.Intra_Trade_List_US_End_Date__c = date.newinstance(2912, 11, 23); prd.Foreign_Trade_List_US_1__c = 201.65; prd.Foreign_Trade_List_US_Date1__c = date.newinstance(2012, 11, 22); prd.Foreign_Trade_List_US_End_Date1__c = date.newinstance(2912, 11, 24); prd.Foreign_Trade_List_US_2__c = 201.43; prd.Foreign_Trade_List_US_Date2__c = date.newinstance(2012, 11, 12); prd.Foreign_Trade_List_US_End_Date2__c = date.newinstance(2912, 11, 14); prd.Foreign_Trade_List_RMB__c = 222.12; prd.Foreign_Trade_List_RMB_Date__c = date.newinstance(2012, 12, 12); prd.Foreign_Trade_List_RMB_End_Date__c = date.newinstance(2912, 12, 14); update prd; NFM005Rest.SalesPrice SalesPrice = new NFM005Rest.SalesPrice(); NFM005Rest.SalesPrices SalesPrices = new NFM005Rest.SalesPrices(); SalesPrices.SalesPrice = new NFM005Rest.SalesPrice[] { SalesPrice }; // Monitoringの設定 Datetime nowDT = Datetime.now(); String nowStr = nowDT.format('yyyyMMddHHmm'); SalesPrices.Monitoring = new NFMUtil.Monitoring(); // 削除、2世代目の金額 SalesPrices.Monitoring.MessageGroupNumber = nowStr + '31'; SalesPrice.SuppliersItemCode = 'testNFM005'; SalesPrice.PriceType = 'OHC-001S'; SalesPrice.Currency_x = 'USD'; SalesPrice.SalesPrice_x = 201.87; SalesPrice.EffectiveDateFrom = '20121202'; SalesPrice.EffectiveDateTo = '29121204'; SalesPrice.PurposeOfAdvice = '1'; BatchIF_Log__c rowData = NFMUtil.saveRowData(SalesPrices.Monitoring, 'NFM005', SalesPrices.SalesPrice); NFM005Rest u = new NFM005Rest(rowData.Id, 0, SalesPrices.SalesPrice.size()); System.Test.startTest(); Database.executeBatch(u, 1); System.Test.stopTest(); List rslts = [select Id, ProductCode, ProductCode_Ext__c, Intra_Trade_List_RMB_1__c, Intra_Trade_List_RMB_Date1__c, Intra_Trade_List_RMB_End_Date1__c, Intra_Trade_List_RMB_2__c, Intra_Trade_List_RMB_Date2__c, Intra_Trade_List_RMB_End_Date2__c, Foreign_Trade_List_US_1__c, Foreign_Trade_List_US_Date1__c, Foreign_Trade_List_US_End_Date1__c, Foreign_Trade_List_US_2__c, Foreign_Trade_List_US_Date2__c, Foreign_Trade_List_US_End_Date2__c, Intra_Trade_List_US__c, Intra_Trade_List_US_Date__c, Intra_Trade_List_US_End_Date__c, Foreign_Trade_List_RMB__c, Foreign_Trade_List_RMB_Date__c, Foreign_Trade_List_RMB_End_Date__c from Product2 where ProductCode_Ext__c = :SalesPrice.SuppliersItemCode]; // deleteの場合、EffectiveDateTo が前日 System.assertEquals(1, rslts.size()); System.assertEquals(Date.today().addDays(-1), rslts[0].Foreign_Trade_List_US_End_Date2__c); } @isTest static void testNFM005_delete_2() { Product2 prd = testNFM005Init(); prd.Intra_Trade_List_RMB_1__c = 1.56; prd.Intra_Trade_List_RMB_Date1__c = date.newinstance(2012, 11, 21); prd.Intra_Trade_List_RMB_End_Date1__c = date.newinstance(2912, 11, 23); prd.Intra_Trade_List_RMB_2__c = 1.78; prd.Intra_Trade_List_RMB_Date2__c = date.newinstance(2012, 12, 1); prd.Intra_Trade_List_RMB_End_Date2__c = date.newinstance(2912, 12, 3); prd.Intra_Trade_List_US__c = 101.12; prd.Intra_Trade_List_US_Date__c = date.newinstance(2012, 11, 12); prd.Intra_Trade_List_US_End_Date__c = date.newinstance(2912, 11, 23); prd.Foreign_Trade_List_US_1__c = 201.65; prd.Foreign_Trade_List_US_Date1__c = date.newinstance(2012, 11, 22); prd.Foreign_Trade_List_US_End_Date1__c = date.newinstance(2912, 11, 24); prd.Foreign_Trade_List_US_2__c = 201.43; prd.Foreign_Trade_List_US_Date2__c = date.newinstance(2012, 11, 12); prd.Foreign_Trade_List_US_End_Date2__c = Date.today().addDays(-1); prd.Foreign_Trade_List_RMB__c = 222.12; prd.Foreign_Trade_List_RMB_Date__c = date.newinstance(2012, 12, 12); prd.Foreign_Trade_List_RMB_End_Date__c = date.newinstance(2912, 12, 14); update prd; NFM005Rest.SalesPrice SalesPrice = new NFM005Rest.SalesPrice(); NFM005Rest.SalesPrices SalesPrices = new NFM005Rest.SalesPrices(); SalesPrices.SalesPrice = new NFM005Rest.SalesPrice[] { SalesPrice }; // Monitoringの設定 Datetime nowDT = Datetime.now(); String nowStr = nowDT.format('yyyyMMddHHmm'); SalesPrices.Monitoring = new NFMUtil.Monitoring(); // 料金更新、2世代目に反映 SalesPrices.Monitoring.MessageGroupNumber = nowStr + '32'; SalesPrice.SuppliersItemCode = 'testNFM005'; SalesPrice.PriceType = 'OHC-001S'; SalesPrice.Currency_x = 'USD'; SalesPrice.SalesPrice_x = 201.87; SalesPrice.EffectiveDateFrom = '20121201'; SalesPrice.EffectiveDateTo = '29121204'; SalesPrice.PurposeOfAdvice = '3'; BatchIF_Log__c rowData = NFMUtil.saveRowData(SalesPrices.Monitoring, 'NFM005', SalesPrices.SalesPrice); NFM005Rest u = new NFM005Rest(rowData.Id, 0, SalesPrices.SalesPrice.size()); System.Test.startTest(); Database.executeBatch(u, 1); System.Test.stopTest(); List rslts = [select Id, ProductCode, ProductCode_Ext__c, Intra_Trade_List_RMB_1__c, Intra_Trade_List_RMB_Date1__c, Intra_Trade_List_RMB_End_Date1__c, Intra_Trade_List_RMB_2__c, Intra_Trade_List_RMB_Date2__c, Intra_Trade_List_RMB_End_Date2__c, Foreign_Trade_List_US_1__c, Foreign_Trade_List_US_Date1__c, Foreign_Trade_List_US_End_Date1__c, Foreign_Trade_List_US_2__c, Foreign_Trade_List_US_Date2__c, Foreign_Trade_List_US_End_Date2__c, Intra_Trade_List_US__c, Intra_Trade_List_US_Date__c, Intra_Trade_List_US_End_Date__c, Foreign_Trade_List_RMB__c, Foreign_Trade_List_RMB_Date__c, Foreign_Trade_List_RMB_End_Date__c from Product2 where ProductCode_Ext__c = :SalesPrice.SuppliersItemCode]; // deleteの場合、EffectiveDateTo が前日 System.assertEquals(1, rslts.size()); System.assertEquals(201.87, rslts[0].Foreign_Trade_List_US_2__c); System.assertEquals(date.newinstance(2012, 12, 01), rslts[0].Foreign_Trade_List_US_Date2__c); System.assertEquals(date.newinstance(2912, 12, 04), rslts[0].Foreign_Trade_List_US_End_Date2__c); } }