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
himanshu huske 7himanshu huske 7 

Please provide testclass for my StandardsetController

public class Claim_Property_from_Sales_Region {

    public contact con {get;set;}
  
    public PageReference Cancel() {
    PageReference prf = new PageReference('https://ap8.salesforce.com/a0H/o');
        return prf;
    }


    public PageReference claimAndCountinue() {
    updateSearchItemsMap();
    SetStatusWorking();
        return null;
    }

    public void SetStatusWorking(){
     List<Property__c> pt = new List<Property__c>();
      set<id> idSet = mapHoldingSelectedRecords.keySet();
     List<Property__c> prplist = [Select id,Status__c from Property__c where id in : idSet];
        for(Property__c prp : prplist){
        Property__c property = new Property__c();
        property.id =  prp.id;
     //   property.Agent__c = UserInfo.getUserId();
        property.Status__c  = 'Working';
        pt.add(property);
        update pt;
        }
}
     
    
    public PageReference claimProp() {
    updateSearchItemsMap();
    SetStatusWorking();
    PageReference pf = new PageReference('https://ap8.salesforce.com/a0H/o');
        return pf;
    }


    public Claim_Property_from_Sales_Region() {
     mapHoldingSelectedRecords = new Map<Id, WrapperClass>();
     init();
    }

   
   Public Integer size{get;set;}
 Public Integer noOfRecords{get; set;}
 public List <WrapperClass> wrapperRecordList{get;set;}
 Map<Id, WrapperClass> mapHoldingSelectedRecords{get;set;}
 
 
 public void init() {
 wrapperRecordList = new List<WrapperClass>();
 for (Property__c p : (List<Property__c>)setCon.getRecords()) {
 if(mapHoldingSelectedRecords != null && mapHoldingSelectedRecords.containsKey(p.id)){
 wrapperRecordList.add(mapHoldingSelectedRecords.get(p.id));
 
 }
 else{
   wrapperRecordList.add(new WrapperClass(p, false));
 }
 }
 } 
 
   public ApexPages.StandardSetController setCon {
 get {
 if(setCon == null) {
   setCon = new ApexPages.StandardSetController(Database.getQueryLocator([SELECT id, Property_Name__c,Property_City__c, Listing_Price__c, Status__c,createdDate FROM Property__c where Status__c = 'open']));
   setCon.setPageSize(5);
 }
   return setCon;
 }
 set;
 }
 public Boolean hasNext {
 get {
   return setCon.getHasNext();
 }
 set;
 }
 
 public Boolean hasPrevious {
 get {
   return setCon.getHasPrevious();
 }
 set;
 }
 
 public Integer pageNumber {
 get {
   return setCon.getPageNumber();
 }
 set;
 }
   Public Integer getTotalPages(){
     Decimal totalSize = setCon.getResultSize();
     Decimal pageSize = setCon.getPageSize();
     Decimal pages = totalSize/pageSize;
     return (Integer)pages.round(System.RoundingMode.CEILING);
 }
 
 public void first() {
   updateSearchItemsMap();
   setCon.first();
   init();
 }
 
 public void last() {
   updateSearchItemsMap();
   setCon.last();
   init();
 }
 public void previous() {
   updateSearchItemsMap();
   setCon.previous();
   init();
 }
 
 public void next() {
   updateSearchItemsMap();
   setCon.next();
   init();
 }

 private void updateSearchItemsMap() {
 for(WrapperClass wrp : wrapperRecordList){
  if(wrp.isSelected){
     mapHoldingSelectedRecords.put(wrp.prop.id, wrp);
  }
  if(wrp.isSelected == false && mapHoldingSelectedRecords.containsKey(wrp.prop.id)){
     mapHoldingSelectedRecords.remove(wrp.prop.id);
  }
 }
 }
 public class WrapperClass {
 public Boolean isSelected {get;set;}
 public Property__c prop {get;set;}
 public WrapperClass(Property__c prop, Boolean isSelected) {
    this.prop = prop;
    this.isSelected = isSelected;
 }
 }
}

 
RAJAT MESHRAMRAJAT MESHRAM
do you have visualforce code of this