From 962519811b7c4be07f30d09e791798b0ea79d3ae Mon Sep 17 00:00:00 2001
From: 黄千龙 <huangqianlong@prec-tech.com>
Date: 星期三, 08 三月 2023 09:54:02 +0800
Subject: [PATCH] 同步代码

---
 force-app/main/default/classes/AttachmentTriggerTest.cls |  169 +++++++++++++++++++++++++++++++++++++++++++-------------
 1 files changed, 129 insertions(+), 40 deletions(-)

diff --git a/force-app/main/default/classes/AttachmentTriggerTest.cls b/force-app/main/default/classes/AttachmentTriggerTest.cls
index 9c3f5ee..d80b14e 100644
--- a/force-app/main/default/classes/AttachmentTriggerTest.cls
+++ b/force-app/main/default/classes/AttachmentTriggerTest.cls
@@ -57,7 +57,7 @@
         opp.Name                = 'GZ-SP-NFM007_1';
         opp.Trade__c            = '鍐呰部';
         opp.StageName           = '寮曞悎';
-        opp.CloseDate           = date.newinstance(2022, 11, 30);
+        opp.CloseDate           = date.newinstance(2023, 12, 30);
         opp.Stock_apply_status__c = '鐢宠涓�';
         insert opp;
 
@@ -190,7 +190,7 @@
         Account hospital = new Account();
         hospital.recordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Account' and DeveloperName = 'HP'].id;
         hospital.Name = 'test hospital';
-        hospital.Is_Active__c = '鏈夊姽';
+        hospital.Is_Active__c = '鑽夋涓�';
         hospital.Attribute_Type__c = '鍗敓閮�';
         hospital.Speciality_Type__c = '缁煎悎鍖婚櫌';
         hospital.Grade__c = '涓�绾�';
@@ -234,6 +234,7 @@
             Name = 'test',
             ParentId = hospital.Id,
             Body = EncodingUtil.base64Decode('test')
+            
         );
         insert att;
         
@@ -293,7 +294,7 @@
         opp.Name                = 'GZ-SP-NFM007_1';
         opp.Trade__c            = '鍐呰部';
         opp.StageName           = '寮曞悎';
-        opp.CloseDate           = date.newinstance(2022, 11, 30);
+        opp.CloseDate           = date.newinstance(2023, 11, 30);
         opp.Stock_apply_status__c = '鐢宠涓�';
         insert opp;
 
@@ -459,61 +460,85 @@
         System.Test.stopTest();
 
     }
