You need to sign in to do that
Don't have an account?
Jonathan Wolff 7
Test class for custom Event Component
Hello,
I build a custom Event component that I would like to convert into Liveground. I know, that I need to build a test class for my apex class.
The component just displays the subject, activityDate, Start and EndDate of an event. Could you give me a code for the test class.
The apex class code is this:
public with sharing class EventController {
@AuraEnabled
public static List<Event> loadEvents(Id recordId){
string userId = UserInfo.getUserId();
return[SELECT Subject, ActivityDate, StartDateTime, EndDateTime FROM Event WHERE WhatId=:recordId And ActivityDate>= TODAY
AND ActivityDate < Next_N_Days:1 AND OwnerId=:userId ];
}
@AuraEnabled
public static List<Event> loadEvents2(Id recordId){
string userId = UserInfo.getUserId();
Date tomorrowDate = Date.today().addDays(1);
Date dayAfterTomorrow = tomorrowDate.addDays(1);
return[SELECT Subject, ActivityDate, StartDateTime, EndDateTime FROM Event WHERE WhatId=:recordId And ActivityDate>= :tomorrowDate AND ActivityDate < :dayAfterTomorrow AND OwnerId=:userId ];
}
@AuraEnabled
public static List<Event> loadEvents3(Id recordId){
string userId = UserInfo.getUserId();
Date tomorrowDate = Date.today().addDays(1);
Date dayAfterTomorrow = tomorrowDate.addDays(1);
Date twodaysAfterTomorrow = tomorrowDate.addDays(2);
return[SELECT Subject, ActivityDate, StartDateTime, EndDateTime FROM Event WHERE WhatId=:recordId And ActivityDate>= :dayAfterTomorrow AND ActivityDate < :twodaysAfterTomorrow AND OwnerId=:userId ];
}
}
I build a custom Event component that I would like to convert into Liveground. I know, that I need to build a test class for my apex class.
The component just displays the subject, activityDate, Start and EndDate of an event. Could you give me a code for the test class.
The apex class code is this:
public with sharing class EventController {
@AuraEnabled
public static List<Event> loadEvents(Id recordId){
string userId = UserInfo.getUserId();
return[SELECT Subject, ActivityDate, StartDateTime, EndDateTime FROM Event WHERE WhatId=:recordId And ActivityDate>= TODAY
AND ActivityDate < Next_N_Days:1 AND OwnerId=:userId ];
}
@AuraEnabled
public static List<Event> loadEvents2(Id recordId){
string userId = UserInfo.getUserId();
Date tomorrowDate = Date.today().addDays(1);
Date dayAfterTomorrow = tomorrowDate.addDays(1);
return[SELECT Subject, ActivityDate, StartDateTime, EndDateTime FROM Event WHERE WhatId=:recordId And ActivityDate>= :tomorrowDate AND ActivityDate < :dayAfterTomorrow AND OwnerId=:userId ];
}
@AuraEnabled
public static List<Event> loadEvents3(Id recordId){
string userId = UserInfo.getUserId();
Date tomorrowDate = Date.today().addDays(1);
Date dayAfterTomorrow = tomorrowDate.addDays(1);
Date twodaysAfterTomorrow = tomorrowDate.addDays(2);
return[SELECT Subject, ActivityDate, StartDateTime, EndDateTime FROM Event WHERE WhatId=:recordId And ActivityDate>= :dayAfterTomorrow AND ActivityDate < :twodaysAfterTomorrow AND OwnerId=:userId ];
}
}