• Teyim Pila
  • NEWBIE
  • 0 Points
  • Member since 2018

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 1
    Replies
Hello,
I have the following ApexTrigger which I want to test. I want to test that the second line in the last condition (first code snippet) is called depending on the size of the payload List. So, my question is, is there a way to assert the number of times the method, "makeCallout" is invoked? I will highly appreciate any pointers.
TriggerCallout.makeCallout(body, type);
 
trigger CaseTrigger on Case (after insert) {
    private String type = 'Case';
    List<Case> payload = new List<Case>();
    
    // Only Cases whose origin is the web are sent.
    for(Case newCase : Trigger.new){
        if(newCase.Origin == 'Web'){
            payload.add(newCase);
        }
    }
    
    // No need making a request with an empty body.
    if(!payload.isEmpty()){
        String body = System.JSON.serialize(payload);
        TriggerCallout.makeCallout(body, type);
    }
}

Cheers
Hello,
I have the following ApexTrigger which I want to test. I want to test that the second line in the last condition (first code snippet) is called depending on the size of the payload List. So, my question is, is there a way to assert the number of times the method, "makeCallout" is invoked? I will highly appreciate any pointers.
TriggerCallout.makeCallout(body, type);
 
trigger CaseTrigger on Case (after insert) {
    private String type = 'Case';
    List<Case> payload = new List<Case>();
    
    // Only Cases whose origin is the web are sent.
    for(Case newCase : Trigger.new){
        if(newCase.Origin == 'Web'){
            payload.add(newCase);
        }
    }
    
    // No need making a request with an empty body.
    if(!payload.isEmpty()){
        String body = System.JSON.serialize(payload);
        TriggerCallout.makeCallout(body, type);
    }
}

Cheers