From d8dc84a3d56df839895f1c417a4d9cbee763d262 Mon Sep 17 00:00:00 2001
From: 高章伟 <gaozhangwei@prec-tech.com>
Date: 星期五, 03 三月 2023 14:50:59 +0800
Subject: [PATCH] gzw 测试环境代码更新

---
 force-app/main/default/classes/LostCancelReport2AssetTriggerTest.cls |  978 ++++++++++++++++++++++++++++----------------------------
 1 files changed, 489 insertions(+), 489 deletions(-)

diff --git a/force-app/main/default/classes/LostCancelReport2AssetTriggerTest.cls b/force-app/main/default/classes/LostCancelReport2AssetTriggerTest.cls
index 2f9ca7b..5c601dc 100644
--- a/force-app/main/default/classes/LostCancelReport2AssetTriggerTest.cls
+++ b/force-app/main/default/classes/LostCancelReport2AssetTriggerTest.cls
@@ -1,538 +1,538 @@
-// /**
-//  * This class contains unit tests for validating the behavior of Apex classes
-//  * and triggers.
-//  *
-//  * Unit tests are class methods that verify whether a particular piece
-//  * of code is working properly. Unit test methods take no arguments,
-//  * commit no data to the database, and are flagged with the testMethod
-//  * keyword in the method definition.
-//  *
-//  * All test methods in an organization are executed whenever Apex code is deployed
-//  * to a production organization to confirm correctness, ensure code
-//  * coverage, and prevent regressions. All Apex classes are
-//  * required to have at least 75% code coverage in order to be deployed
-//  * to a production organization. In addition, all triggers must have some code coverage.
-//  * 
-//  * The @isTest class annotation indicates this class only contains test
-//  * methods. Classes defined with the @isTest annotation do not count against
-//  * the organization size limit for all Apex scripts.
-//  *
-//  * See the Apex Language Reference for more information about Testing and Code Coverage.
-//  */
- @isTest
- private class LostCancelReport2AssetTriggerTest {
-//     /**
-//      * 鏂拌銇椼仸銆乽pdate銆佺鍚�1
-//      * update銆佺鍚�2
-//      */
-//     static testMethod void testLostCancelReport1() {
-//         // recode type 銈掑彇寰�
-//         List<RecordType> rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '鐥呴櫌'];
-//         if (rectCo.size() == 0) {
-//             throw new ControllerUtil.myException('not found 鐥呴櫌 recodetype');
-//         }
-//         List<RecordType> rectSct = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '鎴︾暐绉戝鍒嗛 鍛煎惛绉�'];
-//         if (rectSct.size() == 0) {
-//             throw new ControllerUtil.myException('not found 鎴︾暐绉戝鍒嗛 recodetype');
-//         }
-//         List<RecordType> rectDpt = [select Id, Name from RecordType where IsActive = true and SobjectType = 'Account' and Name IN ('瑷虹檪绉� 娑堝寲绉�', '瑷虹檪绉� 鍛煎惛绉�') order by Name desc];
-//         if (rectDpt.size() == 0) {
-//             throw new ControllerUtil.myException('not found 瑷虹檪绉� recodetype');
-//         }
-//         List<RecordType> rectLost = [select Id, Name from RecordType where IsActive = true and SobjectType = 'Lost_cancel_report__c' and DeveloperName IN ('PCL_Lost_report', 'PCL_Cancel_report') order by DeveloperName desc];
-//         if (rectLost.size() == 0) {
-//             throw new ControllerUtil.myException('not found Lost_cancel_report recodetype');
-//         }
+/**
+ * This class contains unit tests for validating the behavior of Apex classes
+ * and triggers.
+ *
+ * Unit tests are class methods that verify whether a particular piece
+ * of code is working properly. Unit test methods take no arguments,
+ * commit no data to the database, and are flagged with the testMethod
+ * keyword in the method definition.
+ *
+ * All test methods in an organization are executed whenever Apex code is deployed
+ * to a production organization to confirm correctness, ensure code
+ * coverage, and prevent regressions. All Apex classes are
+ * required to have at least 75% code coverage in order to be deployed
+ * to a production organization. In addition, all triggers must have some code coverage.
+ * 
+ * The @isTest class annotation indicates this class only contains test
+ * methods. Classes defined with the @isTest annotation do not count against
+ * the organization size limit for all Apex scripts.
+ *
+ * See the Apex Language Reference for more information about Testing and Code Coverage.
+ */
+@isTest
+private class LostCancelReport2AssetTriggerTest {
+    /**
+     * 鏂拌銇椼仸銆乽pdate銆佺鍚�1
+     * update銆佺鍚�2
+     */
+    static testMethod void testLostCancelReport1() {
+        // recode type 銈掑彇寰�
+        List<RecordType> rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '鐥呴櫌'];
+        if (rectCo.size() == 0) {
+            throw new ControllerUtil.myException('not found 鐥呴櫌 recodetype');
+        }
+        List<RecordType> rectSct = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '鎴︾暐绉戝鍒嗛 鍛煎惛绉�'];
+        if (rectSct.size() == 0) {
+            throw new ControllerUtil.myException('not found 鎴︾暐绉戝鍒嗛 recodetype');
+        }
+        List<RecordType> rectDpt = [select Id, Name from RecordType where IsActive = true and SobjectType = 'Account' and Name IN ('瑷虹檪绉� 娑堝寲绉�', '瑷虹檪绉� 鍛煎惛绉�') order by Name desc];
+        if (rectDpt.size() == 0) {
+            throw new ControllerUtil.myException('not found 瑷虹檪绉� recodetype');
+        }
+        List<RecordType> rectLost = [select Id, Name from RecordType where IsActive = true and SobjectType = 'Lost_cancel_report__c' and DeveloperName IN ('PCL_Lost_report', 'PCL_Cancel_report') order by DeveloperName desc];
+        if (rectLost.size() == 0) {
+            throw new ControllerUtil.myException('not found Lost_cancel_report recodetype');
+        }
 
-//         // insert
-//         Account company1 = new Account();
-//         Account company2 = new Account();
-//         company1.RecordTypeId = rectCo[0].Id;
-//         company1.Name = '鐥呴櫌銉嗐偣銉�1';
-//         company2.RecordTypeId = rectCo[0].Id;
-//         company2.Name = '鐥呴櫌銉嗐偣銉�2';
-//         insert new Account[] {company1, company2};
+        // insert
+        Account company1 = new Account();
+        Account company2 = new Account();
+        company1.RecordTypeId = rectCo[0].Id;
+        company1.Name = '鐥呴櫌銉嗐偣銉�1';
+        company2.RecordTypeId = rectCo[0].Id;
+        company2.Name = '鐥呴櫌銉嗐偣銉�2';
+        insert new Account[] {company1, company2};
 
-//         List<Account> dc1s = [Select Id, Name, Department_Class_Label__c, Sys_Dept_Name_Change_Chk__c from Account where Parent.Id = :company1.Id order by Department_Class_Label__c];
-//         List<Account> dc2s = [Select Id, Name, Department_Class_Label__c, Sys_Dept_Name_Change_Chk__c from Account where Parent.Id = :company2.Id order by Department_Class_Label__c];
+        List<Account> dc1s = [Select Id, Name, Department_Class_Label__c, Sys_Dept_Name_Change_Chk__c from Account where Parent.Id = :company1.Id order by Department_Class_Label__c];
+        List<Account> dc2s = [Select Id, Name, Department_Class_Label__c, Sys_Dept_Name_Change_Chk__c from Account where Parent.Id = :company2.Id order by Department_Class_Label__c];
 
-//         Account depart1 = new Account();
-//         depart1.RecordTypeId = rectDpt[0].Id;
-//         depart1.Name         = '*';
-//         depart1.Department_Name__c  = '瑷虹檪绉�1';
-//         depart1.ParentId            = dc1s[0].Id;
-//         depart1.Department_Class__c = dc1s[0].Id;
-//         depart1.Hospital__c         = company1.Id;
+        Account depart1 = new Account();
+        depart1.RecordTypeId = rectDpt[0].Id;
+        depart1.Name         = '*';
+        depart1.Department_Name__c  = '瑷虹檪绉�1';
+        depart1.ParentId            = dc1s[0].Id;
+        depart1.Department_Class__c = dc1s[0].Id;
+        depart1.Hospital__c         = company1.Id;
 
-//         Account depart2 = new Account();
-//         depart2.RecordTypeId = rectDpt[1].Id;
-//         depart2.Name         = '*';
-//         depart2.Department_Name__c  = '瑷虹檪绉�2';
-//         depart2.ParentId            = dc2s[1].Id;
-//         depart2.Department_Class__c = dc2s[1].Id;
-//         depart2.Hospital__c         = company2.Id;
+        Account depart2 = new Account();
+        depart2.RecordTypeId = rectDpt[1].Id;
+        depart2.Name         = '*';
+        depart2.Department_Name__c  = '瑷虹檪绉�2';
+        depart2.ParentId            = dc2s[1].Id;
+        depart2.Department_Class__c = dc2s[1].Id;
+        depart2.Hospital__c         = company2.Id;
 
-//         insert new Account[] {depart1, depart2};
+        insert new Account[] {depart1, depart2};
 
-//         // 銇俱仛銇层仺銇よ拷鍔�
-//         List<Product2> prdList = new List<Product2>();
-//         Product2 prd1 = new Product2();
-//         prd1.ProductCode_Ext__c     = 'HistoryPrd1';
-//         prd1.ProductCode            = 'HistoryPrd1';
-//         prd1.Repair_Product_Code__c = 'HistoryPrd1_RP';
-//         prd1.Name                   = 'HistoryPrd1';
-//         prd1.Manual_Entry__c        = true;
-//         Product2 prd2 = new Product2();
-//         prd2.ProductCode_Ext__c     = 'HistoryPrd2';
-//         prd2.ProductCode            = 'HistoryPrd2';
-//         prd2.Repair_Product_Code__c = 'HistoryPrd2_RP';
-//         prd2.Name                   = 'HistoryPrd2';
-//         prd2.Manual_Entry__c        = true;
-//         insert new Product2[] {prd1, prd2};
+        // 銇俱仛銇层仺銇よ拷鍔�
+        List<Product2> prdList = new List<Product2>();
+        Product2 prd1 = new Product2();
+        prd1.ProductCode_Ext__c     = 'HistoryPrd1';
+        prd1.ProductCode            = 'HistoryPrd1';
+        prd1.Repair_Product_Code__c = 'HistoryPrd1_RP';
+        prd1.Name                   = 'HistoryPrd1';
+        prd1.Manual_Entry__c        = true;
+        Product2 prd2 = new Product2();
+        prd2.ProductCode_Ext__c     = 'HistoryPrd2';
+        prd2.ProductCode            = 'HistoryPrd2';
+        prd2.Repair_Product_Code__c = 'HistoryPrd2_RP';
+        prd2.Name                   = 'HistoryPrd2';
+        prd2.Manual_Entry__c        = true;
+        insert new Product2[] {prd1, prd2};
 
-//         // 鍟嗚珖
-//         Opportunity opp1 = new Opportunity(Name='aiueo', StageName='contact', CloseDate=Date.today(),
-//             Hospital__c = company1.Id,
-//             Department_Class__c = dc1s[0].Id,
-//             AccountId = depart1.Id
-//         );
-//         Opportunity opp2 = new Opportunity(Name='aiueo', StageName='contact', CloseDate=Date.today(),
-//             Hospital__c = company2.Id,
-//             Department_Class__c = dc2s[0].Id,
-//             AccountId = depart2.Id
-//         );
-//         insert new Opportunity[] {opp1, opp2};
+        // 鍟嗚珖
+        Opportunity opp1 = new Opportunity(Name='aiueo', StageName='contact', CloseDate=Date.today(),
+            Hospital__c = company1.Id,
+            Department_Class__c = dc1s[0].Id,
+            AccountId = depart1.Id
+        );
+        Opportunity opp2 = new Opportunity(Name='aiueo', StageName='contact', CloseDate=Date.today(),
+            Hospital__c = company2.Id,
+            Department_Class__c = dc2s[0].Id,
+            AccountId = depart2.Id
+        );
+        insert new Opportunity[] {opp1, opp2};
 
-//         // 澶卞崟
-//         Lost_cancel_report__c lcr1 = new Lost_cancel_report__c(
-//             Opportunity__c = opp1.Id, 
-//             CompetitorProduct1__c = prd1.Id,
-//             RecordTypeId = rectLost[0].Id
-//         );
-//         // 鍙栨秷
-//         Lost_cancel_report__c lcr2 = new Lost_cancel_report__c(
-//             Opportunity__c = opp2.Id, 
-//             CompetitorProduct1__c = prd2.Id,
-//             RecordTypeId = rectLost[1].Id
-//         );
-//         insert new Lost_cancel_report__c[] {lcr1, lcr2};
+        // 澶卞崟
+        Lost_cancel_report__c lcr1 = new Lost_cancel_report__c(
+            Opportunity__c = opp1.Id, 
+            CompetitorProduct1__c = prd1.Id,
+            RecordTypeId = rectLost[0].Id
+        );
+        // 鍙栨秷
+        Lost_cancel_report__c lcr2 = new Lost_cancel_report__c(
+            Opportunity__c = opp2.Id, 
+            CompetitorProduct1__c = prd2.Id,
+            RecordTypeId = rectLost[1].Id
+        );
+        insert new Lost_cancel_report__c[] {lcr1, lcr2};
         
-//         // Assert
-//         lcr1 = [Select Id, CompetitorAsset1__c, CompetitorAsset1__r.Product2Id from Lost_cancel_report__c where Id = :lcr1.Id];
-//         lcr2 = [Select Id, CompetitorAsset1__c from Lost_cancel_report__c where Id = :lcr2.Id];
-//         List<Asset> asts = [Select Id, Opportunity__c from Asset where Id = :lcr1.CompetitorAsset1__c];
-//         System.assertEquals(False, lcr2.CompetitorAsset1__c <> null);
-//         System.assertEquals(1, asts.size());
-//         System.assertEquals(opp1.Id, asts[0].Opportunity__c);
-//         System.assertEquals(True, lcr1.CompetitorAsset1__c <> null);
-//         System.assertEquals(prd1.Id, lcr1.CompetitorAsset1__r.Product2Id);
+        // Assert
+        lcr1 = [Select Id, CompetitorAsset1__c, CompetitorAsset1__r.Product2Id from Lost_cancel_report__c where Id = :lcr1.Id];
+        lcr2 = [Select Id, CompetitorAsset1__c from Lost_cancel_report__c where Id = :lcr2.Id];
+        List<Asset> asts = [Select Id, Opportunity__c from Asset where Id = :lcr1.CompetitorAsset1__c];
+        System.assertEquals(False, lcr2.CompetitorAsset1__c <> null);
+        System.assertEquals(1, asts.size());
+        System.assertEquals(opp1.Id, asts[0].Opportunity__c);
+        System.assertEquals(True, lcr1.CompetitorAsset1__c <> null);
+        System.assertEquals(prd1.Id, lcr1.CompetitorAsset1__r.Product2Id);
         
-//         // update1
-//         lcr1.CompetitorProduct1__c = prd2.Id;
-//         update lcr1;
-//         lcr1 = [Select Id, CompetitorAsset1__c, CompetitorAsset1__r.Product2Id from Lost_cancel_report__c where Id = :lcr1.Id];
-//         System.assertEquals(True, lcr1.CompetitorAsset1__c <> null);
-//         System.assertEquals(prd2.Id, lcr1.CompetitorAsset1__r.Product2Id);
+        // update1
+        lcr1.CompetitorProduct1__c = prd2.Id;
+        update lcr1;
+        lcr1 = [Select Id, CompetitorAsset1__c, CompetitorAsset1__r.Product2Id from Lost_cancel_report__c where Id = :lcr1.Id];
+        System.assertEquals(True, lcr1.CompetitorAsset1__c <> null);
+        System.assertEquals(prd2.Id, lcr1.CompetitorAsset1__r.Product2Id);
 
-//         // update2
-//         lcr1.CompetitorProduct2__c = prd1.Id;
-//         update lcr1;
-//         lcr1 = [Select Id, CompetitorAsset1__c, CompetitorAsset1__r.Product2Id,
-//                        CompetitorAsset2__c, CompetitorAsset2__r.Product2Id
-//                   from Lost_cancel_report__c where Id = :lcr1.Id];
-//         System.assertEquals(True, lcr1.CompetitorAsset1__c <> null);
-//         System.assertEquals(prd2.Id, lcr1.CompetitorAsset1__r.Product2Id);
-//         System.assertEquals(True, lcr1.CompetitorAsset2__c <> null);
-//         System.assertEquals(prd1.Id, lcr1.CompetitorAsset2__r.Product2Id);
+        // update2
+        lcr1.CompetitorProduct2__c = prd1.Id;
+        update lcr1;
+        lcr1 = [Select Id, CompetitorAsset1__c, CompetitorAsset1__r.Product2Id,
+                       CompetitorAsset2__c, CompetitorAsset2__r.Product2Id
+                  from Lost_cancel_report__c where Id = :lcr1.Id];
+        System.assertEquals(True, lcr1.CompetitorAsset1__c <> null);
+        System.assertEquals(prd2.Id, lcr1.CompetitorAsset1__r.Product2Id);
+        System.assertEquals(True, lcr1.CompetitorAsset2__c <> null);
+        System.assertEquals(prd1.Id, lcr1.CompetitorAsset2__r.Product2Id);
 
-//         // delete
-//         delete lcr1;
-//         asts = [Select Id from Asset where (Id = :lcr1.CompetitorAsset1__c or Id = :lcr1.CompetitorAsset2__c)];
-//         System.assertEquals(0, asts.size());
-//     }
+        // delete
+        delete lcr1;
+        asts = [Select Id from Asset where (Id = :lcr1.CompetitorAsset1__c or Id = :lcr1.CompetitorAsset2__c)];
+        System.assertEquals(0, asts.size());
+    }
 
