• William Boyce 22
  • NEWBIE
  • 10 Points
  • Member since 2020

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 1
    Replies
Hello community!  I am having trouble creating a test class for the following code.  Any assistance would be greatly appreciated. Thank you in advance for your help!

global class Reassign implements Schedulable {
    global void execute(SchedulableContext ctx) {
        // Define 'inprogress' and 'newqueue' string variables
        String inprogress;
        String newqueue;
        
        // Find 'In Progress' queue Id and assign to 'inprogress'
        inprogress = [SELECT Id from Group where Name = 'In Progress' and Type = 'Queue'].Id;
        // Find 'New' queue Id and assign to 'newqueue'
        newqueue = [SELECT Id from Group where Name = 'New' and Type = 'Queue'].Id;
        
        // Create lists for cases
        List<Case> cases1 = [SELECT Id, CaseNumber, OwnerId
                            FROM Case
                            WHERE RecordTypeId = '0124u00000060pmAAA' 
                            AND (Status = 'In Progress' OR Status = 'Outreach Attempted')];
        
        List <Case> cases2 = New List<Case>();
        
        List<Case> newcases1 = [SELECT Id
                              From Case
                              Where RecordTypeId = '0124u00000060pmAAA'
                              AND Status = 'New'];
        
        List <Case> newcases2 = New List<Case>();
        
        // Change the owner and status for each Case in the list and add to respective queue
        for (Case c : cases1){
            c.OwnerId = inprogress;
            c.Status = 'In Progress';
            cases2.add(c);
        }
        update cases2;
        
        for (Case d : newcases1){
            d.OwnerId = newqueue;
            newcases2.add(d);
        }
        update newcases2;
    }
}
Hello community!  I am having trouble creating a test class for the following code.  Any assistance would be greatly appreciated. Thank you in advance for your help!

global class Reassign implements Schedulable {
    global void execute(SchedulableContext ctx) {
        // Define 'inprogress' and 'newqueue' string variables
        String inprogress;
        String newqueue;
        
        // Find 'In Progress' queue Id and assign to 'inprogress'
        inprogress = [SELECT Id from Group where Name = 'In Progress' and Type = 'Queue'].Id;
        // Find 'New' queue Id and assign to 'newqueue'
        newqueue = [SELECT Id from Group where Name = 'New' and Type = 'Queue'].Id;
        
        // Create lists for cases
        List<Case> cases1 = [SELECT Id, CaseNumber, OwnerId
                            FROM Case
                            WHERE RecordTypeId = '0124u00000060pmAAA' 
                            AND (Status = 'In Progress' OR Status = 'Outreach Attempted')];
        
        List <Case> cases2 = New List<Case>();
        
        List<Case> newcases1 = [SELECT Id
                              From Case
                              Where RecordTypeId = '0124u00000060pmAAA'
                              AND Status = 'New'];
        
        List <Case> newcases2 = New List<Case>();
        
        // Change the owner and status for each Case in the list and add to respective queue
        for (Case c : cases1){
            c.OwnerId = inprogress;
            c.Status = 'In Progress';
            cases2.add(c);
        }
        update cases2;
        
        for (Case d : newcases1){
            d.OwnerId = newqueue;
            newcases2.add(d);
        }
        update newcases2;
    }
}