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
Ramesh GuduruRamesh Guduru 

OppLineItemControllerExtension1 --test class failed

I am new to salesforce,could you please assist me,i am getting errror while running these below test class.
(error message :-System.LimitException: Too many SOQL queries: 101) 
class name:-
OppLineItemControllerExtension.cls
test class name:-TestOppLineItemControllerExtension.cls
i have attached both class & test class
PFA.
 
/**********************************************************************
Name:  OppLineItemControllerExtension1
======================================================
                  
***********************************************************************/

 public with  sharing class OppLineItemControllerExtension 
  
{
    public OppLineItemControllerExtension(ApexPages.StandardController controller) {

    }

public Integer count = 1;

    public void Add() {
         count = count+1;
        addMore(); 
    }
public void Add3() {
         count = count+3;
        addMore(); 
    }
public void addMore()
    {
//        innerClass objInnerClass = new innerClass(count);
        OcrWrapper objInnerClass = new OcrWrapper(nextIdent++,LOBNames());      
        wrappers.add(objInnerClass);    
     //   system.debug('lstInner---->'+);            
    }
    public PageReference quicksave() {
        return null;
    }
 
  
  public string selLOB{get; set;}
  public Integer oliIdentity{get; set;}
  public string selFamily {get; set;}
  public String selService {get; set;}
  public OpportunityLineItem oli {get; set;}
  public string accountName {get; set;}
  public Opportunity opp{get; set;}
  public static string oppName {get; set;}
  public static string oppCurrencyIsoCode {get; set;}
  public ID product {get; set;}
  Map <String, Map <String, Map <ID, String>>> LOBServicesMap = new Map <String, Map <String, Map <ID, String>>> ();
  String LOBName = '', Family = '';
  List<SelectOption> LOBoptions = new List<SelectOption>(); // new list for holding all of the picklist items      
  public Boolean displayOLIDetails {get; set;} 
  
  public List<OcrWrapper> wrappers{get;set;}
  public static Integer toDelIdent {get; set;}
  public static Integer toClone {get; set;}
  public static Integer addCount {get; set;}
  private Integer nextIdent=1;    
   public Boolean isLOBChanged = false;    
   public String SerFamily {get; set;}
       
  public void changeLOB ()
 {
     selFamily = '-None-';
           for(OcrWrapper ocrWr : Wrappers) {
               if(ocrWr.ident == oliIdentity) {
                       //selFamily = ocrWr.family;
                       //ocrwr.family =  '';
                       
                       ocrwr.serviceLine = '';
                     ocrWr.lob= ocrwr.ocr.Line_of_Business__c;// = selLOB;
                      selLOB = ocrWr.lob;
        //              ocrwr.subServiceSelectOption.clear();
                       ocrwr.subServiceSelectOption.add(new SelectOption('','-None-'));
                      ocrwr.familySelectOption =  ServiceFamilies();
              }
           }
  
  }
  // Method which is used to collect Service picklist values
  public void changeFamily()
  {
     // system.debug('----------ServiceField---------'+oliIdentity);
                selFamily = '-None-';
        for(OcrWrapper ocrWr : Wrappers) {
                if(ocrWr.ident == oliIdentity) {
                        selFamily = ocrWr.family;
                    ocrWr.subServiceSelectOption = ServiceOfferings();
                } 
    } 
  }
  
  // Method which is used to collect Sub-Service picklist values
  public void ChangeSubService() 
  {
        for(OcrWrapper ocrWr : Wrappers) {
                if(ocrWr.ident == oliIdentity) {
                        ocrWr.serviceLine = ocrWr.serviceLine;
                         system.debug('----------ocrWr.serviceLine---------'+ocrWr.serviceLine);
                } 
  }
  } 
  
  public OppLineItemControllerExtension() 
  {
       selLOB = '-None-'; 
       selFamily = '-None-';
       
       if ((ApexPages.currentPage().getParameters().get('opp_id') != null)&&(ApexPages.currentPage().getParameters().get('opp_id').length() > 0))
       {
         System.debug ('*****Opp in URL: '+ ApexPages.currentPage().getParameters().get('opp_id').length());
         this.oli = new OpportunityLineItem();
         oli.OpportunityId = ApexPages.currentPage().getParameters().get('opp_id');
       
           opp = [select Name, Account.name, CurrencyIsoCode,IsClosed ,ServiceEdit__c,Opportunity_Owner_Country__c,OwnerID,Client_Sub_Type__c from Opportunity where id=:oli.OpportunityId];
       accountName = opp.Account.Name;    
       oppName = opp.Name;
       oppCurrencyIsoCode = opp.CurrencyIsoCode;
       
       
    for (pricebookentry pbe : [SELECT product2.recordtype.name,  product2.family, product2.Sub_Service__c, product2Id from pricebookentry where pricebook2.name like 'OPP%' and isActive = TRUE and pricebookentry.CurrencyIsoCode =: oppCurrencyIsoCode order by product2.recordtype.name, product2.family, product2.Sub_Service__c])
    {
      if (LOBName != pbe.product2.recordtype.name)
      {
        LOBName = pbe.product2.recordtype.name;
        System.debug('LOB NAME::::'+LOBName);
        LOBServicesMap.put (LOBName, new Map <String, Map <ID, String>> ());
      }
      
      if (Family != pbe.product2.family)
      {
        Family = pbe.product2.family;
        LOBServicesMap.get (LOBName).put (Family, new Map <ID, String> ());
      }
      
      LOBServicesMap.get (LOBName).get (Family).put (pbe.id, pbe.product2.Sub_Service__c);
        
    }
    displayOLIDetails = true;
   }
   //PU:03/04/2011 - When the Opportunity Id is null the below error message has to be displayed.
      
   else
   {
       displayOLIDetails = false;
       ApexPages.addMessage(new ApexPages.Message (ApexPages.Severity.Error, Label.oppLI_ErrMsgOppRequired));
                
   }
   
   wrappers=new List<OcrWrapper>();
   for (Integer idx=0; idx<1; idx++)
   {
           List<selectOption> opt = LOBNames();
           wrappers.add(new OcrWrapper(nextIdent+1,opt));
   }
 }
  
   public List<SelectOption> LOBNames() 
    {
        List<SelectOption> LOSoptions = new List<SelectOption>(); // new list for holding all of the picklist items
                
       // LOBoptions.clear(); 
        LOBoptions.add(new SelectOption('-None-','-None-')); //add the first option of '-None-' 
        List<String> LOBNamesList = new List<String>();
        for (String LOBName : LOBServicesMap.keySet())
        {
          LOBNamesList.add(LOBName);
        }
        if(LOBNamesList.size() > 0)
            LOBNamesList.sort();
             
        for (String LOBName : LOBNamesList)
        {
          LOBoptions.add (new SelectOption (LOBName, LOBName));
        }   
        return LOBoptions;
    }  
    
        
    public List<SelectOption> ServiceFamilies() 
    {   
        List<SelectOption> LOSoptions = new List<SelectOption>(); // new list for holding all of the picklist items
  
         
     //   LOSoptions.clear ();
        selService = null;
        LOSoptions.add(new SelectOption('','-None-')); //add the first option of '-None-'
        List<String> LOSoptionsList = new List<String>();
         
        if ((selLOB != null) && (selLOB != '-None-') && (selLOB != ''))
        {
          for (String family : LOBServicesMap.get(selLOB).keySet())
          {
            LOSoptionsList.add(family);
          }
        }
        
        if(LOSoptionsList.size() > 0)
            LOSoptionsList.sort();
        
        for (String family : LOSoptionsList)
        {
            LOSoptions.add(new SelectOption (family, family));
        }
        
        return LOSoptions; // returns all unique picklist options for Family 
    }
    
    public List<SelectOption> ServiceOfferings() 
    {   
        List<SelectOption> serviceOptions = new List<SelectOption>();
           //     serviceOptions.clear ();
        
        serviceOptions.add(new SelectOption('','-None-'));
        List<String> serviceOptionsList = new List<String>();
        List<SelectOption> TempserviceOptions = new List<SelectOption>(); 
        
        //Adding Sub Services to a list to sort
        System.debug('selLOB----$$$$'+selLOB);System.debug('selFamily----$$$$'+selFamily);
        if ((selFamily != null) && (selFamily != '-None-') && (selFamily != ''))
        {
            Map <ID, String> serviceMap = LOBServicesMap.get(selLOB).get (selFamily);
            system.debug('serviceMap$$$'+serviceMap);
            if(serviceMap.size() > 0)
            for (ID service : serviceMap.keySet())
            {
                TempserviceOptions.add(new SelectOption(service, serviceMap.get (service)));
                serviceOptionsList.add(serviceMap.get (service));
            }
        }
        //Sort the Sub Services
        if(serviceOptionsList.size() > 0)
            serviceOptionsList.sort();
        
        //Adding the SubServices into a selectOption list after sorting 
        for(String str: serviceOptionsList)
        {
            for(Selectoption selectOpt : TempserviceOptions)
            {
                if(selectOpt.getLabel().equals(str))
                    serviceOptions.add(new SelectOption(selectOpt.getValue(),selectOpt.getLabel()));
            }
        }
                return serviceOptions;
    } 
    
    
    public PageReference save()
    {
          
        List<OpportunityLineItem> finalOliList = new List<OpportunityLineItem>();
        Boolean isError = false;
        for(OcrWrapper oliwr : Wrappers) {
                if(oliwr.lob == null) {
                                ApexPages.addMessage(new ApexPages.Message (ApexPages.Severity.ERROR, 
                                Label.OppProd_ErrMsgSelectionsRequired)); 
                                isError = true;
                   }                    
                   if(oliwr.family == null) {
                                ApexPages.addMessage(new ApexPages.Message (ApexPages.Severity.ERROR, 
                                Label.OppProd_ErrMsgSelectionsRequired));
                                isError = true;
                   }            
                   if(oliwr.serviceline == null) {
                                ApexPages.addMessage(new ApexPages.Message (ApexPages.Severity.ERROR, 
                                Label.OppProd_ErrMsgSelectionsRequired));
                                isError = true;
                   }            
                   if(oliwr.ocr.UnitPrice  >  oliwr.ocr.Total_Client_Spend__c) {
                                oliwr.ocr.UnitPrice.addError('Please enter a value less than Total Client Spend');
                                isError = true;
                   }                    
                   if(oliwr.ocr.Gross_Profit_Percent__c < 0 || oliwr.ocr.Gross_Profit_Percent__c > 100 ) { 
                                oliwr.ocr.Gross_Profit_Percent__c.addError('Please enter a valid percentage (0-100)');
                                isError = true;         
                   }
                   if(oliwr.ocr.New_Business_Percent__c < 0 || oliwr.ocr.New_Business_Percent__c > 100 ) {
                                oliwr.ocr.New_Business_Percent__c.addError('Please enter a valid percentage (0-100)');
                                isError = true;         
                   }
                   
                  // if(oliwr.ocr.Service_Owner__c == null) {
                   //             oliwr.ocr.Service_Owner__c= UserInfo.getUserId();               
                   //}
           
                   if(isError == True)
                                continue;
                                
                   OpportunityLineItem oliInst = new OpportunityLineItem( OpportunityId = opp.Id,
                                                                                                                                  PricebookEntryId = oliwr.serviceLine,
                                                                                                                                  Quantity =1,UnitPrice = oliwr.ocr.UnitPrice,
                                                                                                                                  Total_Client_Spend__c = oliwr.ocr.Total_Client_Spend__c,
                                                                                                                                  Country__c = oliwr.ocr.Country__c,
                                                                                                                                  New_Engagement__c = oliwr.ocr.New_Engagement__c,
                                                                                                                                  Engagement_Details__c = oliwr.ocr.Engagement_Details__c,
                                                                                                                                  Business_unit__c= oliwr.ocr.Business_Unit__c,
                                                                                                                                  Gross_Profit_Percent__c =  oliwr.ocr.Gross_Profit_Percent__c,
                                                                                                                                  Total_Gross_Profit_Dollar__c =  oliwr.ocr.Total_Gross_Profit_Dollar__c,
                                                                                                                                  Service_Offering__c =  oliwr.ocr.Service_Offering__c,
                                                                                                                                 // Service_Owner__c =  oliwr.ocr.Service_Owner__c,
                                                                                                                                  Line_of_Business__c = oliwr.ocr.Line_of_Business__c,
                                                                                                                                  IBM_Line_of_Business__c = oliwr.ocr.IBM_Line_of_Business__c,
                                                                                                                                  New_Business_Percent__c = oliwr.ocr.New_Business_Percent__c,
                                                                                                                                  Occupation_Category__c = oliwr.ocr.Occupation_Category__c,
                                                                                                                                  Client_Direct_Contribution_Margin_CDCM__c = oliwr.ocr.Client_Direct_Contribution_Margin_CDCM__c,
                                                                                                                                  Job_Title__c = oliwr.ocr.Job_Title__c,
                                                                                                                                  Client_Location_Type__c = oliwr.ocr.Client_Location_Type__c,
                                                                                                                                  OnSite__C = oliwr.ocr.OnSite__C,
                                                                                                                                  X30_Day_Associate_Actual__c = oliwr.ocr.X30_Day_Associate_Actual__c,
                                                                                                                                  X30_Day_Associate_Need__c = oliwr.ocr.X30_Day_Associate_Need__c,
                                                                                                                                  X60_Day_Associate_Actual__c =oliwr.ocr.X60_Day_Associate_Actual__c,
                                                                                                                                  X60_Day_Associate_Need__c = oliwr.ocr.X60_Day_Associate_Need__c,
                                                                                                                                  X90_Day_Associate_Actual__c = oliwr.ocr.X90_Day_Associate_Actual__c,
                                                                                                                                  X90_Day_Associate_Need__c = oliwr.ocr.X90_Day_Associate_Need__c,
                                                                                                                                  Perm_Placement_Fee__c = oliwr.ocr.Perm_Placement_Fee__c,
                                                                                                                                  Perm_Placement_Position_Salary__c = oliwr.ocr.Perm_Placement_Position_Salary__c,
                                                                                                                                  New_LOB_Opportunity__c = oliwr.ocr.New_LOB_Opportunity__c,
                                                                                                                                  Potential_of_Associates__c = oliwr.ocr.Potential_of_Associates__c
                                                                                                                                  );
                        finalOliList.add(oliInst);      
                }
        if(finalOliList.size()>0 && isError == false) {
            try
            {
              if(finalOliList.size() > 0)
                insert finalOliList;
            }
            catch (DMLException de)
            {
              ApexPages.addMessage(new ApexPages.Message (ApexPages.Severity.ERROR, 
                                                   'DML Error: '+ de.getMessage ()));
              return null;
            }
           return new ApexPages.Standardcontroller (opp).view ();
        }
        return null; 
        } 
      
    public PageReference cancel()
    {
      return new ApexPages.Standardcontroller (opp).view ();
    }
    
    //Wrapper class which is used to store list of Opportunity Line Items
    public class OcrWrapper
    {
      public OpportunityLineItem ocr {get;set;}
      public Integer ident {get;set;}
      public String lob {get;set;}
      public String family {get;set;}
      public String serviceLine {get;set;}
      
      public List<SelectOption> lOBSelectOption{get;set;}
      public List<SelectOption> familySelectOption{get;set;}
      public List<SelectOption> subServiceSelectOption{get;set;}
      
      
          //Constructor which is used to initialize variables
      public OCrWrapper(Integer inIdent,List<SelectOption> lobOptions)
      {
     System.debug('!!!!!!!!INSIDE ocrWrapper Funtion!!!!!!!');
       ident=inIdent;
       lob='';
       family='';
       serviceLine = '';
       lOBSelectOption = new List<SelectOption>();
       familySelectOption = new List<SelectOption>();
       familySelectOption.add(new SelectOption('','-None-'));
       subServiceSelectOption = new List<SelectOption>();
       subServiceSelectOption.add(new SelectOption('','-None-'));
       ocr=new OpportunityLineItem (
                                                              //  Total_Client_Spend__c = 0,
                                                              // unitPrice = 0,
                                                              // Service_Owner__c = UserInfo.getUserId()
                                                              // Gross_Profit_Percent__c = 0,
                                                              // Total_Gross_Profit_Dollar__c = 0,
                                                              //  New_Business_Percent__c = 0
                                                                );
       lOBSelectOption = lobOptions;
     System.debug('!!!!!!!!NEW ROW OCR!!!!!!!'+ocr);
      }
      
      //Construtor which is used to add initialize rows for cloning 
      public ocrWrapper(Integer inIdent,OcrWrapper cloneRow) {

        ident=inIdent;
        lOBSelectOption = cloneRow.lOBSelectOption;
        familySelectOption = cloneRow.familySelectOption;
        subServiceSelectOption = cloneRow.subServiceSelectOption;
        lob = cloneRow.lob;
        family = cloneRow.family;
        serviceLine = cloneRow.serviceLine;
        ocr=new OpportunityLineItem (        //Total_Client_Spend__c = 0,
                                             //unitPrice = 0,
                                             //Service_Owner__c = cloneRow.ocr.Service_Owner__c,
                                             Business_Unit__c = cloneRow.ocr.Business_Unit__c,
                                             Service_Offering__c =cloneRow.ocr.Service_Offering__c,
                                             Line_of_Business__c = cloneRow.ocr.Line_of_Business__c
                                             
                                             //Gross_Profit_Percent__c = 0,Total_Gross_Profit_Dollar__c = 0,
                                             //New_Business_Percent__c = 0
                                             );     
                                                  
      }  
   } //end of Wrapper class
    
       
    
     //method which is used to add row(s)

     
     public void addRows()
    {
     System.debug('!!!!!!!!INSIDE ADD ROW!!!!!!!');
      for (Integer idx=0; idx<addCount; idx++)
      {
     System.debug('!!!!!!!!INSIDE FOR LOOP!!!!!!!');
       wrappers.add(new OcrWrapper(nextIdent++,LOBNames()));
      }
    } 
  //Method which is used to delete a particular row in the page
  public void delWrapper()
  {
      Integer toDelPos=-1;
      for (Integer idx=0; idx<wrappers.size(); idx++)
      {
        if (wrappers[idx].ident==toDelIdent) {
               //         wrappers[idx].ocr.Total_Client_Spend__c = 0;
              //  wrappers[idx].ocr.UnitPrice = 0;
               // wrappers[idx].ocr.Gross_Profit_Percent__c = 0;
               // wrappers[idx].ocr.Total_Gross_Profit_Dollar__c = 0;
                //wrappers[idx].ocr.New_Business_Percent__c = 0;
                toDelPos=idx;
       }
      }
      if (-1!=toDelPos) {
        wrappers.remove(toDelPos);
      }
  }
  
  //Method which is used to clone the row
  public void cloning() {
        for (Integer idx=0; idx<wrappers.size(); idx++) {
       if (wrappers[idx].ident==toClone) {
            OcrWrapper wr = wrappers[idx];
            wrappers.add(new OcrWrapper(nextIdent++,wr));
       }
    }
                                                        
  }
 public Boolean getSMBProfiles()
    {
   List<Profile> Prof;
      Prof = [Select id from Profile where Name='System Administrator' or  Name = 'Sales Manager - MP NA' or Name = 'Sales Pro - MP NA' or Name = 'L2 SMB Support'];
      
        for(Profile p :Prof)
        {
            if (UserInfo.getProfileId()== p.Id)
                return true;
        }
        
        return false;
        }
        
   public Boolean getEuropeProfiles()
    {
        List<Profile> Prof;
        Prof = [Select id from Profile where Name='System Administrator' or  Name = 'Sales Manager - Europe' or Name = 'Sales Pro - Europe' or Name = 'L2 Support'];
      
        for(Profile p :Prof)
        {
            if (UserInfo.getProfileId()== p.Id)
                return true;
        }
        
        return false;
        }
     
    
} // End of the main class

