• Santiago Bunce
  • NEWBIE
  • 0 Points
  • Member since 2019

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 3
    Replies
Hello,

I'm working to deploy from sandbox to our production environment.

When I validate the inbound changeset in our production environment, I get the following error:

System.NullPointerException: Attempt to de-reference a null object
Stack Trace: Class.MassUpdateSimpleControllerTest.testOpportunityInRelatedList: line 148, column 1

line 148 reads:         System.assert(controller.getFieldTypeOptions().size()>1);

I've done some research and have seen you can possibly comment-out the line in question, or de-reference the null so that I guess a new object is created and the code works properly (I'm not quite sure I understand this one) I've tried to edit this code to make it work, but still have errors. Can anyone help me, please?!

I have very limited coding and Salesforce experience, so any clarity and insight is appreciated!

Here is the Apex Class Code: 
/**
 * This class contains unit tests for validating the behavior of MassUpdateController
 * and triggers.
 */
@isTest
private class MassUpdateSimpleControllerTest {


    static testMethod void singleUpdateTest() {
        Opportunity o = new Opportunity();
        List<Opportunity> oppList = [SELECT name FROM Opportunity LIMIT 20];
        
        ApexPages.StandardSetController setCtr = new ApexPages.StandardSetController(oppList);
        setCtr.setSelected(new Opportunity[]{o});
        MassUpdateSimpleController controller = new MassUpdateSimpleController(setCtr);
        System.assertEquals(1, controller.getRecordSize());
        
        System.assert(controller.getFieldTypeOptions().size()>1);
        
        system.assertEquals(1, controller.objsToUpdate.size());
        
        String value = '123test';
        controller.fieldName='name';
        controller.valueToUpdate=value; 
        //controller.convertedFieldData = controller.convertUserInputToFieldData(); 
        controller.step4();
        controller.step5();
        
        System.assert(o.name==value);
        
        value ='123';
        controller.step3();
        controller.fieldName='amount';
        controller.valueToUpdate=value; 
        controller.step4();
        controller.step5();
        
        System.assert(o.amount==decimal.valueOf(value));
        
/*      value ='true';
        controller.fieldName='IsPrivate';
        controller.step3();
        controller.valueToUpdate=value;     
        controller.step4();
        controller.step5();
        
        System.assert(o.IsPrivate); */
        // make sure no exception from display tips
        System.assertEquals(controller.getFieldInfoToDisplay()!=null,true);
                
        value ='2009-4-7';
        controller.fieldName='CloseDate';
        controller.valueToUpdate=value;     
        controller.step4();
        controller.step5();
        System.assert(o.CloseDate==Date.valueOf(value));
        
        value ='Closed';
        controller.fieldName='StageName';
        controller.valueToUpdate=value;     
        controller.step4();
        controller.step5();
        System.assert(o.StageName=='Closed');
    }
    
 /*   static testMethod void massUpdateAsStandardUserTest() {
        
        Profile p = [select id from profile where name='Standard User'];
        User u = new User(alias = 'standt', email='standarduser@testorg.com',
          emailencodingkey='UTF-8', lastname='Testing', languagelocalekey='en_US',
          localesidkey='en_US', profileid = p.Id,
          timezonesidkey='America/Los_Angeles', username='standarduser@test.com');
        
        System.runAs(u) {
          Opportunity o = new Opportunity();
          List<Opportunity> oppList = [SELECT name FROM Opportunity LIMIT 20];
        
          ApexPages.StandardSetController setCtr = new ApexPages.StandardSetController(oppList);
          setCtr.setSelected(new Opportunity[]{o});
          MassUpdateSimpleController controller = new MassUpdateSimpleController(setCtr);
          System.assertEquals(1, controller.getRecordSize());
        
          System.assert(controller.getFieldTypeOptions().size()>1);
        
          system.assertEquals(1, controller.objsToUpdate.size());
        
          String value = '123test';
          controller.fieldName='name';
          controller.valueToUpdate=value;       
          controller.save();
        
          System.assert(o.name==value);
         
        }
    }  */
    
    static testMethod void linkTest() {
        Opportunity o = new Opportunity();
        List<Opportunity> oppList = [SELECT name FROM Opportunity LIMIT 20];
        
        ApexPages.StandardSetController setCtr = new ApexPages.StandardSetController(oppList);
        setCtr.setSelected(new Opportunity[]{o});
        MassUpdateSimpleController controller = new MassUpdateSimpleController(setCtr);
        
        // verify following exceptions will not cause exception
        System.assert(controller.step1()!=null);
        System.assert(controller.step2()!=null);
        controller.getFieldTypeOptions();
        System.assert(controller.step3()!=null);
        System.assert(controller.step4()!=null);
        System.assert(controller.step5()!=null);
        //System.assert(controller.cancel()!=null);
        
        System.assert(controller.getFieldTypeOptions()!=null);
    }
    
