• Leslie King
  • NEWBIE
  • 5 Points
  • Member since 2019

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 2
    Replies
I want to add value-"Open" on standard Picklist field "Status" available on standard Object. And also want to set it as Default. I tried doing it but no Luck. Please assist
I am trying to cover this generic method in Apex class,
public class apexClassGeneric{
 public static HttpResponse methodName(HttpRequest request) {
 HttpResponse response = h.send(request);
return response;

}
}

This is my test class.

public static testmethod void testAccountCallout() {
        SingleRequestMock fakeResponse = new SingleRequestMock(200,
                                                 'Complete',
                                                 '[{"Name": "sForceTest1"}]',
                                                 null);
        Test.setMock(HttpCalloutMock.class, fakeResponse);
        
        string endPoint='https://ap5.salesforce.com/services/apexrest/getAccountOnExternalIdtofetchsinglerecord/';
        HttpRequest req1=new HttpRequest();
        
        req1.setMethod('GET');
        req1.setEndpoint(endPoint);
        HttpResponse resp=apexClassGeneric.methodName(req1);
       
    }


I am not able to cover this I am getting error.

System.CalloutException: You have uncommitted work pending. Please commit or rollback before calling out

Note: If it would have been a method without HttpRequest request i would have cover it easily using,

HttpResponse resp=apexClassGeneric.methodName();