I trying to stub the output of this method call
public string getOrgDomainUrl() {
return URL.getOrgDomainURL().toExternalForm();
}
I have so far done it like this
public class UrlServiceStub implements System.StubProvider {
private string domain;
public UrlServiceStub(string domain) {
this.domain = domain;
}
public Object handleMethodCall(
Object stubbedObject,
String stubbedMethodName,
Type returnType,
List<Type> listOfParamTypes,
List<String> listOfParamNames,
List<Object> listOfArgs
) {
if (stubbedMethodName == 'getOrgDomainUrl') {
return domain;
}
return null;
}
}
Problem is though when I try to use the stub api in a test, the method call returns null? and not the expected domain value?