function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
sruthi26sruthi26 

Test class for an Asynchronous class imported by a WSDL(SOAP)

Hi, Here is my Asynchronous class imported by a WSDL. Can anyone tell me how to write a test class for this class. Also I want to know how to deal with 'System.Continuation continuation' . Thanks in advance.


public class AsyncOntrackworkflowComWebservicesAuth {
   
    public class LoginResponse_elementFuture extends System.WebServiceCalloutFuture {
        public String getValue() {
            ontrackworkflowComWebservicesAuth.LoginResponse_element response = (ontrackworkflowComWebservicesAuth.LoginResponse_element)System.WebServiceCallout.endInvoke(this);
            if(!Test.isRunningTest()) {
            return response.LoginResult;
             }
            else {
            return 'Success';
            }
        }
    } 
    public class AsyncOTWSAuthenticationServiceSoap {
        public String endpoint_x = 'https://sites-test.ontrackworkflow.com/adpes/OTWSAuthenticationService.asmx';
        public Map<String,String> inputHttpHeaders_x;
        public String clientCertName_x;
        public Integer timeout_x;
        private String[] ns_map_type_info = new String[]{'http://ontrackworkflow.com/webservices', 'ontrackworkflowComWebservicesAuth'}; 
        public AsyncOntrackworkflowComWebservicesAuth.LoginResponse_elementFuture beginLogin(System.Continuation continuation,String logonName,String logonPassword) {
            ontrackworkflowComWebservicesAuth.Login_element request_x = new ontrackworkflowComWebservicesAuth.Login_element();
            request_x.logonName = logonName;
            request_x.logonPassword = logonPassword;
    return (AsyncOntrackworkflowComWebservicesAuth.LoginResponse_elementFuture) System.WebServiceCallout.beginInvoke(this,request_x,AsyncOntrackworkflowComWebservicesAuth.LoginResponse_elementFuture.class,continuation,new String[]{endpoint_x,'http://ontrackworkflow.com/webservices/Login','http://ontrackworkflow.com/webservices','Login','http://ontrackworkflow.com/webservices','LoginResponse','ontrackworkflowComWebservicesAuth.LoginResponse_element'});
        }
     
    }
}
Best Answer chosen by sruthi26
Amit Chaudhary 8Amit Chaudhary 8
Please check below post for same
1) https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_callouts_wsdl2apex_testing.htm

You need to create mock callout for same