You need to sign in to do that
Don't have an account?
newbiewithapex
How to write test class for method that add Invitees?
This is the only method I have in this class and I am trying to figure out how to write test class for SQL queries and what is @AuraEnabled? Any help and explaination would help me a lot.
public with sharing class CBR_AddInviteesCntrl {
@AuraEnabled
public static Event getCBREventDetails(String cbrId){
Event eve = [SELECT Id, Type, IsAllDayEvent, Location, OwnerId, ActivityDate, Description, DurationInMinutes, RecordTypeId, RecordType.Name,
EndDateTime, EventSubtype, WhoId, isRecurrence, IsPrivate, WhatId, ShowAs, StartDateTime, SC_Responsible__c, ROC_Primary_Deployment__c,
RecurrenceType ,RecurrenceInterval ,RecurrenceMonthOfYear,RecurrenceInstance,RecurrenceDayOfWeekMask ,RecurrenceDayOfMonth,
FFC_Deployment_Type__c, ROC_Comments_for_Other_Deployment__c, Reminder_Duration_LEX__c, Additional_Attendee_Type__c, Follow_Up_Required__c,
RecurrenceActivityId , Subject, Frequency_Details__c, RecurrenceEndDateOnly FROM Event where CBR__c=:cbrId LIMIT 1];
return eve;
}
}
public with sharing class CBR_AddInviteesCntrl {
@AuraEnabled
public static Event getCBREventDetails(String cbrId){
Event eve = [SELECT Id, Type, IsAllDayEvent, Location, OwnerId, ActivityDate, Description, DurationInMinutes, RecordTypeId, RecordType.Name,
EndDateTime, EventSubtype, WhoId, isRecurrence, IsPrivate, WhatId, ShowAs, StartDateTime, SC_Responsible__c, ROC_Primary_Deployment__c,
RecurrenceType ,RecurrenceInterval ,RecurrenceMonthOfYear,RecurrenceInstance,RecurrenceDayOfWeekMask ,RecurrenceDayOfMonth,
FFC_Deployment_Type__c, ROC_Comments_for_Other_Deployment__c, Reminder_Duration_LEX__c, Additional_Attendee_Type__c, Follow_Up_Required__c,
RecurrenceActivityId , Subject, Frequency_Details__c, RecurrenceEndDateOnly FROM Event where CBR__c=:cbrId LIMIT 1];
return eve;
}
}
You can then use the system.assert method to make sure you are getting the expedted result (the record you want). Since this method doesn't have any IF statements it would be fairly easy to test, test it by sending the Id of the record you inserted and then by sending an id of a record that doesn't exist to test for not found. The @AuraEnabled tag doesn't change the way you test apex classes.
I hope this was clear enough.