@isTest
|
private class NFM012WebServiceTest {
|
//resend_test
|
static testMethod void resend_test() {
|
// テストデータ
|
List<BatchIF_Transfer__c> transfers = new List<BatchIF_Transfer__c>();
|
BatchIF_Transfer__c transfer = new BatchIF_Transfer__c();
|
transfer.Table__c = 'Account';
|
transfer.Column__c = 'Sales_Shop_Class__c';
|
transfer.External_Value__c = '02';
|
transfer.Internal_Value__c = '02Internal';
|
transfers.add(transfer);
|
transfer = new BatchIF_Transfer__c();
|
transfer.Table__c = 'Account';
|
transfer.Column__c = 'Sales_Shop_Class__c';
|
transfer.External_Value__c = '03';
|
transfer.Internal_Value__c = '03Internal';
|
transfers.add(transfer);
|
insert transfers;
|
|
List<RecordType> rects = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '販売店'];
|
if (rects.size() == 0) {
|
return;
|
}
|
Account myAccount2 = new Account(name='NFM012Tst1',AgentCode_Ext__c = 'NFM012Tst1',RecordTypeId = rects[0].Id);
|
insert myAccount2;
|
NFM012WebService.Deposit Deposit = new NFM012WebService.Deposit();
|
NFM012WebService.GeneralData GeneralData = new NFM012WebService.GeneralData();
|
Deposit.GeneralData = new NFM012WebService.GeneralData[] { GeneralData };
|
|
// Monitoringの設定
|
Datetime nowDT = Datetime.now();
|
String nowStr = nowDT.format('yyyyMMddHHmm');
|
Deposit.Monitoring = new NFMUtil.Monitoring();
|
Deposit.Monitoring.MessageGroupNumber = nowStr + '21';
|
|
// insert
|
GeneralData.EndUserNo = 'NFM012Tst1';
|
GeneralData.UpdateDate = String.valueOf(Date.today());
|
GeneralData.DepositAmount = Decimal.valueOf('10000000');
|
System.Test.startTest();
|
NFM012WebService.NFM012(Deposit);
|
System.Test.stopTest();
|
Account[] rslts = [select Management_Code__c, Delete_Flag__c,
|
Name,
|
Phone,
|
Fax,
|
Postal_Code__c,
|
Address_Together__c,
|
Tax_Practice_No__c,
|
Tax_Practice_Expiration_Date__c,
|
Business_Authorization_No__c,
|
Business_Paper_Expiration_Date__c,
|
Medical_Equipment_Num__c,
|
Medical_Equipment_Expiration_Date__c,
|
Registration_Day__c,
|
Ban_On_Use_Date__c,
|
Sales_Shop_Class__c
|
from Account where Deposit_Receipt_Finished__c = :GeneralData.DepositAmount];
|
System.assertEquals(1, rslts.size());
|
if (rslts.size() == 1) {
|
System.assertEquals('NFM012Tst1', rslts[0].Management_Code__c);
|
System.assertEquals('NFM012Tst1', rslts[0].Name);
|
System.assertEquals(False, rslts[0].Delete_Flag__c);
|
}
|
|
List<BatchIF_Log__c> rowbl = [Select Id, Log__c, ErrorLog__c
|
from BatchIF_Log__c
|
where RowDataFlg__c = true
|
and Type__c = 'NFM012'
|
order by CreatedDate desc];
|
System.assertEquals(1, rowbl.size());
|
rowbl[0].retry_cnt__c = 1;
|
update rowbl;
|
NFM012WebService.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(0, bl[0].retry_cnt__c);
|
}
|
static testMethod void testNFM012_void() {
|
List<BatchIF_Transfer__c> transfers = new List<BatchIF_Transfer__c>();
|
BatchIF_Transfer__c transfer = new BatchIF_Transfer__c();
|
transfer.Table__c = 'Account';
|
transfer.Column__c = 'Sales_Shop_Class__c';
|
transfer.External_Value__c = '02';
|
transfer.Internal_Value__c = '02Internal';
|
transfers.add(transfer);
|
transfer = new BatchIF_Transfer__c();
|
transfer.Table__c = 'Account';
|
transfer.Column__c = 'Sales_Shop_Class__c';
|
transfer.External_Value__c = '03';
|
transfer.Internal_Value__c = '03Internal';
|
transfers.add(transfer);
|
insert transfers;
|
// null
|
NFM012WebService.NFM012(null);
|
|
NFM012WebService.GeneralData GeneralData = new NFM012WebService.GeneralData();
|
NFM012WebService.Deposit Deposit = new NFM012WebService.Deposit();
|
Deposit.GeneralData = new NFM012WebService.GeneralData[] { GeneralData };
|
// Monitoringをセットしない
|
NFM012WebService.NFM012(Deposit);
|
|
Datetime nowDT = Datetime.now();
|
String nowStr = nowDT.format('yyyyMMddHHmm');
|
Deposit.Monitoring = new NFMUtil.Monitoring();
|
Deposit.Monitoring.MessageGroupNumber = nowStr + '01';
|
// 必須項目をセットしない
|
NFM012WebService.NFM012(Deposit);
|
|
Account[] rslts = [select Id from Account];
|
System.assertEquals(0, rslts.size());
|
}
|
|
static testMethod void testNFM012_insert(){
|
|
// テストデータ
|
List<BatchIF_Transfer__c> transfers = new List<BatchIF_Transfer__c>();
|
BatchIF_Transfer__c transfer = new BatchIF_Transfer__c();
|
transfer.Table__c = 'Account';
|
transfer.Column__c = 'Sales_Shop_Class__c';
|
transfer.External_Value__c = '02';
|
transfer.Internal_Value__c = '02Internal';
|
transfers.add(transfer);
|
transfer = new BatchIF_Transfer__c();
|
transfer.Table__c = 'Account';
|
transfer.Column__c = 'Sales_Shop_Class__c';
|
transfer.External_Value__c = '03';
|
transfer.Internal_Value__c = '03Internal';
|
transfers.add(transfer);
|
insert transfers;
|
|
NFM012WebService.GeneralData GeneralData = new NFM012WebService.GeneralData();
|
NFM012WebService.GeneralData GeneralData2 = new NFM012WebService.GeneralData();
|
NFM012WebService.Deposit Deposit = new NFM012WebService.Deposit();
|
Deposit.GeneralData = new NFM012WebService.GeneralData[] { GeneralData, GeneralData2 };
|
|
// Monitoringの設定
|
Datetime nowDT = Datetime.now();
|
String nowStr = nowDT.format('yyyyMMddHHmm');
|
Deposit.Monitoring = new NFMUtil.Monitoring();
|
Deposit.Monitoring.MessageGroupNumber = nowStr + '11';
|
|
// insert
|
GeneralData.EndUserNo = 'NFM012Tst1';
|
GeneralData.UpdateDate = String.valueOf(Date.today());
|
GeneralData.DepositAmount = Decimal.valueOf('12345678');
|
|
System.Test.startTest();
|
NFM012WebService.NFM012(Deposit);
|
System.Test.stopTest();
|
Account[] rslts = [select Management_Code__c, Delete_Flag__c,
|
Name,
|
Phone,
|
Fax,
|
Postal_Code__c,
|
Address_Together__c,
|
Tax_Practice_No__c,
|
Tax_Practice_Expiration_Date__c,
|
Business_Authorization_No__c,
|
Business_Paper_Expiration_Date__c,
|
Medical_Equipment_Num__c,
|
Medical_Equipment_Expiration_Date__c,
|
Registration_Day__c,
|
Ban_On_Use_Date__c,
|
Sales_Shop_Class__c
|
from Account where AgentCode_Ext__c = :GeneralData.EndUserNo];
|
System.assertEquals(0, rslts.size());
|
List<BatchIF_Log__c> bl = [Select Id, Is_Error__c, Type__c, Log__c, ErrorLog__c from BatchIF_Log__c where Type__c = 'NFM012' and RowDataFlg__c = False order by CreatedDate desc];
|
System.assertEquals(true, bl[0].ErrorLog__c.indexOf('NFM012Tst1, FIELD_CUSTOM_VALIDATION_EXCEPTION') >= 0, bl[0].ErrorLog__c);
|
}
|
|
static testMethod void testNFM012_update(){
|
|
List<BatchIF_Transfer__c> transfers = new List<BatchIF_Transfer__c>();
|
BatchIF_Transfer__c transfer = new BatchIF_Transfer__c();
|
transfer.Table__c = 'Account';
|
transfer.Column__c = 'Sales_Shop_Class__c';
|
transfer.External_Value__c = '02';
|
transfer.Internal_Value__c = '02Internal';
|
transfers.add(transfer);
|
transfer = new BatchIF_Transfer__c();
|
transfer.Table__c = 'Account';
|
transfer.Column__c = 'Sales_Shop_Class__c';
|
transfer.External_Value__c = '03';
|
transfer.Internal_Value__c = '03Internal';
|
transfers.add(transfer);
|
insert transfers;
|
List<RecordType> rects = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '販売店'];
|
if (rects.size() == 0) {
|
return;
|
}
|
Account myAccount2 = new Account(name='NFM012Tst1',AgentCode_Ext__c = 'NFM012Tst1',RecordTypeId = rects[0].Id);
|
insert myAccount2;
|
NFM012WebService.Deposit Deposit = new NFM012WebService.Deposit();
|
NFM012WebService.GeneralData GeneralData = new NFM012WebService.GeneralData();
|
Deposit.GeneralData = new NFM012WebService.GeneralData[] { GeneralData };
|
|
// Monitoringの設定
|
Datetime nowDT = Datetime.now();
|
String nowStr = nowDT.format('yyyyMMddHHmm');
|
Deposit.Monitoring = new NFMUtil.Monitoring();
|
Deposit.Monitoring.MessageGroupNumber = nowStr + '21';
|
|
// insert
|
GeneralData.EndUserNo = 'NFM012Tst1';
|
GeneralData.UpdateDate = String.valueOf(Date.today());
|
GeneralData.DepositAmount = Decimal.valueOf('10000000');
|
|
System.Test.startTest();
|
NFM012WebService.NFM012(Deposit);
|
System.Test.stopTest();
|
Account[] rslts = [select Management_Code__c, Delete_Flag__c,
|
Name,
|
Phone,
|
Fax,
|
Postal_Code__c,
|
Address_Together__c,
|
Tax_Practice_No__c,
|
Tax_Practice_Expiration_Date__c,
|
Business_Authorization_No__c,
|
Business_Paper_Expiration_Date__c,
|
Medical_Equipment_Num__c,
|
Medical_Equipment_Expiration_Date__c,
|
Registration_Day__c,
|
Ban_On_Use_Date__c,
|
Sales_Shop_Class__c
|
from Account where Deposit_Receipt_Finished__c = :GeneralData.DepositAmount];
|
System.assertEquals(1, rslts.size());
|
if (rslts.size() == 1) {
|
System.assertEquals('NFM012Tst1', rslts[0].Management_Code__c);
|
System.assertEquals('NFM012Tst1', rslts[0].Name);
|
System.assertEquals(False, rslts[0].Delete_Flag__c);
|
}
|
}
|
}
|