-//     /**
-//      * 鏂拌銇椼仸1,2銆乽pdate銆佺鍚�1,2
-//      */
-//     static testMethod void testLostCancelReport2() {
-//         // recode type 銈掑彇寰�
-//         List<RecordType> rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '鐥呴櫌'];
-//         if (rectCo.size() == 0) {
-//             throw new ControllerUtil.myException('not found 鐥呴櫌 recodetype');
-//         }
-//         List<RecordType> rectSct = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '鎴︾暐绉戝鍒嗛 鍛煎惛绉�'];
-//         if (rectSct.size() == 0) {
-//             throw new ControllerUtil.myException('not found 鎴︾暐绉戝鍒嗛 recodetype');
-//         }
-//         List<RecordType> rectDpt = [select Id, Name from RecordType where IsActive = true and SobjectType = 'Account' and Name IN ('瑷虹檪绉� 娑堝寲绉�', '瑷虹檪绉� 鍛煎惛绉�') order by Name desc];
-//         if (rectDpt.size() == 0) {
-//             throw new ControllerUtil.myException('not found 瑷虹檪绉� recodetype');
-//         }
-//         List<RecordType> rectLost = [select Id, Name from RecordType where IsActive = true and SobjectType = 'Lost_cancel_report__c' and DeveloperName IN ('PCL_Lost_report', 'PCL_Cancel_report') order by DeveloperName desc];
-//         if (rectLost.size() == 0) {
-//             throw new ControllerUtil.myException('not found Lost_cancel_report recodetype');
-//         }
+    /**
+     * 鏂拌銇椼仸1,2銆乽pdate銆佺鍚�1,2
+     */
+    static testMethod void testLostCancelReport2() {
+        // recode type 銈掑彇寰�
+        List<RecordType> rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '鐥呴櫌'];
+        if (rectCo.size() == 0) {
+            throw new ControllerUtil.myException('not found 鐥呴櫌 recodetype');
+        }
+        List<RecordType> rectSct = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '鎴︾暐绉戝鍒嗛 鍛煎惛绉�'];
+        if (rectSct.size() == 0) {
+            throw new ControllerUtil.myException('not found 鎴︾暐绉戝鍒嗛 recodetype');
+        }
+        List<RecordType> rectDpt = [select Id, Name from RecordType where IsActive = true and SobjectType = 'Account' and Name IN ('瑷虹檪绉� 娑堝寲绉�', '瑷虹檪绉� 鍛煎惛绉�') order by Name desc];
+        if (rectDpt.size() == 0) {
+            throw new ControllerUtil.myException('not found 瑷虹檪绉� recodetype');
+        }
+        List<RecordType> rectLost = [select Id, Name from RecordType where IsActive = true and SobjectType = 'Lost_cancel_report__c' and DeveloperName IN ('PCL_Lost_report', 'PCL_Cancel_report') order by DeveloperName desc];
+        if (rectLost.size() == 0) {
+            throw new ControllerUtil.myException('not found Lost_cancel_report recodetype');
+        }
 
