@isTest
|
private class SetPersonalTargetEngControllerTest {
|
|
static testMethod void myUnitTest() {
|
|
RecordType rt = [select Id from RecordType where SobjectType = 'Opportunity' and IsActive = true and DeveloperName = 'Target'];
|
|
// システム管理者
|
User u3 = new User();
|
u3.LastName = '_サンブリッジ00';
|
u3.FirstName = 'う';
|
u3.Alias = 'う';
|
u3.Email = 'olympusTest03@sunbridge.com';
|
u3.Username = 'olympusTest93@sunbridge.com';
|
u3.CommunityNickname = 'う';
|
u3.IsActive = true;
|
u3.EmailEncodingKey = 'ISO-2022-JP';
|
u3.TimeZoneSidKey = 'Asia/Tokyo';
|
u3.LocaleSidKey = 'ja_JP';
|
u3.LanguageLocaleKey = 'ja';
|
u3.ProfileId = System.Label.ProfileId_SystemAdmin;
|
u3.Job_Category__c = '销售推广';
|
u3.Province__c = '上海市上海市';
|
u3.Use_Start_Date__c = Date.today().addMonths(-6);
|
insert u3;
|
|
System.runAs(u3) {
|
// // 5.华南销售本部に変更
|
// List<User> us = [select Id from User where IsActive = true and Id != :u3.Id];
|
// for (User u : us) {
|
// u.Province__c = '湖北省';
|
// }
|
// update us;
|
|
// 102_销售产品推广
|
User u1 = new User();
|
u1.LastName = '_サンブリッジ01';
|
u1.FirstName = 'あ1';
|
u1.Alias = 'あ9';
|
u1.Email = 'olympusTest01@sunbridge.com';
|
u1.Username = 'olympusTest91@sunbridge.com';
|
u1.CommunityNickname = 'あ9';
|
u1.IsActive = true;
|
u1.EmailEncodingKey = 'ISO-2022-JP';
|
u1.TimeZoneSidKey = 'Asia/Tokyo';
|
u1.LocaleSidKey = 'ja_JP';
|
u1.LanguageLocaleKey = 'ja';
|
u1.ProfileId = System.Label.ProfileId_SystemAdmin;
|
u1.Job_Category__c = '销售推广';
|
u1.Province__c = '河北省';
|
u1.Post__c = '一般';
|
u1.Sales_Speciality__c = '医院担当';
|
u1.Use_Start_Date__c = Date.today().addYears(-1);
|
u1.Dept__c = '能量事业本部';
|
insert u1;
|
|
User u2 = new User();
|
u2.LastName = '_サンブリッジ0';
|
u2.FirstName = 'い';
|
u2.Alias = 'い';
|
u2.Email = 'olympusTest02@sunbridge.com';
|
u2.Username = 'olympusTest92@sunbridge.com';
|
u2.CommunityNickname = 'い';
|
u2.IsActive = true;
|
u2.EmailEncodingKey = 'ISO-2022-JP';
|
u2.TimeZoneSidKey = 'Asia/Tokyo';
|
u2.LocaleSidKey = 'ja_JP';
|
u2.LanguageLocaleKey = 'ja';
|
u2.ProfileId = System.Label.ProfileId_SystemAdmin;
|
u2.Job_Category__c = '销售推广';
|
u2.Province__c = '上海市上海市';
|
u2.Post__c = '一般';
|
u2.Sales_Speciality__c = '医院担当';
|
u2.Use_Start_Date__c = Date.today().addYears(-1);
|
u2.Dept__c = '能量事业本部';
|
insert u2;
|
|
SetPersonalTargetEngController odc = new SetPersonalTargetEngController();
|
// 初期表示
|
odc.init();
|
System.assertEquals(1, odc.getUserSize());
|
System.assertEquals(7, odc.getPSize());
|
System.assertEquals(1, odc.dataBeans.size());
|
|
// 検索
|
// 3.西北销售本部
|
odc.salesDpt = '3.西北销售本部_Dummy';
|
odc.searchByDpt();
|
System.assertEquals(0, odc.dataBeans.size());
|
|
// 上海市
|
odc.loginUser.Province__c = '上海市上海市';
|
odc.searchByProvince();
|
System.assertEquals(1, odc.dataBeans.size());
|
|
// 职位:一般
|
odc.plist[0].check = true;
|
odc.plist[1].check = false;
|
odc.plist[2].check = false;
|
odc.plist[3].check = false;
|
odc.plist[4].check = false;
|
odc.plist[5].check = false;
|
odc.plist[6].check = false;
|
odc.searchByFilter();
|
System.assertEquals(1, odc.dataBeans.size());
|
|
// 保存
|
odc.dataBeans[0].amount[0].Amount = 100;
|
odc.dataBeans[0].isChanged = '1';
|
odc.saveBtn();
|
|
List<Opportunity> opps = [select SAP_Province__c, Amount from Opportunity where RecordTypeId = :rt.Id];
|
System.assertEquals('上海市上海市', opps[0].SAP_Province__c);
|
System.assertEquals(100, opps[0].Amount);
|
|
// 上年度
|
odc.previous();
|
//System.assertEquals(false, odc.previousRendered);
|
|
// 下年度
|
odc.next();
|
//System.assertEquals(null, odc.dataBeans[0].amount[0].Amount);
|
|
// 返回
|
odc.backBtn();
|
}
|
}
|
}
|