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
Nishant Shrivastava 30Nishant Shrivastava 30 

I am not getting complete coverage for soql query

thanks in advance

My class 

Public class  Invoice_details {
        Public List<VoiceWrapper> InvoiceList {get;set;}
        Public kognoz1__Invoice2__c InvoiceInfo { get;set;}
           Public static Date StartDate {get;set;}
        Public static Date EndDate {get;set;}
        Public static string querystr;
        Public integer counter = 0; 
        Public integer list_size=100;
        Static set<Id> ids = New set<Id>();
        
         
                Public Invoice_details() { 
                InvoiceInfo = new kognoz1__Invoice2__c();
                InvoiceList = New List<VoiceWrapper>();
                for(kognoz1__Invoice2__c k : [SELECT id, kognoz1__Invoice_Date__c, kognoz1__Account__c, Downloaded__c, kognoz1__Opportunity__r.rechnung_per_email__c , kognoz1__Opportunity__c, (select id, name from Attachments) FROM kognoz1__Invoice2__c ORDER BY kognoz1__Invoice_Date__c  DESC limit: List_size ])
                {
                    InvoiceList.add(new VoiceWrapper(K));
                }
                } 
            
                Public void display() {
                InvoiceList.clear();
                Date startDate = InvoiceInfo.kognoz1__Invoice_Date__c;
                Date endDate = InvoiceInfo.kognoz1__Invoice_Due_Date__c;
                if(InvoiceInfo.kognoz1__Invoice_Date__c != null ) {
                //string Query = 'SELECT kognoz1__Invoice_Date__c, kognoz1__Account__c, kognoz1__Opportunity__c,(select id, name from Attachments) FROM kognoz1__Invoice2__c WHERE kognoz1__Invoice_Date__c = '+startDate+' AND kognoz1__Invoice_Date__c= '+EndDate+' ';
                InvoiceList = New List<VoiceWrapper>();
                for(kognoz1__Invoice2__c k : [SELECT Id, kognoz1__Invoice_Date__c, kognoz1__Account__c, Downloaded__c, kognoz1__Opportunity__r.rechnung_per_email__c, kognoz1__Opportunity__c, (select id, name from Attachments) FROM kognoz1__Invoice2__c WHERE kognoz1__Invoice_Date__c >=: startDate AND kognoz1__Invoice_Date__c <=: EndDate ORDER BY kognoz1__Invoice_Date__c  DESC  limit: list_size offset: counter ])
                {
                    InvoiceList.add(new VoiceWrapper(K));
                }
                }
               }
                
   
    
                Public void emailLists() {
                InvoiceList.clear();
                Date startDate = InvoiceInfo.kognoz1__Invoice_Date__c;
                Date endDate = InvoiceInfo.kognoz1__Invoice_Due_Date__c;
                if(InvoiceInfo.kognoz1__Invoice_Date__c != null ) {
                //string Query = 'SELECT kognoz1__Invoice_Date__c, kognoz1__Account__c, kognoz1__Opportunity__c,(select id, name from Attachments) FROM kognoz1__Invoice2__c WHERE kognoz1__Invoice_Date__c = '+startDate+' AND kognoz1__Invoice_Date__c= '+EndDate+' ';
                InvoiceList = New List<VoiceWrapper>();
                for(kognoz1__Invoice2__c k : [SELECT Id, kognoz1__Invoice_Date__c, kognoz1__Account__c, Downloaded__c, kognoz1__Opportunity__r.rechnung_per_email__c, kognoz1__Opportunity__c, (select id, name from Attachments) FROM kognoz1__Invoice2__c WHERE kognoz1__Invoice_Date__c >=: startDate AND kognoz1__Invoice_Date__c <=: EndDate AND kognoz1__Opportunity__r.rechnung_per_email__c like '%' ORDER BY kognoz1__Invoice_Date__c  DESC  limit: list_size offset: counter ])
                {
                    InvoiceList.add(new VoiceWrapper(K));
                }
                }
               }

                Public void PostLists() {
                InvoiceList.clear();
                Date startDate = InvoiceInfo.kognoz1__Invoice_Date__c;
                Date endDate = InvoiceInfo.kognoz1__Invoice_Due_Date__c;
                if(InvoiceInfo.kognoz1__Invoice_Date__c != null ) {
                //string Query = 'SELECT kognoz1__Invoice_Date__c, kognoz1__Account__c, kognoz1__Opportunity__c,(select id, name from Attachments) FROM kognoz1__Invoice2__c WHERE kognoz1__Invoice_Date__c = '+startDate+' AND kognoz1__Invoice_Date__c= '+EndDate+' ';
                InvoiceList = New List<VoiceWrapper>();
                for(kognoz1__Invoice2__c k : [SELECT Id, kognoz1__Invoice_Date__c, kognoz1__Account__c, Downloaded__c, kognoz1__Opportunity__r.rechnung_per_email__c, kognoz1__Opportunity__c, (select id, name from Attachments) FROM kognoz1__Invoice2__c WHERE kognoz1__Invoice_Date__c >=: startDate AND kognoz1__Invoice_Date__c <=: EndDate AND kognoz1__Opportunity__r.rechnung_per_email__c = null ORDER BY kognoz1__Invoice_Date__c  DESC  limit: list_size offset: counter ])
                {
                    InvoiceList.add(new VoiceWrapper(K));
                }
                }
               }
    
   
    
                Public void displayDownload(){
                InvoiceList.clear();
                /*
                 * InvoiceList = New List<VoiceWrapper>();
                for(kognoz1__Invoice2__c k : [SELECT id, kognoz1__Invoice_Date__c, kognoz1__Account__c, Downloaded__c, kognoz1__Opportunity__c, (select id, name from Attachments) FROM kognoz1__Invoice2__c where Downloaded__c =true AND kognoz1__Invoice_Date__c >=: startDate AND kognoz1__Invoice_Date__c <=: EndDate ORDER BY kognoz1__Invoice_Date__c  DESC limit: List_size ])
                {
                    InvoiceList.add(new VoiceWrapper(K));
                }  
                */
                InvoiceList.clear();
                Date startDate = InvoiceInfo.kognoz1__Invoice_Date__c;
                Date endDate = InvoiceInfo.kognoz1__Invoice_Due_Date__c;
                if(InvoiceInfo.kognoz1__Invoice_Date__c != null ) {
                //string Query = 'SELECT kognoz1__Invoice_Date__c, kognoz1__Account__c, kognoz1__Opportunity__c,(select id, name from Attachments) FROM kognoz1__Invoice2__c WHERE kognoz1__Invoice_Date__c = '+startDate+' AND kognoz1__Invoice_Date__c= '+EndDate+' ';
                InvoiceList = New List<VoiceWrapper>();
                for(kognoz1__Invoice2__c k : [SELECT Id, kognoz1__Invoice_Date__c, kognoz1__Account__c, Downloaded__c, kognoz1__Opportunity__r.rechnung_per_email__c, kognoz1__Opportunity__c, (select id, name from Attachments) FROM kognoz1__Invoice2__c WHERE Downloaded__c=false AND kognoz1__Invoice_Date__c >=: startDate AND kognoz1__Invoice_Date__c <=: EndDate ORDER BY kognoz1__Invoice_Date__c  DESC  limit: list_size offset: counter ])
                {
                    InvoiceList.add(new VoiceWrapper(K));
                }
                }
                }
    
                Public class VoiceWrapper {
                Public kognoz1__Invoice2__c KI {get;set;}
                Public boolean selected {get;set;}
                Public VoiceWrapper (kognoz1__Invoice2__c K) {
                    KI = k;
                    selected = false;
                    system.debug(KI);
                 }
                }
        
        
    
    
           Public Pagereference Previous() { 
         
           counter = counter-list_size;
           display();
           return null;
          }
    
           Public pagereference Next() {
            
           counter = counter + list_size;
           display();
           system.debug( InvoiceList);
           return null;
          }
    
        
    
     
    
    
       Public boolean getDisablePrevious() { 
            if (counter<=0) {
           return True;
         }
           else return false;
         }
    
       Public Boolean getDisableNext() {
          if (counter > = InvoiceList.size()-list_size) { 
           return true;
           }
           else return false;
        }
    
    
}




my test class


 
Joy Bing 3Joy Bing 3
Microsoft Office is a family of various software that brings together the best tools for the way people work. Microsoft Office has the ability to change the way you work for the better. So don’t wait, complete the process of Office Setup now and make sure you get the best from the various software they have.