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
cnair1.3929332235576116E12cnair1.3929332235576116E12 

Null pointer exception in test class when deploying a code in production

I am getting a null pointer exception on line 23 column 1  ( highlighed in bold in the below code). I am trying to migrate a visualforce page controller and a test class into production. I am not sure what needs to be fixed. 

@isTest
public class CS_NewQuoteRequestFromRepeater_test{

    static testMethod void quoteRequestCreationTest(){
        Repeater__c testRepeater = new Repeater__c();
        insert testRepeater;
       
        Opportunity opp = new Opportunity();
        opp.Name = 'Test Opportunity';
        opp.StageName = 'Prospect';
        opp.CloseDate = System.today();
        insert opp;
       
        Oracle_Ship_To_Account__c oa = new Oracle_Ship_To_Account__c();
        oa.Customer_Name__c = 'Test Oracle Customer';
//added by ckn to troubleshoot deployment issues
        oa.ADDRESSID_CONTACT_ID__c ='12345';
        insert oa;
       
        ApexPages.Pagereference vfPage = Page.NewQuoteRequestFromRepeater2Step;
        Test.setCurrentPage(vfPage);
        ApexPages.currentPage().getParameters().put('repeaterID', testRepeater.Id);
       
        CS_NewQuoteRequestFromRepeater2StepCC controller = new CS_NewQuoteRequestFromRepeater2StepCC();
        controller.QuoteRequest.Oracle_Ship_To_Account_c__c = oa.Id;

        controller.QuoteRequest.Quote_Name__c = 'Test Quote';
        controller.QuoteRequest.Opportunity__c = opp.Id;
       
        //return url test
        system.assertEquals(controller.getReturnUrl(), '/' + testRepeater.Id);
       
        try{
            ApexPages.Pagereference saveRedirectPage = controller.save();
            system.debug(saveRedirectPage.getUrl());
        }catch(Exception e){
            //system.assert(false);
        }
    }
}
sfdc_ninjasfdc_ninja
Its tough to say without being able to see the class that you are testing.  Just at first glance though, it looks lke your controller property 'QuoteRequest' is null.  You are trying to set an attribute of that object right after you instantiate the class.  Is the QuoteRequest property being instatiated in the consturctor of your CS_NewQuoteRequestFromRepeater2StepCC class?
cnair1.3929332235576116E12cnair1.3929332235576116E12
Thanks so much for your prompt response. I should have attached the code written by our consulting partner. I believe the controller is instantiating the quote request object ( I have highlighted it in bold)

/**
* @description Controller class of NewQuoteRequestFromRepeater2Step
* @author Booz Espiridion
* @company Cloudsherpas
* @date 12-20-2013
*/
public class CS_NewQuoteRequestFromRepeater2StepCC{
    private Id RepeaterId;
    private String[] RepeaterFields;
   
    public Quote_Request__c QuoteRequest {get; set;}
    public String[] tracer {get; set;}

/**
* @description Constructor
* @author Booz Espiridion
* @date 12-20-2013
*/
    public CS_NewQuoteRequestFromRepeater2StepCC(){
        if(ApexPages.currentPage().getParameters().containsKey('repeaterID')){
            RepeaterId = ApexPages.currentPage().getParameters().get('repeaterID');
            try{
                init();
            }catch(Exception e){
                system.debug('\n\nError on CS_NewQuoteRequestFromRepeater2StepCC: ' + e + '\n\n');
            }
        }
    }

/**
* @description Start of the main logic
* @author Booz Espiridion
* @date 12-20-2013
*/   
    private void init(){
        //for debugging
        tracer = new String[]{};
       
        //get current repeater
        Repeater__c usedRepeater = Database.query(getRepeaterQuery());
        //get repeater record type name
        Schema.RecordTypeInfo repeaterType = Schema.SObjectType.Repeater__c.getRecordTypeInfosById().get(usedRepeater.RecordTypeId);
       
        String suffix = getRecordTypeSuffix(repeaterType.getName());
       
        Schema.RecordTypeInfo quoteRecordType = Schema.SObjectType.Quote_Request__c.getRecordTypeInfosByName().get(repeaterType.getName());
       
        Map<String, Schema.SObjectField> quoteFields = Schema.SObjectType.Quote_Request__c.fields.getMap();
       
        QuoteRequest = new Quote_Request__c();
        QuoteRequest.RecordTypeId = quoteRecordType.getRecordTypeId();
        QuoteRequest.Created_From_Repeater__c = true;
        QuoteRequest.Repeater_Type__c = usedRepeater.Id;

       
        for(String field : RepeaterFields){
            String fieldForQuote;
            if(quoteFields.containsKey(suffix + '_' + field)){
                fieldForQuote = suffix + '_' + field;
            }
            if(quoteFields.containsKey(field)){
                fieldForQuote = field;
            }
            if(fieldForQuote != null){
                try{
                    QuoteRequest.put(fieldForQuote, usedRepeater.get(field));
                }catch(Exception e){
                    tracer.addAll(new String[]{'Error on this fields: ' + e.getMessage(),'Repeater Field: ' + field,'Quote Request Field: ' + fieldForQuote,''});
                }
            }
        }
    }