stub api returns null eventhoug value is specified?

19 views Asked by At

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?

0

There are 0 answers