From 399b453ac2f611473885681688f6aa69029e65b8 Mon Sep 17 00:00:00 2001
From: buli <137736985@qq.com>
Date: 星期二, 25 四月 2023 13:44:10 +0800
Subject: [PATCH] backup

---
 force-app/main/default/classes/DNUpsertBatchTest.cls |  197 +++++++++++++++++++++++++++++--------------------
 1 files changed, 117 insertions(+), 80 deletions(-)

diff --git a/force-app/main/default/classes/DNUpsertBatchTest.cls b/force-app/main/default/classes/DNUpsertBatchTest.cls
index d205b99..047dd34 100644
--- a/force-app/main/default/classes/DNUpsertBatchTest.cls
+++ b/force-app/main/default/classes/DNUpsertBatchTest.cls
@@ -1,11 +1,11 @@
-@isTest(SeeAllData = false)
+@isTest(SeeAllData=false)
 public class DNUpsertBatchTest {
     static Account company;
-    static Account section1;        // 鍛煎惛绉�
-    static Account section2;        // 娑堝寲绉�
+    static Account section1; // 鍛煎惛绉�
+    static Account section2; // 娑堝寲绉�
     static Account olympus;
-    static Account olympus1;        // 鍛煎惛绉�
-    static Account olympus2;        // 娑堝寲绉�
+    static Account olympus1; // 鍛煎惛绉�
+    static Account olympus2; // 娑堝寲绉�
     static Account depart1;
     static Account depart2;
     @testSetup
@@ -16,30 +16,82 @@
         ID rectDpt2ID = Schema.SObjectType.Account.getRecordTypeInfosByDeveloperName().get('Department_GI').getRecordTypeId();
 
         // 銉嗐偣銉堛儑銉笺偪
-        company = new Account(RecordTypeId = rectCoID, Name = 'NFM110TestCompany', FSE_SP_Main_Leader__c = UserInfo.getUserId(), FSE_GI_Main_Leader__c = UserInfo.getUserId());
+        company = new Account(
+            RecordTypeId = rectCoID,
+            Name = 'NFM110TestCompany',
+            FSE_SP_Main_Leader__c = UserInfo.getUserId(),
+            FSE_GI_Main_Leader__c = UserInfo.getUserId()
+        );
         olympus = new Account(RecordTypeId = rectCoID, 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 = '鎴︾暐绉戝鍒嗛 娑堝寲绉�'];
+        insert new List<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 = rectDpt1ID, Name = '*', ParentId  = section1.Id, Department_Class__c = section1.Id, Hospital__c = company.Id,
-                              Department_Name__c = 'NFM110TestDepart1');
-        depart2 = new Account(RecordTypeId = rectDpt2ID, Name = '*', ParentId  = section2.Id, Department_Class__c = section2.Id, Hospital__c = company.Id,
-                              Department_Name__c = 'NFM110TestDepart2');
-        Account ocm = new Account(RecordTypeId = rectDpt2ID, 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 = rectDpt2ID, 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];
-        Product2 prd = new Product2(Name = 'NFM110Prd1', ProductCode = 'NFM110Prd1', ProductCode_Ext__c = 'NFM110Prd1', Manual_Entry__c = false);
+        depart1 = new Account(
+            RecordTypeId = rectDpt1ID,
+            Name = '*',
+            ParentId = section1.Id,
+            Department_Class__c = section1.Id,
+            Hospital__c = company.Id,
+            Department_Name__c = 'NFM110TestDepart1'
+        );
+        depart2 = new Account(
+            RecordTypeId = rectDpt2ID,
+            Name = '*',
+            ParentId = section2.Id,
+            Department_Class__c = section2.Id,
+            Hospital__c = company.Id,
+            Department_Name__c = 'NFM110TestDepart2'
+        );
+        Account ocm = new Account(
+            RecordTypeId = rectDpt2ID,
+            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 = rectDpt2ID,
+            Name = '*',
+            ParentId = olympus2.Id,
+            Department_Class__c = olympus2.Id,
+            Hospital__c = olympus.Id,
+            AgentCode_Ext__c = '9999901',
+            Department_Name__c = 'olympus_return'
+        );
+        insert new List<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];
+        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);
+        Product2__c pro1 = new Product2__c(Name = 'NFM110Prd1', OT_CODE_Text__c = 'NFM110Prd1', Product2__c = prd.id);
         insert pro1;
 
         NFM110Rest.GeneralData generalData1 = new NFM110Rest.GeneralData();
@@ -50,18 +102,17 @@
         ProductsDelivery.Monitoring = new NFMUtil.Monitoring();
         ProductsDelivery.Monitoring.MessageGroupNumber = nowStr + '01';
 