    static testMethod void fieldTest() {
        
        List<Opportunity> oppList = new Opportunity[]{};
        
        ApexPages.StandardSetController setCtr = new ApexPages.StandardSetController(oppList);
        MassUpdateSimpleController controller = new MassUpdateSimpleController(setCtr);
        System.assert(controller.cancel()!=null);
        System.assert(controller.getFieldTypeOptions()==null);
    }
    
    static testMethod void miscTest() {
        
        List<Opportunity> oppList = new Opportunity[]{};
        
        ApexPages.StandardSetController setCtr = new ApexPages.StandardSetController(oppList);
        MassUpdateSimpleController controller = new MassUpdateSimpleController(setCtr);
        
        System.assert(controller.getNow(true)!=null);
        System.assert(controller.getNow(false)!=null);
        System.assert(controller.getRecordSize()==0);
        System.assert(controller.getPicklistValues()==null);
    }
    
    @isTest(SeeAllData=true)
    static void testOpportunityInRelatedList(){
        List<Opportunity> oppList = [SELECT name, AccountId FROM Opportunity LIMIT 20];
        ApexPages.StandardSetController setCtr = new ApexPages.StandardSetController(oppList);
        apexpages.currentpage().getparameters().put('id' , oppList.get(0).AccountId);
        MassUpdateSimpleController controller = new MassUpdateSimpleController(setCtr);
        System.debug('list: ' + oppList);
        
        System.assert(controller.getFieldTypeOptions().size()>1);
        
        //system.assertEquals(1, controller.objsToUpdate.size());
        
        String value = '123test';
        controller.fieldName='name';
        controller.valueToUpdate=value; 
        //controller.convertedFieldData = controller.convertUserInputToFieldData(); 
        controller.lexstep4();
        controller.lexstep5();
        List<Opportunity> selectList = (List<Opportunity>)setCtr.getSelected();
        System.assert(selectList.get(0).name==value);
        System.assert(controller.displayTexField=='true');
        System.assert(controller.displayCheckBox=='false');
        System.assert(controller.displayPicklist=='false');
        System.assert(controller.displayTextArea=='false');
        
         value ='Closed';
        controller.lexstep3();
        controller.fieldName='StageName';
        controller.valueToUpdate=value;     
        controller.lexstep4();
        controller.lexstep5();
        System.assert(selectList.get(0).StageName=='Closed');
        System.assert(controller.displayTexField=='false');
        System.assert(controller.displayCheckBox=='false');
        System.assert(controller.displayPicklist=='true');
        System.assert(controller.displayTextArea=='false');
        
        
    }
}
Hello,

I'm working to deploy from sandbox to our production environment.

When I validate the inbound changeset in our production environment, I get the following error:

System.NullPointerException: Attempt to de-reference a null object
Stack Trace: Class.MassUpdateSimpleControllerTest.testOpportunityInRelatedList: line 148, column 1

line 148 reads:         System.assert(controller.getFieldTypeOptions().size()>1);

I've done some research and have seen you can possibly comment-out the line in question, or de-reference the null so that I guess a new object is created and the code works properly (I'm not quite sure I understand this one) I've tried to edit this code to make it work, but still have errors. Can anyone help me, please?!

I have very limited coding and Salesforce experience, so any clarity and insight is appreciated!

Here is the Apex Class Code: 
/**
 * This class contains unit tests for validating the behavior of MassUpdateController
 * and triggers.
 */
@isTest
private class MassUpdateSimpleControllerTest {


    static testMethod void singleUpdateTest() {
        Opportunity o = new Opportunity();
        List<Opportunity> oppList = [SELECT name FROM Opportunity LIMIT 20];
        
        ApexPages.StandardSetController setCtr = new ApexPages.StandardSetController(oppList);
        setCtr.setSelected(new Opportunity[]{o});
        MassUpdateSimpleController controller = new MassUpdateSimpleController(setCtr);
        System.assertEquals(1, controller.getRecordSize());
        
        System.assert(controller.getFieldTypeOptions().size()>1);
        
        system.assertEquals(1, controller.objsToUpdate.size());
        
        String value = '123test';
        controller.fieldName='name';
        controller.valueToUpdate=value; 
        //controller.convertedFieldData = controller.convertUserInputToFieldData(); 
        controller.step4();
        controller.step5();
        
        System.assert(o.name==value);
        
        value ='123';
        controller.step3();
        controller.fieldName='amount';
        controller.valueToUpdate=value; 
        controller.step4();
        controller.step5();
        
        System.assert(o.amount==decimal.valueOf(value));
        
/*      value ='true';
        controller.fieldName='IsPrivate';
        controller.step3();
        controller.valueToUpdate=value;     
        controller.step4();
        controller.step5();
        
        System.assert(o.IsPrivate); */
        // make sure no exception from display tips
        System.assertEquals(controller.getFieldInfoToDisplay()!=null,true);
                
        value ='2009-4-7';
        controller.fieldName='CloseDate';
        controller.valueToUpdate=value;     
        controller.step4();
        controller.step5();
        System.assert(o.CloseDate==Date.valueOf(value));
        
        value ='Closed';
        controller.fieldName='StageName';
        controller.valueToUpdate=value;     
        controller.step4();
        controller.step5();
        System.assert(o.StageName=='Closed');
    }
    