-    @isTest 
+    /*@isTest 
     static void test_method_8() {
-        List<RecordType> rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '鐥呴櫌'];
-        if (rectCo.size() == 0) {
-            return;
-        }
-        List<RecordType> rectSct = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '鎴︾暐绉戝鍒嗛 鍛煎惛绉�'];
-        if (rectSct.size() == 0) {
-            return;
-        }
-        List<RecordType> rectDpt = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '瑷虹檪绉� 娑堝寲绉�'];
-        if (rectDpt.size() == 0) {
-            return;
-        }
+        Oly_TriggerHandler.bypass(Product2Handler.Class.getName());
+        Oly_TriggerHandler.bypass(ContactTriggerHandler.Class.getName());
 
-        Account company = new Account();
-        company.RecordTypeId = rectCo[0].Id;
-        company.Name         = 'TestCompany';
-        upsert company;
-        Account section = new Account();
-        section.RecordTypeId = rectSct[0].Id;
-        section.Name         = '*';
-        section.Department_Class_Label__c = '娑堝寲绉�';
-        section.ParentId                  = company.Id;
-        section.Hospital_Department_Class__c = company.Id;
-        upsert section;
-        Account depart = new Account();
-        depart.RecordTypeId = rectDpt[0].Id;
-        depart.Name         = '*';
-        depart.Department_Name__c  = 'TestDepart';
-        depart.ParentId            = section.Id;
-        depart.Department_Class__c = section.Id;
-        depart.Hospital__c         = company.Id;
-        upsert depart;
+        // 鐪�
+        Address_Level__c al = new Address_Level__c();
+        al.Name = '鏉变含';
+        al.Level1_Code__c = 'CN-99';
+        al.Level1_Sys_No__c = '999999';
+        insert al;
+        // 甯�
+        Address_Level2__c al2 = new Address_Level2__c();
+        al2.Level1_Code__c = 'CN-99';
+        al2.Level1_Sys_No__c = '999999';
+        al2.Level1_Name__c = '鏉变含';
+        al2.Name = '娓嬭胺鍖�';
+        al2.Level2_Code__c = 'CN-9999';
+        al2.Level2_Sys_No__c = '9999999';
+        al2.Address_Level__c = al.id;
+        insert al2;
+        // 鐥呴櫌銈掍綔銈�
+        Account hospital = new Account();
+        String rtId = [SELECT ID FROM RecordType WHERE DeveloperName = 'HP'].Id;
+        hospital.recordtypeId = rtId;
+        hospital.Name = 'test hospital';
+        hospital.Is_Active__c = '鏈夊姽';
+        hospital.Attribute_Type__c = '鍗敓閮�';
+        hospital.Speciality_Type__c = '缁煎悎鍖婚櫌';
+        hospital.Grade__c = '涓�绾�';
+        hospital.OCM_Category__c = 'SLTV';
+        hospital.Is_Medical__c = '鍖荤枟鏈烘瀯';
+        hospital.State_Master__c = al.id;
+        hospital.City_Master__c = al2.id;
+        hospital.Town__c = '涓滀含';
+        insert hospital;   
+        Account[] strategicDep = [SELECT ID, Name FROM Account WHERE parentId = :hospital.Id AND recordType.DeveloperName = 'Department_Class_OTH'];
+        // 瑷虹檪绉戙倰浣溿倠
+        Account dep = new Account();
+        String rtId1 = [SELECT ID FROM RecordType WHERE DeveloperName = 'Department_OTH'].Id;
+        dep.recordtypeId = rtId1;
+        dep.Name = 'test dep1';
+        dep.AgentCode_Ext__c = '9999999';
+        dep.ParentId = strategicDep[0].Id;
+        dep.Department_Class__c = strategicDep[0].Id;
+        dep.Hospital__c = hospital.Id;
+        insert dep;
 
+        Contact contact2 = new Contact();
+        contact2.AccountId = dep.Id;
+        contact2.FirstName = '璨换鑰�';
+        contact2.LastName = 'test1缁忛攢鍟�';
+        insert contact2;
 
         OPDPlan__c opd = new OPDPlan__c();
         opd.Status__c = '璁″垝涓�';
         opd.OPDPlan_ImplementDate__c = Date.today().addDays(5);
         opd.NoOpp_Reason__c = 'HCP瀵瑰簲';
         opd.OPDType__c = '绉戝';
-
         insert opd;
-
 
         Rental_Apply__c  rap = new Rental_Apply__c();
         rap.Name = 'testra';
         rap.Product_category__c = 'GI';
-        rap.Hospital__c = company.Id;
-        rap.Strategic_dept__c = section .Id;
-        rap.Account__c = depart.Id;
+        rap.Hospital__c = hospital.Id;
+        rap.Strategic_dept__c = strategicDep[0].Id;
+        rap.Account__c = dep.Id;
         rap.demo_purpose2__c = '璇曠敤锛堟棤璇环锛�';
         rap.Request_shipping_day__c = Date.toDay();
         rap.Request_return_day__c = Date.toDay();
         rap.OPDPlan__c = opd.id;
+        rap.Demo_purpose1__c ='浜у搧璇曠敤';
+        rap.direct_send__c = '鍖荤枟鏈烘瀯';
+        rap.Hope_Lonaer_date_Num__c = 16;
+        rap.OwnerId = getUser().Id;
+        rap.Loaner_received_staff__c = '鐜嬩簲';
+        rap.Loaner_received_staff_phone__c = '110';
+        rap.direct_shippment_address__c = '鍖椾含甯�';
+        rap.Phone_number__c = '1234567890';
 
         insert rap;
 
@@ -528,7 +553,71 @@
         insert att;
         System.Test.stopTest();
 
+    }*/
+
+    // 20230206  lt  start 
+    @isTest 
+    static void test_method_9() {
+        //鏂板缓鐪�
+        Address_Level__c al = new Address_Level__c();
+        al.Name = '鏉变含';
+        al.Level1_Code__c = 'CN-99';
+        al.Level1_Sys_No__c = '999999';
+        insert al;
+
+        // 鐥呴櫌銈掍綔銈�
+        Account hospital = new Account();
+        hospital.recordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Account' and DeveloperName = 'HP'].id;
+        hospital.Name = 'test hospital';
+        hospital.Is_Active__c = '鑽夋涓�';
+        hospital.Attribute_Type__c = '鍗敓閮�';
+        hospital.Speciality_Type__c = '缁煎悎鍖婚櫌';
+        hospital.Grade__c = '涓�绾�';
+        hospital.OCM_Category__c = 'SLTV';
+        hospital.Is_Medical__c = '鍖荤枟鏈烘瀯';
+        hospital.State_Master__c = al.id;
+        // hospital.City_Master__c = al2.id;
+        hospital.Town__c = '涓滀含';
+        insert hospital;
+
+        RecordType rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and DeveloperName = 'Hp'];
+        
+        Account acc = new Account();
+        acc.RecordTypeId = rectCo.Id;
+        acc.Name = 'HP test1';
+        acc.Is_Active__c = '鏈夊姽';
+        insert acc;
+
+        //鏂板缓 瀹㈡埛鍙樻洿鐢宠
+        Account_Delay_Apply__c ada = new Account_Delay_Apply__c();
+        ada.Hospital__c = acc.Id;
+        ada.ChangeReason__c = '鍦板潃閿欒';
+        ada.State_Master__c = al.Id;
+        insert ada;
+
+        System.Test.startTest();
+
+        Attachment att = new Attachment(
+            Name = 'test',
+            ParentId = hospital.Id,
+            Body = EncodingUtil.base64Decode('test')
+        );
+        insert att;
+        att.Name = 'test01';
+        update att;
+
+        Attachment att1 = new Attachment(
+            Name = '2test',
+            ParentId = ada.Id,
+            Body = EncodingUtil.base64Decode('test')
+        );
+        insert att1;
+        att1.Name = '2test01';
+        update att1;
+        System.Test.stopTest();
+
     }
+    // 20230206  lt  end
 
     private static User getUser() {
         String timenow = Datetime.now().format('yyyyMMddHHmmss');

--
Gitblit v1.9.1