/**
|
* 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 SetPersonalTargetControllerTest {
|
|
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 = 'olympusTest03@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 = 'olympusTest09@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);
|
insert u1;
|
|
User u2 = new User();
|
u2.LastName = '四洋';
|
u2.FirstName = '张';
|
u2.Alias = '张四洋';
|
u2.Email = 'olympusTest02@sunbridge.com';
|
u2.Username = 'olympusTest02@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);
|
insert u2;
|
// 现在时间
|
Date dateNow = Date.today();
|
Integer year = dateNow.year();
|
Integer month = dateNow.month();
|
if (month < 4) {
|
year -= 1;
|
}
|
Amount_Major_Product__c amp=new Amount_Major_Product__c();
|
amp.key__c=U2.id+'_GI';
|
amp.Amount__c=200.0;
|
amp.user_Alias__c=U2.Alias;
|
amp.Is_Processing__c=true;
|
amp.iYear__c=year;
|
amp.SAP_Province__c = U2.Province__c;
|
amp.Use_Start_Date__c = U2.Use_Start_Date__c;
|
|
insert amp;
|
|
SetPersonalTargetController odc = new SetPersonalTargetController();
|
// 初期表示
|
odc.init();
|
//System.assertEquals(1, odc.getUserSize());
|
//System.assertEquals(7, odc.getPSize());
|
//System.assertEquals(1, odc.dataBeans.size());
|
|
//wangweipeng SWAG-C6V8W5 2021/09/16 start
|
odc.saveFlg = true;
|
odc.searchByFilter();
|
//wangweipeng SWAG-C6V8W5 2021/09/16 end
|
|
|
// 検索
|
// 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.exportBycsv();
|
|
//odc.csvFileBody = Blob.valueOf('本部,省,角色,担当,职位,负责产品分类,GI,ET,BF,GS,URO,GYN,ENT,ENG \n,5.华东,上海市,上海GI组,张四洋,主管,GI,2000,2345,123,1200,400,500,40,55');
|
odc.csvAsString = '本部,省,角色,担当,职位,负责产品分类(主),负责产品分类(兼),GI,ET,BF,GS,URO,GYN,ENT,ENG\n5.华东,上海市,上海GI组,张四洋,主管,GI,,2000,2345,123,1200,400,500,40,55';
|
//test read csv file
|
odc.importCSVFile();
|
|
|
// 保存
|
//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();
|
}
|
}
|
}
|