-//         // insert
-//         Account company1 = new Account();
-//         Account company2 = new Account();
-//         company1.RecordTypeId = rectCo[0].Id;
-//         company1.Name = '鐥呴櫌銉嗐偣銉�1';
-//         company2.RecordTypeId = rectCo[0].Id;
-//         company2.Name = '鐥呴櫌銉嗐偣銉�2';
-//         insert new Account[] {company1, company2};
+        // insert
+        Account company1 = new Account();
+        Account company2 = new Account();
+        company1.RecordTypeId = rectCo[0].Id;
+        company1.Name = '鐥呴櫌銉嗐偣銉�1';
+        company2.RecordTypeId = rectCo[0].Id;
+        company2.Name = '鐥呴櫌銉嗐偣銉�2';
+        insert new Account[] {company1, company2};
 
-//         List<Account> dc1s = [Select Id, Name, Department_Class_Label__c, Sys_Dept_Name_Change_Chk__c from Account where Parent.Id = :company1.Id order by Department_Class_Label__c];
-//         List<Account> dc2s = [Select Id, Name, Department_Class_Label__c, Sys_Dept_Name_Change_Chk__c from Account where Parent.Id = :company2.Id order by Department_Class_Label__c];
+        List<Account> dc1s = [Select Id, Name, Department_Class_Label__c, Sys_Dept_Name_Change_Chk__c from Account where Parent.Id = :company1.Id order by Department_Class_Label__c];
+        List<Account> dc2s = [Select Id, Name, Department_Class_Label__c, Sys_Dept_Name_Change_Chk__c from Account where Parent.Id = :company2.Id order by Department_Class_Label__c];
 
-//         Account depart1 = new Account();
-//         depart1.RecordTypeId = rectDpt[0].Id;
-//         depart1.Name         = '*';
-//         depart1.Department_Name__c  = '瑷虹檪绉�1';
-//         depart1.ParentId            = dc1s[0].Id;
-//         depart1.Department_Class__c = dc1s[0].Id;
-//         depart1.Hospital__c         = company1.Id;
+        Account depart1 = new Account();
+        depart1.RecordTypeId = rectDpt[0].Id;
+        depart1.Name         = '*';
+        depart1.Department_Name__c  = '瑷虹檪绉�1';
+        depart1.ParentId            = dc1s[0].Id;
+        depart1.Department_Class__c = dc1s[0].Id;
+        depart1.Hospital__c         = company1.Id;
 