***********
test class name:- TestOppLineItemControllerExtension.cls
*****************************************

/*Class Name: TestOppLineItemControllerExtension.cls
Original Author: Deepak Padhye
Original Creation Date: 03/03/2010
Original Release: 
Purpose: Test Class for OppLineItemControllerExtension.cls
Ticket#: 
Changes: PU 02/14/2011: Ticket#220959 - Completely refactored the test class to improve the
code coverage and efficiency.
Changes: PU 03/04/2011: Ticket#223609- Added a new test method testOppIdNUll.
*/
@isTest
private class TestOppLineItemControllerExtension {
/* Input: No input variables
    Process: Inserts an opportunity record.
    Output: Returns a single opportunity record
    Changes: None
*/
Static opportunity test1;
Static opportunity opp2;

static Opportunity createTestdata()
 {
    Account acc = new Account (name = 'TestOppLineItemAccount',BillingCity = 'TestOppLineItemCity', BillingCountry ='TestOppLineItemCountry', BillingStreet ='TestOppLineItemStreet',phone='1111', BillingPostalCode ='76768');
    insert acc;
    
    Pricebook2 pr = new Pricebook2();
    pr.name = 'test';
    pr.isactive = true;
    insert pr;
    
     opportunity  opp = new Opportunity(Name='Test Opp',Pricebook2Id=pr.Id,
Opportunity_Type__c='Parent', closeDate=Date.today(), stageName = 'Plan', AccountId = acc.id, competitor_lost_to__c = 'Adecco');
     insert opp;
     system.debug(opp.Id);
     opp.name= 'Plan1';
     update opp;
     /*opportunity  opp3 = new Opportunity(Name='Test Opp',Opportunity_Type__c='Child', closeDate=Date.today(), stageName = 'Plan', AccountId = acc.id, competitor_lost_to__c = 'Adecco');
     insert opp3;*/
     
     opp2 = new Opportunity(Name='Test Opp',Parent_Opportunity__c=opp.Id,Opportunity_Type__c='Child', closeDate=Date.today(), stageName = 'Plan', AccountId = acc.id, competitor_lost_to__c = 'Adecco');
     insert opp2;
     opp2.Name = 'test2';
     update opp2;
       
   test1 =  [Select o.Type, o.Pricebook2Id, o.OwnerId, o.Oppotunity_Designation__c, o.Active_Latent__c, o.Solution_Type__c, o.Opportunity_Short_Description__c, o.Opportunity_ID__c, o.NextStep, o.New_Business_Percent__c, o.Name, o.Local_Client__c, o.Local_Client_Short_Name__c, o.IsWon, o.IsDeleted, o.IsClosed, o.Id, o.HasOpportunityLineItem, o.CreatedById, o.Amount, o.AccountId From Opportunity o WHERE o.Id = :opp.Id];
 return test1;

 
 }
 
