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
Douglas TrasterDouglas Traster 

Webservice Unit Test

I am trying to build a unit test for my webservice.

I have the following class that is able to pull an ID from a custom object:

global with sharing class SendDataforForms {
    webservice static string SendDataforForms(Id AccountId) {
    String result = 'need to add try catch to help in debug';
 
        try{
            Id SQId = [Select Id from Student_Questionnaire__c
                      where Account__r.Id =:AccountId ].Id;
        System.debug('StudentQuestionnaireId: ' + SQId);
        TenStreetWebservice.GetStudentIDforData(SQId);
        result = 'OK';  
        return result;
            
        }catch(DmlException e) {
            System.debug('The Following exception has occurred: '+e.getMessage());
            result = e.getMessage();
            return result;  
        }       
    }  
}

Which, in turn, calls a webservice:
global class TenStreetWebservice {
    public TenStreetWebservice () {
        
    }
    @future (callout=true)
    public static void GetStudentIDforData(Id StudentQuestionnaireId) {
        System.debug('Start StudentQID');
        System.debug('StudentQuestionnaireId: ' + StudentQuestionnaireId);
        HttpRequest req = new HttpRequest();
        HttpResponse res = new HttpResponse();
        Http http = new Http();

        req.setEndpoint('http://cloud01.roadmaster.com:46908/api/v1/SendTo10Street?StudentQuestionnaireId='+StudentQuestionnaireId );
        req.setMethod('POST');
        req.setTimeout(50000);        
        try {
            res = http.send(req);
        } catch(System.CalloutException e) {
            System.debug('Callout error: '+ e);
            System.debug(res.toString());
}
     }
       }

I am having problems with testing the string that I should be testing.  I have this so far, but am lost on how I should go:

@isTest
global class TenStreetWebSvcMockImpl 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) {
               public String[] createSendDataforForms; 
               }

   }

Any help would be appreciated.