You need to sign in to do that
Don't have an account?
newbiewithapex
how to write test class for method that fetches recommendations?
Below method fetch recommendations and I am not sure how to write test class for this method. Can someone please help me with this?
@AuraEnabled public static string getRecommendations(string recId) { string errorMessage; Recommendation__c rec = new Recommendation__c(); rec = [select Id, Name, Account__c, Account__r.Name, Account__r.RecordTypeId, Sub_Type__c, Opportunity__c, Description__c, Record_Type_Name__c from Recommendation__c where Id = :recId limit 1]; if (String.IsNOTBlank(rec.Opportunity__c)) { AuraHandledException e = new AuraHandledException(CS_UtilConstants__c.getValues('OPPTY_EXISTS_RECOMMENDATIONS_INFO').Value__c); e.setMessage(CS_UtilConstants__c.getValues('OPPTY_EXISTS_RECOMMENDATIONS_INFO').Value__c); throw e; } else if (rec.Record_Type_Name__c == CS_UtilConstants__c.getInstance('CONVERSION').Value__c && (rec.Description__c == Null || rec.Description__c == '') && (rec.Sub_Type__c == Null || rec.Sub_Type__c == '')) { AuraHandledException e = new AuraHandledException(CS_UtilConstants__c.getValues('CONVERSION ERROR MESSAGE').Value__c); e.setMessage(CS_UtilConstants__c.getValues('CONVERSION ERROR MESSAGE').Value__c); throw e; } return null; }
Complete code
rec1.Account__c =a.Id ;
rec1.RecordtypeId=Schema.Sobjecttype.Recommendation__c.getRecordTypeInfosByName().get('CONVERSION').getRecordTypeId();
And See what is the correct record type name