@isTest
|
private class NewAccountExamineControllerTest {
|
|
private static User getUser() {
|
String timenow = Datetime.now().format('yyyyMMddHHmmss');
|
User user1 = new User(Test_staff__c = true, LastName = 'TestMao', FirstName = 'TestMaoF',
|
Alias = 'hp', CommunityNickname = 'TestMao', Email = 'Test@sunbridge.com',
|
Username = 'Test' + timenow + '@sunbridge.com', IsActive = true,
|
EmailEncodingKey = 'ISO-2022-JP',TimeZoneSidKey = 'Asia/Tokyo',
|
LocaleSidKey = 'ja_JP', LanguageLocaleKey = 'ja',
|
ProfileId = System.Label.ProfileId_SystemAdmin,
|
Dept__c = '医疗华北营业本部', Job_Category__c = '销售服务',
|
Province__c = '北京');
|
|
//List<Profile> p = [Select Id From Profile Where Name = '2S6_销售本部窗口&营业助理'];
|
//System.assertEquals(p.size(), 1);
|
System.runAs(new User(Id = Userinfo.getUserId())) {
|
insert user1;
|
}
|
return user1;
|
}
|
|
static testMethod void testMethod01() {
|
User user = getUser();
|
System.runAs(user) {
|
RecordType rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and DeveloperName = 'Hp'];
|
|
Account acc1 = new Account();
|
acc1.RecordTypeId = rectCo.Id;
|
acc1.Name = 'HP test2';
|
acc1.Is_Active__c = '草案中';
|
acc1.Is_upload_file__c = true;
|
insert acc1;
|
|
String testlink = '医院新建审批_营业支援部';
|
|
Approval.ProcessSubmitRequest r = new Approval.ProcessSubmitRequest();
|
r.setObjectId(acc1.Id);
|
Approval.process(r);
|
String strid = r.getSubmitterId();
|
//'/apex/NewAccountExamine?AccId='+AccId+'&testlink='+testlink+'&'
|
PageReference page = new PageReference('/apex/?AccId='+acc1.Id+'&testlink='+testlink+'&');
|
System.Test.setCurrentPage(page);
|
NewAccountExamineController controller = new NewAccountExamineController();
|
controller.ApprovalAction = 'Approve';
|
controller.Approval();
|
}
|
}
|
|
static testMethod void testMethod02() {
|
User user = getUser();
|
System.runAs(user) {
|
RecordType rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and DeveloperName = 'Hp'];
|
|
Account acc1 = new Account();
|
acc1.RecordTypeId = rectCo.Id;
|
acc1.Name = 'HP test2';
|
acc1.Is_Active__c = '草案中';
|
acc1.Is_upload_file__c = true;
|
acc1.InstitutionalType__c = '非医疗机构';
|
insert acc1;
|
|
String testlink = '医院新建审批_营业支援部';
|
|
Approval.ProcessSubmitRequest r = new Approval.ProcessSubmitRequest();
|
r.setObjectId(acc1.Id);
|
Approval.process(r);
|
String strid = r.getSubmitterId();
|
//'/apex/NewAccountExamine?AccId='+AccId+'&testlink='+testlink+'&'
|
PageReference page = new PageReference('/apex/?AccId='+acc1.Id+'&testlink='+testlink+'&');
|
System.Test.setCurrentPage(page);
|
NewAccountExamineController controller = new NewAccountExamineController();
|
controller.ApprovalAction = 'Approve';
|
controller.Approval();
|
}
|
}
|
|
static testMethod void testMethod03() {
|
User user = getUser();
|
System.runAs(user) {
|
RecordType rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and DeveloperName = 'Hp'];
|
|
Account acc1 = new Account();
|
acc1.RecordTypeId = rectCo.Id;
|
acc1.Name = 'HP test2';
|
acc1.Is_Active__c = '草案中';
|
acc1.Is_upload_file__c = true;
|
acc1.RejectionReason__c = '重复';
|
insert acc1;
|
|
String testlink = '医院新建审批_营业支援部';
|
|
Approval.ProcessSubmitRequest r = new Approval.ProcessSubmitRequest();
|
r.setObjectId(acc1.Id);
|
Approval.process(r);
|
String strid = r.getSubmitterId();
|
//'/apex/NewAccountExamine?AccId='+AccId+'&testlink='+testlink+'&'
|
PageReference page = new PageReference('/apex/?AccId='+acc1.Id+'&testlink='+testlink+'&');
|
System.Test.setCurrentPage(page);
|
NewAccountExamineController controller = new NewAccountExamineController();
|
controller.ApprovalAction = 'Approve';
|
controller.Approval();
|
}
|
}
|
|
static testMethod void testMethod04() {
|
User user = getUser();
|
System.runAs(user) {
|
RecordType rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and DeveloperName = 'Hp'];
|
|
Account acc1 = new Account();
|
acc1.RecordTypeId = rectCo.Id;
|
acc1.Name = 'HP test2';
|
acc1.Is_Active__c = '草案中';
|
acc1.Is_upload_file__c = true;
|
acc1.InstitutionalType__c = '医疗机构';
|
acc1.HospitalType__c = '企业集团';
|
insert acc1;
|
|
String testlink = '医院新建审批_营业支援部';
|
|
Approval.ProcessSubmitRequest r = new Approval.ProcessSubmitRequest();
|
r.setObjectId(acc1.Id);
|
Approval.process(r);
|
String strid = r.getSubmitterId();
|
//'/apex/NewAccountExamine?AccId='+AccId+'&testlink='+testlink+'&'
|
PageReference page = new PageReference('/apex/?AccId='+acc1.Id+'&testlink='+testlink+'&');
|
System.Test.setCurrentPage(page);
|
NewAccountExamineController controller = new NewAccountExamineController();
|
controller.ApprovalAction = 'Approve';
|
controller.Approval();
|
}
|
}
|
|
static testMethod void testMethod04_1() {
|
User user = getUser();
|
System.runAs(user) {
|
RecordType rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and DeveloperName = 'Hp'];
|
|
Account acc1 = new Account();
|
acc1.RecordTypeId = rectCo.Id;
|
acc1.Name = 'HP test2';
|
acc1.Is_Active__c = '草案中';
|
acc1.Is_upload_file__c = true;
|
acc1.InstitutionalType__c = '医疗机构';
|
insert acc1;
|
|
String testlink = '医院新建审批_营业支援部';
|
|
Approval.ProcessSubmitRequest r = new Approval.ProcessSubmitRequest();
|
r.setObjectId(acc1.Id);
|
Approval.process(r);
|
String strid = r.getSubmitterId();
|
//'/apex/NewAccountExamine?AccId='+AccId+'&testlink='+testlink+'&'
|
PageReference page = new PageReference('/apex/?AccId='+acc1.Id+'&testlink='+testlink+'&');
|
System.Test.setCurrentPage(page);
|
NewAccountExamineController controller = new NewAccountExamineController();
|
controller.ApprovalAction = 'Approve';
|
controller.Approval();
|
}
|
}
|
|
static testMethod void testMethod05() {
|
User user = getUser();
|
System.runAs(user) {
|
RecordType rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and DeveloperName = 'Hp'];
|
|
Account acc1 = new Account();
|
acc1.RecordTypeId = rectCo.Id;
|
acc1.Name = 'HP test2';
|
acc1.Is_Active__c = '草案中';
|
acc1.Is_upload_file__c = true;
|
insert acc1;
|
|
String testlink = '医院新建审批_营业支援部';
|
|
Approval.ProcessSubmitRequest r = new Approval.ProcessSubmitRequest();
|
r.setObjectId(acc1.Id);
|
Approval.process(r);
|
String strid = r.getSubmitterId();
|
//'/apex/NewAccountExamine?AccId='+AccId+'&testlink='+testlink+'&'
|
PageReference page = new PageReference('/apex/?AccId='+acc1.Id+'&testlink='+testlink+'&');
|
System.Test.setCurrentPage(page);
|
NewAccountExamineController controller = new NewAccountExamineController();
|
controller.ApprovalAction = 'Reject';
|
controller.Approval();
|
}
|
}
|
|
static testMethod void testMethod06() {
|
User user = getUser();
|
System.runAs(user) {
|
RecordType rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and DeveloperName = 'Hp'];
|
|
Account acc1 = new Account();
|
acc1.RecordTypeId = rectCo.Id;
|
acc1.Name = 'HP test2';
|
acc1.Is_Active__c = '草案中';
|
acc1.Is_upload_file__c = true;
|
acc1.RejectionReason__c = '重复';
|
acc1.InstitutionalType__c = '医疗机构';
|
insert acc1;
|
|
String testlink = '医院新建审批_营业支援部';
|
|
Approval.ProcessSubmitRequest r = new Approval.ProcessSubmitRequest();
|
r.setObjectId(acc1.Id);
|
Approval.process(r);
|
String strid = r.getSubmitterId();
|
//'/apex/NewAccountExamine?AccId='+AccId+'&testlink='+testlink+'&'
|
PageReference page = new PageReference('/apex/?AccId='+acc1.Id+'&testlink='+testlink+'&');
|
System.Test.setCurrentPage(page);
|
NewAccountExamineController controller = new NewAccountExamineController();
|
controller.ApprovalAction = 'Reject';
|
controller.Approval();
|
}
|
}
|
|
static testMethod void testMethod06_1() {
|
User user = getUser();
|
System.runAs(user) {
|
RecordType rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and DeveloperName = 'Hp'];
|
|
Account acc1 = new Account();
|
acc1.RecordTypeId = rectCo.Id;
|
acc1.Name = 'HP test2';
|
acc1.Is_Active__c = '草案中';
|
acc1.Is_upload_file__c = true;
|
acc1.RejectionReason__c = '地址错误';
|
acc1.InstitutionalType__c = '医疗机构';
|
insert acc1;
|
|
String testlink = '医院新建审批_营业支援部';
|
|
Approval.ProcessSubmitRequest r = new Approval.ProcessSubmitRequest();
|
r.setObjectId(acc1.Id);
|
Approval.process(r);
|
String strid = r.getSubmitterId();
|
//'/apex/NewAccountExamine?AccId='+AccId+'&testlink='+testlink+'&'
|
PageReference page = new PageReference('/apex/?AccId='+acc1.Id+'&testlink='+testlink+'&');
|
System.Test.setCurrentPage(page);
|
NewAccountExamineController controller = new NewAccountExamineController();
|
controller.ApprovalAction = 'Reject';
|
controller.Approval();
|
}
|
}
|
|
static testMethod void testMethod06_2() {
|
User user = getUser();
|
System.runAs(user) {
|
RecordType rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and DeveloperName = 'Hp'];
|
|
Account acc1 = new Account();
|
acc1.RecordTypeId = rectCo.Id;
|
acc1.Name = 'HP test2';
|
acc1.Is_Active__c = '草案中';
|
acc1.Is_upload_file__c = true;
|
acc1.RejectionReason__c = '地址错误';
|
insert acc1;
|
|
String testlink = '医院新建审批_营业支援部';
|
|
Approval.ProcessSubmitRequest r = new Approval.ProcessSubmitRequest();
|
r.setObjectId(acc1.Id);
|
Approval.process(r);
|
String strid = r.getSubmitterId();
|
//'/apex/NewAccountExamine?AccId='+AccId+'&testlink='+testlink+'&'
|
PageReference page = new PageReference('/apex/?AccId='+acc1.Id+'&testlink='+testlink+'&');
|
System.Test.setCurrentPage(page);
|
NewAccountExamineController controller = new NewAccountExamineController();
|
controller.ApprovalAction = 'Reject';
|
controller.Approval();
|
}
|
}
|
|
static testMethod void testMethod07() {
|
User user = getUser();
|
System.runAs(user) {
|
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 test2';
|
acc.Is_Active__c = '有効';
|
acc.Is_upload_file__c = true;
|
insert acc;
|
|
Account acc1 = new Account();
|
acc1.RecordTypeId = rectCo.Id;
|
acc1.Name = 'HP test2';
|
acc1.Is_Active__c = '草案中';
|
acc1.Is_upload_file__c = true;
|
acc1.RejectionReason__c = '重复';
|
acc1.AssociatedHospital__c = acc.Id;
|
insert acc1;
|
|
String testlink = '医院新建审批_营业支援部';
|
|
Approval.ProcessSubmitRequest r = new Approval.ProcessSubmitRequest();
|
r.setObjectId(acc1.Id);
|
Approval.process(r);
|
String strid = r.getSubmitterId();
|
//'/apex/NewAccountExamine?AccId='+AccId+'&testlink='+testlink+'&'
|
PageReference page = new PageReference('/apex/?AccId='+acc1.Id+'&testlink='+testlink+'&');
|
System.Test.setCurrentPage(page);
|
NewAccountExamineController controller = new NewAccountExamineController();
|
controller.ApprovalAction = 'Reject';
|
controller.Approval();
|
}
|
}
|
|
static testMethod void testMethod08() {
|
User user = getUser();
|
System.runAs(user) {
|
RecordType rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and DeveloperName = 'Hp'];
|
|
Account acc1 = new Account();
|
acc1.RecordTypeId = rectCo.Id;
|
acc1.Name = 'HP test2';
|
acc1.Is_Active__c = '草案中';
|
acc1.Is_upload_file__c = true;
|
insert acc1;
|
|
String testlink = '质量法规二级部长';
|
|
Approval.ProcessSubmitRequest r = new Approval.ProcessSubmitRequest();
|
r.setObjectId(acc1.Id);
|
Approval.process(r);
|
String strid = r.getSubmitterId();
|
//'/apex/NewAccountExamine?AccId='+AccId+'&testlink='+testlink+'&'
|
PageReference page = new PageReference('/apex/?AccId='+acc1.Id+'&testlink='+testlink+'&');
|
System.Test.setCurrentPage(page);
|
NewAccountExamineController controller = new NewAccountExamineController();
|
controller.ApprovalAction = 'Reject';
|
controller.Approval();
|
}
|
}
|
|
static testMethod void testMethod08_1() {
|
User user = getUser();
|
System.runAs(user) {
|
RecordType rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and DeveloperName = 'Hp'];
|
|
Account acc1 = new Account();
|
acc1.RecordTypeId = rectCo.Id;
|
acc1.Name = 'HP test2';
|
acc1.Is_Active__c = '草案中';
|
acc1.Is_upload_file__c = true;
|
acc1.InstitutionalType__c = '非医疗机构';
|
acc1.HospitalType__c = '高等院校';
|
|
insert acc1;
|
|
String testlink = '质量法规二级部长';
|
|
Approval.ProcessSubmitRequest r = new Approval.ProcessSubmitRequest();
|
r.setObjectId(acc1.Id);
|
Approval.process(r);
|
String strid = r.getSubmitterId();
|
//'/apex/NewAccountExamine?AccId='+AccId+'&testlink='+testlink+'&'
|
PageReference page = new PageReference('/apex/?AccId='+acc1.Id+'&testlink='+testlink+'&');
|
System.Test.setCurrentPage(page);
|
NewAccountExamineController controller = new NewAccountExamineController();
|
controller.ApprovalAction = 'Approve';
|
controller.Approval();
|
}
|
}
|
|
static testMethod void testMethod09() {
|
User user = getUser();
|
System.runAs(user) {
|
RecordType rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and DeveloperName = 'Hp'];
|
|
Account acc1 = new Account();
|
acc1.RecordTypeId = rectCo.Id;
|
acc1.Name = 'HP test2';
|
acc1.Is_Active__c = '草案中';
|
acc1.Is_upload_file__c = true;
|
insert acc1;
|
|
String testlink = '经销商管理部一级审批';
|
|
Approval.ProcessSubmitRequest r = new Approval.ProcessSubmitRequest();
|
r.setObjectId(acc1.Id);
|
Approval.process(r);
|
String strid = r.getSubmitterId();
|
//'/apex/NewAccountExamine?AccId='+AccId+'&testlink='+testlink+'&'
|
PageReference page = new PageReference('/apex/?AccId='+acc1.Id+'&testlink='+testlink+'&');
|
System.Test.setCurrentPage(page);
|
NewAccountExamineController controller = new NewAccountExamineController();
|
controller.ApprovalAction = 'Reject';
|
controller.Approval();
|
}
|
}
|
|
static testMethod void testMethod09_1() {
|
User user = getUser();
|
System.runAs(user) {
|
RecordType rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and DeveloperName = 'Hp'];
|
|
Account acc1 = new Account();
|
acc1.RecordTypeId = rectCo.Id;
|
acc1.Name = 'HP test2';
|
acc1.Is_Active__c = '草案中';
|
acc1.Is_upload_file__c = true;
|
acc1.WhetherRiskPassing__c = '否';
|
insert acc1;
|
|
String testlink = '经销商管理部一级审批';
|
|
Approval.ProcessSubmitRequest r = new Approval.ProcessSubmitRequest();
|
r.setObjectId(acc1.Id);
|
Approval.process(r);
|
String strid = r.getSubmitterId();
|
//'/apex/NewAccountExamine?AccId='+AccId+'&testlink='+testlink+'&'
|
PageReference page = new PageReference('/apex/?AccId='+acc1.Id+'&testlink='+testlink+'&');
|
System.Test.setCurrentPage(page);
|
NewAccountExamineController controller = new NewAccountExamineController();
|
controller.ApprovalAction = 'Reject';
|
controller.Approval();
|
}
|
}
|
|
static testMethod void testMethod09_2() {
|
User user = getUser();
|
System.runAs(user) {
|
RecordType rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and DeveloperName = 'Hp'];
|
|
Account acc1 = new Account();
|
acc1.RecordTypeId = rectCo.Id;
|
acc1.Name = 'HP test2';
|
acc1.Is_Active__c = '草案中';
|
acc1.Is_upload_file__c = true;
|
acc1.WhetherRiskPassing__c = '否';
|
acc1.InstitutionalType__c = '非医疗机构';
|
acc1.HospitalType__c = '企业集团';
|
|
insert acc1;
|
|
String testlink = '经销商管理部一级审批';
|
|
Approval.ProcessSubmitRequest r = new Approval.ProcessSubmitRequest();
|
r.setObjectId(acc1.Id);
|
Approval.process(r);
|
String strid = r.getSubmitterId();
|
//'/apex/NewAccountExamine?AccId='+AccId+'&testlink='+testlink+'&'
|
PageReference page = new PageReference('/apex/?AccId='+acc1.Id+'&testlink='+testlink+'&');
|
System.Test.setCurrentPage(page);
|
NewAccountExamineController controller = new NewAccountExamineController();
|
controller.ApprovalAction = 'Approve';
|
controller.Approval();
|
}
|
}
|
|
static testMethod void testMethod10() {
|
User user = getUser();
|
System.runAs(user) {
|
RecordType rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and DeveloperName = 'Hp'];
|
|
Account acc1 = new Account();
|
acc1.RecordTypeId = rectCo.Id;
|
acc1.Name = 'HP test2';
|
acc1.Is_Active__c = '草案中';
|
acc1.Is_upload_file__c = true;
|
insert acc1;
|
|
String testlink = '总经理审批';
|
|
Approval.ProcessSubmitRequest r = new Approval.ProcessSubmitRequest();
|
r.setObjectId(acc1.Id);
|
Approval.process(r);
|
String strid = r.getSubmitterId();
|
//'/apex/NewAccountExamine?AccId='+AccId+'&testlink='+testlink+'&'
|
PageReference page = new PageReference('/apex/?AccId='+acc1.Id+'&testlink='+testlink+'&');
|
System.Test.setCurrentPage(page);
|
NewAccountExamineController controller = new NewAccountExamineController();
|
controller.ApprovalAction = 'Reject';
|
controller.Approval();
|
}
|
}
|
|
static testMethod void testMethod11() {
|
User user = getUser();
|
System.runAs(user) {
|
RecordType rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and DeveloperName = 'Hp'];
|
|
Account acc1 = new Account();
|
acc1.RecordTypeId = rectCo.Id;
|
acc1.Name = 'HP test2';
|
acc1.Is_Active__c = '草案中';
|
acc1.Is_upload_file__c = true;
|
insert acc1;
|
|
String testlink = '111111';
|
|
Approval.ProcessSubmitRequest r = new Approval.ProcessSubmitRequest();
|
r.setObjectId(acc1.Id);
|
Approval.process(r);
|
String strid = r.getSubmitterId();
|
//'/apex/NewAccountExamine?AccId='+AccId+'&testlink='+testlink+'&'
|
PageReference page = new PageReference('/apex/?AccId='+acc1.Id+'&testlink='+testlink+'&');
|
System.Test.setCurrentPage(page);
|
NewAccountExamineController controller = new NewAccountExamineController();
|
controller.ApprovalAction = 'Reject';
|
controller.Approval();
|
}
|
}
|
}
|