mercredi 25 octobre 2017

Test Apex Class

i need some help to put my visual page on production.

It works OK on devel but i cant create the test.

The visualpage has six filters and then run query

The code from the report controlles is the following.

     public void ReportFilter()
         { 
         
         if(selectedCCYId != null && selectedFilterDate == null )
         {quo= [SELECT Order_Date__c, Id, Name, Platform_Name__c, Product__c,  related_product__r.Country__c,related_product__r.SKU__c, related_product__r.Enabled__c, related_product__r.Default_provider__c, related_product__r.Default_provider__r.Name, related_product__c, related_product__r.Tipo_producto__c,related_product__r.Brand__c,related_product__r.Brand__r.Name,related_product__r.Tax__c, related_product__r.CurrencyIsoCode, related_product__r.Cost__c, related_product__r.Discount__c, related_product__r.Discounted_cost__c, Quantity__c  FROM Rew_Order__c where Status__c = 'Pending' and Purchase_Order__c = ''  and  Platform_Name__c LIKE :filter1 and  related_product__r.Default_provider__r.Name LIKE :filter2 and related_product__r.Tipo_producto__c LIKE :selectedVendorId and related_product__r.Country__c LIKE :Ctry and related_product__r.CurrencyIsoCode LIKE :selectedCCYId Order by Order_Date__c];}
         if(selectedCCYId == null && selectedFilterDate == null )
         {quo= [SELECT Order_Date__c, Id, Name, Platform_Name__c, Product__c,  related_product__r.Country__c,related_product__r.SKU__c, related_product__r.Enabled__c, related_product__r.Default_provider__c, related_product__r.Default_provider__r.Name, related_product__c, related_product__r.Tipo_producto__c,related_product__r.Brand__c,related_product__r.Brand__r.Name,related_product__r.Tax__c, related_product__r.CurrencyIsoCode, related_product__r.Cost__c, related_product__r.Discount__c, related_product__r.Discounted_cost__c, Quantity__c  FROM Rew_Order__c where Status__c = 'Pending' and Purchase_Order__c = ''  and  Platform_Name__c LIKE :filter1 and  related_product__r.Default_provider__r.Name LIKE :filter2 and related_product__r.Tipo_producto__c LIKE :selectedVendorId and related_product__r.Country__c LIKE :Ctry and related_product__r.CurrencyIsoCode LIKE :Ccy  Order by Order_Date__c];}    
         if(selectedCCYId != null && selectedFilterDate == 'ALL' )
         {quo= [SELECT Order_Date__c, Id, Name, Platform_Name__c, Product__c,  related_product__r.Country__c,related_product__r.SKU__c, related_product__r.Enabled__c, related_product__r.Default_provider__c, related_product__r.Default_provider__r.Name, related_product__c, related_product__r.Tipo_producto__c,related_product__r.Brand__c,related_product__r.Brand__r.Name,related_product__r.Tax__c, related_product__r.CurrencyIsoCode, related_product__r.Cost__c, related_product__r.Discount__c, related_product__r.Discounted_cost__c, Quantity__c  FROM Rew_Order__c where Status__c = 'Pending' and Purchase_Order__c = ''  and  Platform_Name__c LIKE :filter1 and  related_product__r.Default_provider__r.Name LIKE :filter2 and related_product__r.Tipo_producto__c LIKE :selectedVendorId and related_product__r.Country__c LIKE :Ctry and related_product__r.CurrencyIsoCode LIKE :selectedCCYId Order by Order_Date__c];}
         if(selectedCCYId == null && selectedFilterDate == 'ALL' )
         {quo= [SELECT Order_Date__c, Id, Name, Platform_Name__c, Product__c,  related_product__r.Country__c,related_product__r.SKU__c, related_product__r.Enabled__c, related_product__r.Default_provider__c, related_product__r.Default_provider__r.Name, related_product__c, related_product__r.Tipo_producto__c,related_product__r.Brand__c,related_product__r.Brand__r.Name,related_product__r.Tax__c, related_product__r.CurrencyIsoCode, related_product__r.Cost__c, related_product__r.Discount__c, related_product__r.Discounted_cost__c, Quantity__c  FROM Rew_Order__c where Status__c = 'Pending' and Purchase_Order__c = ''  and  Platform_Name__c LIKE :filter1 and  related_product__r.Default_provider__r.Name LIKE :filter2 and related_product__r.Tipo_producto__c LIKE :selectedVendorId and related_product__r.Country__c LIKE :Ctry and related_product__r.CurrencyIsoCode LIKE :Ccy  Order by Order_Date__c];}
         if(selectedCCYId != null && selectedFilterDate == 'TODAY')  
         {quo= [SELECT Order_Date__c, Id, Name, Platform_Name__c, Product__c,  related_product__r.Country__c,related_product__r.SKU__c, related_product__r.Enabled__c, related_product__r.Default_provider__c, related_product__r.Default_provider__r.Name, related_product__c, related_product__r.Tipo_producto__c,related_product__r.Brand__c,related_product__r.Brand__r.Name,related_product__r.Tax__c, related_product__r.CurrencyIsoCode, related_product__r.Cost__c, related_product__r.Discount__c, related_product__r.Discounted_cost__c, Quantity__c  FROM Rew_Order__c where Status__c = 'Pending' and Purchase_Order__c = ''  and  Platform_Name__c LIKE :filter1 and  related_product__r.Default_provider__r.Name LIKE :filter2 and related_product__r.Tipo_producto__c LIKE :selectedVendorId and related_product__r.Country__c LIKE :Ctry and related_product__r.CurrencyIsoCode LIKE :selectedCCYId and Order_Date__c = TODAY Order by Order_Date__c];}
         if(selectedCCYId == null && selectedFilterDate == 'TODAY')  
         {quo= [SELECT Order_Date__c, Id, Name, Platform_Name__c, Product__c,  related_product__r.Country__c,related_product__r.SKU__c, related_product__r.Enabled__c, related_product__r.Default_provider__c, related_product__r.Default_provider__r.Name, related_product__c, related_product__r.Tipo_producto__c,related_product__r.Brand__c,related_product__r.Brand__r.Name,related_product__r.Tax__c, related_product__r.CurrencyIsoCode, related_product__r.Cost__c, related_product__r.Discount__c, related_product__r.Discounted_cost__c, Quantity__c  FROM Rew_Order__c where Status__c = 'Pending' and Purchase_Order__c = ''  and  Platform_Name__c LIKE :filter1 and  related_product__r.Default_provider__r.Name LIKE :filter2 and related_product__r.Tipo_producto__c LIKE :selectedVendorId and related_product__r.Country__c LIKE :Ctry and related_product__r.CurrencyIsoCode LIKE :Ccy and Order_Date__c = TODAY Order by Order_Date__c];}          
         if(selectedCCYId != null && selectedFilterDate == 'THIS_MONTH')  
         {quo= [SELECT Order_Date__c, Id, Name, Platform_Name__c, Product__c,  related_product__r.Country__c,related_product__r.SKU__c, related_product__r.Enabled__c, related_product__r.Default_provider__c, related_product__r.Default_provider__r.Name, related_product__c, related_product__r.Tipo_producto__c,related_product__r.Brand__c,related_product__r.Brand__r.Name,related_product__r.Tax__c, related_product__r.CurrencyIsoCode, related_product__r.Cost__c, related_product__r.Discount__c, related_product__r.Discounted_cost__c, Quantity__c  FROM Rew_Order__c where Status__c = 'Pending' and Purchase_Order__c = ''  and  Platform_Name__c LIKE :filter1 and  related_product__r.Default_provider__r.Name LIKE :filter2 and related_product__r.Tipo_producto__c LIKE :selectedVendorId and related_product__r.Country__c LIKE :Ctry and related_product__r.CurrencyIsoCode LIKE :selectedCCYId and Order_Date__c = THIS_MONTH Order by Order_Date__c];}
         if(selectedCCYId == null && selectedFilterDate == 'THIS_MONTH')  
         {quo= [SELECT Order_Date__c, Id, Name, Platform_Name__c, Product__c,  related_product__r.Country__c,related_product__r.SKU__c, related_product__r.Enabled__c, related_product__r.Default_provider__c, related_product__r.Default_provider__r.Name, related_product__c, related_product__r.Tipo_producto__c,related_product__r.Brand__c,related_product__r.Brand__r.Name,related_product__r.Tax__c, related_product__r.CurrencyIsoCode, related_product__r.Cost__c, related_product__r.Discount__c, related_product__r.Discounted_cost__c, Quantity__c  FROM Rew_Order__c where Status__c = 'Pending' and Purchase_Order__c = ''  and  Platform_Name__c LIKE :filter1 and  related_product__r.Default_provider__r.Name LIKE :filter2 and related_product__r.Tipo_producto__c LIKE :selectedVendorId and related_product__r.Country__c LIKE :Ctry and related_product__r.CurrencyIsoCode LIKE :Ccy and Order_Date__c = THIS_MONTH Order by Order_Date__c];}          
         if(selectedCCYId != null && selectedFilterDate == 'LAST_MONTH')  
         {quo= [SELECT Order_Date__c, Id, Name, Platform_Name__c, Product__c,  related_product__r.Country__c,related_product__r.SKU__c, related_product__r.Enabled__c, related_product__r.Default_provider__c, related_product__r.Default_provider__r.Name, related_product__c, related_product__r.Tipo_producto__c,related_product__r.Brand__c,related_product__r.Brand__r.Name,related_product__r.Tax__c, related_product__r.CurrencyIsoCode, related_product__r.Cost__c, related_product__r.Discount__c, related_product__r.Discounted_cost__c, Quantity__c  FROM Rew_Order__c where Status__c = 'Pending' and Purchase_Order__c = ''  and  Platform_Name__c LIKE :filter1 and  related_product__r.Default_provider__r.Name LIKE :filter2 and related_product__r.Tipo_producto__c LIKE :selectedVendorId and related_product__r.Country__c LIKE :Ctry and related_product__r.CurrencyIsoCode LIKE :selectedCCYId and Order_Date__c = LAST_MONTH Order by Order_Date__c];}
         if(selectedCCYId == null && selectedFilterDate == 'LAST_MONTH')  
         {quo= [SELECT Order_Date__c, Id, Name, Platform_Name__c, Product__c,  related_product__r.Country__c,related_product__r.SKU__c, related_product__r.Enabled__c, related_product__r.Default_provider__c, related_product__r.Default_provider__r.Name, related_product__c, related_product__r.Tipo_producto__c,related_product__r.Brand__c,related_product__r.Brand__r.Name,related_product__r.Tax__c, related_product__r.CurrencyIsoCode, related_product__r.Cost__c, related_product__r.Discount__c, related_product__r.Discounted_cost__c, Quantity__c  FROM Rew_Order__c where Status__c = 'Pending' and Purchase_Order__c = ''  and  Platform_Name__c LIKE :filter1 and  related_product__r.Default_provider__r.Name LIKE :filter2 and related_product__r.Tipo_producto__c LIKE :selectedVendorId and related_product__r.Country__c LIKE :Ctry and related_product__r.CurrencyIsoCode LIKE :Ccy and Order_Date__c = LAST_MONTH Order by Order_Date__c];}          
         if(selectedCCYId != null && selectedFilterDate == 'LAST_N_MONTHS:3')  
         {quo= [SELECT Order_Date__c, Id, Name, Platform_Name__c, Product__c,  related_product__r.Country__c,related_product__r.SKU__c, related_product__r.Enabled__c, related_product__r.Default_provider__c, related_product__r.Default_provider__r.Name, related_product__c, related_product__r.Tipo_producto__c,related_product__r.Brand__c,related_product__r.Brand__r.Name,related_product__r.Tax__c, related_product__r.CurrencyIsoCode, related_product__r.Cost__c, related_product__r.Discount__c, related_product__r.Discounted_cost__c, Quantity__c  FROM Rew_Order__c where Status__c = 'Pending' and Purchase_Order__c = ''  and  Platform_Name__c LIKE :filter1 and  related_product__r.Default_provider__r.Name LIKE :filter2 and related_product__r.Tipo_producto__c LIKE :selectedVendorId and related_product__r.Country__c LIKE :Ctry and related_product__r.CurrencyIsoCode LIKE :selectedCCYId and Order_Date__c = LAST_N_MONTHS:3 Order by Order_Date__c];}
         if(selectedCCYId == null && selectedFilterDate == 'LAST_N_MONTHS:3')  

         {quo= [SELECT Order_Date__c, Id, Name, Platform_Name__c, Product__c,  related_product__r.Country__c,related_product__r.SKU__c, related_product__r.Enabled__c, related_product__r.Default_provider__c, related_product__r.Default_provider__r.Name, related_product__c, related_product__r.Tipo_producto__c,related_product__r.Brand__c,related_product__r.Brand__r.Name,related_product__r.Tax__c, related_product__r.CurrencyIsoCode, related_product__r.Cost__c, related_product__r.Discount__c, related_product__r.Discounted_cost__c, Quantity__c  FROM Rew_Order__c where Status__c = 'Pending' and Purchase_Order__c = ''  and  Platform_Name__c LIKE :filter1 and  related_product__r.Default_provider__r.Name LIKE :filter2 and related_product__r.Tipo_producto__c LIKE :selectedVendorId and related_product__r.Country__c LIKE :Ctry and related_product__r.CurrencyIsoCode LIKE :Ccy and Order_Date__c = LAST_N_MONTHS:3 Order by Order_Date__c];}          
         if(selectedCCYId != null && selectedFilterDate == 'LAST_N_MONTHS:6')  
         {quo= [SELECT Order_Date__c, Id, Name, Platform_Name__c, Product__c,  related_product__r.Country__c,related_product__r.SKU__c, related_product__r.Enabled__c, related_product__r.Default_provider__c, related_product__r.Default_provider__r.Name, related_product__c, related_product__r.Tipo_producto__c,related_product__r.Brand__c,related_product__r.Brand__r.Name,related_product__r.Tax__c, related_product__r.CurrencyIsoCode, related_product__r.Cost__c, related_product__r.Discount__c, related_product__r.Discounted_cost__c, Quantity__c  FROM Rew_Order__c where Status__c = 'Pending' and Purchase_Order__c = ''  and  Platform_Name__c LIKE :filter1 and  related_product__r.Default_provider__r.Name LIKE :filter2 and related_product__r.Tipo_producto__c LIKE :selectedVendorId and related_product__r.Country__c LIKE :Ctry and related_product__r.CurrencyIsoCode LIKE :selectedCCYId and Order_Date__c = LAST_N_MONTHS:6 Order by Order_Date__c];}
         if(selectedCCYId == null && selectedFilterDate == 'LAST_N_MONTHS:6')  

         {quo= [SELECT Order_Date__c, Id, Name, Platform_Name__c, Product__c,  related_product__r.Country__c,related_product__r.SKU__c, related_product__r.Enabled__c, related_product__r.Default_provider__c, related_product__r.Default_provider__r.Name, related_product__c, related_product__r.Tipo_producto__c,related_product__r.Brand__c,related_product__r.Brand__r.Name,related_product__r.Tax__c, related_product__r.CurrencyIsoCode, related_product__r.Cost__c, related_product__r.Discount__c, related_product__r.Discounted_cost__c, Quantity__c  FROM Rew_Order__c where Status__c = 'Pending' and Purchase_Order__c = ''  and  Platform_Name__c LIKE :filter1 and  related_product__r.Default_provider__r.Name LIKE :filter2 and related_product__r.Tipo_producto__c LIKE :selectedVendorId and related_product__r.Country__c LIKE :Ctry and related_product__r.CurrencyIsoCode LIKE :Ccy and Order_Date__c = LAST_N_MONTHS:6 Order by Order_Date__c];}                       
         if(selectedCCYId != null && selectedFilterDate == 'THIS_YEAR')  
         {quo= [SELECT Order_Date__c, Id, Name, Platform_Name__c, Product__c,  related_product__r.Country__c,related_product__r.SKU__c, related_product__r.Enabled__c, related_product__r.Default_provider__c, related_product__r.Default_provider__r.Name, related_product__c, related_product__r.Tipo_producto__c,related_product__r.Brand__c,related_product__r.Brand__r.Name,related_product__r.Tax__c, related_product__r.CurrencyIsoCode, related_product__r.Cost__c, related_product__r.Discount__c, related_product__r.Discounted_cost__c, Quantity__c  FROM Rew_Order__c where Status__c = 'Pending' and Purchase_Order__c = ''  and  Platform_Name__c LIKE :filter1 and  related_product__r.Default_provider__r.Name LIKE :filter2 and related_product__r.Tipo_producto__c LIKE :selectedVendorId and related_product__r.Country__c LIKE :Ctry and related_product__r.CurrencyIsoCode LIKE :selectedCCYId and Order_Date__c = THIS_YEAR Order by Order_Date__c];}
         if(selectedCCYId == null && selectedFilterDate == 'THIS_YEAR')  
         {quo= [SELECT Order_Date__c, Id, Name, Platform_Name__c, Product__c,  related_product__r.Country__c,related_product__r.SKU__c, related_product__r.Enabled__c, related_product__r.Default_provider__c, related_product__r.Default_provider__r.Name, related_product__c, related_product__r.Tipo_producto__c,related_product__r.Brand__c,related_product__r.Brand__r.Name,related_product__r.Tax__c, related_product__r.CurrencyIsoCode, related_product__r.Cost__c, related_product__r.Discount__c, related_product__r.Discounted_cost__c, Quantity__c  FROM Rew_Order__c where Status__c = 'Pending' and Purchase_Order__c = ''  and  Platform_Name__c LIKE :filter1 and  related_product__r.Default_provider__r.Name LIKE :filter2 and related_product__r.Tipo_producto__c LIKE :selectedVendorId and related_product__r.Country__c LIKE :Ctry and related_product__r.CurrencyIsoCode LIKE :Ccy and Order_Date__c = THIS_YEAR Order by Order_Date__c];}                       
         if(selectedCCYId != null && selectedFilterDate == 'LAST_YEAR')  
         {quo= [SELECT Order_Date__c, Id, Name, Platform_Name__c, Product__c,  related_product__r.Country__c,related_product__r.SKU__c, related_product__r.Enabled__c, related_product__r.Default_provider__c, related_product__r.Default_provider__r.Name, related_product__c, related_product__r.Tipo_producto__c,related_product__r.Brand__c,related_product__r.Brand__r.Name,related_product__r.Tax__c, related_product__r.CurrencyIsoCode, related_product__r.Cost__c, related_product__r.Discount__c, related_product__r.Discounted_cost__c, Quantity__c  FROM Rew_Order__c where Status__c = 'Pending' and Purchase_Order__c = ''  and  Platform_Name__c LIKE :filter1 and  related_product__r.Default_provider__r.Name LIKE :filter2 and related_product__r.Tipo_producto__c LIKE :selectedVendorId and related_product__r.Country__c LIKE :Ctry and related_product__r.CurrencyIsoCode LIKE :selectedCCYId and Order_Date__c = LAST_YEAR Order by Order_Date__c];}
         if(selectedCCYId == null && selectedFilterDate == 'LAST_YEAR')  
         {quo= [SELECT Order_Date__c, Id, Name, Platform_Name__c, Product__c,  related_product__r.Country__c,related_product__r.SKU__c, related_product__r.Enabled__c, related_product__r.Default_provider__c, related_product__r.Default_provider__r.Name, related_product__c, related_product__r.Tipo_producto__c,related_product__r.Brand__c,related_product__r.Brand__r.Name,related_product__r.Tax__c, related_product__r.CurrencyIsoCode, related_product__r.Cost__c, related_product__r.Discount__c, related_product__r.Discounted_cost__c, Quantity__c  FROM Rew_Order__c where Status__c = 'Pending' and Purchase_Order__c = ''  and  Platform_Name__c LIKE :filter1 and  related_product__r.Default_provider__r.Name LIKE :filter2 and related_product__r.Tipo_producto__c LIKE :selectedVendorId and related_product__r.Country__c LIKE :Ctry and related_product__r.CurrencyIsoCode LIKE :Ccy and Order_Date__c = LAST_YEAR Order by Order_Date__c];}                              

         }

Could you please help me to create the following test class??

I thing so i need yo put test valuest to filters and run.

Regards

Aucun commentaire:

Enregistrer un commentaire