-//         Account depart2 = new Account();
-//         depart2.RecordTypeId = rectDpt[1].Id;
-//         depart2.Name         = '*';
-//         depart2.Department_Name__c  = '瑷虹檪绉�2';
-//         depart2.ParentId            = dc2s[1].Id;
-//         depart2.Department_Class__c = dc2s[1].Id;
-//         depart2.Hospital__c         = company2.Id;
+        Account depart2 = new Account();
+        depart2.RecordTypeId = rectDpt[1].Id;
+        depart2.Name         = '*';
+        depart2.Department_Name__c  = '瑷虹檪绉�2';
+        depart2.ParentId            = dc2s[1].Id;
+        depart2.Department_Class__c = dc2s[1].Id;
+        depart2.Hospital__c         = company2.Id;
 
-//         insert new Account[] {depart1, depart2};
+        insert new Account[] {depart1, depart2};
 
-//         // 銇俱仛銇层仺銇よ拷鍔�
-//         List<Product2> prdList = new List<Product2>();
-//         Product2 prd1 = new Product2();
-//         prd1.ProductCode_Ext__c     = 'HistoryPrd1';
-//         prd1.ProductCode            = 'HistoryPrd1';
-//         prd1.Repair_Product_Code__c = 'HistoryPrd1_RP';
-//         prd1.Name                   = 'HistoryPrd1';
-//         prd1.Manual_Entry__c        = true;
-//         Product2 prd2 = new Product2();
-//         prd2.ProductCode_Ext__c     = 'HistoryPrd2';
-//         prd2.ProductCode            = 'HistoryPrd2';
-//         prd2.Repair_Product_Code__c = 'HistoryPrd2_RP';
-//         prd2.Name                   = 'HistoryPrd2';
-//         prd2.Manual_Entry__c        = true;
-//         insert new Product2[] {prd1, prd2};
+        // 銇俱仛銇层仺銇よ拷鍔�
+        List<Product2> prdList = new List<Product2>();
+        Product2 prd1 = new Product2();
+        prd1.ProductCode_Ext__c     = 'HistoryPrd1';
+        prd1.ProductCode            = 'HistoryPrd1';
+        prd1.Repair_Product_Code__c = 'HistoryPrd1_RP';
+        prd1.Name                   = 'HistoryPrd1';
+        prd1.Manual_Entry__c        = true;
+        Product2 prd2 = new Product2();
+        prd2.ProductCode_Ext__c     = 'HistoryPrd2';
+        prd2.ProductCode            = 'HistoryPrd2';
+        prd2.Repair_Product_Code__c = 'HistoryPrd2_RP';
+        prd2.Name                   = 'HistoryPrd2';
+        prd2.Manual_Entry__c        = true;
+        insert new Product2[] {prd1, prd2};
 
-//         // 鍟嗚珖
-//         Opportunity opp1 = new Opportunity(Name='aiueo', StageName='contact', CloseDate=Date.today(),
-//             Hospital__c = company1.Id,
-//             Department_Class__c = dc1s[0].Id,
-//             AccountId = depart1.Id
-//         );
-//         Opportunity opp2 = new Opportunity(Name='aiueo', StageName='contact', CloseDate=Date.today(),
-//             Hospital__c = company2.Id,
-//             Department_Class__c = dc2s[0].Id,
-//             AccountId = depart2.Id
-//         );
-//         insert new Opportunity[] {opp1, opp2};
+        // 鍟嗚珖
+        Opportunity opp1 = new Opportunity(Name='aiueo', StageName='contact', CloseDate=Date.today(),
+            Hospital__c = company1.Id,
+            Department_Class__c = dc1s[0].Id,
+            AccountId = depart1.Id
+        );
+        Opportunity opp2 = new Opportunity(Name='aiueo', StageName='contact', CloseDate=Date.today(),
+            Hospital__c = company2.Id,
+            Department_Class__c = dc2s[0].Id,
+            AccountId = depart2.Id
+        );
+        insert new Opportunity[] {opp1, opp2};
 
-//         // 澶卞崟
-//         Lost_cancel_report__c lcr1 = new Lost_cancel_report__c(
-//             Opportunity__c = opp1.Id, 
-//             CompetitorProduct1__c = prd1.Id,
-//             CompetitorProduct2__c = prd2.Id,
-//             RecordTypeId = rectLost[0].Id
-//         );
-//         // 鍙栨秷
-//         Lost_cancel_report__c lcr2 = new Lost_cancel_report__c(
-//             Opportunity__c = opp2.Id, 
-//             RecordTypeId = rectLost[1].Id
-//         );
-//         insert new Lost_cancel_report__c[] {lcr1, lcr2};
+        // 澶卞崟
+        Lost_cancel_report__c lcr1 = new Lost_cancel_report__c(
+            Opportunity__c = opp1.Id, 
+            CompetitorProduct1__c = prd1.Id,
+            CompetitorProduct2__c = prd2.Id,
+            RecordTypeId = rectLost[0].Id
+        );
+        // 鍙栨秷
+        Lost_cancel_report__c lcr2 = new Lost_cancel_report__c(
+            Opportunity__c = opp2.Id, 
+            RecordTypeId = rectLost[1].Id
+        );
+        insert new Lost_cancel_report__c[] {lcr1, lcr2};
         
-//         // Assert
-//         lcr1 = [Select Id, CompetitorAsset1__c, CompetitorAsset1__r.Product2Id,
-//                        CompetitorAsset2__c, CompetitorAsset2__r.Product2Id
-//                   from Lost_cancel_report__c where Id = :lcr1.Id];
-//         lcr2 = [Select Id, CompetitorAsset2__c from Lost_cancel_report__c where Id = :lcr2.Id];
-//         List<Asset> asts = [Select Id, Opportunity__c from Asset where Id = :lcr1.CompetitorAsset2__c];
-//         System.assertEquals(False, lcr2.CompetitorAsset2__c <> null);
-//         System.assertEquals(1, asts.size());
-//         System.assertEquals(opp1.Id, asts[0].Opportunity__c);
-//         System.assertEquals(True, lcr1.CompetitorAsset1__c <> null);
-//         System.assertEquals(prd1.Id, lcr1.CompetitorAsset1__r.Product2Id);
-//         System.assertEquals(True, lcr1.CompetitorAsset2__c <> null);
-//         System.assertEquals(prd2.Id, lcr1.CompetitorAsset2__r.Product2Id);
+        // Assert
+        lcr1 = [Select Id, CompetitorAsset1__c, CompetitorAsset1__r.Product2Id,
+                       CompetitorAsset2__c, CompetitorAsset2__r.Product2Id
+                  from Lost_cancel_report__c where Id = :lcr1.Id];
+        lcr2 = [Select Id, CompetitorAsset2__c from Lost_cancel_report__c where Id = :lcr2.Id];
+        List<Asset> asts = [Select Id, Opportunity__c from Asset where Id = :lcr1.CompetitorAsset2__c];
+        System.assertEquals(False, lcr2.CompetitorAsset2__c <> null);
+        System.assertEquals(1, asts.size());
+        System.assertEquals(opp1.Id, asts[0].Opportunity__c);
+        System.assertEquals(True, lcr1.CompetitorAsset1__c <> null);
+        System.assertEquals(prd1.Id, lcr1.CompetitorAsset1__r.Product2Id);
+        System.assertEquals(True, lcr1.CompetitorAsset2__c <> null);
+        System.assertEquals(prd2.Id, lcr1.CompetitorAsset2__r.Product2Id);
         
