• Vidya
  • NEWBIE
  • 0 Points
  • Member since 2011

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 4
    Replies

Pls help me to write a test class for the below class.

 

 

public class transferinnew1 {
String pid = ApexPages.currentPage().getParameters().get('id');
public  List<Product_serial__c> pserial=new List<Product_Serial__c>();
);

public  List<Transfer_In__c> pt=new List<Transfer_in__c>();

 
 public transferinnew1(){


 pserial=[select id,name,Product_disp__c,type__c,serial_number__c,status__c,warehouse__c,bin__c,order__c,select__c,project__c
from product_serial__c where status__c='Out'  order by order__c asc];
 
 
 pt=[select id,reasons__c ,order__c from transfer_in__c where id =:ApexPages.currentPage().getParameters().get('id') ];

}

public List<product_serial__c> getRecord() {
            return pserial;
      }
      public List<transfer_in__c> getRec() {
            return pt;
      }

    public PageReference save() {
   
      
  update pserial;
for ( product_serial__c ps:pserial){

  if(ps.select__c==true){
  Transfer_In_Line__c iv = new Transfer_In_Line__c(product_serial__c = ps.id,
        transfer_in__c=pid,warehouse__c=ps.warehouse__c,bin__c=ps.bin__c );
insert iv;
ps.select__c=false;
ps.status__c='Available';
  ps.tid__c=pt[0].reasons__c;      
update ps;
if (pt[0].reasons__c=='Excess Material')
{
ps.order_stock__c=false;
ps.type__c='Spare Stock';
ps.order__c=null;
update ps;
}
if (pt[0].reasons__c=='Ongoing Project (Hold Stock)')
{
ps.order_stock__c=true;
ps.order__c=pt[0].order__c;
ps.status__c='Order Stock';
ps.type__c='Spare Stock';

update ps;
}

}
 
}

 
  Pagereference p = new PageReference('/'+pid);

p.setRedirect(true);

return p;  
   
   }   
   public PageReference Cancel() {
  delete pt;

PageReference mysample = Page.tabinv;
       mysample.setRedirect(true);    
                     return mysample;
 

}


}

 

 

 

 

Thanks,

 

Vidya

 

 

  • May 11, 2011
  • Like
  • 0

Pls help me to write a test class for the below class.

 

 

public class transferinnew1 {
String pid = ApexPages.currentPage().getParameters().get('id');
public  List<Product_serial__c> pserial=new List<Product_Serial__c>();
);

public  List<Transfer_In__c> pt=new List<Transfer_in__c>();

 
 public transferinnew1(){


 pserial=[select id,name,Product_disp__c,type__c,serial_number__c,status__c,warehouse__c,bin__c,order__c,select__c,project__c
from product_serial__c where status__c='Out'  order by order__c asc];
 
 
 pt=[select id,reasons__c ,order__c from transfer_in__c where id =:ApexPages.currentPage().getParameters().get('id') ];

}

public List<product_serial__c> getRecord() {
            return pserial;
      }
      public List<transfer_in__c> getRec() {
            return pt;
      }

    public PageReference save() {
   
      
  update pserial;
for ( product_serial__c ps:pserial){

  if(ps.select__c==true){
  Transfer_In_Line__c iv = new Transfer_In_Line__c(product_serial__c = ps.id,
        transfer_in__c=pid,warehouse__c=ps.warehouse__c,bin__c=ps.bin__c );
insert iv;
ps.select__c=false;
ps.status__c='Available';
  ps.tid__c=pt[0].reasons__c;      
update ps;
if (pt[0].reasons__c=='Excess Material')
{
ps.order_stock__c=false;
ps.type__c='Spare Stock';
ps.order__c=null;
update ps;
}
if (pt[0].reasons__c=='Ongoing Project (Hold Stock)')
{
ps.order_stock__c=true;
ps.order__c=pt[0].order__c;
ps.status__c='Order Stock';
ps.type__c='Spare Stock';

update ps;
}

}
 
}

 
  Pagereference p = new PageReference('/'+pid);

p.setRedirect(true);

return p;  
   
   }   
   public PageReference Cancel() {
  delete pt;

PageReference mysample = Page.tabinv;
       mysample.setRedirect(true);    
                     return mysample;
 

}


}

 

 

 

 

Thanks,

 

Vidya

 

 

  • May 11, 2011
  • Like
  • 0