 static testMethod void testInsertOLI() {
 
 createTestdata();
 test.startTest();
 ApexPages.StandardController sc = new ApexPages.StandardController (test1);
  
 OppLineItemControllerExtension str1 = new OppLineItemControllerExtension (sc);
 str1.LOBNames();
 ApexPages.currentPage().getParameters().put('opp_id',test1.Id);
 OppLineItemControllerExtension str = new OppLineItemControllerExtension (); 
 str.Add();
 str.Add3();

 str.ServiceFamilies();
 str.changeLOB ();
 str.changeFamily();
 str.ChangeSubService();
 str.quicksave();
 //str.ServiceSubServices();  
 str.ServiceOfferings(); 
 try{
 str.save();
 }catch(exception e){}
 str.addRows();
 str.cancel();
 str.delWrapper();
 str.cloning(); 

 test.stopTest();
 }


      static testMethod void testOppIdNull() 
    {
        
        // Set the current page to OpportunityLineItemEdit VF Page
        PageReference servicesPage = new PageReference('apex/OpportunityLineItemEdit');
        Test.setCurrentPage(servicesPage);
        //Create an object of the OppLineItemControllerExtension class
        OppLineItemControllerExtension oliCE = new OppLineItemControllerExtension ();
        
        //Test the error message
        for(ApexPages.Message m : ApexPages.getMessages())
        {
        if(m.getDetail() == Label.oppLI_ErrMsgOppRequired)
        system.assert(true);
        }
       
    }
     
  
    Process: Set the current page to OpportunityLineItemEdit and created an object of 
             the Controller class.Invoked the cancel method and tested the url of the
             page it navigates to.
    Output: It navigates to the opp detail page.
    Changes: None */
 
