Salesforce Apex Test Class with sendRequest generic method
Hi All,
i've created a Salesforce class that uses the Box API to check what is in an account's folder. Where I am getting stuck is creating a test class in Apex. The usual process would be to create a httpMock class to simulate a response but this does not work when you use the sendRequest method, example below
// Instantiate the Toolkit object
box.Toolkit toolkit = new box.Toolkit();
// Sets endpoint to Box API call using the account's folder id
string endpoint = 'https://api.box.com/2.0/folders/' + folderId + '/items';
// Creates httprequest
HttpRequest request = new HttpRequest();
request.setMethod('GET');
request.setEndpoint(endpoint);
// stores the json response form the Box API
//HttpResponse response = toolkit.sendRequest(request);
if i replace the httpResponse line with the below,
Http h = new Http();
HttpResponse response = h.send(Request);
The httpMock class works perfectly and my test will work.
Has anyone had any success in developing an Apex test class than can work with the sendRequest generic method?
Cheers
Daniel
サインインしてコメントを残してください。
コメント
0件のコメント