-//         // update
-//         lcr1.CompetitorProduct1__c = prd2.Id;
-//         lcr1.CompetitorProduct2__c = prd1.Id;
-//         update lcr1;
-//         lcr1 = [Select Id, CompetitorAsset1__c, CompetitorAsset1__r.Product2Id,
-//                        CompetitorAsset2__c, CompetitorAsset2__r.Product2Id
-//                   from Lost_cancel_report__c where Id = :lcr1.Id];
-//         System.assertEquals(True, lcr1.CompetitorAsset2__c <> null);
-//         System.assertEquals(prd1.Id, lcr1.CompetitorAsset2__r.Product2Id);
-//         System.assertEquals(True, lcr1.CompetitorAsset1__c <> null);
-//         System.assertEquals(prd2.Id, lcr1.CompetitorAsset1__r.Product2Id);
+        // update
+        lcr1.CompetitorProduct1__c = prd2.Id;
+        lcr1.CompetitorProduct2__c = prd1.Id;
+        update lcr1;
+        lcr1 = [Select Id, CompetitorAsset1__c, CompetitorAsset1__r.Product2Id,
+                       CompetitorAsset2__c, CompetitorAsset2__r.Product2Id
+                  from Lost_cancel_report__c where Id = :lcr1.Id];
+        System.assertEquals(True, lcr1.CompetitorAsset2__c <> null);
+        System.assertEquals(prd1.Id, lcr1.CompetitorAsset2__r.Product2Id);
+        System.assertEquals(True, lcr1.CompetitorAsset1__c <> null);
+        System.assertEquals(prd2.Id, lcr1.CompetitorAsset1__r.Product2Id);
 
-//         // delete
-//         delete lcr1;
-//         asts = [Select Id from Asset where (Id = :lcr1.CompetitorAsset1__c or Id = :lcr1.CompetitorAsset2__c)];
-//         System.assertEquals(0, asts.size());
-//     }
+        // delete
+        delete lcr1;
+        asts = [Select Id from Asset where (Id = :lcr1.CompetitorAsset1__c or Id = :lcr1.CompetitorAsset2__c)];
+        System.assertEquals(0, asts.size());
+    }
 
-//     /**
-//      * 鏂拌銇椼仸銆乽pdate銆佺鍚�3
-//      * update銆佺鍚�4
-//      */
-//     static testMethod void testLostCancelReport3() {
-//         // recode type 銈掑彇寰�
-//         List<RecordType> rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '鐥呴櫌'];
-//         if (rectCo.size() == 0) {
-//             throw new ControllerUtil.myException('not found 鐥呴櫌 recodetype');
-//         }
-//         List<RecordType> rectSct = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '鎴︾暐绉戝鍒嗛 鍛煎惛绉�'];
-//         if (rectSct.size() == 0) {
-//             throw new ControllerUtil.myException('not found 鎴︾暐绉戝鍒嗛 recodetype');
-//         }
-//         List<RecordType> rectDpt = [select Id, Name from RecordType where IsActive = true and SobjectType = 'Account' and Name IN ('瑷虹檪绉� 娑堝寲绉�', '瑷虹檪绉� 鍛煎惛绉�') order by Name desc];
-//         if (rectDpt.size() == 0) {
-//             throw new ControllerUtil.myException('not found 瑷虹檪绉� recodetype');
-//         }
-//         List<RecordType> rectLost = [select Id, Name from RecordType where IsActive = true and SobjectType = 'Lost_cancel_report__c' and DeveloperName IN ('PCL_Lost_report', 'PCL_Cancel_report') order by DeveloperName desc];
-//         if (rectLost.size() == 0) {
-//             throw new ControllerUtil.myException('not found Lost_cancel_report recodetype');
-//         }
+    /**
+     * 鏂拌銇椼仸銆乽pdate銆佺鍚�3
+     * update銆佺鍚�4
+     */
+    static testMethod void testLostCancelReport3() {
+        // recode type 銈掑彇寰�
+        List<RecordType> rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '鐥呴櫌'];
+        if (rectCo.size() == 0) {
+            throw new ControllerUtil.myException('not found 鐥呴櫌 recodetype');
+        }
+        List<RecordType> rectSct = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '鎴︾暐绉戝鍒嗛 鍛煎惛绉�'];
+        if (rectSct.size() == 0) {
+            throw new ControllerUtil.myException('not found 鎴︾暐绉戝鍒嗛 recodetype');
+        }
+        List<RecordType> rectDpt = [select Id, Name from RecordType where IsActive = true and SobjectType = 'Account' and Name IN ('瑷虹檪绉� 娑堝寲绉�', '瑷虹檪绉� 鍛煎惛绉�') order by Name desc];
+        if (rectDpt.size() == 0) {
+            throw new ControllerUtil.myException('not found 瑷虹檪绉� recodetype');
+        }
+        List<RecordType> rectLost = [select Id, Name from RecordType where IsActive = true and SobjectType = 'Lost_cancel_report__c' and DeveloperName IN ('PCL_Lost_report', 'PCL_Cancel_report') order by DeveloperName desc];
+        if (rectLost.size() == 0) {
+            throw new ControllerUtil.myException('not found Lost_cancel_report recodetype');
+        }
 
-//         // insert
-//         Account company1 = new Account();
-//         Account company2 = new Account();
-//         company1.RecordTypeId = rectCo[0].Id;
-//         company1.Name = '鐥呴櫌銉嗐偣銉�1';
-//         company2.RecordTypeId = rectCo[0].Id;
-//         company2.Name = '鐥呴櫌銉嗐偣銉�2';
-//         insert new Account[] {company1, company2};
+        // insert
+        Account company1 = new Account();
+        Account company2 = new Account();
+        company1.RecordTypeId = rectCo[0].Id;
+        company1.Name = '鐥呴櫌銉嗐偣銉�1';
+        company2.RecordTypeId = rectCo[0].Id;
+        company2.Name = '鐥呴櫌銉嗐偣銉�2';
+        insert new Account[] {company1, company2};
 
-//         List<Account> dc1s = [Select Id, Name, Department_Class_Label__c, Sys_Dept_Name_Change_Chk__c from Account where Parent.Id = :company1.Id order by Department_Class_Label__c];
-//         List<Account> dc2s = [Select Id, Name, Department_Class_Label__c, Sys_Dept_Name_Change_Chk__c from Account where Parent.Id = :company2.Id order by Department_Class_Label__c];
+        List<Account> dc1s = [Select Id, Name, Department_Class_Label__c, Sys_Dept_Name_Change_Chk__c from Account where Parent.Id = :company1.Id order by Department_Class_Label__c];
+        List<Account> dc2s = [Select Id, Name, Department_Class_Label__c, Sys_Dept_Name_Change_Chk__c from Account where Parent.Id = :company2.Id order by Department_Class_Label__c];
 
-//         Account depart1 = new Account();
-//         depart1.RecordTypeId = rectDpt[0].Id;
-//         depart1.Name         = '*';
-//         depart1.Department_Name__c  = '瑷虹檪绉�1';
-//         depart1.ParentId            = dc1s[0].Id;
-//         depart1.Department_Class__c = dc1s[0].Id;
-//         depart1.Hospital__c         = company1.Id;
+        Account depart1 = new Account();
+        depart1.RecordTypeId = rectDpt[0].Id;
+        depart1.Name         = '*';
+        depart1.Department_Name__c  = '瑷虹檪绉�1';
+        depart1.ParentId            = dc1s[0].Id;
+        depart1.Department_Class__c = dc1s[0].Id;
+        depart1.Hospital__c         = company1.Id;
 
-//         Account depart2 = new Account();
-//         depart2.RecordTypeId = rectDpt[1].Id;
-//         depart2.Name         = '*';
-//         depart2.Department_Name__c  = '瑷虹檪绉�2';
-//         depart2.ParentId            = dc2s[1].Id;
-//         depart2.Department_Class__c = dc2s[1].Id;
-//         depart2.Hospital__c         = company2.Id;
+        Account depart2 = new Account();
+        depart2.RecordTypeId = rectDpt[1].Id;
+        depart2.Name         = '*';
+        depart2.Department_Name__c  = '瑷虹檪绉�2';
+        depart2.ParentId            = dc2s[1].Id;
+        depart2.Department_Class__c = dc2s[1].Id;
+        depart2.Hospital__c         = company2.Id;
 
-//         insert new Account[] {depart1, depart2};
+        insert new Account[] {depart1, depart2};
 
