Create an Apex class that calls a REST endpoint and write a test class

To pass this challenge, create an Apex class that calls a REST endpoint to return the name of an animal, write unit tests that achieve 100% code coverage for the class using a mock response, and run your Apex tests.
  • The Apex class must be called ‘AnimalLocator’, have a ‘getAnimalNameById’ method that accepts an Integer and returns a String.
  • The ‘getAnimalNameById’ method must call https://th-apex-http-callout.herokuapp.com/animals/:id, using the ID passed into the method. The method returns the value of the ‘name’ property (i.e., the animal name).
  • Create a test class named AnimalLocatorTest that uses a mock class called AnimalLocatorMock to mock the callout response.
  • The unit tests must cover all lines of code included in the AnimalLocator class, resulting in 100% code coverage.
  • Run your test class at least once (via ‘Run All’ tests the Developer Console) before attempting to verify this challenge.

Generate an Apex class using WSDL2Apex and write a test class

Generate an Apex class using WSDL2Apex for a SOAP web service, write unit tests that achieve 100% code coverage for the class using a mock response, and run your Apex tests.
  • Use WSDL2Apex to generate a class called ‘ParkService’ in public scope using this WSDL file. After you click the ‘Parse WSDL’ button don’t forget to change the name of the Apex Class Name from ‘parksServices’ to ‘ParkService’.
  • Create a class called ‘ParkLocator’ that has a ‘country’ method that uses the ‘ParkService’ class and returns an array of available park names for a particular country passed to the web service. Possible country names that can be passed to the web service include Germany, India, Japan and United States.
  • Create a test class named ParkLocatorTest that uses a mock class called ParkServiceMock to mock the callout response.
  • The unit tests must cover all lines of code included in the ParkLocator class, resulting in 100% code coverage.
  • Run your test class at least once (via ‘Run All’ tests the Developer Console) before attempting to verify this challenge.

Create an Apex REST service that returns an account and it’s contacts

To pass this challenge, create an Apex REST class that is accessible at ‘/Accounts/<Account_ID>/contacts’. The service will return the account’s ID and Name plus the ID and Name of all contacts associated with the account. Write unit tests that achieve 100% code coverage for the class and run your Apex tests.
  • The Apex class must be called ‘AccountManager’.
  • The Apex class must have a method called ‘getAccount’ that is annotated with @HttpGet and returns an Account object.
  • The method must return the ID and Name for the requested record and all associated contacts with their ID and Name.
  • The unit tests must be in a separate Apex class called ‘AccountManagerTest’.
  • The unit tests must cover all lines of code included in the AccountManager class, resulting in 100% code coverage.
  • Run your test class at least once (via ‘Run All’ tests the Developer Console) before attempting to verify this challenge.