• CRM Project
  • NEWBIE
  • 15 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 4
    Replies
When I try to add some apex classes in unmanaged package, I am not able to found some of the classes but the test classes for those classes are there. 

Please advice me
I am trying to write a test class for my Wrapper Class, unfortunately my overall code coverage is 51%, so I need to get more then 75% in order to deploy.how i will do plz help me 
public with sharing class CRM_AddProducts
{

    public String message { get; set; }
 
  public String SelectedProduct{get;set;}
  public list<pProduct> lstproduct { get; set; }
  public list<cproduct> cartlstproduct {get;set;}
  
  public list<CProduct__c> lstselproduct { get; set; }
  public list<CQuote_Line_Item__c> lstaddquoteproduct { get; set; }
  public List<SelectOption> Product_Selectionoptions {get;set;} 
  public boolean selected {get;set;}
  public boolean display {get;set;}
  public CProduct__c pro {get;set;}
 // public CProduct__c cpro{get;set;}
 // public CProduct__c cess{get;set;}
  public map<Id,double> mapProductIdToQuantity { get; set; }
  public string strid;
  public boolean blnStatus1 ;
  
  
  
  

    public CRM_AddProducts()
      {
          lstproduct=new list<pProduct>();
          mapProductIdToQuantity = new map<Id,double>();
          cartlstproduct = new list<cproduct>();
          lstaddquoteproduct = new list<CQuote_Line_Item__c>();
          strid = apexpages.currentPage().getParameters().get('id');
         
        
                for(CProduct__c objproduct : [select id,
                                              Name,
                                              List_Price__c,
                                              Product_Code__c,
                                              Product_Description__c,
                                              Sales_Price__c,
                                              Product_Family__c
                                      from    CProduct__c])
          {
              lstproduct.add(new pProduct(objproduct));
              system.debug('---lstproduct---'+lstproduct);
          }
      }
      
      
       public pageReference check()
    {
      return null;
    }
        
         
  
    //builds a picklist of product names based on their product id
      public List<SelectOption>getProduct_Selection() 
    
     {
        List<SelectOption> Product_Selectionoptions = new List<SelectOption>();
  //new list for holding all of the picklist options
       
       for (CProduct__c Product_Selection : [SELECT Id, Name FROM CProduct__c]) 
       { 
  //query for Product records 
       Product_Selectionoptions.add(new selectOption(Product_Selection.Id,Product_Selection.Name));
      
  //for all records found - add them to the picklist options
       }
       system.debug('-Product_Selectionoptions-'+Product_Selectionoptions);
      return Product_Selectionoptions; //return the picklist options
       
   }
   
         
         public pageReference addtocart()
         {
            for(pProduct cProd : lstproduct)
        {
                
                system.debug('----cProd---'+cProd);
                system.debug('--SelectedProduct--'+SelectedProduct);
                system.debug('-Product_Selectionoptions-'+Product_Selectionoptions);
               //  system.debug('-Product_Selection-'+Product_Selectionoptions.Product_Selection);
                if(cProd.selected == true)
                {
                  system.debug('----cProd---'+cProd);
                  CProduct__c objproduct1 =  [  select id,  Name,
                                                    List_Price__c,
                                                    Product_Code__c,
                                                    Product_Description__c,
                                                    Sales_Price__c,
                                                    Product_Family__c
                                            from    CProduct__c  
                                            where   id =:SelectedProduct];
                        cartlstproduct.add(new cproduct(objproduct1))     ;             
                     system.debug('---cartlstproduct---'+cartlstproduct);                       
                } 
        }      
           return null ;
         }
         
         
         
         
          public pageReference processSelected()
         {
           list<CQuote_Line_Item__c> lstaddquoteproduct = new list<CQuote_Line_Item__c>();
        //   list<CProduct__c> lstselproduct = new list<CProduct__c>();
           system.debug(lstproduct+'===lstproduct====');
  
          for(cproduct cess:cartlstproduct)
             {
                  system.debug('-----cess---'+cess);
                  if(cess.Display== true)
      {
        
                
       if((cess.quantity!=null && cess.quantity!='' && cess.quantity!=string.valueof(0) )&& (cess.salesprice!=null && cess.salesprice!='' ) )
        {
                  
              //mapProductIdToQuantity.put(cPro.pro.id,double.valueof(cPro.quantity));
              //system.debug(mapProductIdToQuantity+'---map---');
                
                CQuote_Line_Item__c objQuoteli = new CQuote_Line_Item__c();
                system.debug('---cess.quantity---'+cess.quantity);
                objQuoteli.Name = cess.cpro.Name  ;
                objQuoteli.Quantity__c =double.valueOf(cess.quantity) ;
                objQuoteli.Unit_Price__c =cess.cpro.List_Price__c;
                objQuoteli.Quote__c = strid;
                objQuoteli.Total_Amount__c= double.valueof(cess.TotalAmount );
                //objQuoteli.Discount_Percent__c = double.valueOf(cess.discount) ;
                objQuoteli.Sales_Price__c = double.valueOf(cess.salesprice) ;
                system.debug('---objQuoteli---'+objQuoteli);
                lstaddquoteproduct.add(objQuoteli);
                system.debug(lstaddquoteproduct+'----lstaddquoteproduct----');
                  }
            else
                     {
                            system.debug('---else---');
                            ApexPages.Message errormessage = new ApexPages.Message(ApexPages.Severity.ERROR,'Please enter all the values.');
                            ApexPages.addMessage(errormessage);
                     }
                          
                  }
      
   }//for loop
    if(lstaddquoteproduct.size()>0)
                {
                   insert lstaddquoteproduct;
                   system.debug('---strid--'+strid);
                   pageReference pageRef1 = new pageReference('/'+strid);
                   pageRef1.setredirect(true);
                   return pageRef1;
              }
           return null;
           }
              
              
                //product list wrapper class
    
      public class pProduct
        {
            public CProduct__c pro {get;set;}
            public boolean selected {get;set;}
            public string quantity {get;set;}
            public string salesprice {get;set;}
            public integer TotalAmount {get;set;}
            public integer discount {get;set;}
             //public string discount {get;set;}
            public pProduct(CProduct__c p)
                {
                    pro = p;    
                    selected = false ;   
                    quantity='1';
                }
        
        
        }  
        
        //cart list wrapper class
        public class cproduct
        {
            public CProduct__c cpro{get;set;}
            public boolean selected {get;set;}
            public boolean Display {get;set;}
            public string quantity {get;set;}
            public string salesprice {get;set;}
            public string TotalAmount {get;set;}
            public string discount {get;set;}
            public cProduct(CProduct__c c)
                {
                    cpro = c;  
                    selected = false ;  
                    quantity='1';
                   salesprice= string.valueof( cpro.List_Price__c );
                     TotalAmount = string.valueof( cpro.List_Price__c );
                    Display = false ;
                }
        
        
        }
        
       
  
  
    public pageReference cancelbutton()
        {
            pageReference pageRef1 = new pageReference('/'+strid);
            pageRef1.setredirect(true);
            return pageRef1;
        }
 }

 
