5

I have tried to create a test coverage method against a database Query which goes after an external object. The external datasource is a Lightning ODATA 2.0 connector. I setup the MockHTTPcallout but, it does not appear that the call is working. No errors, but no data is returned. Does anyone have an example of how to do this?

@isTest static void testGetSubmittedCSPQuotes() 
{
    String body = '{"QuoteNumber":"0030015397","QuoteType":"02","CustomerNumber":"0806253084","StatusCode":"AC","StartDate":"/Date(1452988800000)/","EndDate":"/Date(1455580800000)/","SubmitDate":"/Date(1452988800000)/","ReqDueDate":"/Date(1453075200000)/","LineCount":1,"QuoteValue":"0.00","SendEquoteToGcom":"N","EmailAddress":"[email protected]","SellerUserId": "CSPT1"}';
    SingleRequestMock fakeResponse = new SingleRequestMock(200, 'SUCCESS',body,null);
    Test.setMock(HttpCalloutMock.class, fakeResponse);

    testUser1.FederationIdentifier='CSPT1';

    System.runAs(testUser1)
    {
      Test.startTest();
      List<Quotes__x> myQuotes1 = CSPQuoteCoreController.getSubmittedCSPQuotes(testUser1);
      Test.stopTest();  
    }

    system.assertEquals(1,myQuotes1.size());
}
3

0

You must log in to answer this question.

Browse other questions tagged .