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
EnozzirEnozzir 

Multiple soql statements pull similar data, but i'm trying to figure out a test class for the old info.

public Risk_AnalysisExtController(ApexPages.StandardController stdController) {
        string trustedTicket ='';
        //dashboard url with trusted ticket
        server = 'https://test.tableaureporting.test.com';
        if (Functions.isProduction()) server = 'https://tableaureporting.test.com';
        
        //currently loggedin user 
        User u = [select name, Alias, CommunityNickname, FederationIdentifier, Domain_Credential__c, SAP_Partner_Number__c from user where Id = :UserInfo.getUserId() limit 1]; //added Domain_Credential__c
        string userid = ''; 
        if(vUser(u.id).equals('Correct'))
            userid =u.Domain_Credential__c.toLowerCase();
        
        if(u.SAP_Partner_Number__c!=null)uId = String.valueof('000'+u.SAP_Partner_Number__c); 
      system.debug('uId'+uId); 
        
      //  system.debug('userid = ' +userid);
      //  system.debug('server = '+ server);
        //retrieve trusted ticket
        trustedTicket = getTicket(userid, 'Sales_Ops', server);
        rootURL = server+ '/trusted/'+trustedTicket;
        system.debug('rootURL = '+rootURL);
        system.debug('trustedTicket = '+ trustedTicket);
        
        //buffer
        serListHistory = [Select Id, Customer__c, Comments__c, Serial_Number__c, Theme__c, End_of_Life_Date__c, Action__c, 
                          Removal_Reason__c, Customer_Name__c, Brand_Name__c, Theme_Name__c, Cabinet__c
                          from Risk_Analysis__c where  Serial_Number__c=: paramSer];   
        serListAllExist = [Select Id, Customer__c, Comments__c, Serial_Number__c, Theme__c, End_of_Life_Date__c, Action__c, 
                           Removal_Reason__c, Customer_Name__c, Brand_Name__c, Theme_Name__c, Cabinet__c
                           from Risk_Analysis__c where  Serial_Number__c=: paramSer];  
        serListAllNew = [Select Id, Customer__c, Comments__c, Serial_Number__c, Theme__c, End_of_Life_Date__c, Action__c, 
                         Removal_Reason__c, Customer_Name__c, Brand_Name__c, Theme_Name__c, Cabinet__c
                         from Risk_Analysis__c where  Serial_Number__c=: paramSer]; 
        
        listRiskAnalysis = [Select Id, Customer__c, Comments__c, Serial_Number__c, Theme__c, End_of_Life_Date__c, Action__c, 
                            Removal_Reason__c, Customer_Name__c, Brand_Name__c, Theme_Name__c, Cabinet__c
                            from Risk_Analysis__c]; 
        
    public void ShowSer() {
       // system.debug('paramSer = '+paramSer);
      //  system.debug('paramCust = '+paramCust);
      //  system.debug('paramThem ='+paramThem);
      //  system.debug('inputComment = '+inputComment);
      //  system.debug('paramBrandT = '+paramBrandT);
        
        if((paramSer!=null && paramCust != null && paramThem != null) && (paramSer!='' && paramCust != '' && paramThem != '') )  {
            
            //Risk_Analysis__c serList; 
            serList = [Select Id, Customer__c, Comments__c, Serial_Number__c, Theme__c, End_of_Life_Date__c, Action__c, Removal_Reason__c, 
                       Customer_Name__c, Brand_Name__c, Theme_Name__c, Cabinet__c
                       from Risk_Analysis__c where Serial_Number__c =: paramSer and Theme__c =:paramThem ]; 
            
            if(serList.isEmpty()) {                      
                String CustNum; 
                CustNum = paramCust.right(7);
                Risk_Analysis__c riskTemp = new Risk_Analysis__c(
                    Serial_Number__c = paramSer,
                    Customer__c = CustNum,
                    Theme__c = paramThem, 
                    Comments__c = inputComment,
                    End_of_Life_Date__c = inputDate, 
                    Action__c = actionOpt, 
                    Removal_Reason__c = removalReason, 
                    Customer_Name__c = paramCustText, 
                    Brand_Name__c = paramBrandT, 
                    Theme_Name__c = paramThemText,
                    Cabinet__c = paramMat
                );
                MapCheckSer.put(paramSer, riskTemp); 
                serListAllNew = MapCheckSer.values();
                MapCommentsExist.put(paramSer, inputComment);
                 
            }
            
            
            
            if(!serList.isEmpty()) {
                
                Risk_Analysis__c serListTemp;
                
                serListTemp = [Select Id, Customer__c, Comments__c, Serial_Number__c, Theme__c, End_of_Life_Date__c, Action__c, Removal_Reason__c, 
                               Customer_Name__c, Brand_Name__c, Theme_Name__c, Cabinet__c
                               from Risk_Analysis__c where Serial_Number__c =: paramSer and Theme__c =:paramThem ]; 
                
                MapCheckExist.put(serListTemp.Serial_Number__c, serListTemp);
                
                
                serListHistory = MapCheckExist.values(); 
                
                MapCommentsExist.put(paramSer, serListTemp.Comments__c); 
            }
           // system.debug('MapCommentsExist value = '+MapCommentsExist);
        } 
    }
    
    
    public void saveAll() {
       
        
        boolean hasComments = true; 
        
        if(serListAllNew!=null) {
            for(integer j= 0; j<serListAllNew.size(); j++)  {
                if(serListAllNew.get(j).Comments__c == null || serListAllNew.get(j).Comments__c == '' || serListAllNew.get(j).Comments__c == ' ') 
                    hasComments = false;    
            }
            if(hasComments == true) {
                
                insert serListAllNew;     
                serListAllNew.clear(); 
                MapCheckSer.clear(); 
            }
            else
                ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error, 'Please enter a comment, or remove this record from the list to process further.') );  
        }
        
        
        if(serListHistory!=null) {
            for(integer j= 0; j<serListHistory.size(); j++)  {
                if(serListHistory.get(j).Comments__c == null || serListHistory.get(j).Comments__c == '') 
                    ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error, 'Please enter a comment, or remove this record from the list to process further.') ); 
                else {
                    upsert serListHistory; 
                    serListHistory.clear(); 
                    MapCheckExist.clear(); 
                }
                
            }
            
        }
    }
    

    }