When I try to add some apex classes in unmanaged package, I am not able to found some of the classes but the test classes for those classes are there. 

Please advice me
I am trying to write a test class for my Wrapper Class, unfortunately my overall code coverage is 51%, so I need to get more then 75% in order to deploy.how i will do plz help me 
public with sharing class CRM_AddProducts
{

    public String message { get; set; }
 
  public String SelectedProduct{get;set;}
  public list<pProduct> lstproduct { get; set; }
  public list<cproduct> cartlstproduct {get;set;}
  
  public list<CProduct__c> lstselproduct { get; set; }
  public list<CQuote_Line_Item__c> lstaddquoteproduct { get; set; }
  public List<SelectOption> Product_Selectionoptions {get;set;} 
  public boolean selected {get;set;}
  public boolean display {get;set;}
  public CProduct__c pro {get;set;}
 // public CProduct__c cpro{get;set;}
 // public CProduct__c cess{get;set;}
  public map<Id,double> mapProductIdToQuantity { get; set; }
  public string strid;
  public boolean blnStatus1 ;
  
  
  
  

    public CRM_AddProducts()
      {
          lstproduct=new list<pProduct>();
          mapProductIdToQuantity = new map<Id,double>();
          cartlstproduct = new list<cproduct>();
          lstaddquoteproduct = new list<CQuote_Line_Item__c>();
          strid = apexpages.currentPage().getParameters().get('id');
         
        
                for(CProduct__c objproduct : [select id,
                                              Name,
                                              List_Price__c,
                                              Product_Code__c,
                                              Product_Description__c,
                                              Sales_Price__c,
                                              Product_Family__c
                                      from    CProduct__c])
          {
              lstproduct.add(new pProduct(objproduct));
              system.debug('---lstproduct---'+lstproduct);
          }
      }
      
      
       public pageReference check()
    {
      return null;
    }
        
         
  
    //builds a picklist of product names based on their product id
      public List<SelectOption>getProduct_Selection() 
    
     {
        List<SelectOption> Product_Selectionoptions = new List<SelectOption>();
  //new list for holding all of the picklist options
       
       for (CProduct__c Product_Selection : [SELECT Id, Name FROM CProduct__c]) 
       { 
  //query for Product records 
       Product_Selectionoptions.add(new selectOption(Product_Selection.Id,Product_Selection.Name));
      
  //for all records found - add them to the picklist options
       }
       system.debug('-Product_Selectionoptions-'+Product_Selectionoptions);
      return Product_Selectionoptions; //return the picklist options
       
   }
   
         
         public pageReference addtocart()
         {
            for(pProduct cProd : lstproduct)
        {
                
                system.debug('----cProd---'+cProd);
                system.debug('--SelectedProduct--'+SelectedProduct);
                system.debug('-Product_Selectionoptions-'+Product_Selectionoptions);
               //  system.debug('-Product_Selection-'+Product_Selectionoptions.Product_Selection);
                if(cProd.selected == true)
                {
                  system.debug('----cProd---'+cProd);
                  CProduct__c objproduct1 =  [  select id,  Name,
                                                    List_Price__c,
                                                    Product_Code__c,
                                                    Product_Description__c,
                                                    Sales_Price__c,
                                                    Product_Family__c
                                            from    CProduct__c  
                                            where   id =:SelectedProduct];
                        cartlstproduct.add(new cproduct(objproduct1))     ;             
                     system.debug('---cartlstproduct---'+cartlstproduct);                       
                } 
        }      
           return null ;
         }
         
         
         
         
          public pageReference processSelected()
         {
           list<CQuote_Line_Item__c> lstaddquoteproduct = new list<CQuote_Line_Item__c>();
        //   list<CProduct__c> lstselproduct = new list<CProduct__c>();
           system.debug(lstproduct+'===lstproduct====');
  
          for(cproduct cess:cartlstproduct)
             {
                  system.debug('-----cess---'+cess);
                  if(cess.Display== true)
      {
        
                
       if((cess.quantity!=null && cess.quantity!='' && cess.quantity!=string.valueof(0) )&& (cess.salesprice!=null && cess.salesprice!='' ) )
        {
                  
              //mapProductIdToQuantity.put(cPro.pro.id,double.valueof(cPro.quantity));
              //system.debug(mapProductIdToQuantity+'---map---');
                
                CQuote_Line_Item__c objQuoteli = new CQuote_Line_Item__c();
                system.debug('---cess.quantity---'+cess.quantity);
                objQuoteli.Name = cess.cpro.Name  ;
                objQuoteli.Quantity__c =double.valueOf(cess.quantity) ;
                objQuoteli.Unit_Price__c =cess.cpro.List_Price__c;
                objQuoteli.Quote__c = strid;
                objQuoteli.Total_Amount__c= double.valueof(cess.TotalAmount );
                //objQuoteli.Discount_Percent__c = double.valueOf(cess.discount) ;
                objQuoteli.Sales_Price__c = double.valueOf(cess.salesprice) ;
                system.debug('---objQuoteli---'+objQuoteli);
                lstaddquoteproduct.add(objQuoteli);
                system.debug(lstaddquoteproduct+'----lstaddquoteproduct----');
                  }
            else
                     {
                            system.debug('---else---');
                            ApexPages.Message errormessage = new ApexPages.Message(ApexPages.Severity.ERROR,'Please enter all the values.');
                            ApexPages.addMessage(errormessage);
                     }
                          
                  }
      
   }//for loop
    if(lstaddquoteproduct.size()>0)
                {
                   insert lstaddquoteproduct;
                   system.debug('---strid--'+strid);
                   pageReference pageRef1 = new pageReference('/'+strid);
                   pageRef1.setredirect(true);
                   return pageRef1;
              }
           return null;
           }
              
              
                //product list wrapper class
    
      public class pProduct
        {
            public CProduct__c pro {get;set;}
            public boolean selected {get;set;}
            public string quantity {get;set;}
            public string salesprice {get;set;}
            public integer TotalAmount {get;set;}
            public integer discount {get;set;}
             //public string discount {get;set;}
            public pProduct(CProduct__c p)
                {
                    pro = p;    
                    selected = false ;   
                    quantity='1';
                }
        
        
        }  
        
        //cart list wrapper class
        public class cproduct
        {
            public CProduct__c cpro{get;set;}
            public boolean selected {get;set;}
            public boolean Display {get;set;}
            public string quantity {get;set;}
            public string salesprice {get;set;}
            public string TotalAmount {get;set;}
            public string discount {get;set;}
            public cProduct(CProduct__c c)
                {
                    cpro = c;  
                    selected = false ;  
                    quantity='1';
                   salesprice= string.valueof( cpro.List_Price__c );
                     TotalAmount = string.valueof( cpro.List_Price__c );
                    Display = false ;
                }
        
        
        }
        
       
  
  
    public pageReference cancelbutton()
        {
            pageReference pageRef1 = new pageReference('/'+strid);
            pageRef1.setredirect(true);
            return pageRef1;
        }
 }