You need to sign in to do that
Don't have an account?
Dmitriy Jedi
Cannot complete Apex REST Callouts module
Have 100% coverage using AnimalLocatorMock.apxc class in my connected org, but got the error when check challenge:
Challenge Not yet complete... here's what's wrong:
No Apex class named 'AnimalLocatorMock' was found.
Please help!!!
Challenge Not yet complete... here's what's wrong:
No Apex class named 'AnimalLocatorMock' was found.
Please help!!!
https://developer.salesforce.com/forums/?id=906F0000000MJiPIAW
Looks like the same problem (with solution), maybe it can help you.
All Answers
paste here your source code for this module and I belive someone will help you ;)
I passed this module without error, so I can check when you share your code.
Or if this is related to lightning development, see here for a user who had a similar issue and managed to resolve it:
http://salesforce.stackexchange.com/questions/92847/cant-set-lightning-component-controller
https://developer.salesforce.com/forums/?id=906F0000000MJiPIAW
Looks like the same problem (with solution), maybe it can help you.
( please mark this question as solved ;) )
public class AnimalLocator { public static String getAnimalNameById(Integer animalId) { String animalName = ''; String endPointUrl = ' https://th-apex-http-callout.herokuapp.com/animals/' + String.valueOf(animalId); Http http = new Http(); HttpRequest request = new HttpRequest(); request.setEndpoint(endPointUrl); request.setMethod('GET'); HttpResponse response = http.send(request); // If the request is successful, parse the JSON response. String result = 'None'; if (response.getStatusCode() == 200) { String jsn = response.getBody(); result = jsn; System.debug(' --------------> ' + jsn); } return result; } } @isTest global class AnimalLocatorMock implements HttpCalloutMock { // Implement this interface method global HTTPResponse respond(HTTPRequest request) { // Create a fake response HttpResponse response = new HttpResponse(); response.setHeader('Content-Type', 'application/json'); response.setBody('{"animal":{"id":2,"name":"bear","eats":"berries, campers, adam seligman","says":"yum yum"}}'); response.setStatusCode(200); return response; } } @isTest private class AnimalLocatorTest{ static testMethod void testLocator() { Test.setMock(HttpCalloutMock.class, new AnimalLocatorMock()); String actualValue = AnimalLocator.getAnimalNameById(2); String expectedValue = '{"animal":{"id":2,"name":"bear","eats":"berries, campers, adam seligman","says":"yum yum"}}'; System.assertEquals(actualValue, expectedValue); } }