-        ProductsDelivery.GeneralData = new NFM110Rest.GeneralData[] { generalData1 };
+        ProductsDelivery.GeneralData = new List<NFM110Rest.GeneralData>{ generalData1 };
         generalData1.DeliveryNote = 'DeliveryNote';
         NFM110Rest.DnInformation dnInfo1 = new NFM110Rest.DnInformation();
-        generalData1.DnInformation = new NFM110Rest.DnInformation[] { dnInfo1 };
-        generalData1.EndUserNo     = company.Management_Code_Auto__c;
-        generalData1.DepartmentNo  = depart1.Management_Code_Auto__c;
+        generalData1.DnInformation = new List<NFM110Rest.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.SorLMark = 'S';
+        dnInfo1.OTCode = prd.ProductCode_Ext__c;
         dnInfo1.SerialNoorLotNo = '2577010001675';
         generalData1.DeliveryNote = '11111';
-
 
         NFM110Rest.GeneralData generalData2 = new NFM110Rest.GeneralData();
         NFM110Rest.ProductsDelivery ProductsDelivery1 = new NFM110Rest.ProductsDelivery();
@@ -71,38 +122,35 @@
         ProductsDelivery1.Monitoring = new NFMUtil.Monitoring();
         ProductsDelivery1.Monitoring.MessageGroupNumber = nowStr1 + '01';
 
-        ProductsDelivery1.GeneralData = new NFM110Rest.GeneralData[] { generalData1 };
+        ProductsDelivery1.GeneralData = new List<NFM110Rest.GeneralData>{ generalData1 };
         generalData2.DeliveryNote = '';
         NFM110Rest.DnInformation dnInfo2 = new NFM110Rest.DnInformation();
-        generalData2.DnInformation = new NFM110Rest.DnInformation[] { dnInfo2 };
-        generalData2.EndUserNo     = company.Management_Code_Auto__c;
-        generalData2.DepartmentNo  = depart1.Management_Code_Auto__c;
+        generalData2.DnInformation = new List<NFM110Rest.DnInformation>{ dnInfo2 };
+        generalData2.EndUserNo = company.Management_Code_Auto__c;
+        generalData2.DepartmentNo = depart1.Management_Code_Auto__c;
         generalData2.InquiryNo = 'test0001' + ',';
-        dnInfo2.SorLMark        = 'S';
-        dnInfo2.OTCode          = prd.ProductCode_Ext__c;
+        dnInfo2.SorLMark = 'S';
+        dnInfo2.OTCode = prd.ProductCode_Ext__c;
         dnInfo2.SerialNoorLotNo = '2577010001675';
         generalData2.DeliveryNote = '';
 
-       
         BatchIF_Log__c rowData = NFMUtil.saveRowData(ProductsDelivery1.Monitoring, 'NFM110', ProductsDelivery1.GeneralData);
-         
-        
     }
     @isTest
