You can set both types of mocks, which is the purpose of the first parameter.
@isTest static void testPageAction() {
Test.setMock(WebServiceMock.class, new WSServicesMock());
Test.setMock(HttpCalloutMock.class, new RestServicesMock());
// rest of test
Please note that each mock may need to read the input parameters to determine the appropriate output, as you can only set one mock of each type. However, you can definitely respond to both types of callouts that may be in a single function call.
public class WSServicesMock implements WebServiceMock {
public void doInvoke(
Object stub,
Object request,
Map<String, Object> response,
String endpoint,
String soapAction,
String requestName,
String responseNS,
String responseName,
String responseType) {
// corrected syntax for switch expression, using 'switch on (requestName)' instead of 'switch (requestName)'
switch on (requestName) {
when 'abc' {
// handle first type
}
when 'xyz' {
// handle second type
}
when else {
// return an error?
}
}
}
}