You need to sign in to do that
Don't have an account?
Raghavendra M 13
How can i cover test class for the following code?
public class IntegrationClss
{
@future(callout=true)
public Static void MealTimeCall()
{
Http h = new Http();
// Instantiate a new HTTP request, specify the method (GET) as well as the endpoint
HttpRequest req = new HttpRequest();
req.setMethod('GET');
req.setHeader('Connection','keep-alive');
req.setTimeOut(120000);
req.setHeader('Content-Type', 'application/xml;charset=UTF-8');
req.setEndpoint('https://lightningnumberofopportunities-dev-ed.my.salesforce.com/MealTime.php');
HttpResponse res = h.send(req);
system.debug(res.getbody());
ProfitCenterCall();
}
public Static void ProfitCenterCall()
{
Http h = new Http();
// Instantiate a new HTTP request, specify the method (GET) as well as the endpoint
HttpRequest req = new HttpRequest();
req.setMethod('GET');
req.setHeader('Connection','keep-alive');
req.setTimeOut(120000);
req.setHeader('Content-Type', 'application/xml;charset=UTF-8');
req.setEndpoint('https://lightningnumberofopportunities-dev-ed.my.salesforce.com/Profit%20Center.php');
HttpResponse res = h.send(req);
system.debug(res.getbody());
StoreCall();
}
public Static void StoreCall()
{
Http h = new Http();
// Instantiate a new HTTP request, specify the method (GET) as well as the endpoint
HttpRequest req = new HttpRequest();
req.setMethod('GET');
req.setHeader('Connection','keep-alive');
req.setTimeOut(120000);
req.setHeader('Content-Type', 'application/xml;charset=UTF-8');
req.setEndpoint('https://lightningnumberofopportunities-dev-ed.my.salesforce.com/Store.php');
HttpResponse res = h.send(req);
system.debug(res.getbody());
SalesDepartmentCall();
}
}
{
@future(callout=true)
public Static void MealTimeCall()
{
Http h = new Http();
// Instantiate a new HTTP request, specify the method (GET) as well as the endpoint
HttpRequest req = new HttpRequest();
req.setMethod('GET');
req.setHeader('Connection','keep-alive');
req.setTimeOut(120000);
req.setHeader('Content-Type', 'application/xml;charset=UTF-8');
req.setEndpoint('https://lightningnumberofopportunities-dev-ed.my.salesforce.com/MealTime.php');
HttpResponse res = h.send(req);
system.debug(res.getbody());
ProfitCenterCall();
}
public Static void ProfitCenterCall()
{
Http h = new Http();
// Instantiate a new HTTP request, specify the method (GET) as well as the endpoint
HttpRequest req = new HttpRequest();
req.setMethod('GET');
req.setHeader('Connection','keep-alive');
req.setTimeOut(120000);
req.setHeader('Content-Type', 'application/xml;charset=UTF-8');
req.setEndpoint('https://lightningnumberofopportunities-dev-ed.my.salesforce.com/Profit%20Center.php');
HttpResponse res = h.send(req);
system.debug(res.getbody());
StoreCall();
}
public Static void StoreCall()
{
Http h = new Http();
// Instantiate a new HTTP request, specify the method (GET) as well as the endpoint
HttpRequest req = new HttpRequest();
req.setMethod('GET');
req.setHeader('Connection','keep-alive');
req.setTimeOut(120000);
req.setHeader('Content-Type', 'application/xml;charset=UTF-8');
req.setEndpoint('https://lightningnumberofopportunities-dev-ed.my.salesforce.com/Store.php');
HttpResponse res = h.send(req);
system.debug(res.getbody());
SalesDepartmentCall();
}
}
Please go through this documention on how to cover callouts in test class.
https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_classes_restful_http_testing.htm
Alternatively, as you are not relying on the response, you can wrap the callout like below:
if(!test.isRunningTest()){
HttpResponse res = h.send(req);
system.debug(res.getbody());
}