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/AttachmentTriggerTest.cls | 200 +++++++++++++++++++++++++++++++++++++++-----------
1 files changed, 156 insertions(+), 44 deletions(-)
diff --git a/force-app/main/default/classes/AttachmentTriggerTest.cls b/force-app/main/default/classes/AttachmentTriggerTest.cls
index 9312c10..9d39928 100644
--- a/force-app/main/default/classes/AttachmentTriggerTest.cls
+++ b/force-app/main/default/classes/AttachmentTriggerTest.cls
@@ -1,5 +1,10 @@
@isTest
private class AttachmentTriggerTest {
+ @TestSetup
+ static void setup(){
+ TestDataUtility.CreatePIPolicyConfigurations(new string[]{'Agency_Contact__c','Contact'});
+ }
+
@isTest
static void test_method_one() {
@@ -52,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;
@@ -185,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 = '涓�绾�';
@@ -214,12 +219,22 @@
contact2.LastName = 'test1缁忛攢鍟�';
insert contact2;
+ Test.setMock(HttpCalloutMock.class, new HttpMock());
+
+ List<Agency_Contact__c> lra = new List<Agency_Contact__c>();
+ lra.add(new Agency_Contact__c(
+ Aws_Data_Id__c = '123456'
+ ));
+
System.Test.startTest();
+ AWSServiceTool2.EncryptPushCore(Json.serialize(lra),'Agency_Contact__c');
+ AWSServiceTool2.EncryptPushFuture(null,null);
//insert att1;
Attachment att = new Attachment(
Name = 'test',
ParentId = hospital.Id,
Body = EncodingUtil.base64Decode('test')
+
);
insert att;
@@ -279,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;
@@ -324,48 +339,50 @@
}
@isTest
static void test_method_6() {
- List<RecordType> rectC = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '鐥呴櫌'];
- if (rectC.size() == 0) {
- return;
+ User thisUser = [select Id from User where Id = :UserInfo.getUserId() ];
+ System.runAs ( thisUser ){
+ List<RecordType> rectC = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '鐥呴櫌'];
+ if (rectC.size() == 0) {
+ return;
+ }
+ Account act1 = new Account();
+ act1.Name = 'TestAccount01';
+ act1.RecordTypeId = rectC[0].Id;
+
+ upsert act1;
+
+ List<RecordType> rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '濂戠磩'];
+ if (rectCo.size() == 0) {
+ return;
+ }
+ Account act2 = new Account();
+ act2.Name = 'TestAccount02';
+ act2.Business_Assistant__c = getUser().id;
+ act2.RecordTypeId = rectCo[0].Id;
+ act2.ParentId = act1.Id;
+
+ upsert act2;
+
+ Consumable_order__c co = new Consumable_order__c();
+ co.Name = 'TestCo';
+ co.Order_status__c = '鑽夋涓�';
+ co.Order_effective_contact__c = act2.id;
+
+ insert co;
+ System.Test.startTest();
+
+ Attachment att = new Attachment(
+ Name = 'test',
+ ParentId = co.Id,
+ Body = EncodingUtil.base64Decode('test')
+ );
+
+ insert att;
+
+ delete att;
+
+ System.Test.stopTest();
}
- Account act1 = new Account();
- act1.Name = 'TestAccount01';
- act1.RecordTypeId = rectC[0].Id;
-
- upsert act1;
-
- List<RecordType> rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '濂戠磩'];
- if (rectCo.size() == 0) {
- return;
- }
- Account act2 = new Account();
- act2.Name = 'TestAccount02';
- act2.Business_Assistant__c = getUser().id;
- act2.RecordTypeId = rectCo[0].Id;
- act2.ParentId = act1.Id;
-
- upsert act2;
-
- Consumable_order__c co = new Consumable_order__c();
- co.Name = 'TestCo';
- co.Order_status__c = '鑽夋涓�';
- co.Order_effective_contact__c = act2.id;
-
- insert co;
- System.Test.startTest();
-
- Attachment att = new Attachment(
- Name = 'test',
- ParentId = co.Id,
- Body = EncodingUtil.base64Decode('test')
- );
-
- insert att;
-
- delete att;
-
- System.Test.stopTest();
-
}
@isTest
@@ -514,6 +531,70 @@
}
+ // 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');
User usr = new User(Test_staff__c = true, LastName = 'TestZY', FirstName = 'TestZY',
@@ -526,5 +607,36 @@
}
// MZY SWAG-BXXBKA 2021-02-19 end
+
+ class HttpMock implements HttpCalloutMock{
+ public HTTPResponse respond(HTTPRequest request) {
+ // 鍒涘缓涓�涓亣鐨勫洖搴�
+ System.debug('------------------------------------------------------');
+ HttpResponse response = new HttpResponse();
+ string body = '';
+ system.debug(request.getEndpoint());
+ if(request.getEndpoint().contains('token')){
+ system.debug('url=token');
+ response.setHeader('Content-Type', 'application/json');
+ body='{ "message": "", "object": "freqfewqfewewfewfew", "status": "", "success": true, "timestamp": 0, "txId": "" }';
+ } else if(request.getEndpoint().contains('insert')){
+ system.debug('url=Insert');
+ response.setHeader('Content-Type', 'application/json');
+ body='{ "message": "", "object": [ { "dataId": "123456", "directShippmentAddress": "", "directShippmentAddressEncrypt": "", "isDelete": 0, "phoneNumber": "", "phoneNumberEncrypt": "", "sfRecordId": "a2R1m0000007BPD" } ], "status": "", "success": true, "timestamp": 0, "txId": "" }';
+ } else if(request.getEndpoint().contains('update')){
+ system.debug('url=update');
+ response.setHeader('Content-Type', 'application/json');
+ body='{ "message": "", "object": [ { "dataId": "123456", "directShippmentAddress": "", "directShippmentAddressEncrypt": "", "isDelete": 0, "phoneNumber": "", "phoneNumberEncrypt": "", "sfRecordId": "a2R1m0000007BPD" } ], "status": "", "success": true, "timestamp": 0, "txId": "" }';
+ } else{
+
+ }
+
+ response.setBody(body);
+ response.setStatus('OK');
+ response.setStatusCode(200);
+ return response;
+ // }
+ }
+ }
}
\ No newline at end of file
--
Gitblit v1.9.1