Skip to main content
Challenge Not yet complete... here's what's wrong:

Ensure that after you clear test data, you run your tests once and the required test coverage is achieved.

here is my code for AnnouncementQueueable covage 58 % for this:-

AnnouncementQueueable:

/**

 * @name AnnouncementQueueable

 * @description This class posts Chatter Announcements

**/

public class AnnouncementQueueable implements Queueable{

public List<ConnectApi.AnnouncementInput> toPost;

    //ToDo: Modify this class to implement the Queueable interface and call the postAnnouncements method

    public void execute(QueueableContext context) {

        PostAnnouncements(toPost);

    }

    

    /**

     * @name postAnnouncements

     * @description This method is provided for you to facilitate the Super Badge

    **/

    public static void PostAnnouncements(List<ConnectApi.AnnouncementInput> announcements){

        while ( announcements.size() > 0 ){

            if ( Limits.getDMLStatements() < Limits.getLimitDMLStatements() && !test.isRunningTest() ){

                ConnectApi.AnnouncementInput a = announcements.remove(0);

                ConnectApi.Announcements.postAnnouncement('Internal', a);

            } else {

                break;

            }

        }

        if ( announcements.size() > 0 && !test.isRunningTest() ){

            AnnouncementQueueable q = new AnnouncementQueueable();

            q.toPost = announcements;

            //ToDo: Enqueue the above instance of announcementQueueable

            System.enqueueJob(q);

            

        }

    }

}
2 answers
0/9000