From c376deadef754aa59c002386c2f3c98904be37f8 Mon Sep 17 00:00:00 2001
From: 19626 <1962676589@qq.com>
Date: 星期四, 15 六月 2023 09:49:06 +0800
Subject: [PATCH] 测试类代码覆盖率优化

---
 force-app/main/default/classes/ConsumReassignControllerTest.cls |   75 ++++++++++++++++++++++++++++++++++++-
 1 files changed, 72 insertions(+), 3 deletions(-)

diff --git a/force-app/main/default/classes/ConsumReassignControllerTest.cls b/force-app/main/default/classes/ConsumReassignControllerTest.cls
index ea64808..1fa0c58 100644
--- a/force-app/main/default/classes/ConsumReassignControllerTest.cls
+++ b/force-app/main/default/classes/ConsumReassignControllerTest.cls
@@ -1,6 +1,75 @@
 @isTest
 private class ConsumReassignControllerTest {
-    static testMethod void testCoverUp() {
-        ConsumReassignController.test();
-    }
+
+    @isTest(SeeAllData=true) static void test_init() {
+            RecordType rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and DeveloperName = 'Hp'];
+            List<RecordType> rectDpt = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and DeveloperName IN ('Department_GI', 'Department_BF') order by DeveloperName desc];
+
+            Account acc = new Account();
+            acc.RecordTypeId = rectCo.Id;
+            acc.Name = 'HP test1';
+            insert acc;
+
+            List<Account> dept = [select Id, Name from Account where ParentId = :acc.Id and Department_Class_Label__c IN ('娑堝寲绉�', '鍛煎惛绉�') order by Department_Class_Label__c];
+
+            Account depart1 = new Account();
+            depart1.RecordTypeId = rectDpt[0].Id;
+            depart1.Name         = '*';
+            depart1.Department_Name__c  = 'Gastoro Intestin Test';
+            depart1.ParentId            = dept[0].Id;
+            depart1.Department_Class__c = dept[0].Id;
+            depart1.Hospital__c         = acc.Id;
+
+            Account depart2 = new Account();
+            depart2.RecordTypeId = rectDpt[1].Id;
+            depart2.Name         = '*';
+            depart2.Department_Name__c  = '瑷虹檪绉�2';
+            depart2.ParentId            = dept[1].Id;
+            depart2.Department_Class__c = dept[1].Id;
+            depart2.Hospital__c         = acc.Id;
+            insert new Account[] {depart1, depart2};
+
+            Contact con = new Contact();
+            con.LastName = 'lastname2';
+            con.FirstName = 'firstname2';
+            con.Email = 'olympustest033@sunbridge.com';
+            con.MobilePhone = '99999999';
+            con.Work_Location_manual__c = 'location2';
+            con.Post_picklist__c = '閮ㄩ暱';
+            con.Job_Category_picklist__c = '閿�鍞帹骞�';
+            con.Hire_date_text__c = Date.today().addMonths(-6);
+            con.Gender_text__c = '鐢�';
+            con.dept__c = '鏈嶅姟鏈儴';
+            con.Pregnant_Rest__c = true;
+            insert con;
+            Consum_Apply__c ca = new Consum_Apply__c();
+            ca.DataMigration_Flag__c = true;
+            insert ca;
+            Consum_Apply_Equipment_Set__c caes = new Consum_Apply_Equipment_Set__c();
+            caes.Consum_Apply__c = ca.Id;
+            caes.Consum_Start_Date__c = Date.today().addDays(20);
+            caes.DataMigration_Flag__c = true;
+            insert caes;
+            Consum_Apply_Equipment_Set_Detail__c caesd = new Consum_Apply_Equipment_Set_Detail__c();
+            caesd.DataMigration_Flag__c = true;
+            caesd.Consum_Apply__c = ca.Id;
+            caesd.Consum_Apply_Equipment_Set__c = caes.Id;
+            caesd.Consum_Start_Date__c = caes.Consum_Start_Date__c;
+            caesd.Trial_User__c = '鎴�';
+            caesd.Follower_User__c = UserInfo.getUserId();
+            caesd.Received_Confirm__c = 'NG';
+            caesd.Asset_Center_Confirm__c = 'OK';
+            caesd.Cancel_Select__c = false;
+            insert caesd; // 鑽夋涓�
+            PageReference page = new PageReference('/apex/ConsumReassign?caid=' + ca.id);
+            System.Test.setCurrentPage(page);
+            ConsumReassignController consumReassignPage = new ConsumReassignController();
+            consumReassignPage.init();
+            System.debug(consumReassignPage);
+            for (ConsumReassignController.LineInfo lineInfo : consumReassignPage.lineInfoList) {
+                lineInfo.isSelect = true;
+            }
+            System.debug(consumReassignPage);
+            consumReassignPage.saveBtn();
+    } 
 }
\ No newline at end of file

--
Gitblit v1.9.1