0

I'm new in salesforce and I'm learning through the trails. Doing the Apex Integration Services module, in the Apex SOAP Callouts unit I had to get info from outside salesforce. It asked me this:

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.

My question is, where I can find the park list that the service is suposed to return, to make the Mock class? I already finished the challenge finding the park list for Germany in a salesforce developer forum, but it doesn't explain where I can get this list. It would be nice if you can help me, thanks.

0

The point of the mock is that you only need to return data that allows you to verify the behavior. It doesn't need to be the exact list that the service returns, just a sample bit of data that your Apex class is expecting and generates sufficient coverage. As long as the data returned can be processed correctly, the mock has done its job.

  • Thank you very much!! I apreciate your help. This is something that is not very clear on the trailhed, but with your answer now I understand how does de Mock works. – HugoCa Mar 28 at 6:58
  • @HugoCa You're welcome! Always glad to help when I can. – sfdcfox Mar 28 at 6:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.