1.ParkServiceMock ------------------------------------- @isTest global class ParkServiceMock implements WebServiceMock { global void doInvoke( Object stub, Object request, Map 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{'Yellowstone', 'Mackinac National Park', 'Yosemite'}; // end response.put('response_x', response_x); } } 2.ParkLocator ----------------------------- public class ParkLocator { public static string[] country(string theCountry) { ParkService.ParksImplPort parkSvc = new ParkService.ParksImplPort(); // remove space return parkSvc.byCountry(theCountry);
} } 3.ParkLocatorTest -------------------------------- @isTest private class ParkLocatorTest { @isTest static void testCallout() { Test.setMock(WebServiceMock.class, new ParkServiceMock ()); String country = 'United States'; List result = ParkLocator.country(country); List parks = new List{'Yellowstone', 'Mackinac National Park', 'Yosemite'}; System.assertEquals(parks, result); } }
bhai remote site setting ka url mera galat bata rha hai kyu?
Thanks the lord thank you sir
my code have 6 problems
1.ParkServiceMock
-------------------------------------
@isTest
global class ParkServiceMock implements WebServiceMock {
global void doInvoke(
Object stub,
Object request,
Map 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{'Yellowstone', 'Mackinac National Park', 'Yosemite'};
// end
response.put('response_x', response_x);
}
}
2.ParkLocator
-----------------------------
public class ParkLocator {
public static string[] country(string theCountry) {
ParkService.ParksImplPort parkSvc = new ParkService.ParksImplPort(); // remove space
return parkSvc.byCountry(theCountry);
}
}
3.ParkLocatorTest
--------------------------------
@isTest
private class ParkLocatorTest {
@isTest static void testCallout() {
Test.setMock(WebServiceMock.class, new ParkServiceMock ());
String country = 'United States';
List result = ParkLocator.country(country);
List parks = new List{'Yellowstone', 'Mackinac National Park', 'Yosemite'};
System.assertEquals(parks, result);
}
}
code coming error
Yes
Code getting 6 errors
please help me bro
me too@@ajaypalla2003