From ba1c90575c47f9cb5c2ce0a20da90d3b1739b5fa Mon Sep 17 00:00:00 2001
From: buli <137736985@qq.com>
Date: 星期二, 26 四月 2022 11:47:45 +0800
Subject: [PATCH] 0425 Commit
---
force-app/main/default/classes/LogAutoSendBatchTest.cls | 362 ++++++++++++++++++++++++++++++++++++--------------
1 files changed, 258 insertions(+), 104 deletions(-)
diff --git a/force-app/main/default/classes/LogAutoSendBatchTest.cls b/force-app/main/default/classes/LogAutoSendBatchTest.cls
index 1d9e412..1e7e265 100644
--- a/force-app/main/default/classes/LogAutoSendBatchTest.cls
+++ b/force-app/main/default/classes/LogAutoSendBatchTest.cls
@@ -1,98 +1,262 @@
@isTest
-public class LogAutoSendBatchTest {
+private class LogAutoSendBatchTest {
- static Account company;
- static Account section1; // 鍛煎惛绉�
- static Account section2; // 娑堝寲绉�
- static Account olympus;
- static Account olympus1; // 鍛煎惛绉�
- static Account olympus2; // 娑堝寲绉�
- static Account depart1;
- static Account depart2;
-
- static void initHpData() {
- StaticParameter.EscapeNFM007Trigger = true;
- ControllerUtil.EscapeNFM001Trigger = true;
- RecordType rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '鐥呴櫌'];
- RecordType rectDpt1 = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '瑷虹檪绉� 鍛煎惛绉�'];
- RecordType rectDpt2 = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '瑷虹檪绉� 娑堝寲绉�'];
- // 銉嗐偣銉堛儑銉笺偪
- company = new Account(RecordTypeId = rectCo.Id, Name = 'NFM110TestCompany');
- olympus = new Account(RecordTypeId = rectCo.Id, AgentCode_Ext__c = '9999999', Name = 'olympus');
- insert new Account[] {company, olympus};
- company = [select Management_Code__c, Management_Code_Auto__c, Name, Id from Account where Id =:company.Id];
- section1 = [select Management_Code__c, Management_Code_Auto__c, Name, Id, Department_Class_Label__c from Account where ParentId =:company.Id and RecordType.name = '鎴︾暐绉戝鍒嗛 鍛煎惛绉�'];
- section2 = [select Management_Code__c, Management_Code_Auto__c, Name, Id, Department_Class_Label__c from Account where ParentId =:company.Id and RecordType.name = '鎴︾暐绉戝鍒嗛 娑堝寲绉�'];
- olympus1 = [select Management_Code__c, Management_Code_Auto__c, Name, Id, Department_Class_Label__c from Account where ParentId =:olympus.Id and RecordType.name = '鎴︾暐绉戝鍒嗛 鍛煎惛绉�'];
- olympus2 = [select Management_Code__c, Management_Code_Auto__c, Name, Id, Department_Class_Label__c from Account where ParentId =:olympus.Id and RecordType.name = '鎴︾暐绉戝鍒嗛 娑堝寲绉�'];
-System.debug('section1.Department_Class_Label__c='+section1.Department_Class_Label__c);
-System.debug('section2.Department_Class_Label__c='+section2.Department_Class_Label__c);
- depart1 = new Account(RecordTypeId = rectDpt1.Id, Name = '*', ParentId = section1.Id, Department_Class__c = section1.Id, Hospital__c = company.Id,
- Department_Name__c = 'NFM110TestDepart1');
- depart2 = new Account(RecordTypeId = rectDpt2.Id, Name = '*', ParentId = section2.Id, Department_Class__c = section2.Id, Hospital__c = company.Id,
- Department_Name__c = 'NFM110TestDepart2');
- Account ocm = new Account(RecordTypeId = rectDpt2.Id, Name = '*', ParentId = section2.Id, Department_Class__c = section2.Id, Hospital__c = company.Id,
- AgentCode_Ext__c = '9999900', Department_Name__c = 'NFM110TestDepart3');
- Account olympus_return = new Account(RecordTypeId = rectDpt2.Id, Name = '*', ParentId = olympus2.Id, Department_Class__c = olympus2.Id, Hospital__c = olympus.Id,
- AgentCode_Ext__c = '9999901', Department_Name__c = 'olympus_return');
- insert new Account[] {depart1, depart2, ocm,olympus_return};
- depart1 = [select Management_Code__c, Management_Code_Auto__c, Name, Id from Account where Id =:depart1.Id];
- depart2 = [select Management_Code__c, Management_Code_Auto__c, Name, Id from Account where Id =:depart2.Id];
- }
-
-
-
@isTest
- static void test_insert() {
- initHpData();
- Product2 prd = new Product2(Name = 'NFM110Prd1', ProductCode = 'NFM110Prd1', ProductCode_Ext__c = 'NFM110Prd1', Manual_Entry__c = false);
- insert prd;
- Product2__c pro1 = new Product2__c(Name='NFM110Prd1',OT_CODE_Text__c='NFM110Prd1',Product2__c=prd.id);
- insert pro1;
-
- NFM110WebService.GeneralData generalData1 = new NFM110WebService.GeneralData();
- NFM110WebService.ProductsDelivery ProductsDelivery = new NFM110WebService.ProductsDelivery();
+ static void test_LogAutoSendBatch_SBGITM() {
+ Id pricebookId = ControllerUtil.getStandardPricebook().Id;
+ SBGITMRest.GeData GeData = new SBGITMRest.GeData();
+ SBGITMRest.GeDatas GeDatas = new SBGITMRest.GeDatas();
+ GeDatas.GeData = new SBGITMRest.GeData[] { GeData };
Datetime nowDT = Datetime.now();
String nowStr = nowDT.format('yyyyMMddHHmm');
- ProductsDelivery.Monitoring = new NFMUtil.Monitoring();
- ProductsDelivery.Monitoring.MessageGroupNumber = nowStr + '01';
+ GeDatas.Monitoring = new NFMUtil.Monitoring();
+ GeDatas.Monitoring.MessageGroupNumber = nowStr + '01';
+ GeData.EffectiveDateTo = '29121103';
+ GeData.ProductCode = 'SBGITMTst1';
+ // SBGITMRest.SBGITM(GeDatas);
+ //
+ BatchIF_Log__c rowData = NFMUtil.saveRowData(GeDatas.Monitoring, 'SBGITM', GeDatas.GeData);
+ SBGITMRest.main(rowData.Id);
+ BatchIF_Log__c[] logs = [Select Id,
+ Name,
+ Log__c,
+ ErrorLog__c,
+ Log2__c,
+ Log3__c,
+ Log4__c,
+ Log5__c,
+ Log6__c,
+ Log7__c,
+ Log8__c,
+ Log9__c,
+ Log10__c,
+ Log11__c,
+ Log12__c,
+ MessageGroupNumber__c,
+ retry_cnt__c
+ from BatchIF_Log__c
+ where RowDataFlg__c = true
+ and Type__c = 'SBGITM'
+ order by CreatedDate desc ];
- ProductsDelivery.GeneralData = new NFM110WebService.GeneralData[] { generalData1 };
- generalData1.DeliveryNote = 'DeliveryNote';
- NFM110WebService.DnInformation dnInfo1 = new NFM110WebService.DnInformation();
- generalData1.DnInformation = new NFM110WebService.DnInformation[] { dnInfo1 };
- generalData1.EndUserNo = company.Management_Code_Auto__c;
- generalData1.DepartmentNo = depart1.Management_Code_Auto__c;
- generalData1.InquiryNo = 'test0001' + ',';
- dnInfo1.SorLMark = 'S';
- dnInfo1.OTCode = prd.ProductCode_Ext__c;
- dnInfo1.SerialNoorLotNo = '2577010001675';
+ logs[0].retry_cnt__c = 1;
+ update logs;
+ Id execBTId = Database.executeBatch(new LogAutoSendBatch(), 1);
+ }
+ @isTest
+ static void test_LogAutoSendBatch_SBG010() {
+ Id pricebookId = ControllerUtil.getStandardPricebook().Id;
+ SBGITMRest.GeData GeData = new SBGITMRest.GeData();
+ SBGITMRest.GeDatas GeDatas = new SBGITMRest.GeDatas();
+ GeDatas.GeData = new SBGITMRest.GeData[] { GeData };
+
+ Datetime nowDT = Datetime.now();
+ String nowStr = nowDT.format('yyyyMMddHHmm');
+ GeDatas.Monitoring = new NFMUtil.Monitoring();
+ GeDatas.Monitoring.MessageGroupNumber = nowStr + '01';
+ GeData.EffectiveDateTo = '29121103';
+ GeData.ProductCode = 'SBGITMTst1';
+ // SBGITMRest.SBGITM(GeDatas);
+ //
+ BatchIF_Log__c rowData = NFMUtil.saveRowData(GeDatas.Monitoring, 'SBG010', GeDatas.GeData);
+ SBG010WebService.execute(rowData.Id);
+ BatchIF_Log__c[] logs = [Select Id,
+ Name,
+ Log__c,
+ ErrorLog__c,
+ Log2__c,
+ Log3__c,
+ Log4__c,
+ Log5__c,
+ Log6__c,
+ Log7__c,
+ Log8__c,
+ Log9__c,
+ Log10__c,
+ Log11__c,
+ Log12__c,
+ MessageGroupNumber__c,
+ retry_cnt__c
+ from BatchIF_Log__c
+ where RowDataFlg__c = true
+ and Type__c = 'SBG010'
+ order by CreatedDate desc ];
+
+ logs[0].retry_cnt__c = 1;
+ update logs;
+ Id execBTId = Database.executeBatch(new LogAutoSendBatch(), 1);
+
+ }
+
+ @isTest
+ static void test_LogAutoSendBatch_SBG017() {
+ Id pricebookId = ControllerUtil.getStandardPricebook().Id;
+ SBGITMRest.GeData GeData = new SBGITMRest.GeData();
+ SBGITMRest.GeDatas GeDatas = new SBGITMRest.GeDatas();
+ GeDatas.GeData = new SBGITMRest.GeData[] { GeData };
+
+ Datetime nowDT = Datetime.now();
+ String nowStr = nowDT.format('yyyyMMddHHmm');
+ GeDatas.Monitoring = new NFMUtil.Monitoring();
+ GeDatas.Monitoring.MessageGroupNumber = nowStr + '01';
+ GeData.EffectiveDateTo = '29121103';
+ GeData.ProductCode = 'SBGITMTst1';
+ // SBGITMRest.SBGITM(GeDatas);
+ //
+ BatchIF_Log__c rowData = NFMUtil.saveRowData(GeDatas.Monitoring, 'SBG017', GeDatas.GeData);
+ SBG017Rest.main(rowData.Id);
+ BatchIF_Log__c[] logs = [Select Id,
+ Name,
+ Log__c,
+ ErrorLog__c,
+ Log2__c,
+ Log3__c,
+ Log4__c,
+ Log5__c,
+ Log6__c,
+ Log7__c,
+ Log8__c,
+ Log9__c,
+ Log10__c,
+ Log11__c,
+ Log12__c,
+ MessageGroupNumber__c,
+ retry_cnt__c
+ from BatchIF_Log__c
+ where RowDataFlg__c = true
+ and Type__c = 'SBG017'
+ order by CreatedDate desc ];
+
+ logs[0].retry_cnt__c = 1;
+ update logs;
+ Id execBTId = Database.executeBatch(new LogAutoSendBatch(), 1);
+
+ }
+
+ @isTest
+ static void test_LogAutoSendBatch_SBG203() {
+ Id pricebookId = ControllerUtil.getStandardPricebook().Id;
+ SBGITMRest.GeData GeData = new SBGITMRest.GeData();
+ SBGITMRest.GeDatas GeDatas = new SBGITMRest.GeDatas();
+ GeDatas.GeData = new SBGITMRest.GeData[] { GeData };
+
+ Datetime nowDT = Datetime.now();
+ String nowStr = nowDT.format('yyyyMMddHHmm');
+ GeDatas.Monitoring = new NFMUtil.Monitoring();
+ GeDatas.Monitoring.MessageGroupNumber = nowStr + '01';
+ GeData.EffectiveDateTo = '29121103';
+ GeData.ProductCode = 'SBGITMTst1';
+ // SBGITMRest.SBGITM(GeDatas);
+ //
+ BatchIF_Log__c rowData = NFMUtil.saveRowData(GeDatas.Monitoring, 'SBG203', GeDatas.GeData);
+ SBG203Rest.main(rowData.Id);
+ BatchIF_Log__c[] logs = [Select Id,
+ Name,
+ Log__c,
+ ErrorLog__c,
+ Log2__c,
+ Log3__c,
+ Log4__c,
+ Log5__c,
+ Log6__c,
+ Log7__c,
+ Log8__c,
+ Log9__c,
+ Log10__c,
+ Log11__c,
+ Log12__c,
+ MessageGroupNumber__c,
+ retry_cnt__c
+ from BatchIF_Log__c
+ where RowDataFlg__c = true
+ and Type__c = 'SBG203'
+ order by CreatedDate desc ];
+
+ logs[0].retry_cnt__c = 1;
+ update logs;
+ Id execBTId = Database.executeBatch(new LogAutoSendBatch(), 1);
+
+ }
+
+ @isTest
+ static void test_LogAutoSendBatch_SBG204() {
+ Id pricebookId = ControllerUtil.getStandardPricebook().Id;
+ SBGITMRest.GeData GeData = new SBGITMRest.GeData();
+ SBGITMRest.GeDatas GeDatas = new SBGITMRest.GeDatas();
+ GeDatas.GeData = new SBGITMRest.GeData[] { GeData };
+
+ Datetime nowDT = Datetime.now();
+ String nowStr = nowDT.format('yyyyMMddHHmm');
+ GeDatas.Monitoring = new NFMUtil.Monitoring();
+ GeDatas.Monitoring.MessageGroupNumber = nowStr + '01';
+ GeData.EffectiveDateTo = '29121103';
+ GeData.ProductCode = 'SBGITMTst1';
+ // SBGITMRest.SBGITM(GeDatas);
+ //
+ BatchIF_Log__c rowData = NFMUtil.saveRowData(GeDatas.Monitoring, 'SBG204', GeDatas.GeData);
+ SBG204Rest.main(rowData.Id);
+ BatchIF_Log__c[] logs = [Select Id,
+ Name,
+ Log__c,
+ ErrorLog__c,
+ Log2__c,
+ Log3__c,
+ Log4__c,
+ Log5__c,
+ Log6__c,
+ Log7__c,
+ Log8__c,
+ Log9__c,
+ Log10__c,
+ Log11__c,
+ Log12__c,
+ MessageGroupNumber__c,
+ retry_cnt__c
+ from BatchIF_Log__c
+ where RowDataFlg__c = true
+ and Type__c = 'SBG204'
+ order by CreatedDate desc ];
+
+ logs[0].retry_cnt__c = 1;
+ update logs;
+ Id execBTId = Database.executeBatch(new LogAutoSendBatch(), 1);
+
+ }
+
+ @isTest
+ static void test_LogAutoSendBatch_SBG018() {
+ SBG018Rest.GeData GeData = new SBG018Rest.GeData();
+ SBG018Rest.GeDatas GeDatas = new SBG018Rest.GeDatas();
+ GeDatas.GeData = new SBG018Rest.GeData[] { GeData };
+ Datetime nowDT = Datetime.now();
+ String nowStr = nowDT.format('yyyyMMddHHmm');
+ GeDatas.Monitoring = new NFMUtil.Monitoring();
+ GeDatas.Monitoring.MessageGroupNumber = nowStr + '01';
+ SBG018Rest.GeDataDetails GeDataDetail01 = new SBG018Rest.GeDataDetails();
+ SBG018Rest.GeDataDetails GeDataDetail02 = new SBG018Rest.GeDataDetails();
+ GeData.GeDataDetails = new SBG018Rest.GeDataDetails[] {GeDataDetail01, GeDataDetail02};
+ GeData.Status = 'Z5';
+ GeData.TransforDate = String.valueOf(Date.today());//'20210113';
+ GeDataDetail01.ProductCode = 'testSBG018';
+ GeDataDetail01.Plant = 'CCTV';
+ GeDataDetail01.Department = 'LS';
+ GeDataDetail01.FGSP = 'SP';
+ GeDataDetail01.Qty = '11';
+ GeDataDetail01.TradeType = 'Taxation';
+ GeDataDetail02.ProductCode = 'testSBG018';
+ // 鐢ㄤ簬瑙﹀彂寮傚父 杩涘叆Catch
+ GeDataDetail02.Plant = 'CC31';
+
+ GeDataDetail02.Department = 'LS';
+ GeDataDetail02.FGSP = 'FG';
+ GeDataDetail02.Qty = '11';
+ GeDataDetail02.TradeType = 'Taxation';
System.Test.startTest();
- //NFM110WebService.NFM110(ProductsDelivery);
- BatchIF_Log__c rowData = NFMUtil.saveRowData(ProductsDelivery.Monitoring, 'NFM110', ProductsDelivery.GeneralData);
- if (String.isBlank(rowData.Log__c) == false)
- NFM110Rest.executefuture(rowData.Id);
- System.Test.stopTest();
-
- Asset[] rslts = [select Id, Return_Flag__c, AccountId, Department_Class__c, Hospital__c, Product2Id, SerialNumber, SLMark__c, IF_Information_From__c, InstallDate from Asset];
- List<BatchIF_Log__c> rowbl = [Select Id, Log__c, ErrorLog__c from BatchIF_Log__c where RowDataFlg__c = false and Type__c = 'NFM110' order by CreatedDate desc];
- //System.assertEquals('1', rowbl[0].ErrorLog__c);
- System.assertEquals(1, rslts.size());
- if(rslts.size() > 0){
- System.assertEquals(1, rslts.size());
- System.assertEquals(false, rslts[0].Return_Flag__c);
- System.assertEquals(depart1.Id, rslts[0].AccountId);
- System.assertEquals(section1.Id, rslts[0].Department_Class__c);
- System.assertEquals(company.Id, rslts[0].Hospital__c);
- System.assertEquals(prd.Id, rslts[0].Product2Id);
- System.assertEquals(dnInfo1.SerialNoorLotNo, rslts[0]. SerialNumber);
- System.assertEquals('Serial Number', rslts[0]. SLMark__c);
- System.assertEquals(true, rslts[0]. IF_Information_From__c);
- System.assertEquals(null, rslts[0]. InstallDate);
- }
-
+ BatchIF_Log__c rowData = NFMUtil.saveRowData(GeDatas.Monitoring, 'SBG018', GeDatas.GeData);
+ SBG018Rest.main(rowData.Id);
+
BatchIF_Log__c[] logs =[Select Id,
Name,
Log__c,
@@ -114,29 +278,19 @@
retry_cnt__c
from BatchIF_Log__c
where RowDataFlg__c = true
- and Type__c = 'NFM110'
+ and Type__c = 'SBG018'
order by CreatedDate desc ];
logs[0].retry_cnt__c=1;
update logs;
- System.assertEquals(1, logs[0].retry_cnt__c);
-
- System.assertEquals('NFM110', logs[0].Type__c);
-
Id execBTId = Database.executeBatch(new LogAutoSendBatch(), 5);
- BatchIF_Log__c[] logss =[Select Id, Name, Log__c, ErrorLog__c, Log2__c,retry_cnt__c from BatchIF_Log__c where id = :logs[0].id];
- System.assertEquals(1, logss[0].retry_cnt__c);
-
- List<BatchIF_Log__c> ll = [SELECT Id, Name, Log__c, ErrorLog__c, Log2__c, Log3__c, Log4__c, Log5__c, Log6__c,
- Log7__c, Log8__c, Log9__c, Log10__c, Log11__c, Log12__c, MessageGroupNumber__c,Type__c,
- retry_cnt__c
- FROM BatchIF_Log__c
- WHERE RowDataFlg__c = true
- AND Type__c = :logs[0].Type__c AND CreatedDate >= :logs[0].CreatedDate AND MessageGroupNumber__c >= :logs[0].MessageGroupNumber__c ];
- System.assertEquals(1, ll.size());
-
Database.executeBatch(new LogAutoSendBatch(logs[0].Type__c,logs[0].MessageGroupNumber__c,logs[0].CreatedDate), 1);
- BatchIF_Log__c[] logsss =[Select Id, Name, Log__c, ErrorLog__c, Log2__c,retry_cnt__c from BatchIF_Log__c where id = :logs[0].id];
- System.assertEquals(1, logsss[0].retry_cnt__c);
+
+
}
+
+
+
+
+
}
\ No newline at end of file
--
Gitblit v1.9.1