You need to sign in to do that
Don't have an account?
Shane K 8
Method incorrect signature
Hello,
I am getting this error when calling the CalloutClass from test method.
Method does not exist or incorrect signature: void getParams(Id) from the type CalloutClass
I am getting this error when calling the CalloutClass from test method.
Method does not exist or incorrect signature: void getParams(Id) from the type CalloutClass
public class CalloutClass { @future (callout=true) public static void getParams(List<Id> Ids) { try{ //logic } catch (Exception e) { system.debug(e); } } }
@isTest public class CalloutClassTest { static testMethod void testMethod() { ObjX__c testX = new ObjX__c(); testx.Name = 'test record' ; insert testX; Test.setMock(HttpCalloutMock.class, new MockHttpResponseGenerator()); // Call method to test. // This causes a fake response to be sent // from the class that implements HttpCalloutMock. HttpResponse res = CalloutClass.getParams(testX.id); // Verify response received contains fake values String contentType = res.getHeader('Content-Type'); System.assert(contentType == 'application/json'); String actualValue = res.getBody(); String expectedValue = '{"example":"test"}'; System.assertEquals(actualValue, expectedValue); System.assertEquals(200, res.getStatusCode()); } }
@isTest global class MockHttpResponseGenerator implements HttpCalloutMock { // Implement this interface method global HTTPResponse respond(HTTPRequest req) { // Optionally, only send a mock response for a specific endpoint // and method. System.assertEquals('http://example.com/example/test', req.getEndpoint()); System.assertEquals('GET', req.getMethod()); // Create a fake response HttpResponse res = new HttpResponse(); res.setHeader('Content-Type', 'application/json'); res.setBody('{"example":"test"}'); res.setStatusCode(200); return res; } }
Can you try checking if the error disappears if the id is sent as a list instead of a single id?
Looking forward to your response.
Regards,
Anutej
Tried passing a list but the error persists.
Thanks.