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/LastbuyProductHandlerTest.cls | 175 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 175 insertions(+), 0 deletions(-)
diff --git a/force-app/main/default/classes/LastbuyProductHandlerTest.cls b/force-app/main/default/classes/LastbuyProductHandlerTest.cls
index 6bb9229..8ed4a42 100644
--- a/force-app/main/default/classes/LastbuyProductHandlerTest.cls
+++ b/force-app/main/default/classes/LastbuyProductHandlerTest.cls
@@ -2,14 +2,189 @@
private class LastbuyProductHandlerTest {
@isTest
static void TestMethod1() {
+
Product2 pro = new Product2();
pro.Name = 'Testname0215';
pro.LastbuyProductFLG__c = false;
insert pro;
+ Product2 pro1 = new Product2();
+ pro1.Name = 'Testname0216';
+ pro1.LastbuyProductFLG__c = false;
+ insert pro1;
+
+ 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 company = new Account();
+ company.Name = 'aiueo鐥呴櫌';
+ company.RecordTypeId = Schema.SObjectType.Account.getRecordTypeInfosByDeveloperName().get('HP').getRecordTypeId();
+ company.State_Master__c = al.Id;
+ company.City_Master__c = al2.Id;
+ insert company;
+
+ Account sct = [Select Id, Name, Department_Class_Label__c, Sys_Dept_Name_Change_Chk__c from Account where Parent.Id = :company.Id and RecordTypeId = :Schema.SObjectType.Account.getRecordTypeInfosByDeveloperName().get('Department_Class_BF').getRecordTypeId() Limit 1];
+
+ Account depart = new Account();
+ depart.RecordTypeId = Schema.SObjectType.Account.getRecordTypeInfosByDeveloperName().get('Department_BF').getRecordTypeId();
+ depart.Name = '*';
+ depart.Department_Name__c = 'aiueo瑷虹檪绉�';
+ depart.ParentId = sct.Id;
+ depart.Department_Class__c = sct.Id;
+ depart.Hospital__c = company.Id;
+ insert depart;
+ StaticParameter.EscapeOpportunityBefUpdTrigger = true;
+ Opportunity opp1 = new Opportunity(Name = 'aiueo鍟嗚珖', StageName = 'contact', CloseDate=Date.today(), SAP_Send_OK__c = false, AccountId = depart.Id);
+ insert opp1;
+
LastbuyProduct__c lbp = new LastbuyProduct__c();
lbp.Name = 'Test0215';
lbp.ProductName__c = pro.Id;
+ lbp.InquiryCode__c = opp1.Id;
+ lbp.effectiveFLG__c = true;
insert lbp;
+
+ lbp.effectiveFLG__c = false;
+ update lbp;
+
+ lbp.effectiveFLG__c = true;
+ update lbp;
+
+ delete lbp;
+ }
+
+ @isTest
+ static void TestMethod2() {
+
+ Product2 pro = new Product2();
+ pro.Name = 'Testname0215';
+ pro.LastbuyProductFLG__c = false;
+ insert pro;
+
+ 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 company = new Account();
+ company.Name = 'aiueo鐥呴櫌';
+ company.RecordTypeId = Schema.SObjectType.Account.getRecordTypeInfosByDeveloperName().get('HP').getRecordTypeId();
+ company.State_Master__c = al.Id;
+ company.City_Master__c = al2.Id;
+ insert company;
+
+ Account sct = [Select Id, Name, Department_Class_Label__c, Sys_Dept_Name_Change_Chk__c from Account where Parent.Id = :company.Id and RecordTypeId = :Schema.SObjectType.Account.getRecordTypeInfosByDeveloperName().get('Department_Class_BF').getRecordTypeId() Limit 1];
+
+ Account depart = new Account();
+ depart.RecordTypeId = Schema.SObjectType.Account.getRecordTypeInfosByDeveloperName().get('Department_BF').getRecordTypeId();
+ depart.Name = '*';
+ depart.Department_Name__c = 'aiueo瑷虹檪绉�';
+ depart.ParentId = sct.Id;
+ depart.Department_Class__c = sct.Id;
+ depart.Hospital__c = company.Id;
+ insert depart;
+ StaticParameter.EscapeOpportunityBefUpdTrigger = true;
+ Opportunity opp1 = new Opportunity(Name = 'aiueo鍟嗚珖', StageName = 'contact', CloseDate=Date.today(), SAP_Send_OK__c = true, AccountId = depart.Id);
+ insert opp1;
+
+ Opportunity opp2 = new Opportunity(Name = 'aiueo鍟嗚珖', StageName = 'contact', CloseDate=Date.today(), SAP_Send_OK__c = false, AccountId = depart.Id);
+ insert opp2;
+
+ LastbuyProduct__c lbp = new LastbuyProduct__c();
+ lbp.Name = 'Test0215';
+ lbp.ProductName__c = pro.Id;
+ lbp.InquiryCode__c = opp1.Id;
+ lbp.effectiveFLG__c = true;
+ insert lbp;
+
+ try{
+ lbp.InquiryCode__c = opp2.Id;
+ update lbp;
+ } catch (Exception e) {
+
+ }
+ }
+
+ @isTest
+ static void TestMethod3() {
+
+ Product2 pro = new Product2();
+ pro.Name = 'Testname0215';
+ pro.LastbuyProductFLG__c = false;
+ insert pro;
+
+ 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 company = new Account();
+ company.Name = 'aiueo鐥呴櫌';
+ company.RecordTypeId = Schema.SObjectType.Account.getRecordTypeInfosByDeveloperName().get('HP').getRecordTypeId();
+ company.State_Master__c = al.Id;
+ company.City_Master__c = al2.Id;
+ insert company;
+
+ Account sct = [Select Id, Name, Department_Class_Label__c, Sys_Dept_Name_Change_Chk__c from Account where Parent.Id = :company.Id and RecordTypeId = :Schema.SObjectType.Account.getRecordTypeInfosByDeveloperName().get('Department_Class_BF').getRecordTypeId() Limit 1];
+
+ Account depart = new Account();
+ depart.RecordTypeId = Schema.SObjectType.Account.getRecordTypeInfosByDeveloperName().get('Department_BF').getRecordTypeId();
+ depart.Name = '*';
+ depart.Department_Name__c = 'aiueo瑷虹檪绉�';
+ depart.ParentId = sct.Id;
+ depart.Department_Class__c = sct.Id;
+ depart.Hospital__c = company.Id;
+ insert depart;
+ StaticParameter.EscapeOpportunityBefUpdTrigger = true;
+ Opportunity opp1 = new Opportunity(Name = 'aiueo鍟嗚珖', StageName = 'contact', CloseDate=Date.today(), SAP_Send_OK__c = true, AccountId = depart.Id);
+ insert opp1;
+
+ LastbuyProduct__c lbp = new LastbuyProduct__c();
+ lbp.Name = 'Test0215';
+ lbp.ProductName__c = pro.Id;
+ lbp.InquiryCode__c = opp1.Id;
+ lbp.effectiveFLG__c = true;
+ insert lbp;
+
+ try{
+ delete lbp;
+ } catch (Exception e) {
+
+ }
}
}
\ No newline at end of file
--
Gitblit v1.9.1