2

I have the following class with constructor chaining , but the validations are returning Method not found or incorrect signature

class

@IsTest
global class CalloutMock implements HttpCalloutMock {
    private Map<String,HttpResponse> httpResponseMap = new Map<String,HttpResponse>();

   global CalloutMock(Map<String,HttpResponse> responseMap){
        if (responseMap != null) {
            httpResponseMap = responseMap;
        }
    }

   global CalloutMock(){
        CalloutMock(null);
    }

    global HttpResponse respond(HttpRequest req) {
        System.debug('req end point hitting is ' + req.getEndpoint());
        return  httpResponseMap.get(req.getEndpoint());
  
    }

}

why is that ? and how do i resolve it?

1
  • You should use this(null); instead of CalloutMock(null); Nov 8, 2021 at 9:11

1 Answer 1

4

To call a different constructor, you should call this(null);, instead CalloutMock(null);. The latter would just call an instance method called CalloutMock, which is not exactly what you're doing.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .