• Beltran Baja
  • NEWBIE
  • 10 Points
  • Member since 2018

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

Hi guys, I'm wondering of how I am going to write a Test Class for Apex Class and a Trigger. This is just a simple Class and a Trigger please see below exact codes I am using.

trigger LeadUpdateListener on Lead (after update) {

    for ( Lead updatedLead : Trigger.New ) {
        CalloutExternal.pipelineConnect(updatedLead.Id);
	}
    
}
public class CalloutExternal {

    @future(callout=true)
    
    public static void pipelineConnect (String id) {
        
        String token = 'xxxxxxxxx';
        
        HttpRequest request = new HttpRequest();
        String endpoint = 'https://xxx.xxxxxxx.com/trigger/'+ token + '/' + id;
        request.setEndpoint(endpoint);
        request.setMethod('GET');
               
        HttpResponse response = new HTTP().send(request);
        
        System.debug('xxxx Response...' + response);
    }

}
I tried creating a Test Class but it doesn't let me through. If anyone who could show me here that would be much appreciated. Thank you!

Hi guys, I'm wondering of how I am going to write a Test Class for Apex Class and a Trigger. This is just a simple Class and a Trigger please see below exact codes I am using.

trigger LeadUpdateListener on Lead (after update) {

    for ( Lead updatedLead : Trigger.New ) {
        CalloutExternal.pipelineConnect(updatedLead.Id);
	}
    
}
public class CalloutExternal {

    @future(callout=true)
    
    public static void pipelineConnect (String id) {
        
        String token = 'xxxxxxxxx';
        
        HttpRequest request = new HttpRequest();
        String endpoint = 'https://xxx.xxxxxxx.com/trigger/'+ token + '/' + id;
        request.setEndpoint(endpoint);
        request.setMethod('GET');
               
        HttpResponse response = new HTTP().send(request);
        
        System.debug('xxxx Response...' + response);
    }

}
I tried creating a Test Class but it doesn't let me through. If anyone who could show me here that would be much appreciated. Thank you!