From ba1c90575c47f9cb5c2ce0a20da90d3b1739b5fa Mon Sep 17 00:00:00 2001
From: buli <137736985@qq.com>
Date: 星期二, 26 四月 2022 11:47:45 +0800
Subject: [PATCH] 0425 Commit
---
force-app/main/default/classes/AccountWebServiceTest.cls | 212 ++++++++++++++++++++++++++++++++++++++--------------
1 files changed, 155 insertions(+), 57 deletions(-)
diff --git a/force-app/main/default/classes/AccountWebServiceTest.cls b/force-app/main/default/classes/AccountWebServiceTest.cls
index 9c1d543..aa0b5ac 100644
--- a/force-app/main/default/classes/AccountWebServiceTest.cls
+++ b/force-app/main/default/classes/AccountWebServiceTest.cls
@@ -1,68 +1,166 @@
-/**
- * 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 AccountWebServiceTest {
static testMethod void myUnitTest() {
- 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', 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;
-
- Account hp = new Account(
- RecordTypeId = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '鐥呴櫌'].Id,
- Name = 'AccountCaseHistoryTestHp1',
- OwnerId = hpOwner.Id
+ List<RecordType> rectIE = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = 'Customer IE'];
+ Account acc1 = new Account(
+ name = '*',
+ RecordTypeId = rectIE[0].Id,
+ OwnerId = UserInfo.getUserId(),
+ DivisionName__c = 'Customer IE',
+ FacilityName__c = 'abc',
+ DivisionName_D__c = 'Customer IE',
+ FacilityNameD__c = 'abc',
+ AccountStatus__c = 'Cancel',
+ PostCode__c = '123456'
);
- insert hp;
+ Account acc2 = new Account(
+ name = '*',
+ RecordTypeId = rectIE[0].Id,
+ OwnerId = UserInfo.getUserId(),
+ DivisionName__c = 'Customer IE',
+ FacilityName__c = 'abc',
+ DivisionName_D__c = 'Customer IE',
+ FacilityNameD__c = 'abc',
+ PostCode__c = '123456'
+ );
+ Account acc3 = new Account(
+ name = '*',
+ RecordTypeId = rectIE[0].Id,
+ OwnerId = UserInfo.getUserId(),
+ DivisionName__c = 'Customer IE',
+ FacilityName__c = 'abc',
+ DivisionName_D__c = 'Customer IE',
+ FacilityNameD__c = 'abc',
+ CancelReason__c = 'test',
+ PostCode__c = '123456'
+ );
+ insert new List<Account> {acc1,acc2,acc3};
- RecordType rectSct = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '鎴︾暐绉戝鍒嗛 娑堝寲绉�'];
- Account section = [Select Name, Department_Class_Label__c, OwnerId, ParentId, Hospital_Department_Class__c from Account where ParentId = :hp.Id and RecordTypeId = :rectSct.Id];
+ String rs = '';
+ rs = AccountWebService.AccountCancel('12345678');
+ System.assertEquals('鏃犳晥鐨勫鎴�', rs);
- Account depart = new Account();
- depart.RecordTypeId = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '瑷虹檪绉� 娑堝寲绉�'].Id;
- depart.Name = '*';
- depart.Department_Name__c = 'dept1';
- depart.ParentId = section.Id;
- depart.Department_Class__c = section.Id;
- depart.Hospital__c = hp.Id;
- insert depart;
+ rs = AccountWebService.AccountCancel(acc1.Id);
+ System.assertEquals('瀹㈡埛宸茬粡鍙栨秷', rs);
- // 瑷虹檪绉戙儐銈广儓
- depart.Is_Active__c = '鐒″姽';
- update depart;
+ rs = AccountWebService.AccountCancel(acc2.Id);
+ System.assertEquals('蹇呴』杈撳叆鍙栨秷鐞嗙敱', rs);
- AccountWebService.toBatchOwner(hp.Id);
- depart = [select OwnerId from Account where Id = :depart.Id];
- System.assertEquals('00510000000fSYI', depart.OwnerId);
-
- // 鐥呴櫌銉嗐偣銉�
- hp.Is_Active__c = '鐒″姽';
- update hp;
-
- AccountWebService.toBatchOwner(hp.Id);
- hp = [select OwnerId from Account where Id = :hp.Id];
- System.assertEquals('00510000000fSYI', hp.OwnerId);
- section = [select OwnerId from Account where Id = :section.Id];
- System.assertEquals('00510000000fSYI', section.OwnerId);
+ rs = AccountWebService.AccountCancel(acc3.Id);
+ System.assertEquals('1', rs);
+ List<Account> accList = [select Id,AccountStatus__c from Account where Id = :acc3.Id];
+ System.assertEquals('Cancel', accList[0].AccountStatus__c);
+ }
+
+ static testMethod void myUnitTest2() {
+ List<RecordType> rectIE = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = 'Customer IE'];
+ String localid = UserInfo.getUserId();
+
+ Account acc1 = new Account(
+ name = '*',
+ RecordTypeId = rectIE[0].Id,
+ OwnerId = UserInfo.getUserId(),
+ DivisionName__c = 'Customer IE',
+ FacilityName__c = 'abc',
+ DivisionName_D__c = 'Customer IE',
+ FacilityNameD__c = 'abc',
+ AccountStatus__c = 'Cancel',
+ PostCode__c = '123456'
+ );
+ insert acc1;
+
+ User user = new User();
+ user.LastName = 'test20201014';
+ user.FirstName = 'test';
+ user.Alias = 'test';
+ user.Email = 'test@test.com';
+ user.Username = 'test111@test222.com';
+ user.CommunityNickname = 'test20201014';
+ user.IsActive = true;
+ user.EmailEncodingKey = 'ISO-2022-JP';
+ user.TimeZoneSidKey = 'Asia/Tokyo';
+ user.LocaleSidKey = 'ja_JP';
+ user.LanguageLocaleKey = 'ja';
+ user.ProfileId = System.Label.SystemAdmin;
+ insert user;
+
+ AccountTeamMember atm = new AccountTeamMember(
+ AccountId = acc1.Id,
+ userId = localid,
+ teamMemberRole = 'Sales Manager'
+ );
+ AccountTeamMember atm2 = new AccountTeamMember(
+ AccountId = acc1.Id,
+ userId = user.Id,
+ teamMemberRole = 'Sales Manager'
+ );
+ insert new AccountTeamMember[] {atm,atm2};
+
+ String rs = '';
+ rs = AccountWebService.UpdateShare(acc1.Id, localid, user.Id);
+ System.assertEquals('1', rs);
+
+ List<AccountTeamMember> atmList = [select Id, AccountAccessLevel from AccountTeamMember where Id = :atm.Id];
+ System.assertEquals('Edit', atmList[0].AccountAccessLevel);
+ }
+ // 鎶�鏈湇鍔¢儴瀹㈡埛涓庤仈绯讳汉鐢宠鎻愪氦鏃跺瓧娈甸獙璇�
+ static testMethod void TechnicalServiceCreated() {
+ List<RecordType> rectIE = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = 'Customer IE'];
+ List<RecordType> rectBS = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = 'Customer BS'];
+ Account acc1 = new Account(
+ name = '*',
+ RecordTypeId = rectIE[0].Id,
+ OwnerId = UserInfo.getUserId(),
+ DivisionName__c = 'Customer IE',
+ FacilityName__c = 'abc',
+ DivisionName_D__c = 'Customer IE',
+ FacilityNameD__c = 'abc',
+ AccountStatus__c = 'Cancel',
+ PostCode__c = '123456',
+ serviceCreate__c = true
+ );
+ Account acc2 = new Account(
+ name = '*',
+ RecordTypeId = rectBS[0].Id,
+ OwnerId = UserInfo.getUserId(),
+ //DivisionName__c = 'Customer BS',
+ FacilityName__c = 'abc'
+ );
+ Account acc3 = new Account(
+ name = '*',
+ RecordTypeId = rectIE[0].Id,
+ OwnerId = UserInfo.getUserId(),
+ DivisionName__c = 'Customer IE',
+ FacilityName__c = 'abc',
+ DivisionName_D__c = 'Customer IE',
+ FacilityNameD__c = 'abc',
+ CancelReason__c = 'test',
+ PostCode__c = '123456'
+ );
+ User hpOwner = new User( LastName = 'hp', FirstName = 'owner', Alias = 'hp', 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 = System.Label.SystemAdmin2,MarketingStrategy__c =true);
+ insert hpOwner;
+ System.runAs(hpOwner){
+ insert new List<Account> {acc1,acc2,acc3};
+
+ // insert dealer;
+ Contact core = new Contact(email='jplumber@salesforce.com', firstname='Joe',lastname='Plumber',accountid=acc1.id);
+ insert core;
+
+ String rs = '';
+ // rs = AccountWebService.AccountCancel('12345678');
+ // System.assertEquals('鏃犳晥鐨勫鎴�', rs);
+
+ rs = AccountWebService.RequiredField(acc1.Id);
+ // System.assertEquals('瀹㈡埛宸茬粡鍙栨秷', rs);
+
+ rs = AccountWebService.RequiredField(acc2.Id);
+ // System.assertEquals('蹇呴』杈撳叆鍙栨秷鐞嗙敱', rs);
+ rs = AccountWebService.ContactRequiredField(core.Id);
+ // rs = AccountWebService.AccountCancel(acc3.Id);
+ // System.assertEquals('1', rs);
+ // List<Account> accList = [select Id,AccountStatus__c from Account where Id = :acc3.Id];
+ // System.assertEquals('Cancel', accList[0].AccountStatus__c);
+ }
}
}
\ No newline at end of file
--
Gitblit v1.9.1