@isTest private class OPDSortManageControllerTest { public static User user = new User(); static testMethod void testMethod1() { //OPD计划 OPDPlan__c oPDPlan1 = new OPDPlan__c(); oPDPlan1.Status__c = '计划中'; oPDPlan1.OPDPlan_ImplementDate__c = Date.today().addMonths(1); oPDPlan1.NoOpp_Reason__c = 'HCP对应'; //无询价理由 oPDPlan1.OPDLendSortDraft__c = 1; //备品借出优先度 //oPDPlan1.OPDType__c = '学会'; insert oPDPlan1; OPDPlan__c oPDPlan2 = new OPDPlan__c(); oPDPlan2.Status__c = '计划中'; oPDPlan2.OPDPlan_ImplementDate__c = Date.today().addMonths(1); oPDPlan2.NoOpp_Reason__c = 'HCP对应'; //oPDPlan2.OPDType__c = '学会'; insert oPDPlan2; OPDPlan__c oPDPlan3 = new OPDPlan__c(); oPDPlan3.Status__c = '计划中'; oPDPlan3.OPDPlan_ImplementDate__c = Date.today().addMonths(1); oPDPlan3.NoOpp_Reason__c = 'HCP对应'; oPDPlan3.OPDLendSortDraft__c = 2; //oPDPlan3.OPDType__c = '学会'; insert oPDPlan3; OPDPlan__c oPDPlan4 = new OPDPlan__c(); oPDPlan4.Status__c = '计划中'; oPDPlan4.OPDPlan_ImplementDate__c = Date.today().addMonths(1); oPDPlan4.NoOpp_Reason__c = 'HCP对应'; //oPDPlan4.OPDType__c = '学会'; insert oPDPlan4; OPDPlan__c oPDPlan5 = new OPDPlan__c(); oPDPlan5.Status__c = '计划中'; oPDPlan5.OPDPlan_ImplementDate__c = Date.today().addMonths(1); oPDPlan5.NoOpp_Reason__c = 'HCP对应'; //oPDPlan5.OPDType__c = '学会'; oPDPlan5.IsJump__c = true; oPDPlan5.JumpCause__c = '想插队'; oPDPlan5.OPDLendSortDraft__c = 15; insert oPDPlan5; OPDPlan__c oPDPlan6 = new OPDPlan__c(); oPDPlan6.Status__c = '计划中'; oPDPlan6.OPDPlan_ImplementDate__c = Date.today().addMonths(1); oPDPlan6.NoOpp_Reason__c = 'HCP对应'; //oPDPlan6.OPDType__c = '学会'; oPDPlan6.IsJump__c = true; oPDPlan6.JumpCause__c = '想插队'; oPDPlan6.OPDLendSort__c = 0; insert oPDPlan6; OPDPlan__c oPDPlan7 = new OPDPlan__c(); oPDPlan7.Status__c = '计划中'; oPDPlan7.OPDPlan_ImplementDate__c = Date.today().addMonths(1); oPDPlan7.NoOpp_Reason__c = 'HCP对应'; //oPDPlan7.OPDType__c = '学会'; oPDPlan7.IsJump__c = true; oPDPlan7.JumpCause__c = '想插队'; insert oPDPlan7; user = getUser(); List oplist = [select id,IsJump__c,JumpCause__c,OPDLendSortDraft__c,OPDLendSort__c,IsSaveOrSubmit__c from OPDPlan__c where Status__c='计划中']; System.assertEquals(7, oplist.size()); PageReference ref = new PageReference('/apex/OPDSortManage'); Test.setCurrentPage(ref); OPDSortManageController target = new OPDSortManageController(); target.init(); System.assertEquals(2, target.unCheckedOPDPlan.size()); //未排序的 //target.Salesdepartment = '1.华北'; target.searchBtn(); //System.assertEquals(2, target.unCheckedOPDPlan.size()); //未排序的 target.unCheckedOPDPlan[0].check = true; target.saveAdd(); target.autoSort(); target.opdDelId = oPDPlan5.id; target.del(); target.checkedOPDPlan[4].op.OPDLendSortDraft__c = 18; target.save(); //2020-12-02 mzy add 点击项目自行排序功能 target.sortTableFlagSort ='asc'; target.sortKey ='Sort'; target.sortTable(); target.sortTableFlagNDetail ='asc'; target.sortKey ='NDetail'; target.sortTable(); target.sortTableFlagNtime ='asc'; target.sortKey ='Ntime'; target.sortTable(); //2020-12-02 mzy add 点击项目自行排序功能 System.runAs(user) { List glist = [select id from group WHERE DeveloperName in ('X00_LOHBbeijing')]; GroupMember mb = new GroupMember(); mb.groupid = glist[0].id; mb.userOrGroupId = user.id; insert mb; target.submitBtn(); } } private static User getUser() { String timenow = Datetime.now().format('yyyyMMddHHmmss'); User usr = new User(Test_staff__c = true, LastName = 'TestZY', FirstName = 'TestZY', Alias = 'zy', CommunityNickname = 'TestMiao', Email = 'TestZY@test.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, Province__c = '北京市',Work_Location__c = '北京'); insert usr; return usr; } }