0

Whenever a new record of object abc is created, a queueable trigger handler makes http callout. My trigger handler is working fine and i am able to do what I intended, but when I test this trigger handler, I get this error -

"System.TypeException: Mock object doesn't implement the supplied interface"

Please provide some insights on what I am doing wrong and how to correct it. Thanks.

this is my mock response generator-

@isTest
global class MockFirebaseResponseGenerator {
    global HttpResponse respond(HttpRequest req) {
        HttpResponse response = new HttpResponse();
        response.setBody('{"success":1,"failure":0}');
        response.setStatusCode(200);
        return response;
    }
}

@isTest
public class TEST_FirebaseNotificationHandler {
    @isTest 
    static void testCallout(){
        // create test data
        Test.setMock(HttpCalloutMock.class, new MockFirebaseResponseGenerator());       
    }
}
1

This specific error is a simple omission of the implementation of HttpCalloutMock. Change:

global class MockFirebaseResponseGenerator

To:

global class MockFirebaseResponseGenerator implements HttpCalloutMock

Note, too, that it is unlikely you need to make any of what you have here global and should instead use public. The global access modifier is for cross-namespace access.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.