You need to sign in to do that
Don't have an account?
dhruv arora
please help me to complete this challenge.help me in writting its test class
public class AnimalLocator { public class Animal { public Integer id; public String name; public String eats; public String says; } public class AnimalResult { public Animal animal; } public static String getAnimalNameById(Integer id) { Http http = new Http(); HttpRequest request = new HttpRequest(); request.setEndpoint('https://th-apex-http-callout.herokuapp.com/animals/' + id); request.setMethod('GET'); HttpResponse response = http.send(request); AnimalResult result = (AnimalResult) JSON.deserialize(response.getBody(), AnimalResult.class); return result.animal.name; } }
Use the below code.
Mark it solution if it will solve your problem.
Naresh.
1) https://developer.salesforce.com/forums/?id=906F0000000MJXvIAO
2) https://developer.salesforce.com/forums/?id=906F0000000MJiKIAW
Create moke class like below Test class like below NOTE:- always try to use Assert
Let us know if this will help you
Thanks
Amit Chaudhary