So theres some of the prelimary, now i have coverage on everything there minus a apexpages.addmessage, but thats just one line so i don't mind right now. my main issue is this
 
//Test, please don't delete
    /*public void myTest() {
outputComment = inputComment; 
}*/
    
    public PageReference removeRecord() { 
        outputSer = inputSer; 
        Risk_Analysis__c removedItem; 
        if(MapCheckSer.containsKey(inputSer)) {
            removedItem = MapCheckSer.remove(inputSer); 
            serListAllNew.clear();
            serListAllNew = MapCheckSer.values(); 
            PageReference page = new PageReference(ApexPages.currentPage().getURL()); 
            page.setRedirect(true); 
            return null; 
        }
        else if(MapCheckExist.containsKey(inputSer)) {
            removedItem = MapCheckExist.remove(inputSer); 
            serListHistory.clear();
            serListHistory = MapCheckExist.values(); 
            PageReference page = new PageReference(ApexPages.currentPage().getURL()); 
            page.setRedirect(true); 
            return null;
            
        }
        return null;

The else if statement, i can't get that to get coverage. Now i was handed this code and told "hey intern finish test coverage, get it to 90%" i'm at 87%.... :( 

now if i don't have data for either the if line will be covers and the else if line will be covered but obviously it wont cover 
 
else if(MapCheckExist.containsKey(inputSer)) {
            removedItem = MapCheckExist.remove(inputSer); 
            serListHistory.clear();
            serListHistory = MapCheckExist.values(); 
            PageReference page = new PageReference(ApexPages.currentPage().getURL()); 
            page.setRedirect(true); 
            return null;

I'm stuck..