   static testMethod void testcancelMethod() 
    {
         //Create test data
        Opportunity opp = new opportunity();
        opp = createTestData();
        Test.startTest();
        // Set the current page to OpportunityLineItemEdit VF Page  
        PageReference servicesPage = new PageReference('apex/OpportunityLineItemEdit?opp_id='+opp.id);
        Test.setCurrentPage(servicesPage);
        
        //Create an object of the OppLineItemControllerExtension class
        OppLineItemControllerExtension oliCE = new OppLineItemControllerExtension ();
        //Invoke the cancel method and verify the url of the page it navigates to
        String nextpage = oliCE.cancel().getUrl();
        PageReference p = new ApexPages.Standardcontroller (opp).view ();
        Test.stopTest(); 
       system.assertequals(p.getUrl(),nextpage);
        
    }
    
    
    /* Input: No input variables
    Process: Set the current page to OpportunityLineItemEdit and created an object of 
             the Controller class.Populate all the fields on the Vf page.Re- populate the
             Line Of business and invoke the changeLOB method. Now the value of the service
             line would be "None" since the LOB has changed and the value of sub-service
             would be "null" since the value of the service line is None.
                         
    Output: The values of the serviceline and sub-service are refreshed
    Changes: None
*/ 
      static testMethod void testChangeLOB() 
    {
        //Create test data
        Opportunity opp = new opportunity();
        opp = createTestData();
        Test.startTest();
        // Set the current page to OpportunityLineItemEdit VF Page  
        PageReference servicesPage = new PageReference('apex/OpportunityLineItemEdit?opp_id='+opp.id);
        Test.setCurrentPage(servicesPage);
        Test.stopTest();

        //Create an object of the OppLineItemControllerExtension class
        OppLineItemControllerExtension oliCE = new OppLineItemControllerExtension ();
        
        //Populate the values of LOB, Service Line and Sub-service
         //oliCE.selLOB = oliCE.getLOBNames()[1].getValue();
         //oliCE.selFamily = oliCE.getServiceFamilies()[1].getValue();
         //oliCE.selService = oliCE.getServiceOfferings()[1].getValue();
        Test.startTest();
        //The values of service Line and sub-service are not null
        system.assertnotEquals(null, oliCE.selFamily);
        system.assertEquals(null, oliCE.selService);
        
        //re-populate the value of LOB and invoke the changeLOB method
      //  oliCE.selLOB = oliCE.getLOBNames()[2].getValue();
        oliCE.changeLOB();
        //Retrieve the values of service line and sub-service
      //  oliCE.getServiceFamilies();
       // oliCE.getServiceOfferings();
        // The service line will be none because the LOB has changed
        system.assertEquals('-None-', oliCE.selFamily);
         // The sub-service  will be null because the service line is NONE
        system.assertEquals(null, oliCE.selService);
      //Test.stopTest();
               
    }
    
     
}

 
pconpcon
This is because you are using your controller in a way that you wouldn't really use it.  Running through all the methods like this is probably what's causing you to reach that limit.  You should split each one of these into their own test method and only have the single class method inside of your start/stop test.