• Eden
  • NEWBIE
  • 0 Points
  • Member since 2013

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 0
    Replies

How do I set multiple responses for different call outs in this class that implements WebServiceMock?

@isTest
global class PuchaseWSMock_IsTest 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) {
       
        //set response for web service method 1                   
        PurchaseWS.ProgramInfoResponse responseElement = new PurchaseWS.ProgramInfoResponse();
        responseElement.AgreementID = 344;
                            
        response.put('response_x', responseElement);

       //set response for web service method2?
    }
}

 


Test method:
static testMethod void myTest() {
       Test.setMock(WebServiceMock.class, new PurchaseWSMock_IsTest());
       
     Test.startTest();
      //call web service method 1
      //call web service method 2
     Test.startTest();
}

  • October 18, 2013
  • Like
  • 0