function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
SFD SalesforceSFD Salesforce 

Please can i have the test case For this

public with sharing class Pagings{

public String pb { get; set; }
Public Integer noOfRecords{get; set;}
Public Integer size{get;set;}
public string sortingstring{get;set;}
public string sortingcolumn{get;set;}
public string errormsg{get;set;}
public string queryString = 'Select Name, Type from Account order by Name' ;

public String sortDirection
{
get;
set;
}

public integer getpage{
get{
integer i;

if(math.mod(noOfRecords,size)==0)
{
i=noOfRecords/size;
}else
{
i=noOfRecords/size+1;
}
return i;
}

set;}


public ApexPages.StandardSetController setCon {
get{
if(setCon == null){
size =10;
setCon = new ApexPages.StandardSetController(Database.getQueryLocator(queryString));
setCon.setPageSize(size);

noOfRecords = setCon.getResultSize();
if(noOfRecords ==0)
{
errormsg='No records to display';
}
else{
errormsg='';
}


}
return setCon;
}set;
}

public pageReference getquery()
{

if(sortingstring=='others')
{
queryString = 'Select Name, Type from Account where Name not like \''+sortingstring+'%\' order by Name';
}else if(sortingstring=='all' || sortingstring==null)
{
queryString = 'Select Name, Type from Account order by Name';
}else {
queryString = 'Select Name, Type from Account where Name like \''+sortingstring+'%\' order by Name';
}

if(sortingcolumn=='Name' || sortingcolumn=='Type')
{
sortDirection=sortDirection=='ASC' ? 'DESC' : 'ASC';
string sortFullExp = sortingcolumn + ' ' + sortDirection;
if(sortingstring!='all' && sortingstring!=null)
{
queryString = 'Select Name, Type from Account where Name like \''+sortingstring+'%\' order by ' + sortFullExp ;
}else
{
queryString = 'Select Name, Type from Account order by ' + sortFullExp ;
}

}
setCon = null;
getAccounts();
setCon.setPageNumber(1);
return null;

}


Public List<Account> getAccounts(){
List<Account> accList = new List<Account>();
for(Account a : (List<Account>)setCon.getRecords())
accList.add(a);
return accList;
}

public pageReference refresh() {

//Vary in displaying records according to the selected size
if( size ==10)
{try{
setCon = new ApexPages.StandardSetController(Database.getQueryLocator(queryString));
setCon.setPageSize(size); }
catch(Exception e) {}
}
if( size ==25)
{
try{
setCon = new ApexPages.StandardSetController(Database.getQueryLocator(queryString));
setCon.setPageSize(size);}
catch(Exception e) {}} }
if( size ==50)
{try{
setCon = new ApexPages.StandardSetController(Database.getQueryLocator(queryString));
setCon.setPageSize(size); }
catch(Exception e) {}
}
if( size ==100)
{try{
setCon = new ApexPages.StandardSetController(Database.getQueryLocator(queryString));
setCon.setPageSize(size); }
catch(Exception e) {}
}if(size ==200)
{
setCon = new ApexPages.StandardSetController(Database.getQueryLocator(queryString));
setCon.setPageSize(size);
}
return null;

}

}

 

Can i  have test case for the above pagination class.