• Nagaraju Mogili 33
  • NEWBIE
  • 0 Points
  • Member since 2018

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 5
    Questions
  • 5
    Replies
public class SearchFilter_ctrl {
  public list<innerclass> innerlist {get;set;} 
  public list<opportunity> opplist {get;set;}
  public opportunity oppp{get;set;}
  public string text {get;set;} 
  public list<opportunity> opplist1 {get;set;}
   public  List<Opportunity> optyList {get;set;}
   
    public SearchFilter_ctrl (){
    optyList  = new List<Opportunity>();
      innerlist = new list<innerclass>();
      opplist = [select id,StageName,name,(select id,ProductCode,UnitPrice,Quantity,PricebookEntry.product2id,PricebookEntry.product2.ProductCode,product2.name from OpportunityLineItems),(select id,Phone,QuoteNumber,Tax,TotalPrice from Quotes) from opportunity];
      
      for(Opportunity o :opplist){
         innerlist .add(new innerclass(o,o.quotes,o.OpportunityLineItems)); 
         
        }
       
    }
    
   
  
   public class innerclass{
     public Opportunity opp {get;set;}
     public list<Product2> prolist {get;set;}
     public list<Quote> quolist {get;set;} 
     public list<QuoteLineItem> quolineitem {get;set;}
     public list<OpportunityLineItem> opplineitems {get;set;}
        
     public innerclass(Opportunity  opps,list<Quote> q,list<OpportunityLineItem> ol )
     {   //list<Product2> pro 
     quolist = new list<quote>();
       opp = opps;
       //prolist = pro;
       //quolist = q;
       for(Quote q1:q)
       {
       Quote Q2= [select id,Phone,QuoteNumber,Tax,TotalPrice,(select id from quotelineitems) from quote where id=:q1.id];   
          quolist.add(q2);  
       }
     
      opplineitems = ol;
     }
   }
   
 
  public void search()
  {
     string searchfield = '%'+text+'%';
  opplist = [select id,StageName,name,(select id,ProductCode,UnitPrice,Quantity,PricebookEntry.product2id,PricebookEntry.product2.ProductCode,product2.name from OpportunityLineItems),(select id,Phone,QuoteNumber,Tax,TotalPrice from Quotes) from opportunity where name like : searchfield ];

  }
}


can anyone help me on this...
Hi All,
These are my Controller and my Test Class.
Whatever I change I could not reach more than 50% coverage.
Could you please help me to get at least 75% to deploy in Production?
public class MyCPDPointsAPEXController {
    
@AuraEnabled    
    public CPD_Points_Total__c total {get;set;}
    string recordId = ApexPages.currentPage().getParameters().get('recordId');
    
    public MyCPDPointsAPEXController(ApexPages.StandardController controller) { 
        
        total = [select Id, Name, Total_Points__c, (select Id, Activity_Date__c, Activity_Title__c, Organiser_Company__c, Points__c from CPD_Register__r) from CPD_Points_Total__c where Id=:ApexPages.currentPage().getParameters().get('recordId')];
    }
    
    public PageReference cancel(){   
        return new PageReference('/' + recordId);   
    }
}
 
@isTest
private class MyCPDPointsAPEXTest {
    
    static testMethod void MyTest()
    {
        CPD_Points_Total__c total = new CPD_Points_Total__c(Name='Test-2017');  
        
        ApexPages.CurrentPage().getparameters().put('id', total.id);      
        
        Apexpages.StandardController sc = new Apexpages.StandardController(total);
        MyCPDPointsAPEXController ext = new MyCPDPointsAPEXController(sc); 
        
        ext.cancel();      
    }
}



Thank you in advance for your help.
Sylvie
 
In a class I have used standard set controller.How to cover the same in the test class?
Please help.