You need to sign in to do that
Don't have an account?
Raffus
How to write test test method for below code
@AuraEnabled public static String loadData(String strCaseInfo) { System.debug('caseInfo ' + strCaseInfo); CaseInfoWrapper caseInfo = (CaseInfoWrapper)JSON.deserialize(strCaseInfo, CaseInfoWrapper.class); //rand_App_Customer__c customer = getCustomerInfo(caseInfo.partyId, caseInfo.mobile); rand_App_Customer__c customer = getCustomerInfo2(caseInfo.emailId); Case cse = new Case(); cse.subject = 'tan One Problem Report'; cse.Origin = rand_APP; cse.Status = 'Awaiting Approval'; cse.Priority = 'Medium'; cse.RecordTypeId = Schema.SObjectType.Case.getRecordTypeInfosByDeveloperName().get(rand_APP).getRecordTypeId(); // cse.Hex_Service_Request__c = 'System Update'; // cse.Hex_Service_Request_new__c = 'System Update'; // cse.ProblemCode__c = 'NOC for Name Addition - HO'; cse.Description = caseInfo.description; //RN Comment //cse.Current_Location__Latitude__s = caseInfo.latitude; //cse.Current_Location__Longitude__s = caseInfo.longitude; cse.rand_App_Customer__c = customer?.Id; //cse.LocationName__c = caseInfo.locationName; */ cse.Issue_category__c = caseInfo.category; cse.Issue_Sub_Category__c = caseInfo.subCategory; insert cse; // for skip the triggers of ContentDocumentLink && ContentDocument ContentDocumentLinkTriggerUtil.skipTrigger = true; ContentDocumentTriggerUtil.skipTrigger = true; List<ContentVersion> cVersions = new List<ContentVersion>(); for (FileInfoWrapper file : caseInfo.files) { System.debug('fileInfo ' + file); if (String.isNotBlank(file.base64Data)) { ContentVersion cv = new ContentVersion(); cv.ContentLocation = 'S'; cv.PathOnClient = file.fileName; cv.VersionData = EncodingUtil.base64Decode(file.base64Data); cv.Title = file.fileName; cVersions.add(cv); } } List<Id> contentDocumentIds = new List<Id>(caseInfo.contentDocumentIds); if (cVersions.size() > 0) { insert cVersions; List<ContentDistribution> ContentDistributionList = new List<ContentDistribution>(); for(ContentVersion ctv : cVersions){ ContentDistribution cd = new ContentDistribution(); cd.Name = ctv.Title; cd.ContentVersionId = ctv.Id; cd.PreferencesAllowViewInBrowser = true; cd.PreferencesLinkLatestVersion = true; cd.PreferencesNotifyOnVisit = false; cd.PreferencesPasswordRequired = false; cd.PreferencesAllowOriginalDownload = true; ContentDistributionList.add(cd); } if(ContentDistributionList.size() > 0){ INSERT ContentDistributionList; } Set<Id> cvIds = new Map<Id, ContentVersion>(cVersions).keySet(); for (ContentVersion cVersion : [SELECT Id, ContentDocumentId FROM ContentVersion WHERE Id IN:cvIds ORDER BY CreatedDate ASC]) { contentDocumentIds.add(cVersion.ContentDocumentId); } } List<ContentDocumentLink> links = new List<ContentDocumentLink>(); for (Id contentDocumentId : contentDocumentIds) { ContentDocumentLink link = new ContentDocumentLink(); link.LinkedEntityId = cse.Id; link.ContentDocumentId = contentDocumentId; link.ShareType = 'V'; links.add(link); } insert links; return [SELECT CaseNumber FROM Case WHERE Id = :cse.Id]?.CaseNumber; }Please help me to write a test method for the above method.
This class contains refernece of some other class like CaseInfoWrapper and getCustomerInfo2 method.
Can you share those so can try the test class for the same.
Thanks,
getCustomerInfo2 Method-
Which part of code is not covering or is test class failing.
Thanks,
but from this for loop code is not covered-
please help