@isTest private class ConSearchAgencyPlaceTest { // @isTest static void test_method_one() { // RecordType rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and DeveloperName = 'Agency']; // Account acc = new Account(); // acc.RecordTypeId = rectCo.Id; // acc.Name = 'HP test1'; // insert acc; // PageReference page = new PageReference('/apex/ConSearchAgencyPlace?q=Gastoro&r='); // System.Test.setCurrentPage(page); // ConSearchAgencyPlace cmsd = new ConSearchAgencyPlace(); // cmsd.getIsOverLimit(); // //初始化测试 // cmsd.search(); // } // 测试模糊查询方法 @isTest static void testSearch(){ List rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '販売店']; if (rectCo.size() == 0) { return; } List rectCotac = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '契約']; if (rectCotac.size() == 0) { return; } Account myAccount2 = new Account(name='济南浓美',Dealer_discount__c =20,RecordTypeId = rectCo[0].Id,Product_Limit_Date__c = 'Test01|5|55,Test02|2|4',ET_SP_Dealer__c = true); insert myAccount2; Account contact = new Account(name='Testaccount002',RecordTypeId = rectCotac[0].Id,SpecialDealerName__c = '济南浓美',ParentId = myAccount2.Id,Agent_Ref__c = myAccount2.Id,Delete_Flag__c = false,Contract_Department_Class__c = 'ET',Contract_Decide_Start_Date__c = Date.today().addDays(-1),Contract_Decide_End_Date__c = Date.today().addDays(1),AgentCode_Ext__c = '9999900',ET_SP_Dealer__c = true); insert contact; // Set qwords = new Set(); // String nameCondition = '%济南%'; // List accs; // accs = [SELECT id,Parentid // FROM Account // WHERE Parent.Name like :nameCondition // AND Contract_Decide_Start_Date__c <= :Date.Today() // AND Contract_Decide_End_Date__c >= :Date.Today()]; // // 検索 // for (Account acc : accs) { // qwords.add(acc.Parentid); // } // accs = [ // SELECT Id, Name, // Department_Class__c, Department_Class__r.Name, // Hospital__c, Hospital__r.Name // FROM Account // WHERE Id IN :qwords // AND RecordType.DeveloperName = 'Agency' // AND Is_Active__c <> '無効' order by Name limit 51 // ]; // // Map accMap = new Map((List) Database.query(queryString)); // // List accs = accMap.values(); // Map accMap = new Map(accs); // System.debug('print acc start'); // for (Account acc : accMap.values()) { // System.debug(acc); // } // System.debug('print acc end'); System.debug('search start'); PageReference page = new PageReference('/apex/ConSearchAgencyPlace?q=济南&r='); System.Test.setCurrentPage(page); ConSearchAgencyPlace cmsd = new ConSearchAgencyPlace(); cmsd.getIsOverLimit(); //初始化测试 cmsd.search(); System.debug('search end'); } }