+ 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';
            Id SQId = [Select Id from Student_Questionnaire__c
                      where Account__r.Id =:AccountId ].Id;
        System.debug('StudentQuestionnaireId: ' + 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 );
        try {
            res = http.send(req);
        } catch(System.CalloutException e) {
            System.debug('Callout error: '+ e);

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:

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.