• Richard Ludwig 12
  • NEWBIE
  • 0 Points
  • Member since 2019

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 1
    Replies
Good day developers

I have a Apex Class in Sandbox which redirects a user to a record created from a visual workflow with the help of a visualforce page:

public with sharing class FlowRedirectController {

    public Object FlowRedirectController() { 
        String unique_id = ApexPages.currentPage().getParameters().get('id');
        
        if(unique_id == null){
            // Return Home if no ID 
            String url = '/home/home.jsp';
            return new PageReference(url);
         } 
         
         // Get Order ID and set Redirect 
         String orderId = [SELECT Name,
                                    Unique_Flow_Identifier__c, 
                                    Id  
                             FROM Order  
                             WHERE Unique_Flow_Identifier__c = :unique_id 
                             ORDER BY CreatedDate DESC   
                             LIMIT 1].Id;
                             
        // Did we find a Order? 
        if (orderId == null) {
            // Return Home if no ID 
            String url = '/home/home.jsp'; 
            return new PageReference(url); 
            }

        // Redirect to Order 
        String url = '/' + orderId;
        return new PageReference(url); 
        }
}


When deploying to production I am getting code coverage error. This is becasue I need to create an Apex Test Class however being new to Apex i'm unsure what I would need to test in this code... Is anyone able to help with this?

Thanks