@isTest
|
private class NFM004WebServiceTest {
|
|
static Product2 testNFM004Init() {
|
// テストデータ
|
Product2 prd = new Product2();
|
prd.ProductCode_Ext__c = 'testNFM004';
|
prd.ProductCode = 'testNFM004';
|
prd.Name = 'testNFM004';
|
prd.Manual_Entry__c = false;
|
insert prd;
|
return prd;
|
}
|
|
// そのままreturn
|
@isTest
|
static void testNFM004_void() {
|
testNFM004Init();
|
// null
|
NFM004WebService.NFM004(null);
|
|
NFM004WebService.PurchasePrice PurchasePrice = new NFM004WebService.PurchasePrice();
|
NFM004WebService.PurchasePrices PurchasePrices = new NFM004WebService.PurchasePrices();
|
PurchasePrices.PurchasePrice = new NFM004WebService.PurchasePrice[] { PurchasePrice };
|
// Monitoringをセットしない
|
NFM004WebService.NFM004(PurchasePrices);
|
|
Datetime nowDT = Datetime.now();
|
String nowStr = nowDT.format('yyyyMMddHHmm');
|
PurchasePrices.Monitoring = new NFMUtil.Monitoring();
|
PurchasePrices.Monitoring.MessageGroupNumber = nowStr + '01';
|
// 必須項目をセットしない
|
NFM004WebService.NFM004(PurchasePrices);
|
|
// 商品コードが存在しない
|
PurchasePrices.Monitoring.MessageGroupNumber = nowStr + '02';
|
PurchasePrice.SuppliersItemCode = 'testNFM004X';
|
System.Test.startTest();
|
NFM004WebService.NFM004(PurchasePrices);
|
System.Test.stopTest();
|
|
Product2[] rslts = [select Id from Product2 where ProductCode_Ext__c = :PurchasePrice.SuppliersItemCode];
|
System.assertEquals(0, rslts.size());
|
}
|
|
@isTest
|
static void testNFM004_update_RMB_1() {
|
testNFM004Init();
|
|
NFM004WebService.PurchasePrice PurchasePrice = new NFM004WebService.PurchasePrice();
|
NFM004WebService.PurchasePrices PurchasePrices = new NFM004WebService.PurchasePrices();
|
|
// Monitoringの設定
|
Datetime nowDT = Datetime.now();
|
String nowStr = nowDT.format('yyyyMMddHHmm');
|
PurchasePrices.Monitoring = new NFMUtil.Monitoring();
|
|
// update RMB 内貿 1回目
|
PurchasePrices.PurchasePrice = new NFM004WebService.PurchasePrice[] { PurchasePrice };
|
PurchasePrices.Monitoring.MessageGroupNumber = nowStr + '11';
|
PurchasePrice.SuppliersItemCode = 'testNFM004';
|
PurchasePrice.PriceType = 'OCM-001';
|
PurchasePrice.Currency_x = 'RMB';
|
PurchasePrice.PurchasePrice = 1.12;
|
PurchasePrice.EffectiveDateFrom = '20121101';
|
PurchasePrice.EffectiveDateTo = '29121103';
|
PurchasePrice.PurposeOfAdvice = '3';
|
|
System.Test.startTest();
|
NFM004WebService.NFM004(PurchasePrices);
|
System.Test.stopTest();
|
|
List<Product2> rslts = [select Id, ProductCode, ProductCode_Ext__c,
|
Intra_Trade_Cost_RMB_1__c,
|
Intra_Trade_Cost_RMB_Date1__c,
|
Intra_Trade_Cost_RMB_End_Date1__c,
|
Intra_Trade_Cost_RMB_2__c,
|
Intra_Trade_Cost_RMB_Date2__c,
|
Intra_Trade_Cost_RMB_End_Date2__c,
|
Foreign_Trade_Cost_US_1__c,
|
Foreign_Trade_Cost_US_Date1__c,
|
Foreign_Trade_Cost_US_End_Date1__c,
|
Foreign_Trade_Cost_US_2__c,
|
Foreign_Trade_Cost_US_Date2__c,
|
Foreign_Trade_Cost_US_End_Date2__c,
|
Intra_Trade_Cost_US__c,
|
Intra_Trade_Cost_US_Date__c,
|
Intra_Trade_Cost_US_End_Date__c,
|
Foreign_Trade_Cost_RMB__c,
|
Foreign_Trade_Cost_RMB_Date__c,
|
Foreign_Trade_Cost_RMB_End_Date__c
|
from Product2
|
where ProductCode_Ext__c = :PurchasePrice.SuppliersItemCode];
|
System.assertEquals(1, rslts.size());
|
if (rslts.size() == 1) {
|
System.assertEquals('testNFM004', rslts[0].ProductCode);
|
System.assertEquals(1.12, rslts[0].Intra_Trade_Cost_RMB_1__c);
|
System.assertEquals(date.newinstance(2012, 11, 1), rslts[0].Intra_Trade_Cost_RMB_Date1__c);
|
System.assertEquals(date.newinstance(2912, 11, 3), rslts[0].Intra_Trade_Cost_RMB_End_Date1__c);
|
System.assertEquals(null, rslts[0].Intra_Trade_Cost_RMB_2__c);
|
System.assertEquals(null, rslts[0].Intra_Trade_Cost_RMB_Date2__c);
|
System.assertEquals(null, rslts[0].Intra_Trade_Cost_RMB_End_Date2__c);
|
System.assertEquals(null, rslts[0].Foreign_Trade_Cost_US_1__c);
|
System.assertEquals(null, rslts[0].Foreign_Trade_Cost_US_Date1__c);
|
System.assertEquals(null, rslts[0].Foreign_Trade_Cost_US_End_Date1__c);
|
System.assertEquals(null, rslts[0].Foreign_Trade_Cost_US_2__c);
|
System.assertEquals(null, rslts[0].Foreign_Trade_Cost_US_Date2__c);
|
System.assertEquals(null, rslts[0].Foreign_Trade_Cost_US_End_Date2__c);
|
System.assertEquals(null, rslts[0].Intra_Trade_Cost_US__c);
|
System.assertEquals(null, rslts[0].Intra_Trade_Cost_US_Date__c);
|
System.assertEquals(null, rslts[0].Intra_Trade_Cost_US_End_Date__c);
|
System.assertEquals(null, rslts[0].Foreign_Trade_Cost_RMB__c);
|
System.assertEquals(null, rslts[0].Foreign_Trade_Cost_RMB_Date__c);
|
System.assertEquals(null, rslts[0].Foreign_Trade_Cost_RMB_End_Date__c);
|
}
|
}
|
|
@isTest
|
static void testNFM004_update_RMB_2() {
|
Product2 prd = testNFM004Init();
|
prd.Intra_Trade_Cost_RMB_1__c = 1.12;
|
prd.Intra_Trade_Cost_RMB_Date1__c = date.newinstance(2012, 11, 1);
|
prd.Intra_Trade_Cost_RMB_End_Date1__c = date.newinstance(2912, 11, 3);
|
update prd;
|
|
NFM004WebService.PurchasePrice PurchasePrice = new NFM004WebService.PurchasePrice();
|
NFM004WebService.PurchasePrices PurchasePrices = new NFM004WebService.PurchasePrices();
|
|
// Monitoringの設定
|
Datetime nowDT = Datetime.now();
|
String nowStr = nowDT.format('yyyyMMddHHmm');
|
PurchasePrices.Monitoring = new NFMUtil.Monitoring();
|
|
// update RMB 内貿 2回目
|
PurchasePrices.PurchasePrice = new NFM004WebService.PurchasePrice[] { PurchasePrice };
|
PurchasePrices.Monitoring.MessageGroupNumber = nowStr + '12';
|
PurchasePrice.SuppliersItemCode = 'testNFM004';
|
PurchasePrice.PriceType = 'OCM-001';
|
PurchasePrice.Currency_x = 'RMB';
|
PurchasePrice.PurchasePrice = 1.34;
|
PurchasePrice.EffectiveDateFrom = '20121111';
|
PurchasePrice.EffectiveDateTo = '29121113';
|
PurchasePrice.PurposeOfAdvice = '3';
|
|
System.Test.startTest();
|
NFM004WebService.NFM004(PurchasePrices);
|
System.Test.stopTest();
|
|
List<Product2> rslts = [select Id, ProductCode, ProductCode_Ext__c,
|
Intra_Trade_Cost_RMB_1__c,
|
Intra_Trade_Cost_RMB_Date1__c,
|
Intra_Trade_Cost_RMB_End_Date1__c,
|
Intra_Trade_Cost_RMB_2__c,
|
Intra_Trade_Cost_RMB_Date2__c,
|
Intra_Trade_Cost_RMB_End_Date2__c,
|
Foreign_Trade_Cost_US_1__c,
|
Foreign_Trade_Cost_US_Date1__c,
|
Foreign_Trade_Cost_US_End_Date1__c,
|
Foreign_Trade_Cost_US_2__c,
|
Foreign_Trade_Cost_US_Date2__c,
|
Foreign_Trade_Cost_US_End_Date2__c,
|
Intra_Trade_Cost_US__c,
|
Intra_Trade_Cost_US_Date__c,
|
Intra_Trade_Cost_US_End_Date__c,
|
Foreign_Trade_Cost_RMB__c,
|
Foreign_Trade_Cost_RMB_Date__c,
|
Foreign_Trade_Cost_RMB_End_Date__c
|
from Product2
|
where ProductCode_Ext__c = :PurchasePrice.SuppliersItemCode];
|
System.assertEquals(1, rslts.size());
|
if (rslts.size() == 1) {
|
System.assertEquals('testNFM004', rslts[0].ProductCode);
|
System.assertEquals(1.12, rslts[0].Intra_Trade_Cost_RMB_1__c);
|
System.assertEquals(date.newinstance(2012, 11, 1), rslts[0].Intra_Trade_Cost_RMB_Date1__c);
|
System.assertEquals(date.newinstance(2912, 11, 3), rslts[0].Intra_Trade_Cost_RMB_End_Date1__c);
|
System.assertEquals(1.34, rslts[0].Intra_Trade_Cost_RMB_2__c);
|
System.assertEquals(date.newinstance(2012, 11, 11), rslts[0].Intra_Trade_Cost_RMB_Date2__c);
|
System.assertEquals(date.newinstance(2912, 11, 13), rslts[0].Intra_Trade_Cost_RMB_End_Date2__c);
|
System.assertEquals(null, rslts[0].Foreign_Trade_Cost_US_1__c);
|
System.assertEquals(null, rslts[0].Foreign_Trade_Cost_US_Date1__c);
|
System.assertEquals(null, rslts[0].Foreign_Trade_Cost_US_End_Date1__c);
|
System.assertEquals(null, rslts[0].Foreign_Trade_Cost_US_2__c);
|
System.assertEquals(null, rslts[0].Foreign_Trade_Cost_US_Date2__c);
|
System.assertEquals(null, rslts[0].Foreign_Trade_Cost_US_End_Date2__c);
|
System.assertEquals(null, rslts[0].Intra_Trade_Cost_US__c);
|
System.assertEquals(null, rslts[0].Intra_Trade_Cost_US_Date__c);
|
System.assertEquals(null, rslts[0].Intra_Trade_Cost_US_End_Date__c);
|
System.assertEquals(null, rslts[0].Foreign_Trade_Cost_RMB__c);
|
System.assertEquals(null, rslts[0].Foreign_Trade_Cost_RMB_Date__c);
|
System.assertEquals(null, rslts[0].Foreign_Trade_Cost_RMB_End_Date__c);
|
}
|
}
|
|
@isTest
|
static void testNFM004_update_RMB_3() {
|
Product2 prd = testNFM004Init();
|
prd.Intra_Trade_Cost_RMB_1__c = 1.12;
|
prd.Intra_Trade_Cost_RMB_Date1__c = date.newinstance(2012, 11, 1);
|
prd.Intra_Trade_Cost_RMB_End_Date1__c = date.newinstance(2912, 11, 3);
|
prd.Intra_Trade_Cost_RMB_2__c = 1.34;
|
prd.Intra_Trade_Cost_RMB_Date2__c = date.newinstance(2012, 11, 11);
|
prd.Intra_Trade_Cost_RMB_End_Date2__c = date.newinstance(2912, 11, 13);
|
update prd;
|
|
NFM004WebService.PurchasePrice PurchasePrice = new NFM004WebService.PurchasePrice();
|
NFM004WebService.PurchasePrices PurchasePrices = new NFM004WebService.PurchasePrices();
|
|
// Monitoringの設定
|
Datetime nowDT = Datetime.now();
|
String nowStr = nowDT.format('yyyyMMddHHmm');
|
PurchasePrices.Monitoring = new NFMUtil.Monitoring();
|
|
// update RMB 内貿 3回目
|
PurchasePrices.PurchasePrice = new NFM004WebService.PurchasePrice[] { PurchasePrice };
|
PurchasePrices.Monitoring.MessageGroupNumber = nowStr + '13';
|
PurchasePrice.SuppliersItemCode = 'testNFM004';
|
PurchasePrice.PriceType = 'OCM-001';
|
PurchasePrice.Currency_x = 'RMB';
|
PurchasePrice.PurchasePrice = 1.56;
|
PurchasePrice.EffectiveDateFrom = '00000000';
|
PurchasePrice.EffectiveDateTo = '29121123';
|
PurchasePrice.PurposeOfAdvice = '3';
|
|
System.Test.startTest();
|
NFM004WebService.NFM004(PurchasePrices);
|
System.Test.stopTest();
|
|
List<Product2> rslts = [select Id, ProductCode, ProductCode_Ext__c,
|
Intra_Trade_Cost_RMB_1__c,
|
Intra_Trade_Cost_RMB_Date1__c,
|
Intra_Trade_Cost_RMB_End_Date1__c,
|
Intra_Trade_Cost_RMB_2__c,
|
Intra_Trade_Cost_RMB_Date2__c,
|
Intra_Trade_Cost_RMB_End_Date2__c,
|
Foreign_Trade_Cost_US_1__c,
|
Foreign_Trade_Cost_US_Date1__c,
|
Foreign_Trade_Cost_US_End_Date1__c,
|
Foreign_Trade_Cost_US_2__c,
|
Foreign_Trade_Cost_US_Date2__c,
|
Foreign_Trade_Cost_US_End_Date2__c,
|
Intra_Trade_Cost_US__c,
|
Intra_Trade_Cost_US_Date__c,
|
Intra_Trade_Cost_US_End_Date__c,
|
Foreign_Trade_Cost_RMB__c,
|
Foreign_Trade_Cost_RMB_Date__c,
|
Foreign_Trade_Cost_RMB_End_Date__c
|
from Product2
|
where ProductCode_Ext__c = :PurchasePrice.SuppliersItemCode];
|
System.assertEquals(1, rslts.size());
|
if (rslts.size() == 1) {
|
System.assertEquals('testNFM004', rslts[0].ProductCode);
|
System.assertEquals(1.56, rslts[0].Intra_Trade_Cost_RMB_1__c);
|
System.assertEquals(null, rslts[0].Intra_Trade_Cost_RMB_Date1__c);
|
System.assertEquals(date.newinstance(2912, 11, 23), rslts[0].Intra_Trade_Cost_RMB_End_Date1__c);
|
System.assertEquals(1.34, rslts[0].Intra_Trade_Cost_RMB_2__c);
|
System.assertEquals(date.newinstance(2012, 11, 11), rslts[0].Intra_Trade_Cost_RMB_Date2__c);
|
System.assertEquals(date.newinstance(2912, 11, 13), rslts[0].Intra_Trade_Cost_RMB_End_Date2__c);
|
System.assertEquals(null, rslts[0].Foreign_Trade_Cost_US_1__c);
|
System.assertEquals(null, rslts[0].Foreign_Trade_Cost_US_Date1__c);
|
System.assertEquals(null, rslts[0].Foreign_Trade_Cost_US_End_Date1__c);
|
System.assertEquals(null, rslts[0].Foreign_Trade_Cost_US_2__c);
|
System.assertEquals(null, rslts[0].Foreign_Trade_Cost_US_Date2__c);
|
System.assertEquals(null, rslts[0].Foreign_Trade_Cost_US_End_Date2__c);
|
System.assertEquals(null, rslts[0].Intra_Trade_Cost_US__c);
|
System.assertEquals(null, rslts[0].Intra_Trade_Cost_US_Date__c);
|
System.assertEquals(null, rslts[0].Intra_Trade_Cost_US_End_Date__c);
|
System.assertEquals(null, rslts[0].Foreign_Trade_Cost_RMB__c);
|
System.assertEquals(null, rslts[0].Foreign_Trade_Cost_RMB_Date__c);
|
System.assertEquals(null, rslts[0].Foreign_Trade_Cost_RMB_End_Date__c);
|
}
|
}
|
|
@isTest
|
static void testNFM004_update_RMB_4() {
|
Product2 prd = testNFM004Init();
|
prd.Intra_Trade_Cost_RMB_1__c = 1.56;
|
prd.Intra_Trade_Cost_RMB_Date1__c = date.newinstance(1900, 1, 1);
|
prd.Intra_Trade_Cost_RMB_End_Date1__c = date.newinstance(2912, 11, 23);
|
prd.Intra_Trade_Cost_RMB_2__c = 1.34;
|
prd.Intra_Trade_Cost_RMB_Date2__c = date.newinstance(2012, 11, 11);
|
prd.Intra_Trade_Cost_RMB_End_Date2__c = date.newinstance(2912, 11, 13);
|
update prd;
|
|
NFM004WebService.PurchasePrice PurchasePrice = new NFM004WebService.PurchasePrice();
|
NFM004WebService.PurchasePrice PurchasePrice2 = new NFM004WebService.PurchasePrice();
|
NFM004WebService.PurchasePrices PurchasePrices = new NFM004WebService.PurchasePrices();
|
|
// Monitoringの設定
|
Datetime nowDT = Datetime.now();
|
String nowStr = nowDT.format('yyyyMMddHHmm');
|
PurchasePrices.Monitoring = new NFMUtil.Monitoring();
|
|
// update RMB 内貿 4回目、複数
|
PurchasePrices.PurchasePrice = new NFM004WebService.PurchasePrice[] { PurchasePrice, PurchasePrice2 };
|
PurchasePrices.Monitoring.MessageGroupNumber = nowStr + '14';
|
PurchasePrice.SuppliersItemCode = 'testNFM004';
|
PurchasePrice.PriceType = 'OCM-001';
|
PurchasePrice.Currency_x = 'RMB';
|
PurchasePrice.PurchasePrice = 1.78;
|
PurchasePrice.EffectiveDateFrom = '20121201';
|
PurchasePrice.EffectiveDateTo = '29121203';
|
PurchasePrice.PurposeOfAdvice = '3';
|
// update US 内貿
|
PurchasePrice2.SuppliersItemCode = 'testNFM004';
|
PurchasePrice2.PriceType = 'OCM-001';
|
PurchasePrice2.Currency_x = 'USD';
|
PurchasePrice2.PurchasePrice = 101.12;
|
PurchasePrice2.EffectiveDateFrom = '00000000';
|
PurchasePrice2.EffectiveDateTo = '29121123';
|
PurchasePrice2.PurposeOfAdvice = '3';
|
|
System.Test.startTest();
|
NFM004WebService.NFM004(PurchasePrices);
|
System.Test.stopTest();
|
|
List<Product2> rslts = [select Id, ProductCode, ProductCode_Ext__c,
|
Intra_Trade_Cost_RMB_1__c,
|
Intra_Trade_Cost_RMB_Date1__c,
|
Intra_Trade_Cost_RMB_End_Date1__c,
|
Intra_Trade_Cost_RMB_2__c,
|
Intra_Trade_Cost_RMB_Date2__c,
|
Intra_Trade_Cost_RMB_End_Date2__c,
|
Foreign_Trade_Cost_US_1__c,
|
Foreign_Trade_Cost_US_Date1__c,
|
Foreign_Trade_Cost_US_End_Date1__c,
|
Foreign_Trade_Cost_US_2__c,
|
Foreign_Trade_Cost_US_Date2__c,
|
Foreign_Trade_Cost_US_End_Date2__c,
|
Intra_Trade_Cost_US__c,
|
Intra_Trade_Cost_US_Date__c,
|
Intra_Trade_Cost_US_End_Date__c,
|
Foreign_Trade_Cost_RMB__c,
|
Foreign_Trade_Cost_RMB_Date__c,
|
Foreign_Trade_Cost_RMB_End_Date__c
|
from Product2
|
where ProductCode_Ext__c = :PurchasePrice.SuppliersItemCode];
|
System.assertEquals(1, rslts.size());
|
if (rslts.size() == 1) {
|
System.assertEquals('testNFM004', rslts[0].ProductCode);
|
System.assertEquals(1.78, rslts[0].Intra_Trade_Cost_RMB_1__c);
|
System.assertEquals(date.newinstance(2012, 12, 01), rslts[0].Intra_Trade_Cost_RMB_Date1__c);
|
System.assertEquals(date.newinstance(2912, 12, 03), rslts[0].Intra_Trade_Cost_RMB_End_Date1__c);
|
System.assertEquals(1.34, rslts[0].Intra_Trade_Cost_RMB_2__c);
|
System.assertEquals(date.newinstance(2012, 11, 11), rslts[0].Intra_Trade_Cost_RMB_Date2__c);
|
System.assertEquals(date.newinstance(2912, 11, 13), rslts[0].Intra_Trade_Cost_RMB_End_Date2__c);
|
System.assertEquals(null, rslts[0].Foreign_Trade_Cost_US_1__c);
|
System.assertEquals(null, rslts[0].Foreign_Trade_Cost_US_Date1__c);
|
System.assertEquals(null, rslts[0].Foreign_Trade_Cost_US_End_Date1__c);
|
System.assertEquals(null, rslts[0].Foreign_Trade_Cost_US_2__c);
|
System.assertEquals(null, rslts[0].Foreign_Trade_Cost_US_Date2__c);
|
System.assertEquals(null, rslts[0].Foreign_Trade_Cost_US_End_Date2__c);
|
System.assertEquals(101.12, rslts[0].Intra_Trade_Cost_US__c);
|
System.assertEquals(null, rslts[0].Intra_Trade_Cost_US_Date__c);
|
System.assertEquals(date.newinstance(2912, 11, 23), rslts[0].Intra_Trade_Cost_US_End_Date__c);
|
System.assertEquals(null, rslts[0].Foreign_Trade_Cost_RMB__c);
|
System.assertEquals(null, rslts[0].Foreign_Trade_Cost_RMB_Date__c);
|
System.assertEquals(null, rslts[0].Foreign_Trade_Cost_RMB_End_Date__c);
|
}
|
}
|
|
@isTest
|
static void testNFM004_update_USD_1() {
|
Product2 prd = testNFM004Init();
|
prd.Intra_Trade_Cost_RMB_1__c = 1.78;
|
prd.Intra_Trade_Cost_RMB_Date1__c = date.newinstance(2012, 12, 1);
|
prd.Intra_Trade_Cost_RMB_End_Date1__c = date.newinstance(2912, 12, 03);
|
prd.Intra_Trade_Cost_RMB_2__c = 1.34;
|
prd.Intra_Trade_Cost_RMB_Date2__c = date.newinstance(2012, 11, 11);
|
prd.Intra_Trade_Cost_RMB_End_Date2__c = date.newinstance(2912, 11, 13);
|
prd.Intra_Trade_Cost_US__c = 101.12;
|
prd.Intra_Trade_Cost_US_Date__c = date.newinstance(1900, 1, 1);
|
prd.Intra_Trade_Cost_US_End_Date__c = date.newinstance(2912, 11, 23);
|
update prd;
|
|
NFM004WebService.PurchasePrice PurchasePrice = new NFM004WebService.PurchasePrice();
|
NFM004WebService.PurchasePrices PurchasePrices = new NFM004WebService.PurchasePrices();
|
|
// Monitoringの設定
|
Datetime nowDT = Datetime.now();
|
String nowStr = nowDT.format('yyyyMMddHHmm');
|
PurchasePrices.Monitoring = new NFMUtil.Monitoring();
|
|
// update USD 外貿 1回目
|
PurchasePrices.PurchasePrice = new NFM004WebService.PurchasePrice[] { PurchasePrice };
|
PurchasePrices.Monitoring.MessageGroupNumber = nowStr + '21';
|
PurchasePrice.SuppliersItemCode = 'testNFM004';
|
PurchasePrice.PriceType = 'OHC-001';
|
PurchasePrice.Currency_x = 'USD';
|
PurchasePrice.PurchasePrice = 201.21;
|
PurchasePrice.EffectiveDateFrom = '20121102';
|
PurchasePrice.EffectiveDateTo = '29121104';
|
PurchasePrice.PurposeOfAdvice = '3';
|
|
System.Test.startTest();
|
NFM004WebService.NFM004(PurchasePrices);
|
System.Test.stopTest();
|
|
List<Product2> rslts = [select Id, ProductCode, ProductCode_Ext__c,
|
Intra_Trade_Cost_RMB_1__c,
|
Intra_Trade_Cost_RMB_Date1__c,
|
Intra_Trade_Cost_RMB_End_Date1__c,
|
Intra_Trade_Cost_RMB_2__c,
|
Intra_Trade_Cost_RMB_Date2__c,
|
Intra_Trade_Cost_RMB_End_Date2__c,
|
Foreign_Trade_Cost_US_1__c,
|
Foreign_Trade_Cost_US_Date1__c,
|
Foreign_Trade_Cost_US_End_Date1__c,
|
Foreign_Trade_Cost_US_2__c,
|
Foreign_Trade_Cost_US_Date2__c,
|
Foreign_Trade_Cost_US_End_Date2__c,
|
Intra_Trade_Cost_US__c,
|
Intra_Trade_Cost_US_Date__c,
|
Intra_Trade_Cost_US_End_Date__c,
|
Foreign_Trade_Cost_RMB__c,
|
Foreign_Trade_Cost_RMB_Date__c,
|
Foreign_Trade_Cost_RMB_End_Date__c
|
from Product2
|
where ProductCode_Ext__c = :PurchasePrice.SuppliersItemCode];
|
System.assertEquals(1, rslts.size());
|
if (rslts.size() == 1) {
|
System.assertEquals('testNFM004', rslts[0].ProductCode);
|
System.assertEquals(1.78, rslts[0].Intra_Trade_Cost_RMB_1__c);
|
System.assertEquals(date.newinstance(2012, 12, 01), rslts[0].Intra_Trade_Cost_RMB_Date1__c);
|
System.assertEquals(date.newinstance(2912, 12, 03), rslts[0].Intra_Trade_Cost_RMB_End_Date1__c);
|
System.assertEquals(1.34, rslts[0].Intra_Trade_Cost_RMB_2__c);
|
System.assertEquals(date.newinstance(2012, 11, 11), rslts[0].Intra_Trade_Cost_RMB_Date2__c);
|
System.assertEquals(date.newinstance(2912, 11, 13), rslts[0].Intra_Trade_Cost_RMB_End_Date2__c);
|
System.assertEquals(201.21, rslts[0].Foreign_Trade_Cost_US_1__c);
|
System.assertEquals(date.newinstance(2012, 11, 02), rslts[0].Foreign_Trade_Cost_US_Date1__c);
|
System.assertEquals(date.newinstance(2912, 11, 04), rslts[0].Foreign_Trade_Cost_US_End_Date1__c);
|
System.assertEquals(null, rslts[0].Foreign_Trade_Cost_US_2__c);
|
System.assertEquals(null, rslts[0].Foreign_Trade_Cost_US_Date2__c);
|
System.assertEquals(null, rslts[0].Foreign_Trade_Cost_US_End_Date2__c);
|
System.assertEquals(101.12, rslts[0].Intra_Trade_Cost_US__c);
|
System.assertEquals(date.newinstance(1900, 1, 1), rslts[0].Intra_Trade_Cost_US_Date__c);
|
System.assertEquals(date.newinstance(2912, 11, 23), rslts[0].Intra_Trade_Cost_US_End_Date__c);
|
System.assertEquals(null, rslts[0].Foreign_Trade_Cost_RMB__c);
|
System.assertEquals(null, rslts[0].Foreign_Trade_Cost_RMB_Date__c);
|
System.assertEquals(null, rslts[0].Foreign_Trade_Cost_RMB_End_Date__c);
|
}
|
}
|
|
@isTest
|
static void testNFM004_update_USD_2() {
|
Product2 prd = testNFM004Init();
|
prd.Intra_Trade_Cost_RMB_1__c = 1.78;
|
prd.Intra_Trade_Cost_RMB_Date1__c = date.newinstance(2012, 12, 1);
|
prd.Intra_Trade_Cost_RMB_End_Date1__c = date.newinstance(2912, 12, 03);
|
prd.Intra_Trade_Cost_RMB_2__c = 1.34;
|
prd.Intra_Trade_Cost_RMB_Date2__c = date.newinstance(2012, 11, 11);
|
prd.Intra_Trade_Cost_RMB_End_Date2__c = date.newinstance(2912, 11, 13);
|
prd.Intra_Trade_Cost_US__c = 101.12;
|
prd.Intra_Trade_Cost_US_Date__c = date.newinstance(1900, 1, 1);
|
prd.Intra_Trade_Cost_US_End_Date__c = date.newinstance(2912, 11, 23);
|
prd.Foreign_Trade_Cost_US_1__c = 201.21;
|
prd.Foreign_Trade_Cost_US_Date1__c = date.newinstance(2012, 11, 2);
|
prd.Foreign_Trade_Cost_US_End_Date1__c = date.newinstance(2912, 11, 4);
|
update prd;
|
|
NFM004WebService.PurchasePrice PurchasePrice = new NFM004WebService.PurchasePrice();
|
NFM004WebService.PurchasePrices PurchasePrices = new NFM004WebService.PurchasePrices();
|
|
// Monitoringの設定
|
Datetime nowDT = Datetime.now();
|
String nowStr = nowDT.format('yyyyMMddHHmm');
|
PurchasePrices.Monitoring = new NFMUtil.Monitoring();
|
|
// update USD 外貿 2回目
|
PurchasePrices.PurchasePrice = new NFM004WebService.PurchasePrice[] { PurchasePrice };
|
PurchasePrices.Monitoring.MessageGroupNumber = nowStr + '22';
|
PurchasePrice.SuppliersItemCode = 'testNFM004';
|
PurchasePrice.PriceType = 'OHC-001';
|
PurchasePrice.Currency_x = 'USD';
|
PurchasePrice.PurchasePrice = 201.43;
|
PurchasePrice.EffectiveDateFrom = '20121112';
|
PurchasePrice.EffectiveDateTo = '29121114';
|
PurchasePrice.PurposeOfAdvice = '3';
|
|
System.Test.startTest();
|
NFM004WebService.NFM004(PurchasePrices);
|
System.Test.stopTest();
|
|
List<Product2> rslts = [select Id, ProductCode, ProductCode_Ext__c,
|
Intra_Trade_Cost_RMB_1__c,
|
Intra_Trade_Cost_RMB_Date1__c,
|
Intra_Trade_Cost_RMB_End_Date1__c,
|
Intra_Trade_Cost_RMB_2__c,
|
Intra_Trade_Cost_RMB_Date2__c,
|
Intra_Trade_Cost_RMB_End_Date2__c,
|
Foreign_Trade_Cost_US_1__c,
|
Foreign_Trade_Cost_US_Date1__c,
|
Foreign_Trade_Cost_US_End_Date1__c,
|
Foreign_Trade_Cost_US_2__c,
|
Foreign_Trade_Cost_US_Date2__c,
|
Foreign_Trade_Cost_US_End_Date2__c,
|
Intra_Trade_Cost_US__c,
|
Intra_Trade_Cost_US_Date__c,
|
Intra_Trade_Cost_US_End_Date__c,
|
Foreign_Trade_Cost_RMB__c,
|
Foreign_Trade_Cost_RMB_Date__c,
|
Foreign_Trade_Cost_RMB_End_Date__c
|
from Product2
|
where ProductCode_Ext__c = :PurchasePrice.SuppliersItemCode];
|
System.assertEquals(1, rslts.size());
|
if (rslts.size() == 1) {
|
System.assertEquals('testNFM004', rslts[0].ProductCode);
|
System.assertEquals(1.78, rslts[0].Intra_Trade_Cost_RMB_1__c);
|
System.assertEquals(date.newinstance(2012, 12, 01), rslts[0].Intra_Trade_Cost_RMB_Date1__c);
|
System.assertEquals(date.newinstance(2912, 12, 03), rslts[0].Intra_Trade_Cost_RMB_End_Date1__c);
|
System.assertEquals(1.34, rslts[0].Intra_Trade_Cost_RMB_2__c);
|
System.assertEquals(date.newinstance(2012, 11, 11), rslts[0].Intra_Trade_Cost_RMB_Date2__c);
|
System.assertEquals(date.newinstance(2912, 11, 13), rslts[0].Intra_Trade_Cost_RMB_End_Date2__c);
|
System.assertEquals(201.21, rslts[0].Foreign_Trade_Cost_US_1__c);
|
System.assertEquals(date.newinstance(2012, 11, 02), rslts[0].Foreign_Trade_Cost_US_Date1__c);
|
System.assertEquals(date.newinstance(2912, 11, 04), rslts[0].Foreign_Trade_Cost_US_End_Date1__c);
|
System.assertEquals(201.43, rslts[0].Foreign_Trade_Cost_US_2__c);
|
System.assertEquals(date.newinstance(2012, 11, 12), rslts[0].Foreign_Trade_Cost_US_Date2__c);
|
System.assertEquals(date.newinstance(2912, 11, 14), rslts[0].Foreign_Trade_Cost_US_End_Date2__c);
|
System.assertEquals(101.12, rslts[0].Intra_Trade_Cost_US__c);
|
System.assertEquals(date.newinstance(1900, 1, 1), rslts[0].Intra_Trade_Cost_US_Date__c);
|
System.assertEquals(date.newinstance(2912, 11, 23), rslts[0].Intra_Trade_Cost_US_End_Date__c);
|
System.assertEquals(null, rslts[0].Foreign_Trade_Cost_RMB__c);
|
System.assertEquals(null, rslts[0].Foreign_Trade_Cost_RMB_Date__c);
|
System.assertEquals(null, rslts[0].Foreign_Trade_Cost_RMB_End_Date__c);
|
}
|
}
|
|
@isTest
|
static void testNFM004_update_USD_3() {
|
Product2 prd = testNFM004Init();
|
prd.Intra_Trade_Cost_RMB_1__c = 1.78;
|
prd.Intra_Trade_Cost_RMB_Date1__c = date.newinstance(2012, 12, 1);
|
prd.Intra_Trade_Cost_RMB_End_Date1__c = date.newinstance(2912, 12, 03);
|
prd.Intra_Trade_Cost_RMB_2__c = 1.34;
|
prd.Intra_Trade_Cost_RMB_Date2__c = date.newinstance(2012, 11, 11);
|
prd.Intra_Trade_Cost_RMB_End_Date2__c = date.newinstance(2912, 11, 13);
|
prd.Intra_Trade_Cost_US__c = 101.12;
|
prd.Intra_Trade_Cost_US_Date__c = date.newinstance(1900, 1, 1);
|
prd.Intra_Trade_Cost_US_End_Date__c = date.newinstance(2912, 11, 23);
|
prd.Foreign_Trade_Cost_US_1__c = 201.21;
|
prd.Foreign_Trade_Cost_US_Date1__c = date.newinstance(2012, 11, 2);
|
prd.Foreign_Trade_Cost_US_End_Date1__c = date.newinstance(2912, 11, 4);
|
prd.Foreign_Trade_Cost_US_2__c = 201.43;
|
prd.Foreign_Trade_Cost_US_Date2__c = date.newinstance(2012, 11, 12);
|
prd.Foreign_Trade_Cost_US_End_Date2__c = date.newinstance(2912, 11, 14);
|
update prd;
|
|
NFM004WebService.PurchasePrice PurchasePrice = new NFM004WebService.PurchasePrice();
|
NFM004WebService.PurchasePrices PurchasePrices = new NFM004WebService.PurchasePrices();
|
|
// Monitoringの設定
|
Datetime nowDT = Datetime.now();
|
String nowStr = nowDT.format('yyyyMMddHHmm');
|
PurchasePrices.Monitoring = new NFMUtil.Monitoring();
|
|
// update USD 外貿 3回目
|
PurchasePrices.PurchasePrice = new NFM004WebService.PurchasePrice[] { PurchasePrice };
|
PurchasePrices.Monitoring.MessageGroupNumber = nowStr + '23';
|
PurchasePrice.SuppliersItemCode = 'testNFM004';
|
PurchasePrice.PriceType = 'OHC-001';
|
PurchasePrice.Currency_x = 'USD';
|
PurchasePrice.PurchasePrice = 201.65;
|
PurchasePrice.EffectiveDateFrom = '20121122';
|
PurchasePrice.EffectiveDateTo = '29121124';
|
PurchasePrice.PurposeOfAdvice = '3';
|
|
System.Test.startTest();
|
NFM004WebService.NFM004(PurchasePrices);
|
System.Test.stopTest();
|
|
List<Product2> rslts = [select Id, ProductCode, ProductCode_Ext__c,
|
Intra_Trade_Cost_RMB_1__c,
|
Intra_Trade_Cost_RMB_Date1__c,
|
Intra_Trade_Cost_RMB_End_Date1__c,
|
Intra_Trade_Cost_RMB_2__c,
|
Intra_Trade_Cost_RMB_Date2__c,
|
Intra_Trade_Cost_RMB_End_Date2__c,
|
Foreign_Trade_Cost_US_1__c,
|
Foreign_Trade_Cost_US_Date1__c,
|
Foreign_Trade_Cost_US_End_Date1__c,
|
Foreign_Trade_Cost_US_2__c,
|
Foreign_Trade_Cost_US_Date2__c,
|
Foreign_Trade_Cost_US_End_Date2__c,
|
Intra_Trade_Cost_US__c,
|
Intra_Trade_Cost_US_Date__c,
|
Intra_Trade_Cost_US_End_Date__c,
|
Foreign_Trade_Cost_RMB__c,
|
Foreign_Trade_Cost_RMB_Date__c,
|
Foreign_Trade_Cost_RMB_End_Date__c
|
from Product2
|
where ProductCode_Ext__c = :PurchasePrice.SuppliersItemCode];
|
System.assertEquals(1, rslts.size());
|
if (rslts.size() == 1) {
|
System.assertEquals('testNFM004', rslts[0].ProductCode);
|
System.assertEquals(1.78, rslts[0].Intra_Trade_Cost_RMB_1__c);
|
System.assertEquals(date.newinstance(2012, 12, 01), rslts[0].Intra_Trade_Cost_RMB_Date1__c);
|
System.assertEquals(date.newinstance(2912, 12, 03), rslts[0].Intra_Trade_Cost_RMB_End_Date1__c);
|
System.assertEquals(1.34, rslts[0].Intra_Trade_Cost_RMB_2__c);
|
System.assertEquals(date.newinstance(2012, 11, 11), rslts[0].Intra_Trade_Cost_RMB_Date2__c);
|
System.assertEquals(date.newinstance(2912, 11, 13), rslts[0].Intra_Trade_Cost_RMB_End_Date2__c);
|
System.assertEquals(201.65, rslts[0].Foreign_Trade_Cost_US_1__c);
|
System.assertEquals(date.newinstance(2012, 11, 22), rslts[0].Foreign_Trade_Cost_US_Date1__c);
|
System.assertEquals(date.newinstance(2912, 11, 24), rslts[0].Foreign_Trade_Cost_US_End_Date1__c);
|
System.assertEquals(201.43, rslts[0].Foreign_Trade_Cost_US_2__c);
|
System.assertEquals(date.newinstance(2012, 11, 12), rslts[0].Foreign_Trade_Cost_US_Date2__c);
|
System.assertEquals(date.newinstance(2912, 11, 14), rslts[0].Foreign_Trade_Cost_US_End_Date2__c);
|
System.assertEquals(101.12, rslts[0].Intra_Trade_Cost_US__c);
|
System.assertEquals(date.newinstance(1900, 1, 1), rslts[0].Intra_Trade_Cost_US_Date__c);
|
System.assertEquals(date.newinstance(2912, 11, 23), rslts[0].Intra_Trade_Cost_US_End_Date__c);
|
System.assertEquals(null, rslts[0].Foreign_Trade_Cost_RMB__c);
|
System.assertEquals(null, rslts[0].Foreign_Trade_Cost_RMB_Date__c);
|
System.assertEquals(null, rslts[0].Foreign_Trade_Cost_RMB_End_Date__c);
|
}
|
}
|
|
@isTest
|
static void testNFM004_update_USD_4() {
|
Product2 prd = testNFM004Init();
|
prd.Intra_Trade_Cost_RMB_1__c = 1.78;
|
prd.Intra_Trade_Cost_RMB_Date1__c = date.newinstance(2012, 12, 1);
|
prd.Intra_Trade_Cost_RMB_End_Date1__c = date.newinstance(2912, 12, 03);
|
prd.Intra_Trade_Cost_RMB_2__c = 1.34;
|
prd.Intra_Trade_Cost_RMB_Date2__c = date.newinstance(2012, 11, 11);
|
prd.Intra_Trade_Cost_RMB_End_Date2__c = date.newinstance(2912, 11, 13);
|
prd.Intra_Trade_Cost_US__c = 101.12;
|
prd.Intra_Trade_Cost_US_Date__c = date.newinstance(1900, 1, 1);
|
prd.Intra_Trade_Cost_US_End_Date__c = date.newinstance(2912, 11, 23);
|
prd.Foreign_Trade_Cost_US_1__c = 201.65;
|
prd.Foreign_Trade_Cost_US_Date1__c = date.newinstance(2012, 11, 22);
|
prd.Foreign_Trade_Cost_US_End_Date1__c = date.newinstance(2912, 11, 24);
|
prd.Foreign_Trade_Cost_US_2__c = 201.43;
|
prd.Foreign_Trade_Cost_US_Date2__c = date.newinstance(2012, 11, 12);
|
prd.Foreign_Trade_Cost_US_End_Date2__c = date.newinstance(2912, 11, 14);
|
update prd;
|
|
NFM004WebService.PurchasePrice PurchasePrice = new NFM004WebService.PurchasePrice();
|
NFM004WebService.PurchasePrice PurchasePrice2 = new NFM004WebService.PurchasePrice();
|
NFM004WebService.PurchasePrices PurchasePrices = new NFM004WebService.PurchasePrices();
|
|
// Monitoringの設定
|
Datetime nowDT = Datetime.now();
|
String nowStr = nowDT.format('yyyyMMddHHmm');
|
PurchasePrices.Monitoring = new NFMUtil.Monitoring();
|
|
// update USD 外貿 4回目
|
PurchasePrices.PurchasePrice = new NFM004WebService.PurchasePrice[] { PurchasePrice, PurchasePrice2 };
|
PurchasePrices.Monitoring.MessageGroupNumber = nowStr + '24';
|
PurchasePrice.SuppliersItemCode = 'testNFM004';
|
PurchasePrice.PriceType = 'OHC-001';
|
PurchasePrice.Currency_x = 'USD';
|
PurchasePrice.PurchasePrice = 201.87;
|
PurchasePrice.EffectiveDateFrom = '20121202';
|
PurchasePrice.EffectiveDateTo = '29121204';
|
PurchasePrice.PurposeOfAdvice = '3';
|
// update RMB 外貿
|
PurchasePrice2.SuppliersItemCode = 'testNFM004';
|
PurchasePrice2.PriceType = 'OHC-001';
|
PurchasePrice2.Currency_x = 'RMB';
|
PurchasePrice2.PurchasePrice = 222.12;
|
PurchasePrice2.EffectiveDateFrom = '20121212';
|
PurchasePrice2.EffectiveDateTo = '29121214';
|
PurchasePrice2.PurposeOfAdvice = '3';
|
|
System.Test.startTest();
|
NFM004WebService.NFM004(PurchasePrices);
|
System.Test.stopTest();
|
|
List<Product2> rslts = [select Id, ProductCode, ProductCode_Ext__c,
|
Intra_Trade_Cost_RMB_1__c,
|
Intra_Trade_Cost_RMB_Date1__c,
|
Intra_Trade_Cost_RMB_End_Date1__c,
|
Intra_Trade_Cost_RMB_2__c,
|
Intra_Trade_Cost_RMB_Date2__c,
|
Intra_Trade_Cost_RMB_End_Date2__c,
|
Foreign_Trade_Cost_US_1__c,
|
Foreign_Trade_Cost_US_Date1__c,
|
Foreign_Trade_Cost_US_End_Date1__c,
|
Foreign_Trade_Cost_US_2__c,
|
Foreign_Trade_Cost_US_Date2__c,
|
Foreign_Trade_Cost_US_End_Date2__c,
|
Intra_Trade_Cost_US__c,
|
Intra_Trade_Cost_US_Date__c,
|
Intra_Trade_Cost_US_End_Date__c,
|
Foreign_Trade_Cost_RMB__c,
|
Foreign_Trade_Cost_RMB_Date__c,
|
Foreign_Trade_Cost_RMB_End_Date__c
|
from Product2
|
where ProductCode_Ext__c = :PurchasePrice.SuppliersItemCode];
|
System.assertEquals(1, rslts.size());
|
if (rslts.size() == 1) {
|
System.assertEquals('testNFM004', rslts[0].ProductCode);
|
System.assertEquals(1.78, rslts[0].Intra_Trade_Cost_RMB_1__c);
|
System.assertEquals(date.newinstance(2012, 12, 01), rslts[0].Intra_Trade_Cost_RMB_Date1__c);
|
System.assertEquals(date.newinstance(2912, 12, 03), rslts[0].Intra_Trade_Cost_RMB_End_Date1__c);
|
System.assertEquals(1.34, rslts[0].Intra_Trade_Cost_RMB_2__c);
|
System.assertEquals(date.newinstance(2012, 11, 11), rslts[0].Intra_Trade_Cost_RMB_Date2__c);
|
System.assertEquals(date.newinstance(2912, 11, 13), rslts[0].Intra_Trade_Cost_RMB_End_Date2__c);
|
System.assertEquals(201.65, rslts[0].Foreign_Trade_Cost_US_1__c);
|
System.assertEquals(date.newinstance(2012, 11, 22), rslts[0].Foreign_Trade_Cost_US_Date1__c);
|
System.assertEquals(date.newinstance(2912, 11, 24), rslts[0].Foreign_Trade_Cost_US_End_Date1__c);
|
System.assertEquals(201.87, rslts[0].Foreign_Trade_Cost_US_2__c);
|
System.assertEquals(date.newinstance(2012, 12, 02), rslts[0].Foreign_Trade_Cost_US_Date2__c);
|
System.assertEquals(date.newinstance(2912, 12, 04), rslts[0].Foreign_Trade_Cost_US_End_Date2__c);
|
System.assertEquals(101.12, rslts[0].Intra_Trade_Cost_US__c);
|
System.assertEquals(date.newinstance(1900, 1, 1), rslts[0].Intra_Trade_Cost_US_Date__c);
|
System.assertEquals(date.newinstance(2912, 11, 23), rslts[0].Intra_Trade_Cost_US_End_Date__c);
|
System.assertEquals(222.12, rslts[0].Foreign_Trade_Cost_RMB__c);
|
System.assertEquals(date.newinstance(2012, 12, 12), rslts[0].Foreign_Trade_Cost_RMB_Date__c);
|
System.assertEquals(date.newinstance(2912, 12, 14), rslts[0].Foreign_Trade_Cost_RMB_End_Date__c);
|
}
|
}
|
|
@isTest
|
static void testNFM004_delete_1() {
|
Product2 prd = testNFM004Init();
|
prd.Intra_Trade_Cost_RMB_1__c = 1.78;
|
prd.Intra_Trade_Cost_RMB_Date1__c = date.newinstance(2012, 12, 1);
|
prd.Intra_Trade_Cost_RMB_End_Date1__c = date.newinstance(2912, 12, 03);
|
prd.Intra_Trade_Cost_RMB_2__c = 1.34;
|
prd.Intra_Trade_Cost_RMB_Date2__c = date.newinstance(2012, 11, 11);
|
prd.Intra_Trade_Cost_RMB_End_Date2__c = date.newinstance(2912, 11, 13);
|
prd.Intra_Trade_Cost_US__c = 101.12;
|
prd.Intra_Trade_Cost_US_Date__c = date.newinstance(1900, 1, 1);
|
prd.Intra_Trade_Cost_US_End_Date__c = date.newinstance(2912, 11, 23);
|
prd.Foreign_Trade_Cost_US_1__c = 201.65;
|
prd.Foreign_Trade_Cost_US_Date1__c = date.newinstance(2012, 11, 22);
|
prd.Foreign_Trade_Cost_US_End_Date1__c = date.newinstance(2912, 11, 24);
|
prd.Foreign_Trade_Cost_US_2__c = 201.87;
|
prd.Foreign_Trade_Cost_US_Date2__c = date.newinstance(2012, 12, 2);
|
prd.Foreign_Trade_Cost_US_End_Date2__c = date.newinstance(2912, 12, 4);
|
prd.Foreign_Trade_Cost_RMB__c = 222.12;
|
prd.Foreign_Trade_Cost_RMB_Date__c = date.newinstance(2012, 12, 12);
|
prd.Foreign_Trade_Cost_RMB_End_Date__c = date.newinstance(2912, 12, 14);
|
update prd;
|
|
NFM004WebService.PurchasePrice PurchasePrice = new NFM004WebService.PurchasePrice();
|
NFM004WebService.PurchasePrices PurchasePrices = new NFM004WebService.PurchasePrices();
|
|
// Monitoringの設定
|
Datetime nowDT = Datetime.now();
|
String nowStr = nowDT.format('yyyyMMddHHmm');
|
PurchasePrices.Monitoring = new NFMUtil.Monitoring();
|
|
// 削除、2世代目の金額
|
PurchasePrices.PurchasePrice = new NFM004WebService.PurchasePrice[] { PurchasePrice };
|
PurchasePrices.Monitoring.MessageGroupNumber = nowStr + '31';
|
PurchasePrice.SuppliersItemCode = 'testNFM004';
|
PurchasePrice.PriceType = 'OHC-001';
|
PurchasePrice.Currency_x = 'USD';
|
PurchasePrice.PurchasePrice = 201.87;
|
PurchasePrice.EffectiveDateFrom = '20121202';
|
PurchasePrice.EffectiveDateTo = '29121204';
|
PurchasePrice.PurposeOfAdvice = '1';
|
|
System.Test.startTest();
|
NFM004WebService.NFM004(PurchasePrices);
|
System.Test.stopTest();
|
|
List<Product2> rslts = [select Id, ProductCode, ProductCode_Ext__c,
|
Intra_Trade_Cost_RMB_1__c,
|
Intra_Trade_Cost_RMB_Date1__c,
|
Intra_Trade_Cost_RMB_End_Date1__c,
|
Intra_Trade_Cost_RMB_2__c,
|
Intra_Trade_Cost_RMB_Date2__c,
|
Intra_Trade_Cost_RMB_End_Date2__c,
|
Foreign_Trade_Cost_US_1__c,
|
Foreign_Trade_Cost_US_Date1__c,
|
Foreign_Trade_Cost_US_End_Date1__c,
|
Foreign_Trade_Cost_US_2__c,
|
Foreign_Trade_Cost_US_Date2__c,
|
Foreign_Trade_Cost_US_End_Date2__c,
|
Intra_Trade_Cost_US__c,
|
Intra_Trade_Cost_US_Date__c,
|
Intra_Trade_Cost_US_End_Date__c,
|
Foreign_Trade_Cost_RMB__c,
|
Foreign_Trade_Cost_RMB_Date__c,
|
Foreign_Trade_Cost_RMB_End_Date__c
|
from Product2
|
where ProductCode_Ext__c = :PurchasePrice.SuppliersItemCode];
|
// deleteの場合、EffectiveDateTo が前日
|
System.assertEquals(1, rslts.size());
|
System.assertEquals(Date.today().addDays(-1), rslts[0].Foreign_Trade_Cost_US_End_Date2__c);
|
}
|
|
@isTest
|
static void testNFM004_delete_2() {
|
Product2 prd = testNFM004Init();
|
prd.Intra_Trade_Cost_RMB_1__c = 1.78;
|
prd.Intra_Trade_Cost_RMB_Date1__c = date.newinstance(2012, 12, 1);
|
prd.Intra_Trade_Cost_RMB_End_Date1__c = date.newinstance(2912, 12, 03);
|
prd.Intra_Trade_Cost_RMB_2__c = 1.34;
|
prd.Intra_Trade_Cost_RMB_Date2__c = date.newinstance(2012, 11, 11);
|
prd.Intra_Trade_Cost_RMB_End_Date2__c = date.newinstance(2912, 11, 13);
|
prd.Intra_Trade_Cost_US__c = 101.12;
|
prd.Intra_Trade_Cost_US_Date__c = date.newinstance(1900, 1, 1);
|
prd.Intra_Trade_Cost_US_End_Date__c = date.newinstance(2912, 11, 23);
|
prd.Foreign_Trade_Cost_US_1__c = 201.65;
|
prd.Foreign_Trade_Cost_US_Date1__c = date.newinstance(2012, 11, 22);
|
prd.Foreign_Trade_Cost_US_End_Date1__c = date.newinstance(2912, 11, 24);
|
prd.Foreign_Trade_Cost_US_2__c = 201.87;
|
prd.Foreign_Trade_Cost_US_Date2__c = date.newinstance(2012, 12, 2);
|
prd.Foreign_Trade_Cost_US_End_Date2__c = Date.today().addDays(-1);
|
prd.Foreign_Trade_Cost_RMB__c = 222.12;
|
prd.Foreign_Trade_Cost_RMB_Date__c = date.newinstance(2012, 12, 12);
|
prd.Foreign_Trade_Cost_RMB_End_Date__c = date.newinstance(2912, 12, 14);
|
update prd;
|
|
NFM004WebService.PurchasePrice PurchasePrice = new NFM004WebService.PurchasePrice();
|
NFM004WebService.PurchasePrices PurchasePrices = new NFM004WebService.PurchasePrices();
|
|
// Monitoringの設定
|
Datetime nowDT = Datetime.now();
|
String nowStr = nowDT.format('yyyyMMddHHmm');
|
PurchasePrices.Monitoring = new NFMUtil.Monitoring();
|
|
|
// 料金更新、2世代目に反映
|
PurchasePrices.PurchasePrice = new NFM004WebService.PurchasePrice[] { PurchasePrice };
|
PurchasePrices.Monitoring.MessageGroupNumber = nowStr + '32';
|
PurchasePrice.SuppliersItemCode = 'testNFM004';
|
PurchasePrice.PriceType = 'OHC-001';
|
PurchasePrice.Currency_x = 'USD';
|
PurchasePrice.PurchasePrice = 201.87;
|
PurchasePrice.EffectiveDateFrom = '20121201';
|
PurchasePrice.EffectiveDateTo = '29121204';
|
PurchasePrice.PurposeOfAdvice = '2';
|
|
System.Test.startTest();
|
NFM004WebService.NFM004(PurchasePrices);
|
System.Test.stopTest();
|
|
List<Product2> rslts = [select Id, ProductCode, ProductCode_Ext__c,
|
Intra_Trade_Cost_RMB_1__c,
|
Intra_Trade_Cost_RMB_Date1__c,
|
Intra_Trade_Cost_RMB_End_Date1__c,
|
Intra_Trade_Cost_RMB_2__c,
|
Intra_Trade_Cost_RMB_Date2__c,
|
Intra_Trade_Cost_RMB_End_Date2__c,
|
Foreign_Trade_Cost_US_1__c,
|
Foreign_Trade_Cost_US_Date1__c,
|
Foreign_Trade_Cost_US_End_Date1__c,
|
Foreign_Trade_Cost_US_2__c,
|
Foreign_Trade_Cost_US_Date2__c,
|
Foreign_Trade_Cost_US_End_Date2__c,
|
Intra_Trade_Cost_US__c,
|
Intra_Trade_Cost_US_Date__c,
|
Intra_Trade_Cost_US_End_Date__c,
|
Foreign_Trade_Cost_RMB__c,
|
Foreign_Trade_Cost_RMB_Date__c,
|
Foreign_Trade_Cost_RMB_End_Date__c
|
from Product2
|
where ProductCode_Ext__c = :PurchasePrice.SuppliersItemCode];
|
// deleteの場合、EffectiveDateTo が前日
|
System.assertEquals(1, rslts.size());
|
System.assertEquals(201.87, rslts[0].Foreign_Trade_Cost_US_2__c);
|
System.assertEquals(date.newinstance(2012, 12, 01), rslts[0].Foreign_Trade_Cost_US_Date2__c);
|
System.assertEquals(date.newinstance(2912, 12, 04), rslts[0].Foreign_Trade_Cost_US_End_Date2__c);
|
}
|
}
|