@isTest
|
private class SBG004WebServiceTest {
|
static Product2 testSBG004Init() {
|
// テストデータ
|
Product2 prd = new Product2();
|
prd.Product_ECCode__c = 'testSBG004';
|
prd.ProductCode = 'testSBG004';
|
prd.Name = 'testSBG004';
|
prd.IsActive = true;
|
insert prd;
|
//Pricebook2 prdbook = new Pricebook2();
|
|
Pricebook2 prdbook1 = new Pricebook2(
|
Name = 'testSBG004',
|
ProductSegment__c = 'BS',
|
TradeType__c = 'Taxation',
|
SalesChannel__c = 'dealer',
|
MachineParts__c = 'Machine',
|
isActive = true);
|
|
insert prdbook1;
|
Pricebook2 prdbook2 = new Pricebook2(
|
Name = 'testSBG004',
|
ProductSegment__c = 'BS',
|
TradeType__c = 'Taxation',
|
SalesChannel__c = 'direct',
|
MachineParts__c = 'Machine',
|
isActive = true);
|
|
insert prdbook2;
|
|
PricebookEntry pbe = new PricebookEntry();
|
pbe.Pricebook2Id = ControllerUtil.getStandardPricebook().Id;
|
pbe.Product2Id = prd.Id;
|
pbe.UnitPrice = 0;
|
pbe.CurrencyIsoCode = 'CNY';
|
pbe.IsActive = true;
|
insert pbe;
|
PricebookEntry pbe1 = new PricebookEntry();
|
pbe1.Pricebook2Id = ControllerUtil.getStandardPricebook().Id;
|
pbe1.Product2Id = prd.Id;
|
pbe1.UnitPrice = 0;
|
pbe1.CurrencyIsoCode = 'USD';
|
pbe1.IsActive = true;
|
insert pbe1;
|
|
return prd;
|
|
}
|
|
|
@isTest
|
static void testSBG004_void() {
|
testSBG004Init();
|
// null
|
SBG004WebService.SBG004(null);
|
|
SBG004WebService.GeData GeData = new SBG004WebService.GeData();
|
SBG004WebService.GeDatas GeDatas = new SBG004WebService.GeDatas();
|
GeDatas.GeData = new SBG004WebService.GeData[] { GeData };
|
// Monitoringをセットしない
|
SBG004WebService.SBG004(GeDatas);
|
|
Datetime nowDT = Datetime.now();
|
String nowStr = nowDT.format('yyyyMMddHHmm');
|
GeDatas.Monitoring = new NFMUtil.Monitoring();
|
GeDatas.Monitoring.MessageGroupNumber = nowStr + '01';
|
// 必須項目をセットしない
|
SBG004WebService.SBG004(GeDatas);
|
|
// 商品コードが存在しない
|
GeDatas.Monitoring.MessageGroupNumber = nowStr + '02';
|
GeData.ProductCode = 'testSBG004X';
|
|
System.Test.startTest();
|
SBG004WebService.SBG004(GeDatas);
|
System.Test.stopTest();
|
|
Product2[] rslts = [select Id from Product2 where Product_ECCode__c = :GeData.ProductCode];
|
System.assertEquals(0, rslts.size());
|
}
|
|
|
|
|
|
|
|
@isTest
|
static void testSBG004_update() {
|
Product2 prd = testSBG004Init();
|
prd.EffectiveDateTo__c = date.newinstance(2012, 12, 1);
|
update prd;
|
|
SBG004WebService.GeData GeData = new SBG004WebService.GeData();
|
SBG004WebService.GeDatas GeDatas = new SBG004WebService.GeDatas();
|
|
// Monitoringの設定
|
Datetime nowDT = Datetime.now();
|
String nowStr = nowDT.format('yyyyMMddHHmm');
|
GeDatas.Monitoring = new NFMUtil.Monitoring();
|
|
|
GeDatas.GeData = new SBG004WebService.GeData[] { GeData };
|
GeDatas.Monitoring.MessageGroupNumber = nowStr + '32';
|
GeData.ProductCode = 'testSBG004';
|
GeData.Currency_x = 'USD';
|
GeData.EffectiveDateFrom = '20121201';
|
GeData.EffectiveDateTo = '29121204';
|
GeData.PurposeOfAdvice = '2';
|
GeData.ProductSegment = 'BS';
|
GeData.MachineParts = 'Machine';
|
GeData.SalesChannel = '99';
|
GeData.TradeType = 'Taxation';
|
GeData.CostPrice = 100;
|
System.Test.startTest();
|
SBG004WebService.SBG004(GeDatas);
|
System.Test.stopTest();
|
|
List<Product2> rslts = [select Id, ProductCode, Product_ECCode__c,
|
EffectiveDateTo__c,
|
ProductModels__c,
|
ProductStatus__c
|
from Product2
|
where Product_ECCode__c = :GeData.ProductCode];
|
// deleteの場合、EffectiveDateTo が前日
|
System.assertEquals(1, rslts.size());
|
System.assertEquals(date.newinstance(2012, 12, 01), rslts[0].EffectiveDateTo__c);
|
|
List<BatchIF_Log__c> log = [Select ErrorLog__c,Id,Name,MessageGroupNumber__c,Log__c From BatchIF_Log__c];
|
System.debug(log);
|
|
List<PricebookEntry> pres = [Select Id,Name,KEY__c,EffectiveDateFrom1__c,EffectiveDateFrom2__c,
|
EffectiveDateTo1__c,EffectiveDateTo2__c,CostPrice1__c,CostPrice2__c,SalesPrice1__c,SalesPrice2__c
|
from PricebookEntry Where KEY__c = 'BS_Taxation_direct_Machine_testSBG004_USD' OR KEY__c = 'BS_Taxation_dealer_Machine_testSBG004_USD'];
|
System.debug(pres.size());
|
System.assertEquals(2, pres.size());
|
}
|
|
@isTest
|
static void testSBG004_delete() {
|
Product2 prd = testSBG004Init();
|
prd.EffectiveDateTo__c = date.newinstance(2012, 12, 1);
|
update prd;
|
|
SBG004WebService.GeData GeData = new SBG004WebService.GeData();
|
SBG004WebService.GeDatas GeDatas = new SBG004WebService.GeDatas();
|
|
// Monitoringの設定
|
Datetime nowDT = Datetime.now();
|
String nowStr = nowDT.format('yyyyMMddHHmm');
|
GeDatas.Monitoring = new NFMUtil.Monitoring();
|
|
|
GeDatas.GeData = new SBG004WebService.GeData[] { GeData };
|
GeDatas.Monitoring.MessageGroupNumber = nowStr + '32';
|
GeData.ProductCode = 'testSBG004';
|
GeData.Currency_x = 'USD';
|
GeData.EffectiveDateFrom = '20121201';
|
GeData.EffectiveDateTo = '29121204';
|
GeData.PurposeOfAdvice = '2';
|
GeData.ProductSegment = 'BS';
|
GeData.MachineParts = 'Machine';
|
GeData.SalesChannel = 'direct';
|
GeData.TradeType = 'Taxation';
|
GeData.CostPrice = 100;
|
GeData.Currency_x = 'RMB';
|
|
|
|
System.Test.startTest();
|
SBG004WebService.SBG004(GeDatas);
|
System.Test.stopTest();
|
|
|
List<BatchIF_Log__c> log = [Select ErrorLog__c,Id,Name,MessageGroupNumber__c,Log__c From BatchIF_Log__c];
|
System.debug(log);
|
|
List<Product2> rslts = [select Id, ProductCode, Product_ECCode__c,
|
EffectiveDateTo__c,
|
ProductModels__c,
|
ProductStatus__c
|
from Product2
|
where Product_ECCode__c = :GeData.ProductCode];
|
// deleteの場合、EffectiveDateTo が前日
|
System.assertEquals(1, rslts.size());
|
System.assertEquals(date.newinstance(2012, 12, 01), rslts[0].EffectiveDateTo__c);
|
String key1 = GeData.ProductSegment + '_' + GeData.TradeType + '_' + GeData.SalesChannel + '_' + GeData.MachineParts + '_' + GeData.ProductCode;
|
List<PricebookEntry> pres1 = [Select Id,Name,KEY__c from PricebookEntry ];
|
System.debug(pres1);
|
|
|
List<PricebookEntry> pres = [Select Id,Name,Pricebook2Id,Product2Id,KEY__c,EffectiveDateFrom1__c,EffectiveDateFrom2__c,
|
EffectiveDateTo1__c,EffectiveDateTo2__c,CostPrice1__c,CostPrice2__c,SalesPrice1__c,SalesPrice2__c
|
from PricebookEntry Where KEY__c = 'BS_Taxation_direct_Machine_testSBG004_RMB'];
|
List<Pricebook2> pr = [Select Id,Name,ProductSegment__c,TradeType__c,SalesChannel__c,MachineParts__c
|
from Pricebook2 Where Id = :pres[0].Pricebook2Id];
|
System.debug(pres.size());
|
System.debug(pr);
|
System.assertEquals(1, pres.size());
|
System.debug(pres[0].KEY__c);
|
System.assertEquals(pres[0].KEY__c,'BS_Taxation_direct_Machine_testSBG004_RMB');
|
System.assertEquals(pr[0].ProductSegment__c,'BS');
|
System.assertEquals(pr[0].TradeType__c,'Taxation');
|
System.assertEquals(pr[0].SalesChannel__c,'direct');
|
System.assertEquals(pr[0].MachineParts__c,'Machine');
|
|
|
}
|
|
|
|
@isTest
|
static void testSBG004_delete0() {
|
Product2 prd = testSBG004Init();
|
prd.EffectiveDateTo__c = date.newinstance(2012, 12, 1);
|
update prd;
|
|
SBG004WebService.GeData GeData = new SBG004WebService.GeData();
|
SBG004WebService.GeDatas GeDatas = new SBG004WebService.GeDatas();
|
|
// Monitoringの設定
|
Datetime nowDT = Datetime.now();
|
String nowStr = nowDT.format('yyyyMMddHHmm');
|
GeDatas.Monitoring = new NFMUtil.Monitoring();
|
|
|
GeDatas.GeData = new SBG004WebService.GeData[] { GeData };
|
GeDatas.Monitoring.MessageGroupNumber = nowStr + '32';
|
GeData.ProductCode = 'testSBG004';
|
GeData.Currency_x = 'USD';
|
GeData.EffectiveDateFrom = '20131203';
|
GeData.EffectiveDateTo = '20191204';
|
GeData.PurposeOfAdvice = '2';
|
GeData.ProductSegment = 'BS';
|
GeData.MachineParts = 'Machine';
|
GeData.SalesChannel = 'direct';
|
GeData.TradeType = 'Taxation';
|
GeData.CostPrice = 100;
|
|
|
|
|
List<Product2> rslts1 = [select Id, ProductCode, Product_ECCode__c,
|
EffectiveDateTo__c,
|
ProductModels__c,
|
ProductStatus__c
|
from Product2];
|
System.debug(rslts1);
|
|
|
|
|
Pricebook2 p2 = [Select Id,Name From Pricebook2 Where SalesChannel__c = 'direct'];
|
PricebookEntry pbe = new PricebookEntry();
|
pbe.Pricebook2Id = p2.Id;
|
pbe.Product2Id = rslts1[0].Id;
|
pbe.UnitPrice = 0;
|
pbe.CurrencyIsoCode = 'CNY';
|
pbe.IsActive = true;
|
pbe.KEY__c = 'BS_Taxation_direct_Machine_testSBG004_USD';
|
pbe.UseStandardPrice = false;
|
|
|
|
|
|
|
insert pbe;
|
|
|
|
System.Test.startTest();
|
SBG004WebService.SBG004(GeDatas);
|
//GeData.Currency_x = 'RMB';
|
//SBG004WebService.SBG004(GeDatas);
|
//GeData.EffectiveDateFrom = '20131202';
|
//GeData.EffectiveDateTo = '20131202';
|
//SBG004WebService.SBG004(GeDatas);
|
//GeData.EffectiveDateFrom = '20141203';
|
//GeData.EffectiveDateTo = '29121204';
|
//SBG004WebService.SBG004(GeDatas);
|
|
System.Test.stopTest();
|
|
|
List<BatchIF_Log__c> log = [Select ErrorLog__c,Id,Name,MessageGroupNumber__c,Log__c From BatchIF_Log__c];
|
System.debug(log);
|
|
List<Product2> rslts = [select Id, ProductCode, Product_ECCode__c,
|
EffectiveDateTo__c,
|
ProductModels__c,
|
ProductStatus__c
|
from Product2
|
where Product_ECCode__c = :GeData.ProductCode];
|
// deleteの場合、EffectiveDateTo が前日
|
System.assertEquals(1, rslts.size());
|
System.assertEquals(date.newinstance(2012, 12, 01), rslts[0].EffectiveDateTo__c);
|
String key1 = GeData.ProductSegment + '_' + GeData.TradeType + '_' + GeData.SalesChannel + '_' + GeData.MachineParts + '_' + GeData.ProductCode;
|
System.debug(key1);
|
|
|
List<PricebookEntry> pres = [Select Id,Name,Pricebook2Id,Product2Id,KEY__c,EffectiveDateFrom1__c,EffectiveDateFrom2__c,
|
EffectiveDateTo1__c,EffectiveDateTo2__c,CostPrice1__c,CostPrice2__c,SalesPrice1__c,SalesPrice2__c
|
from PricebookEntry Where KEY__c = 'BS_Taxation_direct_Machine_testSBG004_USD'];
|
List<Pricebook2> pr = [Select Id,Name,ProductSegment__c,TradeType__c,SalesChannel__c,MachineParts__c
|
from Pricebook2 Where Id = :pres[0].Pricebook2Id];
|
System.debug(pres.size());
|
System.debug(pr);
|
System.assertEquals(1, pres.size());
|
System.debug(pres[0].KEY__c);
|
System.assertEquals(pres[0].KEY__c,'BS_Taxation_direct_Machine_testSBG004_USD');
|
System.assertEquals(pr[0].ProductSegment__c,'BS');
|
System.assertEquals(pr[0].TradeType__c,'Taxation');
|
System.assertEquals(pr[0].SalesChannel__c,'direct');
|
System.assertEquals(pr[0].MachineParts__c,'Machine');
|
|
|
}
|
|
|
@isTest
|
static void testSBG004_delete1() {
|
Product2 prd = testSBG004Init();
|
prd.EffectiveDateTo__c = date.newinstance(2012, 12, 1);
|
update prd;
|
|
SBG004WebService.GeData GeData = new SBG004WebService.GeData();
|
SBG004WebService.GeDatas GeDatas = new SBG004WebService.GeDatas();
|
|
// Monitoringの設定
|
Datetime nowDT = Datetime.now();
|
String nowStr = nowDT.format('yyyyMMddHHmm');
|
GeDatas.Monitoring = new NFMUtil.Monitoring();
|
|
|
GeDatas.GeData = new SBG004WebService.GeData[] { GeData };
|
GeDatas.Monitoring.MessageGroupNumber = nowStr + '32';
|
GeData.ProductCode = 'testSBG004';
|
GeData.Currency_x = 'USD';
|
GeData.EffectiveDateFrom = '20131203';
|
GeData.EffectiveDateTo = '20191204';
|
GeData.PurposeOfAdvice = '2';
|
GeData.ProductSegment = 'BS';
|
GeData.MachineParts = 'Machine';
|
GeData.SalesChannel = 'direct';
|
GeData.TradeType = 'Taxation';
|
GeData.CostPrice = 100;
|
|
|
|
|
List<Product2> rslts1 = [select Id, ProductCode, Product_ECCode__c,
|
EffectiveDateTo__c,
|
ProductModels__c,
|
ProductStatus__c
|
from Product2];
|
System.debug(rslts1);
|
|
|
|
|
Pricebook2 p2 = [Select Id,Name From Pricebook2 Where SalesChannel__c = 'direct'];
|
PricebookEntry pbe = new PricebookEntry();
|
pbe.Pricebook2Id = p2.Id;
|
pbe.Product2Id = rslts1[0].Id;
|
pbe.UnitPrice = 0;
|
pbe.CurrencyIsoCode = 'CNY';
|
pbe.IsActive = true;
|
pbe.KEY__c = 'BS_Taxation_direct_Machine_testSBG004_USD';
|
Date dateFrom = NFMUtil.parseStr2Date('20131201', false);
|
Date dateTo = NFMUtil.parseStr2Date('20191204', true);
|
Date dateFrom2 = NFMUtil.parseStr2Date('20131202', false);
|
Date dateTo2 = NFMUtil.parseStr2Date('20191204', true);
|
pbe.EffectiveDateFrom1__c = dateFrom;
|
pbe.EffectiveDateTo1__c = dateTo;
|
pbe.EffectiveDateFrom2__c = dateFrom2;
|
pbe.EffectiveDateTo2__c = dateTo2;
|
pbe.UseStandardPrice = false;
|
|
|
|
|
|
|
insert pbe;
|
|
|
|
System.Test.startTest();
|
SBG004WebService.SBG004(GeDatas);
|
//GeData.Currency_x = 'RMB';
|
//SBG004WebService.SBG004(GeDatas);
|
//GeData.EffectiveDateFrom = '20131202';
|
//GeData.EffectiveDateTo = '20131202';
|
//SBG004WebService.SBG004(GeDatas);
|
//GeData.EffectiveDateFrom = '20141203';
|
//GeData.EffectiveDateTo = '29121204';
|
//SBG004WebService.SBG004(GeDatas);
|
|
System.Test.stopTest();
|
|
|
List<BatchIF_Log__c> log = [Select ErrorLog__c,Id,Name,MessageGroupNumber__c,Log__c From BatchIF_Log__c];
|
System.debug(log);
|
|
List<Product2> rslts = [select Id, ProductCode, Product_ECCode__c,
|
EffectiveDateTo__c,
|
ProductModels__c,
|
ProductStatus__c
|
from Product2
|
where Product_ECCode__c = :GeData.ProductCode];
|
// deleteの場合、EffectiveDateTo が前日
|
System.assertEquals(1, rslts.size());
|
System.assertEquals(date.newinstance(2012, 12, 01), rslts[0].EffectiveDateTo__c);
|
String key1 = GeData.ProductSegment + '_' + GeData.TradeType + '_' + GeData.SalesChannel + '_' + GeData.MachineParts + '_' + GeData.ProductCode;
|
System.debug(key1);
|
|
|
List<PricebookEntry> pres = [Select Id,Name,Pricebook2Id,Product2Id,KEY__c,EffectiveDateFrom1__c,EffectiveDateFrom2__c,
|
EffectiveDateTo1__c,EffectiveDateTo2__c,CostPrice1__c,CostPrice2__c,SalesPrice1__c,SalesPrice2__c
|
from PricebookEntry Where KEY__c = 'BS_Taxation_direct_Machine_testSBG004_USD'];
|
List<Pricebook2> pr = [Select Id,Name,ProductSegment__c,TradeType__c,SalesChannel__c,MachineParts__c
|
from Pricebook2 Where Id = :pres[0].Pricebook2Id];
|
System.debug(pres.size());
|
System.debug(pr);
|
System.assertEquals(1, pres.size());
|
System.debug(pres[0].KEY__c);
|
System.assertEquals(pres[0].KEY__c,'BS_Taxation_direct_Machine_testSBG004_USD');
|
System.assertEquals(pr[0].ProductSegment__c,'BS');
|
System.assertEquals(pr[0].TradeType__c,'Taxation');
|
System.assertEquals(pr[0].SalesChannel__c,'direct');
|
System.assertEquals(pr[0].MachineParts__c,'Machine');
|
|
|
}
|
|
|
@isTest
|
static void testSBG004_delete2() {
|
Product2 prd = testSBG004Init();
|
prd.EffectiveDateTo__c = date.newinstance(2012, 12, 1);
|
update prd;
|
|
SBG004WebService.GeData GeData = new SBG004WebService.GeData();
|
SBG004WebService.GeDatas GeDatas = new SBG004WebService.GeDatas();
|
|
// Monitoringの設定
|
Datetime nowDT = Datetime.now();
|
String nowStr = nowDT.format('yyyyMMddHHmm');
|
GeDatas.Monitoring = new NFMUtil.Monitoring();
|
|
|
GeDatas.GeData = new SBG004WebService.GeData[] { GeData };
|
GeDatas.Monitoring.MessageGroupNumber = nowStr + '32';
|
GeData.ProductCode = 'testSBG004';
|
GeData.Currency_x = 'USD';
|
GeData.EffectiveDateFrom = '20131202';
|
GeData.EffectiveDateTo = '20191204';
|
GeData.PurposeOfAdvice = '2';
|
GeData.ProductSegment = 'BS';
|
GeData.MachineParts = 'Machine';
|
GeData.SalesChannel = 'direct';
|
GeData.TradeType = 'Taxation';
|
GeData.CostPrice = 100;
|
|
|
|
|
List<Product2> rslts1 = [select Id, ProductCode, Product_ECCode__c,
|
EffectiveDateTo__c,
|
ProductModels__c,
|
ProductStatus__c
|
from Product2];
|
System.debug(rslts1);
|
|
|
|
|
Pricebook2 p2 = [Select Id,Name From Pricebook2 Where SalesChannel__c = 'direct'];
|
PricebookEntry pbe = new PricebookEntry();
|
pbe.Pricebook2Id = p2.Id;
|
pbe.Product2Id = rslts1[0].Id;
|
pbe.UnitPrice = 0;
|
pbe.CurrencyIsoCode = 'CNY';
|
pbe.IsActive = true;
|
pbe.KEY__c = 'BS_Taxation_direct_Machine_testSBG004_USD';
|
Date dateFrom = NFMUtil.parseStr2Date('20131201', false);
|
Date dateTo = NFMUtil.parseStr2Date('20191204', true);
|
pbe.EffectiveDateFrom1__c = dateFrom;
|
pbe.EffectiveDateTo1__c = dateTo;
|
pbe.UseStandardPrice = false;
|
|
|
|
|
|
|
insert pbe;
|
|
|
|
System.Test.startTest();
|
SBG004WebService.SBG004(GeDatas);
|
//GeData.Currency_x = 'RMB';
|
//SBG004WebService.SBG004(GeDatas);
|
//GeData.EffectiveDateFrom = '20131202';
|
//GeData.EffectiveDateTo = '20131202';
|
//SBG004WebService.SBG004(GeDatas);
|
//GeData.EffectiveDateFrom = '20141203';
|
//GeData.EffectiveDateTo = '29121204';
|
//SBG004WebService.SBG004(GeDatas);
|
|
System.Test.stopTest();
|
|
|
List<BatchIF_Log__c> log = [Select ErrorLog__c,Id,Name,MessageGroupNumber__c,Log__c From BatchIF_Log__c];
|
System.debug(log);
|
|
List<Product2> rslts = [select Id, ProductCode, Product_ECCode__c,
|
EffectiveDateTo__c,
|
ProductModels__c,
|
ProductStatus__c
|
from Product2
|
where Product_ECCode__c = :GeData.ProductCode];
|
// deleteの場合、EffectiveDateTo が前日
|
System.assertEquals(1, rslts.size());
|
System.assertEquals(date.newinstance(2012, 12, 01), rslts[0].EffectiveDateTo__c);
|
String key1 = GeData.ProductSegment + '_' + GeData.TradeType + '_' + GeData.SalesChannel + '_' + GeData.MachineParts + '_' + GeData.ProductCode;
|
System.debug(key1);
|
|
|
List<PricebookEntry> pres = [Select Id,Name,Pricebook2Id,Product2Id,KEY__c,EffectiveDateFrom1__c,EffectiveDateFrom2__c,
|
EffectiveDateTo1__c,EffectiveDateTo2__c,CostPrice1__c,CostPrice2__c,SalesPrice1__c,SalesPrice2__c
|
from PricebookEntry Where KEY__c = 'BS_Taxation_direct_Machine_testSBG004_USD'];
|
List<Pricebook2> pr = [Select Id,Name,ProductSegment__c,TradeType__c,SalesChannel__c,MachineParts__c
|
from Pricebook2 Where Id = :pres[0].Pricebook2Id];
|
System.debug(pres.size());
|
System.debug(pr);
|
System.assertEquals(1, pres.size());
|
System.debug(pres[0].KEY__c);
|
System.assertEquals(pres[0].KEY__c,'BS_Taxation_direct_Machine_testSBG004_USD');
|
System.assertEquals(pr[0].ProductSegment__c,'BS');
|
System.assertEquals(pr[0].TradeType__c,'Taxation');
|
System.assertEquals(pr[0].SalesChannel__c,'direct');
|
System.assertEquals(pr[0].MachineParts__c,'Machine');
|
|
|
}
|
|
@isTest
|
static void testSBG004_resend() {
|
Product2 prd = testSBG004Init();
|
prd.EffectiveDateTo__c = date.newinstance(2012, 12, 1);
|
update prd;
|
|
SBG004WebService.GeData GeData = new SBG004WebService.GeData();
|
SBG004WebService.GeDatas GeDatas = new SBG004WebService.GeDatas();
|
|
// Monitoringの設定
|
Datetime nowDT = Datetime.now();
|
String nowStr = nowDT.format('yyyyMMddHHmm');
|
GeDatas.Monitoring = new NFMUtil.Monitoring();
|
|
|
GeDatas.GeData = new SBG004WebService.GeData[] { GeData };
|
GeDatas.Monitoring.MessageGroupNumber = nowStr + '32';
|
GeData.ProductCode = 'testSBG004';
|
GeData.Currency_x = 'USD';
|
GeData.EffectiveDateFrom = '20121201';
|
GeData.EffectiveDateTo = '29121204';
|
GeData.PurposeOfAdvice = '2';
|
GeData.ProductSegment = 'BS';
|
GeData.MachineParts = 'Machine';
|
GeData.SalesChannel = '99';
|
GeData.TradeType = 'Taxation';
|
GeData.CostPrice = 100;
|
|
System.Test.startTest();
|
SBG004WebService.SBG004(GeDatas);
|
System.Test.stopTest();
|
|
List<Product2> rslts = [select Id, ProductCode, Product_ECCode__c,
|
EffectiveDateTo__c,
|
ProductModels__c,
|
ProductStatus__c
|
from Product2
|
where Product_ECCode__c = :GeData.ProductCode];
|
// deleteの場合、EffectiveDateTo が前日
|
System.assertEquals(1, rslts.size());
|
System.assertEquals(date.newinstance(2012, 12, 01), rslts[0].EffectiveDateTo__c);
|
|
List<BatchIF_Log__c> rowbl = [Select Id, Log__c,
|
ErrorLog__c
|
from BatchIF_Log__c
|
where RowDataFlg__c = true
|
and Type__c = 'SBG004'
|
order by CreatedDate desc];
|
System.assertEquals(1, rowbl.size());
|
rowbl[0].retry_cnt__c = 1;
|
update rowbl;
|
|
SBGITMWebService.execute(rowbl[0].id);
|
|
List<BatchIF_Log__c> 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);
|
}
|
}
|