Controller:
global class GetcontentCalloutClass {
public GetcontentCalloutClass(ApexPages.StandardController controller) {}
public static Map<String, String> respStrings;
global static HttpResponse getcontentFromdftlyService(String rec_Id, String appkey) {
HttpRequest req = new HttpRequest();
req.setEndpoint('https://example.com/example');
req.setMethod('GET');
// Create a new http object to send the request object
// A response object is generated as a result of the request
Http http = new Http();
HTTPResponse res = http.send(req);
System.debug(res.getBody());
return res;
}
@RemoteAction
global static Map<String, String> get_content(String rec_Id, String appkey){
HttpResponse res = GetcontentCalloutClass.getcontentFromdftlyService(rec_Id,appkey);
respStrings = new Map<String, String>{'jsonString' => res.getBody()};
return respStrings;
}
}
Test Class:
@isTest
public class get_content_links_test {
static testMethod void testMethod1()
{
dftly_Timesheet_Detail__c dTDetait = new dftly_Timesheet_Detail__c (Name = 'My Test Account');
insert dTDetait ;
Map<String, String> Test_MyStrings = get_content_links.get_content('Test body',dTDetait.id);
}
}
Error message on run test: Methods defined as TestMethod do not support Web service.