@isTest private class cSearchTest{
@isTest static void testbuildQuery(){
Profile p = [select id from profile where name='Standard User'];
User u = new User(alias = 'standt', email='[email protected]',
emailencodingkey='UTF-8', lastname='Testing', languagelocalekey='en_US',
localesidkey='en_US', profileid = p.Id,
timezonesidkey='America/Los_Angeles', username='[email protected]');
System.runAs(u){
//system.debug(conSearch.buildQuery());
system.debug('Tree Types are: ' + conSearch.getTreeType());
}
}
}
The above code causes the error:
Method does not exist or incorrect signature: conSearch.getTreeType()
The code from the conSearch controller
public class conSearch {
public PageReference doFilter() {
return null;
}
public List<Tree2__c> sTree {get;set;}
public String searchString {get;set;}
public Tree2__c tSurgeon {get;set;}
public String searchType {get;set;}
public String searchDisease {get;set;}
public String searchSurgeon {get;set;}
public String searchStatus {get;set;}
public boolean searchBreed {get;set;}
public Date searchDate {get;set;}
String startQuery = 'SELECT TreeID__c, Tree2__c.Name, Status__c FROM Tree2__c WHERE Native_Breed__c = :searchBreed';
List<String> query = new List<String>();
public String testQuery {get;set;}
public void buildQuery(){
Date phDate;
searchSurgeon = tSurgeon.Surgeon__c;
String tyQuery = 'Type_of_Tree__c LIKE :searchType';
String diQuery = 'Disease__c LIKE :searchDisease';
String suQuery = 'Surgeon__c = :searchSurgeon';
String stQuery = 'Status__c LIKE :searchStatus';
String daQuery = 'Date_of_planting__c = :searchDate';
String brQuery = 'Native_Breed__c = :searchBreed';
query.add(startQuery);
if(searchDisease != null){
query.add(diQuery);
}
if(searchSurgeon != null){
query.add(suQuery);
}
if(searchStatus != null){
query.add(stQuery);
}
if(searchDate != phDate){
query.add(daQuery);
}
if(searchType != null){
query.add(tyQuery);
}
String result = String.join( query, ' AND ' );
sTree = Database.query(result);
testQuery = result;
query.clear();
}
public void clear(){
sTree.clear();
}
public conSearch(ApexPages.StandardController controller){
rTreeType = (Tree2__c) controller.getRecord();
rDisease = (Tree2__c) controller.getRecord();
rStatus = (Tree2__c) controller.getRecord();
tSurgeon = new Tree2__c();
}
//**-------------------------------------------populate picklist values-------------------------------------------**//
Tree2__c rTreeType;
Tree2__c rDisease;
Tree2__c rStatus;
public List<SelectOption> getTreeType(){
List<SelectOption> treeType = new List<SelectOption>();
Schema.DescribeFieldResult dfr = Tree2__c.Type_of_Tree__c.getDescribe();
for(Schema.PicklistEntry ple : dfr.getPicklistValues()){
treeType.add(new SelectOption(ple.getValue(), ple.getLabel(), !ple.isActive()));
if(ple.isDefaultValue()){
rTreeType.Type_of_Tree__c = ple.getValue();
}
}
return treeType;
}
public List<SelectOption> getDisease(){
List<SelectOption> disease = new List<SelectOption>();
Schema.DescribeFieldResult dfr = Tree2__c.Disease__c.getDescribe();
for(Schema.PicklistEntry ple : dfr.getPicklistValues()){
disease.add(new SelectOption(ple.getValue(), ple.getLabel(), !ple.isActive()));
if(ple.isDefaultValue()){
rDisease.Disease__c = ple.getValue();
}
}
return disease;
}
public List<SelectOption> getStatus(){
List<SelectOption> status = new List<SelectOption>();
Schema.DescribeFieldResult dfr = Tree2__c.Status__c.getDescribe();
for(Schema.PicklistEntry ple : dfr.getPicklistValues()){
status.add(new SelectOption(ple.getValue(), ple.getLabel(), !ple.isActive()));
if(ple.isDefaultValue()){
rStatus.Status__c = ple.getValue();
}
}
return status;
}
}
Am i incorrectly calling the class? As far as I can this is the correct way to call the method in a unit test.