From 8badb57ea2c82557850ad5b39281c3e8714eb119 Mon Sep 17 00:00:00 2001
From: liuyan <liuyan@prec-tech.com>
Date: 星期四, 24 十一月 2022 10:08:31 +0800
Subject: [PATCH] 科室信息漏传SPO问题
---
force-app/main/default/classes/InquiryFormHandlerTest.cls | 335 +++++++++++++++++++++++++++++++++++++++----------------
1 files changed, 239 insertions(+), 96 deletions(-)
diff --git a/force-app/main/default/classes/InquiryFormHandlerTest.cls b/force-app/main/default/classes/InquiryFormHandlerTest.cls
index 9afbbd0..7863d8d 100644
--- a/force-app/main/default/classes/InquiryFormHandlerTest.cls
+++ b/force-app/main/default/classes/InquiryFormHandlerTest.cls
@@ -1,83 +1,144 @@
@isTest
private class InquiryFormHandlerTest {
+ @TestSetup
+ static void setup(){
+ TestDataUtility.CreatePIPolicyConfiguration('Agency_Contact__c');
+ }
+
+ @isTest
+ static void Test1(){
+ Test.setMock(HttpCalloutMock.class, new HttpMock());
- static testMethod void testBeforeInsert() {
- //鍖婚櫌
- List<RecordType> rectHp = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and DeveloperName = 'HP'];
- if (rectHp.size() == 0) {
- return;
- }
- //绉戝
- List<RecordType> rectDpt = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and DeveloperName = 'Department_GI'];
- if (rectDpt.size() == 0) {
- return;
- }
-
+ List<Agency_Contact__c> lra = new List<Agency_Contact__c>();
+ lra.add(new Agency_Contact__c(
+ Id = 'a2R1m0000007BPD'
+ ));
+ Test.startTest();
+ //system.debug(PIHelper.getPIIntegrationInfo('Agency_Contact__c').newEncryptUrl);
+ AWSServiceTool2.EncryptPushCore(Json.serialize(lra),'Agency_Contact__c');
+ AWSServiceTool2.EncryptPushFuture(null,null);
+ Test.stopTest();
+ }
+
+ class HttpMock implements HttpCalloutMock{
- Profile p = [select Id from Profile where id =:System.Label.ProfileId_SystemAdmin];
+ 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;
+ // }
+ }
+ }
- User hpOwner = new User(Test_staff__c = true, LastName = 'hp', FirstName = 'owner', Alias = 'hp', Work_Location__c = '鍖椾含', CommunityNickname = 'hpOwner', Email = 'olympus_hpowner@sunbridge.com', Username = 'olympus_hpowner@sunbridge.com', IsActive = true, EmailEncodingKey = 'ISO-2022-JP', TimeZoneSidKey = 'Asia/Tokyo', LocaleSidKey = 'ja_JP', LanguageLocaleKey = 'ja', ProfileId = p.id);
- insert hpOwner;
- User hpOwner2 = new User(Test_staff__c = true, LastName = 'hp2', FirstName = 'owner', Alias = 'hp2', Work_Location__c = '閲嶅簡', CommunityNickname = 'hpOwner2', Email = 'olympus_hpowner@sunbridge.com', Username = 'olympus_hpowner2@sunbridge.com', IsActive = true, EmailEncodingKey = 'ISO-2022-JP', TimeZoneSidKey = 'Asia/Tokyo', LocaleSidKey = 'ja_JP', LanguageLocaleKey = 'ja', ProfileId = p.id);
- insert hpOwner2;
+ @isTest static void test_method_one() {
+ Profile p = [select Id from Profile where id =:System.Label.ProfileId_SystemAdmin];
-
-
- Account hp = new Account(RecordTypeId = rectHp[0].Id, Name = 'hp', OwnerId = hpOwner.Id);
- hp.FSE_GI_Main_Leader__c = hpOwner.Id;
- hp.FSE_SP_Main_Leader__c = hpOwner2.Id;
- insert hp;
-
- //鎴樼暐绉戝
- Account dc = [select Id, Name, RecordType_DeveloperName__c, Account2__c from Account where ParentId = :hp.Id and RecordType_DeveloperName__c = 'Department_Class_GI'];
-
- Account dpt = new Account(RecordTypeId = rectDpt[0].Id);
- dpt.Name = '*';
- dpt.Department_Name__c = 'TestDepart';
- dpt.ParentId = dc.Id;
- dpt.Department_Class__c = dc.Id;
- dpt.Hospital__c = hp.Id;
- insert dpt;
-
- Account dpt1 = new Account(RecordTypeId = rectDpt[0].Id);
- dpt1.Name = '*';
- dpt1.Department_Name__c = 'TestDepart1';
- dpt1.ParentId = dc.Id;
- dpt1.Department_Class__c = dc.Id;
- dpt1.Hospital__c = hp.Id;
- insert dpt1;
-
- Contact contact2 = new Contact();
- contact2.AccountId = dpt1.Id;
- contact2.FirstName = '璨换鑰�';
- contact2.LastName = 'test1缁忛攢鍟�';
- insert contact2;
+ User hpOwner = new User(Test_staff__c = true, LastName = 'hp', FirstName = 'owner', Alias = 'hp', Work_Location__c = '鍖椾含', CommunityNickname = 'hpOwner', Email = 'olympus_hpowner@sunbridge.com', Username = 'olympus_hpowner@sunbridge.com', IsActive = true, EmailEncodingKey = 'ISO-2022-JP', TimeZoneSidKey = 'Asia/Tokyo', LocaleSidKey = 'ja_JP', LanguageLocaleKey = 'ja', ProfileId = p.id);
+ insert hpOwner;
Inquiry_form__c inquiryform = new Inquiry_form__c();
- // inquiryform.Name = '2019102101';
- inquiryform.Hospital_Name__c = dpt1.Id;
- List<Account> dpecList = [select Id,Department_Class__c from Account where Id =: dpt1.Id];
- inquiryform.Department_Class__c = dpecList[0].Department_Class__c;
- inquiryform.Status__c ='鏈窡杩�';
- inquiryform.Company__c ='鍖椾含鏌愭煇鏌愭祴璇曞叕鍙�';
- inquiryform.Family_Name__c ='闈�';
- inquiryform.Opportunity_Division__c = '璇环';
- inquiryform.Contact_Name__c = contact2.Id;
- inquiryform.Reasons_options__c ='瀹㈡埛涓嶅瓨鍦�';
- inquiryform.Phone__c = '13844756322';
- inquiryform.Product1__c = '瓒呭0';
+ inquiryform.Name = '2019102101';
inquiryform.Request1__c = '闇�瑕佹姤浠�';
- Test.startTest();
+ inquiryform.Product1__c = '瓒呭0';
+ inquiryform.FSE_Owner__c = hpOwner.id;
insert inquiryform;
-
-
- Test.stopTest();
-
}
- static testMethod void testBeforeUpdate() {
- //鍖婚櫌
- List<RecordType> rectHp = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and DeveloperName = 'HP'];
+ // @isTest static void test_method_two() {
+ // //鍖婚櫌
+ // List<RecordType> rectHp = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and DeveloperName = 'HP'];
+ // if (rectHp.size() == 0) {
+ // return;
+ // }
+ // //绉戝
+ // List<RecordType> rectDpt = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and DeveloperName = 'Department_GI'];
+ // if (rectDpt.size() == 0) {
+ // return;
+ // }
+
+
+ // Profile p = [select Id from Profile where id =:System.Label.ProfileId_SystemAdmin];
+
+ // User hpOwner = new User(Test_staff__c = true, LastName = 'hp', FirstName = 'owner', Alias = 'hp', Work_Location__c = '鍖椾含', CommunityNickname = 'hpOwner', Email = 'olympus_hpowner@sunbridge.com', Username = 'olympus_hpowner@sunbridge.com', IsActive = true, EmailEncodingKey = 'ISO-2022-JP', TimeZoneSidKey = 'Asia/Tokyo', LocaleSidKey = 'ja_JP', LanguageLocaleKey = 'ja', ProfileId = p.id);
+ // insert hpOwner;
+ // User hpOwner2 = new User(Test_staff__c = true, LastName = 'hp2', FirstName = 'owner', Alias = 'hp2', Work_Location__c = '閲嶅簡', CommunityNickname = 'hpOwner2', Email = 'olympus_hpowner@sunbridge.com', Username = 'olympus_hpowner2@sunbridge.com', IsActive = true, EmailEncodingKey = 'ISO-2022-JP', TimeZoneSidKey = 'Asia/Tokyo', LocaleSidKey = 'ja_JP', LanguageLocaleKey = 'ja', ProfileId = p.id);
+ // insert hpOwner2;
+
+
+
+ // Account hp = new Account(RecordTypeId = rectHp[0].Id, Name = 'hp', OwnerId = hpOwner.Id);
+ // hp.FSE_GI_Main_Leader__c = hpOwner.Id;
+ // hp.FSE_SP_Main_Leader__c = hpOwner2.Id;
+ // insert hp;
+
+ // //鎴樼暐绉戝
+ // Account dc = [select Id, Name, RecordType_DeveloperName__c, Account2__c from Account where ParentId = :hp.Id and RecordType_DeveloperName__c = 'Department_Class_GI'];
+
+ // Account dpt = new Account(RecordTypeId = rectDpt[0].Id);
+ // dpt.Name = '*';
+ // dpt.Department_Name__c = 'TestDepart';
+ // dpt.ParentId = dc.Id;
+ // dpt.Department_Class__c = dc.Id;
+ // dpt.Hospital__c = hp.Id;
+ // insert dpt;
+
+ // Account dpt1 = new Account(RecordTypeId = rectDpt[0].Id);
+ // dpt1.Name = '*';
+ // dpt1.Department_Name__c = 'TestDepart1';
+ // dpt1.ParentId = dc.Id;
+ // dpt1.Department_Class__c = dc.Id;
+ // dpt1.Hospital__c = hp.Id;
+ // insert dpt1;
+
+ // Contact contact2 = new Contact();
+ // contact2.AccountId = dpt1.Id;
+ // contact2.FirstName = '璨换鑰�';
+ // contact2.LastName = 'test1缁忛攢鍟�';
+ // insert contact2;
+
+ // Inquiry_form__c inquiryform = new Inquiry_form__c();
+ // inquiryform.Name = '2019102101';
+ // inquiryform.Hospital_Name__c = dpt1.Id;
+ // inquiryform.Status__c ='01.鏈窡杩�';
+ // inquiryform.Family_Name__c ='闈�';
+ // inquiryform.Opportunity_Division__c = '璇环';
+ // inquiryform.Contact_Name__c = contact2.Id;
+ // inquiryform.Reasons_options__c ='瀹㈡埛鏃犳剰鍚�';
+ // inquiryform.Phone__c = '13844756322';
+ // inquiryform.Product1__c = '瓒呭0';
+ // inquiryform.Request1__c = '闇�瑕佹姤浠�';
+
+ // insert inquiryform;
+
+ // List<Inquiry_form__c> info= [select id,Hospital_Name__c,Contact_Name__c,Department_Class__c,Hospital__c,Hospital__r.Name,OwnerId from Inquiry_form__c where id =: inquiryform.Id];
+ // System.assertEquals(hp.Id, info[0].Hospital_Name__c);
+ // System.assertEquals('hp-瓒呭0', info[0].Name);
+ // }
+ @isTest static void test_method_three() {
+ //鍖婚櫌
+ List<RecordType> rectHp = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and DeveloperName = 'HP'];
if (rectHp.size() == 0) {
return;
}
@@ -88,16 +149,16 @@
}
- Profile p = [select Id from Profile where id =:System.Label.ProfileId_SystemAdmin];
+ Profile p = [select Id from Profile where id =:System.Label.ProfileId_SystemAdmin];
- User hpOwner = new User(Test_staff__c = true, LastName = 'hp', FirstName = 'owner', Alias = 'hp', Work_Location__c = '鍖椾含', CommunityNickname = 'hpOwner', Email = 'olympus_hpowner@sunbridge.com', Username = 'olympus_hpowner@sunbridge.com', IsActive = true, EmailEncodingKey = 'ISO-2022-JP', TimeZoneSidKey = 'Asia/Tokyo', LocaleSidKey = 'ja_JP', LanguageLocaleKey = 'ja', ProfileId = p.id);
- insert hpOwner;
- User hpOwner2 = new User(Test_staff__c = true, LastName = 'hp2', FirstName = 'owner', Alias = 'hp2', Work_Location__c = '閲嶅簡', CommunityNickname = 'hpOwner2', Email = 'olympus_hpowner@sunbridge.com', Username = 'olympus_hpowner2@sunbridge.com', IsActive = true, EmailEncodingKey = 'ISO-2022-JP', TimeZoneSidKey = 'Asia/Tokyo', LocaleSidKey = 'ja_JP', LanguageLocaleKey = 'ja', ProfileId = p.id);
- insert hpOwner2;
+ User hpOwner = new User(Test_staff__c = true, LastName = 'hp', FirstName = 'owner', Alias = 'hp', Work_Location__c = '鍖椾含', CommunityNickname = 'hpOwner', Email = 'olympus_hpowner@sunbridge.com', Username = 'olympus_hpowner@sunbridge.com', IsActive = true, EmailEncodingKey = 'ISO-2022-JP', TimeZoneSidKey = 'Asia/Tokyo', LocaleSidKey = 'ja_JP', LanguageLocaleKey = 'ja', ProfileId = p.id);
+ insert hpOwner;
+ User hpOwner2 = new User(Test_staff__c = true, LastName = 'hp2', FirstName = 'owner', Alias = 'hp2', Work_Location__c = '閲嶅簡', CommunityNickname = 'hpOwner2', Email = 'olympus_hpowner@sunbridge.com', Username = 'olympus_hpowner2@sunbridge.com', IsActive = true, EmailEncodingKey = 'ISO-2022-JP', TimeZoneSidKey = 'Asia/Tokyo', LocaleSidKey = 'ja_JP', LanguageLocaleKey = 'ja', ProfileId = p.id);
+ insert hpOwner2;
- Account hp = new Account(RecordTypeId = rectHp[0].Id, Name = 'hp', OwnerId = hpOwner.Id);
+ Account hp = new Account(RecordTypeId = rectHp[0].Id, Name = 'hp', OwnerId = hpOwner.Id);
hp.FSE_GI_Main_Leader__c = hpOwner.Id;
hp.FSE_SP_Main_Leader__c = hpOwner2.Id;
insert hp;
@@ -121,40 +182,122 @@
dpt1.Hospital__c = hp.Id;
insert dpt1;
- Contact contact2 = new Contact();
- contact2.AccountId = dpt1.Id;
- contact2.FirstName = '璨换鑰�';
- contact2.LastName = 'test1缁忛攢鍟�';
- insert contact2;
+ //Contact contact2 = new Contact();
+ //contact2.AccountId = dpt1.Id;
+ //contact2.FirstName = '璨换鑰�';
+ //contact2.LastName = 'test1缁忛攢鍟�';
+ //insert contact2;
Inquiry_form__c inquiryform = new Inquiry_form__c();
- // inquiryform.Name = '2019102101';
+ inquiryform.Name = '2019102101';
inquiryform.Hospital_Name__c = dpt1.Id;
- List<Account> dpecList = [select Id,Department_Class__c from Account where Id =: dpt1.Id];
- inquiryform.Department_Class__c = dpecList[0].Department_Class__c;
- inquiryform.Status__c ='鏈窡杩�';
- inquiryform.Company__c ='鍖椾含鏌愭煇鏌愭祴璇曞叕鍙�';
+ inquiryform.Status__c ='01.鏈窡杩�';
inquiryform.Family_Name__c ='闈�';
inquiryform.Opportunity_Division__c = '璇环';
- inquiryform.Contact_Name__c = contact2.Id;
- inquiryform.Reasons_options__c ='瀹㈡埛涓嶅瓨鍦�';
+ //inquiryform.Contact_Name__c = contact2.Id;
+ inquiryform.Reasons_options__c ='瀹㈡埛鏃犳剰鍚�';
inquiryform.Phone__c = '13844756322';
inquiryform.Product1__c = '瓒呭0';
inquiryform.Request1__c = '闇�瑕佹姤浠�';
- Test.startTest();
+ inquiryform.FSE_Owner__c = hpOwner.id;
insert inquiryform;
- ////.瀹㈡埛浜哄憳鍚嶅墠銈掑鏇淬仚銈�
- inquiryform.Phone__c = '16444756322';
- try {
- update inquiryform;
- } catch (Exception e) {
- }
+ Test.setMock(HttpCalloutMock.class, new HttpMock());
+
+ List<Agency_Contact__c> lra = new List<Agency_Contact__c>();
+ lra.add(new Agency_Contact__c(
+ Id = 'a2R1m0000007BPD',
+ Aws_Data_Id__c = '123456'
+ ));
+ AWSServiceTool2.EncryptPushCore(Json.serialize(lra),'Agency_Contact__c');
+
+ Inquiry_form__c inquiryform0 = new Inquiry_form__c(Id = inquiryform.id);
+ inquiryform0.Hospital_Name__c = null;
+ //System.runAs (inquiryform){
+ update inquiryform0;
+ //}
+
+ }
+ // static testMethod void testBeforeUpdate() {
+ // //鍖婚櫌
+ // List<RecordType> rectHp = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and DeveloperName = 'HP'];
+ // if (rectHp.size() == 0) {
+ // return;
+ // }
+ // //绉戝
+ // List<RecordType> rectDpt = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and DeveloperName = 'Department_GI'];
+ // if (rectDpt.size() == 0) {
+ // return;
+ // }
+
- Test.stopTest();
- }
+ // Profile p = [select Id from Profile where id =:System.Label.ProfileId_SystemAdmin];
+
+ // User hpOwner = new User(Test_staff__c = true, LastName = 'hp', FirstName = 'owner', Alias = 'hp', Work_Location__c = '鍖椾含', CommunityNickname = 'hpOwner', Email = 'olympus_hpowner@sunbridge.com', Username = 'olympus_hpowner@sunbridge.com', IsActive = true, EmailEncodingKey = 'ISO-2022-JP', TimeZoneSidKey = 'Asia/Tokyo', LocaleSidKey = 'ja_JP', LanguageLocaleKey = 'ja', ProfileId = p.id);
+ // insert hpOwner;
+ // User hpOwner2 = new User(Test_staff__c = true, LastName = 'hp2', FirstName = 'owner', Alias = 'hp2', Work_Location__c = '閲嶅簡', CommunityNickname = 'hpOwner2', Email = 'olympus_hpowner@sunbridge.com', Username = 'olympus_hpowner2@sunbridge.com', IsActive = true, EmailEncodingKey = 'ISO-2022-JP', TimeZoneSidKey = 'Asia/Tokyo', LocaleSidKey = 'ja_JP', LanguageLocaleKey = 'ja', ProfileId = p.id);
+ // insert hpOwner2;
+
+
+
+ // Account hp = new Account(RecordTypeId = rectHp[0].Id, Name = 'hp', OwnerId = hpOwner.Id);
+ // hp.FSE_GI_Main_Leader__c = hpOwner.Id;
+ // hp.FSE_SP_Main_Leader__c = hpOwner2.Id;
+ // insert hp;
+
+ // //鎴樼暐绉戝
+ // Account dc = [select Id, Name, RecordType_DeveloperName__c, Account2__c from Account where ParentId = :hp.Id and RecordType_DeveloperName__c = 'Department_Class_GI'];
+
+ // Account dpt = new Account(RecordTypeId = rectDpt[0].Id);
+ // dpt.Name = '*';
+ // dpt.Department_Name__c = 'TestDepart';
+ // dpt.ParentId = dc.Id;
+ // dpt.Department_Class__c = dc.Id;
+ // dpt.Hospital__c = hp.Id;
+ // insert dpt;
+
+ // Account dpt1 = new Account(RecordTypeId = rectDpt[0].Id);
+ // dpt1.Name = '*';
+ // dpt1.Department_Name__c = 'TestDepart1';
+ // dpt1.ParentId = dc.Id;
+ // dpt1.Department_Class__c = dc.Id;
+ // dpt1.Hospital__c = hp.Id;
+ // insert dpt1;
+
+ // Contact contact2 = new Contact();
+ // contact2.AccountId = dpt1.Id;
+ // contact2.FirstName = '璨换鑰�';
+ // contact2.LastName = 'test1缁忛攢鍟�';
+ // insert contact2;
+
+ // Inquiry_form__c inquiryform = new Inquiry_form__c();
+ // // inquiryform.Name = '2019102101';
+ // inquiryform.Hospital_Name__c = dpt1.Id;
+ // List<Account> dpecList = [select Id,Department_Class__c from Account where Id =: dpt1.Id];
+ // inquiryform.Department_Class__c = dpecList[0].Department_Class__c;
+ // inquiryform.Status__c ='01.鏈窡杩�';
+ // inquiryform.Company__c ='鍖椾含鏌愭煇鏌愭祴璇曞叕鍙�';
+ // inquiryform.Family_Name__c ='闈�';
+ // inquiryform.Opportunity_Division__c = '璇环';
+ // inquiryform.Contact_Name__c = contact2.Id;
+ // inquiryform.Reasons_options__c ='瀹㈡埛鏃犳剰鍚�';
+ // inquiryform.Phone__c = '13844756322';
+ // inquiryform.Product1__c = '瓒呭0';
+ // inquiryform.Request1__c = '闇�瑕佹姤浠�';
+ // Test.startTest();
+ // insert inquiryform;
+ // ////.瀹㈡埛浜哄憳鍚嶅墠銈掑鏇淬仚銈�
+ // inquiryform.Phone__c = '16444756322';
+ // try {
+ // update inquiryform;
+ // } catch (Exception e) {
+
+ // }
+
+ // Test.stopTest();
+ // }
// static testMethod void TestshareToOSCM(){
- // List<Inquiry_form__c> tList = [SELECT Name, Id
+ // List<Inquiry_form__c> tList = [SELECT Name, Id
// FROM Inquiry_form__c ORDER BY Id LIMIT 1];
// List<Inquiry_form__Share> tsList = [SELECT Id
--
Gitblit v1.9.1