+ Start a Discussion
AMIT KUMAR 73AMIT KUMAR 73 

Test Class for ServiceMax custom Apex Code

Hi,

I have written a custom apex code for web service integration. Input parameter is the RecordID. 
The functionality working fine but i am unable to achieve code coverage since i am unable to pass the Input parameter to my method "sfmOperation".

global class ServiceMaxOutbound{
    webservice static SVMXC.INTF_WebServicesDef.INTF_Response sfmOperation(SVMXC.INTF_We  bServicesDef.INTF_Response request)
   {     
       String recordId,logDescription;
       List<SVMXC__Service_Order__c> listWO;
       for(SVMXC.INTF_WebServicesDef.SVMXMap objSVXMMap : request.valueMap) {                                                    if(objSVXMMap.key == 'WorkOrder_ID'){                                                                   
                   recordId = objSVXMMap.value; 
                }
            }

Any suggestions will be highly appreciated as can't find any doc on how to write test classes for servicemax apex class.
Sumitkumar_ShingaviSumitkumar_Shingavi
Check: https://www.salesforce.com/us/developer/docs/apexcode/Content/apex_classes_restful_http_testing_httpcalloutmock.htm
AMIT KUMAR 73AMIT KUMAR 73
It is not even relevant to what i asked. Please be specific.
NAGENDRA TEKUMALLA 8NAGENDRA TEKUMALLA 8
Amit, did you ever get an answer or solution to this. I am stuck with similar unit test coverage for Apex web Service for Servicemax. Unfortunately, service max is charging to even provide the docs. I have signature like this 
webservice static SVMXC.SFM_WrapperDef.SFM_PageData processHeader(SVMXC.SFM_WrapperDef.SFM_TargetRecord request)
I have to reverse engineer request object that needs to be parsed in the method. Any help will e appreciated. Please reply to nagendrat@slalom.com
    
Anirudh Bora 14Anirudh Bora 14
Hi You can write test class for this as follows:-

      List<SVMXC.INTF_WebServicesDef.SVMXMap> testMapList = new List<SVMXC.INTF_WebServicesDef.SVMXMap>();
        SVMXC.INTF_WebServicesDef.SVMXMap testmap = new SVMXC.INTF_WebServicesDef.SVMXMap();
        testmap.key = 'WorkOrder_ID';
        testmap.value = workOrderId;   //create workOrder and assign its id here
        testMapList.add(testmap);
        
        SVMXC.INTF_WebServicesDef.INTF_Request request = new SVMXC.INTF_WebServicesDef.INTF_Request();
        request.valueMap = testMapList;
        System.assert(ServiceMaxOutbound.sfmOperation(request)!= null);

Please upvote!!!