Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Apex SOAP Callouts from (module - Apex Integration Services)
- Remote Site URL : https://th-apex-soap-service.herokuapp.com
- -------------------------------------------------
- SOURCE CODE: ParkLocator
- public class ParkLocator {
- public static string[] country(string theCountry) {
- ParkService.ParksImplPort parkSvc = new ParkService.ParksImplPort();
- return parkSvc.byCountry(theCountry);
- } }
- -------------------------------------------------
- SOURCE CODE: ParkLocatorTest
- @isTest
- private class ParkLocatorTest {
- @isTest static void testCallout() {
- Test.setMock(WebServiceMock.class, new ParkServiceMock ());
- String country = 'United States';
- List<String> result = ParkLocator.country(country);
- List<String> parks = new List<String>{'Kaziranga National Park', 'Gir National Park', 'Deer Park'};
- System.assertEquals(parks, result);
- } }
- -------------------------------------------------
- SOURCE CODE: ParkServiceMock
- @isTest
- global class ParkServiceMock implements WebServiceMock {
- global void doInvoke(
- Object stub,
- Object request,
- Map<String, Object> response,
- String endpoint,
- String soapAction,
- String requestName,
- String responseNS,
- String responseName,
- String responseType) {
- // start - specify the response you want to send
- ParkService.byCountryResponse response_x = new ParkService.byCountryResponse();
- response_x.return_x = new List<String>{'Kaziranga National Park', 'Gir National Park', 'Deer Park'};
- // end
- response.put('response_x', response_x);
- } }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement