• Nitin Kumar 162
  • NEWBIE
  • 10 Points
  • Member since 2018

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 4
    Questions
  • 1
    Replies
I am using a class, in this I am using three HttpRequest on different URL for getting the data. 
Now I am creating the test class and for HTTP request I have used HttpCalloutMock but when i am run the test class it threw the error -
12:55:15:828 FATAL_ERROR System.AssertException: Assertion Failed: Expected: http://abcd/donor, Actual: http://xyz/oauth

My code - 
@Istest
public class SyncDonorToGCTest {
    @Istest 
    static void testCallout(){
        
        List<sObject> records = new List<sObject>();
        
        records.add(new Contact(firstname='TestFirstApi',lastname='LastMiddle',Email='TestEmailApi@gmail.com'));
        insert records;
        
        List<Id> ContactId = new List<Id>();
        Contact ContactVal;
        ContactVal = [SELECT Id FROM Contact];
        ContactId.add(ContactVal.Id);
     
        Test.starttest();
        Test.setMock(HttpCalloutMock.class, new SyncDonorCalloutHttpCallout());
        SyncDonorCallout.ContactDataCallout(ContactId);
        System.assertEquals(200, 200);
        Test.StopTest();
    }

}

@Istest 
global class SyncDonorCalloutHttpCallout implements HttpCalloutMock{
    global HTTPResponse respond(HTTPRequest req){
        
        System.assertEquals(Label.NewDonorApi, req.getEndpoint());
        System.assertEquals('POST', req.getMethod());
        
        // Create a fake response
        HttpResponse res = new HttpResponse();
        res.setHeader('Content-Type', 'application/json');
        req.setHeader('Authorization', 'Bearer sfdsdfdfs');
        res.setBody('{"userid":"sffsdf","password":"","first_name":"first_name","last_name":"last_name","email":"email","address1":"address1","address2":"address2","city":"city","state":"state","country":"country","zip":"zip","phone":"phone","date_of_birth":"date_of_birth","phone2":"phone2","suppressConfirmationEmail":"0","sf_api_call":"0"}');
        res.setStatusCode(200);
        return res;
    }
}

Please suggest me what should I do.
Can we customize the standard form code, Can I use DML on a standard form field.
I need to fetch the field value on the form using DML. Is it possible in salesforce?
What is the other solution? Please reply.
 
I want to add two dropdowns at contact create form and I want to fetch these dropdowns value from an object It can be possible.
Please suggest the best idea.
There is an issue with my HTTP request.salesforce is not allowing me to use PATCH method.
Below are the notification which i get after calling a patch.

System.CalloutException: Invalid HTTP method: PATCH.

when we override the method with patch
req.setHeader('X-HTTP-Method-Override','PATCH');
req.setMethod('POST');
Then i am geeting below notification.
System.HttpResponse[Status=Method Not Allowed, StatusCode=405]
I want to add two dropdowns at contact create form and I want to fetch these dropdowns value from an object It can be possible.
Please suggest the best idea.