• Austin Henson
  • NEWBIE
  • 10 Points
  • Member since 2023

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 1
    Replies
Hi all I am new to the Salesforce development side and am wondering how to create a test class for the below Apex Class I have written. I understand I need to create test data in the test class, but I am not sure how to test out the last part of this class which is calling another Apex Class from a managed package that exports Contact records to a 3rd platform. Any help and guidance would be much appreciated.
global class ExportBackgroundCheckCompleteToGolden {

    @InvocableMethod(label='Export Background Check Completed Volunteers To Golden' description='Exports contacts who have completed their background check with Sterling Volunteers to Golden' category='Contact')

    public static List<Contact> BackgroundCheckCompleteToGolden(List<Contact> contacts) {

        List<Contact> exported = new List<Contact>();

        if ((contacts == null) || (contacts.size() == 0)) {

            System.debug('No contacts');

            return exported;

        } else {

            System.debug('There are ' + contacts.size() + ' contacts.');

        }

        for (Contact contact: contacts) {

            if ((contact != null) && (contact.VVSA__VV_Status__c == 'Eligible')) {

                exported.add(contact);

            }

        }

        if (exported.size() > 0) {

            goldenapp.ExportToGoldenBatch.runSyncJob(exported, 'Background Check Completed');

        }

        return exported;

    }

}

 
Hi all I am new to the Salesforce development side and am wondering how to create a test class for the below Apex Class I have written. I understand I need to create test data in the test class, but I am not sure how to test out the last part of this class which is calling another Apex Class from a managed package that exports Contact records to a 3rd platform. Any help and guidance would be much appreciated.
global class ExportBackgroundCheckCompleteToGolden {

    @InvocableMethod(label='Export Background Check Completed Volunteers To Golden' description='Exports contacts who have completed their background check with Sterling Volunteers to Golden' category='Contact')

    public static List<Contact> BackgroundCheckCompleteToGolden(List<Contact> contacts) {

        List<Contact> exported = new List<Contact>();

        if ((contacts == null) || (contacts.size() == 0)) {

            System.debug('No contacts');

            return exported;

        } else {

            System.debug('There are ' + contacts.size() + ' contacts.');

        }

        for (Contact contact: contacts) {

            if ((contact != null) && (contact.VVSA__VV_Status__c == 'Eligible')) {

                exported.add(contact);

            }

        }

        if (exported.size() > 0) {

            goldenapp.ExportToGoldenBatch.runSyncJob(exported, 'Background Check Completed');

        }

        return exported;

    }

}