@isTest
|
private class AccountPCLControllerTest {
|
|
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;
|
// 取引先作成
|
List<RecordType> rectHp = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '病院'];
|
if (rectHp.size() == 0) {
|
return;
|
}
|
List<RecordType> rectDp = [select Id, Name from RecordType where IsActive = true and SobjectType = 'Account' and Name = '戦略科室分類 呼吸科' order by Name desc];
|
if (rectDp.size() == 0) {
|
return;
|
}
|
|
List<RecordType> rectDpt = [select Id, Name from RecordType where IsActive = true and SobjectType = 'Account' and Name = '診療科 呼吸科' order by Name desc];
|
if (rectDpt.size() == 0) {
|
return;
|
}
|
Account hp1 = new Account(RecordTypeId = rectHp[0].Id,Is_Active__c = '有効' ,Name = 'testHp1', OCM_Category__c = 'H0', OwnerId = hpOwner.Id);
|
insert hp1;
|
|
Account dp1 = new Account(RecordTypeId = rectDp[0].Id, Is_Active__c = '有効' , Department_Class_Label__c = '呼吸科',
|
ParentId = hp1.id, Name = 'testdp1', OCM_Category__c = 'H0', OwnerId = hpOwner.Id);
|
insert dp1;
|
|
List<Account> dc1s = [Select Id, Name, Department_Class_Label__c from Account where Parent.Id = :hp1.Id and Department_Class_Label__c = '呼吸科' order by Department_Class_Label__c];
|
|
Account depart1 = new Account();
|
depart1.RecordTypeId = rectDpt[0].Id;
|
depart1.Name = '*';
|
depart1.Department_Name__c = '診療科1';
|
depart1.ParentId = dc1s[0].Id;
|
depart1.Department_Class__c = dc1s[0].Id;
|
depart1.Hospital__c = hp1.Id;
|
depart1.Is_Active__c = '有効';
|
|
insert depart1;
|
|
PageReference page = new PageReference('/apex/AccountPCL');
|
System.Test.setCurrentPage(page);
|
AccountPCLController controller = new AccountPCLController();
|
// 初始化测试
|
controller.init();
|
|
System.assertEquals(1, controller.oppRecords.size());
|
|
// 排序测试
|
controller.sortKey = '1';
|
controller.sortTable();
|
controller.sortTable();
|
|
// 检索测试
|
controller.text = 'S:Name';
|
controller.condition = 'equals';
|
controller.value = 'testHp1';
|
controller.searchOpp();
|
controller.condition = 'contains';
|
controller.value = 'test 1';
|
controller.searchOpp();
|
controller.setUrlStr();
|
|
System.assertEquals(1, controller.oppRecords.size());
|
|
// 保存测试
|
controller.oppRecords[0].changeFlg = '1';
|
controller.save();
|
|
// 返回测试
|
controller.cancel();
|
}
|
|
static testMethod void myUnitTest2() {
|
|
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;
|
// 取引先作成
|
List<RecordType> rectHp = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '病院'];
|
if (rectHp.size() == 0) {
|
return;
|
}
|
List<RecordType> rectDp = [select Id, Name from RecordType where IsActive = true and SobjectType = 'Account' and Name = '戦略科室分類 呼吸科' order by Name desc];
|
if (rectDp.size() == 0) {
|
return;
|
}
|
|
List<RecordType> rectDpt = [select Id, Name from RecordType where IsActive = true and SobjectType = 'Account' and Name = '診療科 呼吸科' order by Name desc];
|
if (rectDpt.size() == 0) {
|
return;
|
}
|
Account hp1 = new Account(RecordTypeId = rectHp[0].Id,Is_Active__c = '有効' ,Name = 'testHp1', OCM_Category__c = 'H0', OwnerId = hpOwner.Id);
|
insert hp1;
|
|
Account dp1 = new Account(RecordTypeId = rectDp[0].Id, Is_Active__c = '有効' , Department_Class_Label__c = '呼吸科',
|
ParentId = hp1.id, Name = 'testdp1', OCM_Category__c = 'H0', OwnerId = hpOwner.Id);
|
insert dp1;
|
|
List<Account> dc1s = [Select Id, Name, Department_Class_Label__c from Account where Parent.Id = :hp1.Id and Department_Class_Label__c = '呼吸科' order by Department_Class_Label__c];
|
|
Account depart1 = new Account();
|
depart1.RecordTypeId = rectDpt[0].Id;
|
depart1.Name = '*';
|
depart1.Department_Name__c = '診療科1';
|
depart1.ParentId = dc1s[0].Id;
|
depart1.Department_Class__c = dc1s[0].Id;
|
depart1.Hospital__c = hp1.Id;
|
depart1.Is_Active__c = '有効';
|
depart1.Ban_On_Use_Date__c = Date.today().addDays(1);
|
insert depart1;
|
|
|
|
PageReference page = new PageReference('/apex/AccountPCL?uid=' + UserInfo.getUserId() + '&hpid=' + hp1.Id);
|
System.Test.setCurrentPage(page);
|
AccountPCLController controller = new AccountPCLController();
|
// 初始化测试
|
controller.init();
|
System.assertEquals(1, controller.oppRecords.size());
|
|
// 保存测试
|
controller.oppRecords[0].changeFlg = '1';
|
controller.saveType = '1';
|
controller.save();
|
|
controller.oppRecords[0].changeFlg = '1';
|
|
controller.saveType = '2';
|
|
controller.save();
|
|
// 检索测试
|
controller.text = 'S:Name';
|
controller.condition = 'notequals';
|
controller.value = '';
|
controller.searchOpp();
|
|
//controller.dateField = 'Ban_On_Use_Date__c';
|
//controller.con1.Birthdate = Date.today();
|
//controller.con2.Birthdate = Date.today().addDays(2);
|
controller.text = 'S:Name';
|
controller.condition = 'contains';
|
controller.value = 'test 1';
|
controller.searchOpp();
|
controller.accTypeForSort = '01210000000QezZ';
|
controller.sortOrder = null;
|
controller.setLayoutRWInfo();
|
|
//System.assertEquals(1, controller.oppRecords.size());
|
}
|
}
|