-//         // 銇俱仛銇层仺銇よ拷鍔�
-//         List<Product2> prdList = new List<Product2>();
-//         Product2 prd1 = new Product2();
-//         prd1.ProductCode_Ext__c     = 'HistoryPrd1';
-//         prd1.ProductCode            = 'HistoryPrd1';
-//         prd1.Repair_Product_Code__c = 'HistoryPrd1_RP';
-//         prd1.Name                   = 'HistoryPrd1';
-//         prd1.Manual_Entry__c        = true;
-//         Product2 prd2 = new Product2();
-//         prd2.ProductCode_Ext__c     = 'HistoryPrd2';
-//         prd2.ProductCode            = 'HistoryPrd2';
-//         prd2.Repair_Product_Code__c = 'HistoryPrd2_RP';
-//         prd2.Name                   = 'HistoryPrd2';
-//         prd2.Manual_Entry__c        = true;
-//         insert new Product2[] {prd1, prd2};
+        // 銇俱仛銇层仺銇よ拷鍔�
+        List<Product2> prdList = new List<Product2>();
+        Product2 prd1 = new Product2();
+        prd1.ProductCode_Ext__c     = 'HistoryPrd1';
+        prd1.ProductCode            = 'HistoryPrd1';
+        prd1.Repair_Product_Code__c = 'HistoryPrd1_RP';
+        prd1.Name                   = 'HistoryPrd1';
+        prd1.Manual_Entry__c        = true;
+        Product2 prd2 = new Product2();
+        prd2.ProductCode_Ext__c     = 'HistoryPrd2';
+        prd2.ProductCode            = 'HistoryPrd2';
+        prd2.Repair_Product_Code__c = 'HistoryPrd2_RP';
+        prd2.Name                   = 'HistoryPrd2';
+        prd2.Manual_Entry__c        = true;
+        insert new Product2[] {prd1, prd2};
 
-//         // 鍟嗚珖
-//         Opportunity opp1 = new Opportunity(Name='aiueo', StageName='contact', CloseDate=Date.today(),
-//             Hospital__c = company1.Id,
-//             Department_Class__c = dc1s[0].Id,
-//             AccountId = depart1.Id
-//         );
-//         Opportunity opp2 = new Opportunity(Name='aiueo', StageName='contact', CloseDate=Date.today(),
-//             Hospital__c = company2.Id,
-//             Department_Class__c = dc2s[0].Id,
-//             AccountId = depart2.Id
-//         );
-//         insert new Opportunity[] {opp1, opp2};
+        // 鍟嗚珖
+        Opportunity opp1 = new Opportunity(Name='aiueo', StageName='contact', CloseDate=Date.today(),
+            Hospital__c = company1.Id,
+            Department_Class__c = dc1s[0].Id,
+            AccountId = depart1.Id
+        );
+        Opportunity opp2 = new Opportunity(Name='aiueo', StageName='contact', CloseDate=Date.today(),
+            Hospital__c = company2.Id,
+            Department_Class__c = dc2s[0].Id,
+            AccountId = depart2.Id
+        );
+        insert new Opportunity[] {opp1, opp2};
 
-//         // 澶卞崟
-//         Lost_cancel_report__c lcr1 = new Lost_cancel_report__c(
-//             Opportunity__c = opp1.Id, 
-//             CompetitorProduct3__c = prd1.Id,
-//             RecordTypeId = rectLost[0].Id
-//         );
-//         // 鍙栨秷
-//         Lost_cancel_report__c lcr2 = new Lost_cancel_report__c(
-//             Opportunity__c = opp2.Id, 
-//             CompetitorProduct3__c = prd2.Id,
-//             RecordTypeId = rectLost[1].Id
-//         );
-//         insert new Lost_cancel_report__c[] {lcr1, lcr2};
+        // 澶卞崟
+        Lost_cancel_report__c lcr1 = new Lost_cancel_report__c(
+            Opportunity__c = opp1.Id, 
+            CompetitorProduct3__c = prd1.Id,
+            RecordTypeId = rectLost[0].Id
+        );
+        // 鍙栨秷
+        Lost_cancel_report__c lcr2 = new Lost_cancel_report__c(
+            Opportunity__c = opp2.Id, 
+            CompetitorProduct3__c = prd2.Id,
+            RecordTypeId = rectLost[1].Id
+        );
+        insert new Lost_cancel_report__c[] {lcr1, lcr2};
         
-//         // Assert
-//         lcr1 = [Select Id, CompetitorAsset3__c, CompetitorAsset3__r.Product2Id from Lost_cancel_report__c where Id = :lcr1.Id];
-//         lcr2 = [Select Id, CompetitorAsset3__c from Lost_cancel_report__c where Id = :lcr2.Id];
-//         List<Asset> asts = [Select Id, Opportunity__c from Asset where Id = :lcr1.CompetitorAsset3__c];
-//         System.assertEquals(False, lcr2.CompetitorAsset3__c <> null);
-//         System.assertEquals(1, asts.size());
-//         System.assertEquals(opp1.Id, asts[0].Opportunity__c);
-//         System.assertEquals(True, lcr1.CompetitorAsset3__c <> null);
-//         System.assertEquals(prd1.Id, lcr1.CompetitorAsset3__r.Product2Id);
+        // Assert
+        lcr1 = [Select Id, CompetitorAsset3__c, CompetitorAsset3__r.Product2Id from Lost_cancel_report__c where Id = :lcr1.Id];
+        lcr2 = [Select Id, CompetitorAsset3__c from Lost_cancel_report__c where Id = :lcr2.Id];
+        List<Asset> asts = [Select Id, Opportunity__c from Asset where Id = :lcr1.CompetitorAsset3__c];
+        System.assertEquals(False, lcr2.CompetitorAsset3__c <> null);
+        System.assertEquals(1, asts.size());
+        System.assertEquals(opp1.Id, asts[0].Opportunity__c);
+        System.assertEquals(True, lcr1.CompetitorAsset3__c <> null);
+        System.assertEquals(prd1.Id, lcr1.CompetitorAsset3__r.Product2Id);
         
-//         // update3
-//         lcr1.CompetitorProduct3__c = prd2.Id;
-//         update lcr1;
-//         lcr1 = [Select Id, CompetitorAsset3__c, CompetitorAsset3__r.Product2Id from Lost_cancel_report__c where Id = :lcr1.Id];
-//         System.assertEquals(True, lcr1.CompetitorAsset3__c <> null);
-//         System.assertEquals(prd2.Id, lcr1.CompetitorAsset3__r.Product2Id);
+        // update3
+        lcr1.CompetitorProduct3__c = prd2.Id;
+        update lcr1;
+        lcr1 = [Select Id, CompetitorAsset3__c, CompetitorAsset3__r.Product2Id from Lost_cancel_report__c where Id = :lcr1.Id];
+        System.assertEquals(True, lcr1.CompetitorAsset3__c <> null);
+        System.assertEquals(prd2.Id, lcr1.CompetitorAsset3__r.Product2Id);
 
-//         // update4
-//         lcr1.CompetitorProduct4__c = prd1.Id;
-//         update lcr1;
-//         lcr1 = [Select Id,
-//                        CompetitorAsset3__c, CompetitorAsset3__r.Product2Id,
-//                        CompetitorAsset4__c, CompetitorAsset4__r.Product2Id
-//                   from Lost_cancel_report__c where Id = :lcr1.Id];
-//         System.assertEquals(True, lcr1.CompetitorAsset3__c <> null);
-//         System.assertEquals(prd2.Id, lcr1.CompetitorAsset3__r.Product2Id);
-//         System.assertEquals(True, lcr1.CompetitorAsset4__c <> null);
-//         System.assertEquals(prd1.Id, lcr1.CompetitorAsset4__r.Product2Id);
+        // update4
+        lcr1.CompetitorProduct4__c = prd1.Id;
+        update lcr1;
+        lcr1 = [Select Id,
+                       CompetitorAsset3__c, CompetitorAsset3__r.Product2Id,
+                       CompetitorAsset4__c, CompetitorAsset4__r.Product2Id
+                  from Lost_cancel_report__c where Id = :lcr1.Id];
+        System.assertEquals(True, lcr1.CompetitorAsset3__c <> null);
+        System.assertEquals(prd2.Id, lcr1.CompetitorAsset3__r.Product2Id);
+        System.assertEquals(True, lcr1.CompetitorAsset4__c <> null);
+        System.assertEquals(prd1.Id, lcr1.CompetitorAsset4__r.Product2Id);
 
