You need to sign in to do that
Don't have an account?
Raju Chi 5
testclass for approval process
Hi,
How to write test class for below class.
global class RecordAttachmentValidate {
@AuraEnabled public static List<ContentDocumentLink> ContentDocumentList{get;set;}
@AuraEnabled
webservice static void ValidateAttachment(String RecordID){
ContentDocumentList=[SELECT Id FROM ContentDocumentLink where LinkedEntityId =:RecordID];
system.debug('ContentDocumentList'+ContentDocumentList);
try{
if(ContentDocumentList.size() !=0){
Approval.ProcessSubmitRequest req1 = new Approval.ProcessSubmitRequest();
req1.setComments('Submitting request for approval automatically using Trigger');
req1.setObjectId(RecordID);
Approval.ProcessResult result = Approval.process(req1);
} else{
throw new AuraHandledException('Please add attchments');
}
}catch(Exception e){
throw new AuraHandledException(e.getMessage());
//return null;
}
}
}
How to write test class for below class.
global class RecordAttachmentValidate {
@AuraEnabled public static List<ContentDocumentLink> ContentDocumentList{get;set;}
@AuraEnabled
webservice static void ValidateAttachment(String RecordID){
ContentDocumentList=[SELECT Id FROM ContentDocumentLink where LinkedEntityId =:RecordID];
system.debug('ContentDocumentList'+ContentDocumentList);
try{
if(ContentDocumentList.size() !=0){
Approval.ProcessSubmitRequest req1 = new Approval.ProcessSubmitRequest();
req1.setComments('Submitting request for approval automatically using Trigger');
req1.setObjectId(RecordID);
Approval.ProcessResult result = Approval.process(req1);
} else{
throw new AuraHandledException('Please add attchments');
}
}catch(Exception e){
throw new AuraHandledException(e.getMessage());
//return null;
}
}
}
Hi Raju,
Please find the solution of your test class with 91% coverage.
Test Class:
Class :
Please let me know it is working or not?
If it works then please mark it as the Best Answer so that other people would take reference from it.
Thank You!
All Answers
Hi Raju,
Please find the solution of your test class with 91% coverage.
Test Class:
Class :
Please let me know it is working or not?
If it works then please mark it as the Best Answer so that other people would take reference from it.
Thank You!
Perfect.