You need to sign in to do that
Don't have an account?
miteshsura
writing test class for a web service method
hello all,
I have a APEX class, with a webservice
global class ProductAdminWebService { ... ... webservice static string goLive(string recordId, string status, string productRegion){ ... ... } }
The only purpose why its a web service, so I can call from my custom button on VF page with a page refresh. It does not make any call outs.
The webservice has a SOSL (NOT SOQL) querry and returns result when called from my custom button on VF page but returns nothing when called from my test method. Am I missing anything here? Below is the SOSL query:
List<List<SObject>> searchList; searchList = [FIND :productRegion IN ALL FIELDS RETURNING Product_Administration__c (id, Description__c, Product__c, Product_Region__c, AP_Price__c, Direct_Price__c, Dist_Price__c, LA_Price__c, Standard_Price__c, Schedule_Date__c WHERE Id= :recordId), Service_Administration__c (id, Description__c, Product__c, Product_Region__c, AP_Price__c, Direct_Price__c, Dist_Price__c, LA_Price__c, Standard_Price__c WHERE Product_Administration__c= :recordId LIMIT 7) LIMIT 8];
This is urgent, as I need to deploy to production asap. Please help.
SOSL doesn't work in test methods.
however you can use methods in test class to force the search results to be returned
eg straight from the docs
After hard day looking at it, I fig'd yday night.. one thing I am trying now is, in my SOSL, I am serching in multiple objects, how can I add Id for additional object in that test eg you provided ??
Does it make sense?