-  private static void test_void() {
-        list<BatchIF_Log__c> rowDataList  = [select id from BatchIF_Log__c where RowDataFlg__c = true ];
+    private static void test_void() {
+        list<BatchIF_Log__c> rowDataList = [SELECT id FROM BatchIF_Log__c WHERE RowDataFlg__c = TRUE];
         rowDataList[0].IsUpsertDN__c = true;
         update rowDataList;
-    System.Test.startTest();
-        Database.executeBatch(new DNUpsertBatch(rowDataList[0].Id),1);
+        System.Test.startTest();
+        Database.executeBatch(new DNUpsertBatch(rowDataList[0].Id), 1);
         System.Test.stopTest();
     }
     @isTest
-  private static void test_checkSerialNoorLotNo() {
+    private static void test_checkSerialNoorLotNo() {
         string a = 'strsA0trstr';
         string b = 'strA50trstr';
         string c = 'str250trstr';
-         
+
         DNUpsertBatch.checkSerialNoorLotNo(a);
         DNUpsertBatch.checkSerialNoorLotNo(b);
         DNUpsertBatch.checkSerialNoorLotNo(c);
@@ -111,56 +159,42 @@
     //璺戝垱寤虹數瀛愮鏀跺崟鐨勬柟娉�
     @isTest
     private static void test_upsertESign() {
-
-
         // 妫�绱㈠嚭绛炬敹鍗曪紝骞剁敓鎴愮鏀跺崟map key 涓篋N鍙�
-        map <string, eSignForm__c> eSFMap = new  map <string, eSignForm__c>();
-
-       
+        map<string, eSignForm__c> eSFMap = new Map<string, eSignForm__c>();
 
         //鏂板缓鐢靛瓙绛炬敹鍗�
         eSignForm__c eSignForm = new eSignForm__c();
         eSignForm.Name = '::娴嬭瘯鐢靛瓙绛炬敹鍗�';
         eSignForm.DNName__c = '112233';
 
-
         eSFMap.put(eSignForm.DNName__c, eSignForm);
 
-
-        Statu_Achievements_DN__c  sad = new Statu_Achievements_DN__c();
+        Statu_Achievements_DN__c sad = new Statu_Achievements_DN__c();
         sad.Name = '112233';
         sad.DeliveryDate_Raw__c = '1111';
         sad.Sales_assistant_name_text__c = UserInfo.getUserId();
         sad.RC_Manager__c = UserInfo.getUserId();
-        sad.EsignTestAccount__c =true;
+        sad.EsignTestAccount__c = true;
         sad.ReturnMark__c = false;
 
-
-
-        list<Statu_Achievements_DN__c> DNList = new list<Statu_Achievements_DN__c>();
+        list<Statu_Achievements_DN__c> DNList = new List<Statu_Achievements_DN__c>();
         DNList.add(sad);
 
-        
         DNUpsertBatch.SetupeSignForm(eSFMap, DNList);
-
-        
     }
     //璺戝垱寤虹鏀跺崟鏄庣粏鐨勬柟娉�
     @isTest
     private static void test_upsertESignLineItems() {
-
-
-        list<Statu_Achievements_DN_details__c> insertSADNdetailList = new list<Statu_Achievements_DN_details__c>();
+        list<Statu_Achievements_DN_details__c> insertSADNdetailList = new List<Statu_Achievements_DN_details__c>();
 
         Statu_Achievements_DN_details__c saddc = new Statu_Achievements_DN_details__c();
         saddc.DNName__c = '112233';
         saddc.CaseNumber__c = '112233';
-        saddc.OTCode_Raw__c= '112233';
+        saddc.OTCode_Raw__c = '112233';
         insertSADNdetailList.add(saddc);
 
-        
-        map <string, eSignFormLineItem__c> eSFLMap = new map <string, eSignFormLineItem__c>();
-        
+        map<string, eSignFormLineItem__c> eSFLMap = new Map<string, eSignFormLineItem__c>();
+
         //鏂板缓鐢靛瓙绛炬敹鍗曟槑缁�
         eSignFormLineItem__c eSignFormLineItem = new eSignFormLineItem__c();
         eSignFormLineItem.Name = '::鐢靛瓙绛炬敹鍗曟槑缁�';
@@ -168,29 +202,32 @@
         eSignFormLineItem.DNProductNo__c = '112233-112233-112233';
         eSignFormLineItem.Count__c = 0;
 
-        eSFLMap.put(eSignFormLineItem.DNProductNo__c,eSignFormLineItem);
+        eSFLMap.put(eSignFormLineItem.DNProductNo__c, eSignFormLineItem);
 
         // 妫�绱㈠嚭绛炬敹鍗曪紝骞剁敓鎴愮鏀跺崟map key 涓篋N鍙�
-        map <string, eSignForm__c> eSFMap = new  map <string, eSignForm__c>();
+        map<string, eSignForm__c> eSFMap = new Map<string, eSignForm__c>();
 
         //鏂板缓鐢靛瓙绛炬敹鍗�
         eSignForm__c eSignForm = new eSignForm__c();
         eSignForm.Name = '::娴嬭瘯鐢靛瓙绛炬敹鍗�';
         eSignForm.DNName__c = '112233';
 
-
         eSFMap.put(eSignForm.DNName__c, eSignForm);
 
         Map<String, Product2> prdsMap = new Map<String, Product2>();
-        Product2 prd  = new Product2();
+        Product2 prd = new Product2();
         prd.ProductCode_Ext__c = '112233';
 
-        prdsMap.put(prd.ProductCode_Ext__c,prd);
+        prdsMap.put(prd.ProductCode_Ext__c, prd);
 
-        
-        DNUpsertBatch.SetupeSignFormLineItems(insertSADNdetailList,eSFLMap,eSFMap, prdsMap);
-
-        
+        DNUpsertBatch.SetupeSignFormLineItems(insertSADNdetailList, eSFLMap, eSFMap, prdsMap);
+        //Add By DTT - Li Jun Start 20230425
+        OCM_Management_Province__c ocsmTest = new OCM_Management_Province__c();
+        ocsmTest.Name = '鍏朵粬';
+        ocsmTest.Province__c = '鍖椾含甯�';
+        ocsmTest.Window1__c = UserInfo.getUserId();
+        insert ocsmTest;
+        Map<String, OCM_Management_Province__c> provinceMap = DNUpsertBatch.getManagementProvince();
+        //Add by DTT - Li Jun End 20230425
     }
-
-}
\ No newline at end of file
+}

--
Gitblit v1.9.1