You need to sign in to do that
Don't have an account?
Manasa Dhandapani 7
how to write test class for the following controller which uses a constructor.
Here is my code. Please help me with the testclass.
public class AccountContactListController {
@AuraEnabled
public static List<Contact> fetchAccts(id recordId, String pageSize, String pageNumber) {
List<Contact> conlist = new List<Contact>();
ApexPages.StandardSetController ssc = new ApexPages.StandardSetController(Database.getQueryLocator('SELECT Id, Name, Title, Status__c, Email, Phone, AccountId, Account_Name_Formula__c FROM Contact where Flag_For_Deletion__c = false AND (AccountId =: recordId OR Account.ParentId =: recordId OR Account.Parent.ParentId =: recordId OR Account.Parent.Parent.ParentId =: recordId OR Account.Parent.Parent.Parent.ParentId =: recordId) ORDER BY Status__c ASC, Name ASC'));
ssc.setpagesize(Integer.valueOf(pageSize));
ssc.setPageNumber(Integer.valueOf(pageNumber));
conlist = (List<Contact>)ssc.getRecords();
return conlist;
}
Thanks in advance.
public class AccountContactListController {
@AuraEnabled
public static List<Contact> fetchAccts(id recordId, String pageSize, String pageNumber) {
List<Contact> conlist = new List<Contact>();
ApexPages.StandardSetController ssc = new ApexPages.StandardSetController(Database.getQueryLocator('SELECT Id, Name, Title, Status__c, Email, Phone, AccountId, Account_Name_Formula__c FROM Contact where Flag_For_Deletion__c = false AND (AccountId =: recordId OR Account.ParentId =: recordId OR Account.Parent.ParentId =: recordId OR Account.Parent.Parent.ParentId =: recordId OR Account.Parent.Parent.Parent.ParentId =: recordId) ORDER BY Status__c ASC, Name ASC'));
ssc.setpagesize(Integer.valueOf(pageSize));
ssc.setPageNumber(Integer.valueOf(pageNumber));
conlist = (List<Contact>)ssc.getRecords();
return conlist;
}
Thanks in advance.
Just add more information into the Account that is being created and also the Contact being created. (Such as Statuc__c and other custom fields.)
This class should then cover the most of your fetchAccts method.