 /*   static testMethod void massUpdateAsStandardUserTest() {
        
        Profile p = [select id from profile where name='Standard User'];
        User u = new User(alias = 'standt', email='standarduser@testorg.com',
          emailencodingkey='UTF-8', lastname='Testing', languagelocalekey='en_US',
          localesidkey='en_US', profileid = p.Id,
          timezonesidkey='America/Los_Angeles', username='standarduser@test.com');
        
        System.runAs(u) {
          Opportunity o = new Opportunity();
          List<Opportunity> oppList = [SELECT name FROM Opportunity LIMIT 20];
        
          ApexPages.StandardSetController setCtr = new ApexPages.StandardSetController(oppList);
          setCtr.setSelected(new Opportunity[]{o});
          MassUpdateSimpleController controller = new MassUpdateSimpleController(setCtr);
          System.assertEquals(1, controller.getRecordSize());
        
          System.assert(controller.getFieldTypeOptions().size()>1);
        
          system.assertEquals(1, controller.objsToUpdate.size());
        
          String value = '123test';
          controller.fieldName='name';
          controller.valueToUpdate=value;       
          controller.save();
        
          System.assert(o.name==value);
         
        }
    }  */
    
    static testMethod void linkTest() {
        Opportunity o = new Opportunity();
        List<Opportunity> oppList = [SELECT name FROM Opportunity LIMIT 20];
        
        ApexPages.StandardSetController setCtr = new ApexPages.StandardSetController(oppList);
        setCtr.setSelected(new Opportunity[]{o});
        MassUpdateSimpleController controller = new MassUpdateSimpleController(setCtr);
        
        // verify following exceptions will not cause exception
        System.assert(controller.step1()!=null);
        System.assert(controller.step2()!=null);
        controller.getFieldTypeOptions();
        System.assert(controller.step3()!=null);
        System.assert(controller.step4()!=null);
        System.assert(controller.step5()!=null);
        //System.assert(controller.cancel()!=null);
        
        System.assert(controller.getFieldTypeOptions()!=null);
    }
    
    static testMethod void fieldTest() {
        
        List<Opportunity> oppList = new Opportunity[]{};
        
        ApexPages.StandardSetController setCtr = new ApexPages.StandardSetController(oppList);
        MassUpdateSimpleController controller = new MassUpdateSimpleController(setCtr);
        System.assert(controller.cancel()!=null);
        System.assert(controller.getFieldTypeOptions()==null);
    }
    
    static testMethod void miscTest() {
        
        List<Opportunity> oppList = new Opportunity[]{};
        
        ApexPages.StandardSetController setCtr = new ApexPages.StandardSetController(oppList);
        MassUpdateSimpleController controller = new MassUpdateSimpleController(setCtr);
        
        System.assert(controller.getNow(true)!=null);
        System.assert(controller.getNow(false)!=null);
        System.assert(controller.getRecordSize()==0);
        System.assert(controller.getPicklistValues()==null);
    }
    
    @isTest(SeeAllData=true)
    static void testOpportunityInRelatedList(){
        List<Opportunity> oppList = [SELECT name, AccountId FROM Opportunity LIMIT 20];
        ApexPages.StandardSetController setCtr = new ApexPages.StandardSetController(oppList);
        apexpages.currentpage().getparameters().put('id' , oppList.get(0).AccountId);
        MassUpdateSimpleController controller = new MassUpdateSimpleController(setCtr);
        System.debug('list: ' + oppList);
        
        System.assert(controller.getFieldTypeOptions().size()>1);
        
        //system.assertEquals(1, controller.objsToUpdate.size());
        
        String value = '123test';
        controller.fieldName='name';
        controller.valueToUpdate=value; 
        //controller.convertedFieldData = controller.convertUserInputToFieldData(); 
        controller.lexstep4();
        controller.lexstep5();
        List<Opportunity> selectList = (List<Opportunity>)setCtr.getSelected();
        System.assert(selectList.get(0).name==value);
        System.assert(controller.displayTexField=='true');
        System.assert(controller.displayCheckBox=='false');
        System.assert(controller.displayPicklist=='false');
        System.assert(controller.displayTextArea=='false');
        
         value ='Closed';
        controller.lexstep3();
        controller.fieldName='StageName';
        controller.valueToUpdate=value;     
        controller.lexstep4();
        controller.lexstep5();
        System.assert(selectList.get(0).StageName=='Closed');
        System.assert(controller.displayTexField=='false');
        System.assert(controller.displayCheckBox=='false');
        System.assert(controller.displayPicklist=='true');
        System.assert(controller.displayTextArea=='false');
        
        
    }
}
I have a custom tab for a custom object that is used regularly in our org. We are making the switch to Lightning, but I cannot get this one tab to show up in Lightning. It is available in classic and I can access it from the waffle icon in Lightning. Below are some screen caps of me adding it to our Lightning navigation menu. I've set everything else up the same way and it is working fine. Any thoughts on what I could be missing?

Editing Lightning navigation menu