-//         // delete
-//         delete lcr1;
-//         asts = [Select Id from Asset where (Id = :lcr1.CompetitorAsset3__c or Id = :lcr1.CompetitorAsset4__c)];
-//         System.assertEquals(0, asts.size());
-//     }
+        // delete
+        delete lcr1;
+        asts = [Select Id from Asset where (Id = :lcr1.CompetitorAsset3__c or Id = :lcr1.CompetitorAsset4__c)];
+        System.assertEquals(0, asts.size());
+    }
 
-//     /**
-//      * 鏂拌銇椼仸3,4銆乽pdate銆佺鍚�3,4
-//      */
-//     static testMethod void testLostCancelReport4() {
-//         // recode type 銈掑彇寰�
-//         List<RecordType> rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '鐥呴櫌'];
-//         if (rectCo.size() == 0) {
-//             throw new ControllerUtil.myException('not found 鐥呴櫌 recodetype');
-//         }
-//         List<RecordType> rectSct = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '鎴︾暐绉戝鍒嗛 鍛煎惛绉�'];
-//         if (rectSct.size() == 0) {
-//             throw new ControllerUtil.myException('not found 鎴︾暐绉戝鍒嗛 recodetype');
-//         }
-//         List<RecordType> rectDpt = [select Id, Name from RecordType where IsActive = true and SobjectType = 'Account' and Name IN ('瑷虹檪绉� 娑堝寲绉�', '瑷虹檪绉� 鍛煎惛绉�') order by Name desc];
-//         if (rectDpt.size() == 0) {
-//             throw new ControllerUtil.myException('not found 瑷虹檪绉� recodetype');
-//         }
-//         List<RecordType> rectLost = [select Id, Name from RecordType where IsActive = true and SobjectType = 'Lost_cancel_report__c' and DeveloperName IN ('PCL_Lost_report', 'PCL_Cancel_report') order by DeveloperName desc];
-//         if (rectLost.size() == 0) {
-//             throw new ControllerUtil.myException('not found Lost_cancel_report recodetype');
-//         }
+    /**
+     * 鏂拌銇椼仸3,4銆乽pdate銆佺鍚�3,4
+     */
+    static testMethod void testLostCancelReport4() {
+        // recode type 銈掑彇寰�
+        List<RecordType> rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '鐥呴櫌'];
+        if (rectCo.size() == 0) {
+            throw new ControllerUtil.myException('not found 鐥呴櫌 recodetype');
+        }
+        List<RecordType> rectSct = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '鎴︾暐绉戝鍒嗛 鍛煎惛绉�'];
+        if (rectSct.size() == 0) {
+            throw new ControllerUtil.myException('not found 鎴︾暐绉戝鍒嗛 recodetype');
+        }
+        List<RecordType> rectDpt = [select Id, Name from RecordType where IsActive = true and SobjectType = 'Account' and Name IN ('瑷虹檪绉� 娑堝寲绉�', '瑷虹檪绉� 鍛煎惛绉�') order by Name desc];
+        if (rectDpt.size() == 0) {
+            throw new ControllerUtil.myException('not found 瑷虹檪绉� recodetype');
+        }
+        List<RecordType> rectLost = [select Id, Name from RecordType where IsActive = true and SobjectType = 'Lost_cancel_report__c' and DeveloperName IN ('PCL_Lost_report', 'PCL_Cancel_report') order by DeveloperName desc];
+        if (rectLost.size() == 0) {
+            throw new ControllerUtil.myException('not found Lost_cancel_report recodetype');
+        }
 
-//         // insert
-//         Account company1 = new Account();
-//         Account company2 = new Account();
-//         company1.RecordTypeId = rectCo[0].Id;
-//         company1.Name = '鐥呴櫌銉嗐偣銉�1';
-//         company2.RecordTypeId = rectCo[0].Id;
-//         company2.Name = '鐥呴櫌銉嗐偣銉�2';
-//         insert new Account[] {company1, company2};
+        // insert
+        Account company1 = new Account();
+        Account company2 = new Account();
+        company1.RecordTypeId = rectCo[0].Id;
+        company1.Name = '鐥呴櫌銉嗐偣銉�1';
+        company2.RecordTypeId = rectCo[0].Id;
+        company2.Name = '鐥呴櫌銉嗐偣銉�2';
+        insert new Account[] {company1, company2};
 
-//         List<Account> dc1s = [Select Id, Name, Department_Class_Label__c, Sys_Dept_Name_Change_Chk__c from Account where Parent.Id = :company1.Id order by Department_Class_Label__c];
-//         List<Account> dc2s = [Select Id, Name, Department_Class_Label__c, Sys_Dept_Name_Change_Chk__c from Account where Parent.Id = :company2.Id order by Department_Class_Label__c];
+        List<Account> dc1s = [Select Id, Name, Department_Class_Label__c, Sys_Dept_Name_Change_Chk__c from Account where Parent.Id = :company1.Id order by Department_Class_Label__c];
+        List<Account> dc2s = [Select Id, Name, Department_Class_Label__c, Sys_Dept_Name_Change_Chk__c from Account where Parent.Id = :company2.Id order by Department_Class_Label__c];
 
-//         Account depart1 = new Account();
-//         depart1.RecordTypeId = rectDpt[0].Id;
-//         depart1.Name         = '*';
-//         depart1.Department_Name__c  = '瑷虹檪绉�1';
-//         depart1.ParentId            = dc1s[0].Id;
-//         depart1.Department_Class__c = dc1s[0].Id;
-//         depart1.Hospital__c         = company1.Id;
+        Account depart1 = new Account();
+        depart1.RecordTypeId = rectDpt[0].Id;
+        depart1.Name         = '*';
+        depart1.Department_Name__c  = '瑷虹檪绉�1';
+        depart1.ParentId            = dc1s[0].Id;
+        depart1.Department_Class__c = dc1s[0].Id;
+        depart1.Hospital__c         = company1.Id;
 
-//         Account depart2 = new Account();
-//         depart2.RecordTypeId = rectDpt[1].Id;
-//         depart2.Name         = '*';
-//         depart2.Department_Name__c  = '瑷虹檪绉�2';
-//         depart2.ParentId            = dc2s[1].Id;
-//         depart2.Department_Class__c = dc2s[1].Id;
-//         depart2.Hospital__c         = company2.Id;
+        Account depart2 = new Account();
+        depart2.RecordTypeId = rectDpt[1].Id;
+        depart2.Name         = '*';
+        depart2.Department_Name__c  = '瑷虹檪绉�2';
+        depart2.ParentId            = dc2s[1].Id;
+        depart2.Department_Class__c = dc2s[1].Id;
+        depart2.Hospital__c         = company2.Id;
 
-//         insert new Account[] {depart1, depart2};
+        insert new Account[] {depart1, depart2};
 
