• satish marisetty 10
  • NEWBIE
  • 0 Points
  • Member since 2016

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 2
    Replies
how can i conver exception catch block of this method in my test class

public static Boolean checkFaultAnalysis(String stockingRecordId,String mmId){
        Boolean faultAnalysisFlag = false;
        try{
            if(!String.IsEmpty(stockingRecordId) && !String.isEmpty(mmId)){
                
                List<ICS_WR_Customer_Warranty_Config_Matrix__c> faultMatrix = [SELECT id,Name,RecordTypeId FROM ICS_WR_Customer_Warranty_Config_Matrix__c WHERE ICS_WR_Stocking__c=:stockingRecordId AND ICS_WR_MMID__r.Name=:mmId AND RecordTypeId=:Label.ICS_WR_Fault_Analysis_RT_ID AND ICS_WR_Inactive__c = false];
                System.debug('faultMatrix ='+faultMatrix );
                if(faultMatrix!=null && faultMatrix.size()>0)
                    faultAnalysisFlag = true;
            }
        }catch(Exception e){
            System.Debug(e.getMessage());
            ApexPages.addMessages(e);
            String strInvocationID ='ICS_WR_Warranty_CreateExtension'+UserInfo.getUserId() + '_' + system.now().formatGmt('yyyyMMddkkmmssSS')
                + '_' + String.valueOf((Math.random() * 10).round()).leftpad(3,'0');
            Core_Log_Entry.logEntryWithException(strInvocationID,System.Label.ICS_WR_logging_Scope,'ICS_WR_Warranty_CreateExtension__checkFaultAnalysis','Error',e.getMessage(),'',e);
        }
        return faultAnalysisFlag;
    }
how can i conver exception catch block of this method in my test class

public static Boolean checkFaultAnalysis(String stockingRecordId,String mmId){
        Boolean faultAnalysisFlag = false;
        try{
            if(!String.IsEmpty(stockingRecordId) && !String.isEmpty(mmId)){
                
                List<ICS_WR_Customer_Warranty_Config_Matrix__c> faultMatrix = [SELECT id,Name,RecordTypeId FROM ICS_WR_Customer_Warranty_Config_Matrix__c WHERE ICS_WR_Stocking__c=:stockingRecordId AND ICS_WR_MMID__r.Name=:mmId AND RecordTypeId=:Label.ICS_WR_Fault_Analysis_RT_ID AND ICS_WR_Inactive__c = false];
                System.debug('faultMatrix ='+faultMatrix );
                if(faultMatrix!=null && faultMatrix.size()>0)
                    faultAnalysisFlag = true;
            }
        }catch(Exception e){
            System.Debug(e.getMessage());
            ApexPages.addMessages(e);
            String strInvocationID ='ICS_WR_Warranty_CreateExtension'+UserInfo.getUserId() + '_' + system.now().formatGmt('yyyyMMddkkmmssSS')
                + '_' + String.valueOf((Math.random() * 10).round()).leftpad(3,'0');
            Core_Log_Entry.logEntryWithException(strInvocationID,System.Label.ICS_WR_logging_Scope,'ICS_WR_Warranty_CreateExtension__checkFaultAnalysis','Error',e.getMessage(),'',e);
        }
        return faultAnalysisFlag;
    }
Can any one help me out that how to cover the code coverage for below catch excpetion in test class.
I dont have permission to change Apex Controller so it has to do something in test class itself.

catch(Exception e) {
         new ApexPages.Message(ApexPages.Severity.Error,'Easy Button Config Custom Setting doesn\'t exist!');
     }