I am trying to test an HttpCallout using mocks and I get the following error :
System.TypeException: Supplied type is not an interface Stack Trace Class.System.Test.setMock: line 57, column 1 Class.ProjectCalloutServiceTest.testBillingCalloutService: line 15, column 1
Here is my test class
@IsTest
private class ProjectCalloutServiceTest {
@IsTest
private static void testBillingCalloutService() {
Account a = new Account(Name = 'Acme');
insert a;
Opportunity o = new Opportunity(Name='Test', StageName='Submitted Project', AccountId=a.Id, Amount=1000, CloseDate=Date.Today());
insert o;
List<Id> oppList = new List<Id>();
oppList.add(o.Id);
Test.setMock(ProjectCalloutServiceMock.class, new ProjectCalloutServiceMock());
Test.startTest();
ProjectCalloutService.postOpportunityToPMS(oppList);
Test.stopTest();
// runs callout and check results
o = [select StageName from Opportunity where id =: o.Id];
System.assertEquals('Submitted Project', o.StageName);
}
}
@isTest
global class ProjectCalloutServiceMock implements HttpCalloutMock {
global HttpResponse respond(HttpRequest req) {
// Create a fake response
HttpResponse res = new HttpResponse();
res.setHeader('Content-Type', 'application/json');
res.setBody('{"status":"success"}');
res.setStatusCode(200);
return res;
}
}
I can't find any documentation on this error. What could cause this type of exception?