-//         // 銇俱仛銇层仺銇よ拷鍔�
-//         List<Product2> prdList = new List<Product2>();
-//         Product2 prd1 = new Product2();
-//         prd1.ProductCode_Ext__c     = 'HistoryPrd1';
-//         prd1.ProductCode            = 'HistoryPrd1';
-//         prd1.Repair_Product_Code__c = 'HistoryPrd1_RP';
-//         prd1.Name                   = 'HistoryPrd1';
-//         prd1.Manual_Entry__c        = true;
-//         Product2 prd2 = new Product2();
-//         prd2.ProductCode_Ext__c     = 'HistoryPrd2';
-//         prd2.ProductCode            = 'HistoryPrd2';
-//         prd2.Repair_Product_Code__c = 'HistoryPrd2_RP';
-//         prd2.Name                   = 'HistoryPrd2';
-//         prd2.Manual_Entry__c        = true;
-//         insert new Product2[] {prd1, prd2};
+        // 銇俱仛銇层仺銇よ拷鍔�
+        List<Product2> prdList = new List<Product2>();
+        Product2 prd1 = new Product2();
+        prd1.ProductCode_Ext__c     = 'HistoryPrd1';
+        prd1.ProductCode            = 'HistoryPrd1';
+        prd1.Repair_Product_Code__c = 'HistoryPrd1_RP';
+        prd1.Name                   = 'HistoryPrd1';
+        prd1.Manual_Entry__c        = true;
+        Product2 prd2 = new Product2();
+        prd2.ProductCode_Ext__c     = 'HistoryPrd2';
+        prd2.ProductCode            = 'HistoryPrd2';
+        prd2.Repair_Product_Code__c = 'HistoryPrd2_RP';
+        prd2.Name                   = 'HistoryPrd2';
+        prd2.Manual_Entry__c        = true;
+        insert new Product2[] {prd1, prd2};
 
-//         // 鍟嗚珖
-//         Opportunity opp1 = new Opportunity(Name='aiueo', StageName='contact', CloseDate=Date.today(),
-//             Hospital__c = company1.Id,
-//             Department_Class__c = dc1s[0].Id,
-//             AccountId = depart1.Id
-//         );
-//         Opportunity opp2 = new Opportunity(Name='aiueo', StageName='contact', CloseDate=Date.today(),
-//             Hospital__c = company2.Id,
-//             Department_Class__c = dc2s[0].Id,
-//             AccountId = depart2.Id
-//         );
-//         insert new Opportunity[] {opp1, opp2};
+        // 鍟嗚珖
+        Opportunity opp1 = new Opportunity(Name='aiueo', StageName='contact', CloseDate=Date.today(),
+            Hospital__c = company1.Id,
+            Department_Class__c = dc1s[0].Id,
+            AccountId = depart1.Id
+        );
+        Opportunity opp2 = new Opportunity(Name='aiueo', StageName='contact', CloseDate=Date.today(),
+            Hospital__c = company2.Id,
+            Department_Class__c = dc2s[0].Id,
+            AccountId = depart2.Id
+        );
+        insert new Opportunity[] {opp1, opp2};
 
-//         // 澶卞崟
-//         Lost_cancel_report__c lcr1 = new Lost_cancel_report__c(
-//             Opportunity__c = opp1.Id, 
-//             CompetitorProduct3__c = prd1.Id,
-//             CompetitorProduct4__c = prd2.Id,
-//             RecordTypeId = rectLost[0].Id
-//         );
-//         // 鍙栨秷
-//         Lost_cancel_report__c lcr2 = new Lost_cancel_report__c(
-//             Opportunity__c = opp2.Id, 
-//             RecordTypeId = rectLost[1].Id
-//         );
-//         insert new Lost_cancel_report__c[] {lcr1, lcr2};
+        // 澶卞崟
+        Lost_cancel_report__c lcr1 = new Lost_cancel_report__c(
+            Opportunity__c = opp1.Id, 
+            CompetitorProduct3__c = prd1.Id,
+            CompetitorProduct4__c = prd2.Id,
+            RecordTypeId = rectLost[0].Id
+        );
+        // 鍙栨秷
+        Lost_cancel_report__c lcr2 = new Lost_cancel_report__c(
+            Opportunity__c = opp2.Id, 
+            RecordTypeId = rectLost[1].Id
+        );
+        insert new Lost_cancel_report__c[] {lcr1, lcr2};
         
-//         // Assert
-//         lcr1 = [Select Id, CompetitorAsset3__c, CompetitorAsset3__r.Product2Id,
-//                        CompetitorAsset4__c, CompetitorAsset4__r.Product2Id
-//                   from Lost_cancel_report__c where Id = :lcr1.Id];
-//         lcr2 = [Select Id, CompetitorAsset4__c from Lost_cancel_report__c where Id = :lcr2.Id];
-//         List<Asset> asts = [Select Id, Opportunity__c from Asset where Id = :lcr1.CompetitorAsset4__c];
-//         System.assertEquals(False, lcr2.CompetitorAsset4__c <> null);
-//         System.assertEquals(1, asts.size());
-//         System.assertEquals(opp1.Id, asts[0].Opportunity__c);
-//         System.assertEquals(True, lcr1.CompetitorAsset3__c <> null);
-//         System.assertEquals(prd1.Id, lcr1.CompetitorAsset3__r.Product2Id);
-//         System.assertEquals(True, lcr1.CompetitorAsset4__c <> null);
-//         System.assertEquals(prd2.Id, lcr1.CompetitorAsset4__r.Product2Id);
+        // Assert
+        lcr1 = [Select Id, CompetitorAsset3__c, CompetitorAsset3__r.Product2Id,
+                       CompetitorAsset4__c, CompetitorAsset4__r.Product2Id
+                  from Lost_cancel_report__c where Id = :lcr1.Id];
+        lcr2 = [Select Id, CompetitorAsset4__c from Lost_cancel_report__c where Id = :lcr2.Id];
+        List<Asset> asts = [Select Id, Opportunity__c from Asset where Id = :lcr1.CompetitorAsset4__c];
+        System.assertEquals(False, lcr2.CompetitorAsset4__c <> null);
+        System.assertEquals(1, asts.size());
+        System.assertEquals(opp1.Id, asts[0].Opportunity__c);
+        System.assertEquals(True, lcr1.CompetitorAsset3__c <> null);
+        System.assertEquals(prd1.Id, lcr1.CompetitorAsset3__r.Product2Id);
+        System.assertEquals(True, lcr1.CompetitorAsset4__c <> null);
+        System.assertEquals(prd2.Id, lcr1.CompetitorAsset4__r.Product2Id);
         
-//         // update
-//         lcr1.CompetitorProduct3__c = prd2.Id;
-//         lcr1.CompetitorProduct4__c = prd1.Id;
-//         update lcr1;
-//         lcr1 = [Select Id, CompetitorAsset3__c, CompetitorAsset3__r.Product2Id,
-//                        CompetitorAsset4__c, CompetitorAsset4__r.Product2Id
-//                   from Lost_cancel_report__c where Id = :lcr1.Id];
-//         System.assertEquals(True, lcr1.CompetitorAsset4__c <> null);
-//         System.assertEquals(prd1.Id, lcr1.CompetitorAsset4__r.Product2Id);
-//         System.assertEquals(True, lcr1.CompetitorAsset3__c <> null);
-//         System.assertEquals(prd2.Id, lcr1.CompetitorAsset3__r.Product2Id);
+        // update
+        lcr1.CompetitorProduct3__c = prd2.Id;
+        lcr1.CompetitorProduct4__c = prd1.Id;
+        update lcr1;
+        lcr1 = [Select Id, CompetitorAsset3__c, CompetitorAsset3__r.Product2Id,
+                       CompetitorAsset4__c, CompetitorAsset4__r.Product2Id
+                  from Lost_cancel_report__c where Id = :lcr1.Id];
+        System.assertEquals(True, lcr1.CompetitorAsset4__c <> null);
+        System.assertEquals(prd1.Id, lcr1.CompetitorAsset4__r.Product2Id);
+        System.assertEquals(True, lcr1.CompetitorAsset3__c <> null);
+        System.assertEquals(prd2.Id, lcr1.CompetitorAsset3__r.Product2Id);
 
-//         // delete
-//         delete lcr1;
-//         asts = [Select Id from Asset where (Id = :lcr1.CompetitorAsset3__c or Id = :lcr1.CompetitorAsset4__c)];
-//         System.assertEquals(0, asts.size());
-//     }
- }
\ No newline at end of file
+        // delete
+        delete lcr1;
+        asts = [Select Id from Asset where (Id = :lcr1.CompetitorAsset3__c or Id = :lcr1.CompetitorAsset4__c)];
+        System.assertEquals(0, asts.size());
+    }
+}
\ No newline at end of file

--
Gitblit v1.9.1