• jayaramu Talapala
  • NEWBIE
  • 10 Points
  • Member since 2016

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 1
    Replies
I am new to salesforce, Could you please help me to write test class for below code

 for(Release__c rel : releaseLst){
                for(Material__c mat : rel.Materials__r){
                    if(mat.Material_Status__c == 'Draft' && Date.TODAY() < rel.Internal_Announce_Date__c && mat.Format_Description__c != null){ 
                        if(mat.Format_Description__c != 'EST (ELECTRONIC SELL THRU)' && mat.Format_Description__c != 'DVD RENTAL' && mat.Format_Description__c != 'BD RENTAL' && mat.Format_Description__c != 'VOD' && mat.Format_Description__c != 'HD VOD'){
                            if(rel.Street_Date__c != null){
                                mat.Street_Date__c = rel.Street_Date__c;
                            }
                            if(rel.First_Theatrical_Date__c != null){
                                mat.Theatrical_Release_Date__c = rel.First_Theatrical_Date__c;
                            }
                            if(rel.Internal_Announce_Date__c != null){
                                mat.Internal_Announce_Date__c = rel.Internal_Announce_Date__c;
                            }
                            if(rel.Trade_Solicitation_Date__c != null){
                                mat.Trade_Solicitation_Date__c = rel.Trade_Solicitation_Date__c;
                            }
                            if(rel.In_Plant_Date__c != null){
                                mat.In_Plant_Date__c = rel.In_Plant_Date__c;
                            }
                            if(rel.Pre_Order_Close_Date__c != null){
                                mat.Pre_Order_Close_Date__c = rel.Pre_Order_Close_Date__c;
                            }
Challenge Not yet complete... here's what's wrong: 
There was an unexpected error in your org which is preventing this assessment check from completing: System.NullPointerException: Attempt to de-reference a null object

my code is :

public class AccountHandler {

    public static Account insertNewAccount (String accName){
        
        
    if(accName!=''){    
        try{
            Account a = new Account(Name=accName);
            insert a;
            System.debug(' Account created');
            return a;
        } catch(Exception e){
            System.Debug('Account not created');
            return null;
        }
    } else {
        return null;
    }
     
        
    }    
}
Challenge Not yet complete... here's what's wrong: 
There was an unexpected error in your org which is preventing this assessment check from completing: System.NullPointerException: Attempt to de-reference a null object

my code is :

public class AccountHandler {

    public static Account insertNewAccount (String accName){
        
        
    if(accName!=''){    
        try{
            Account a = new Account(Name=accName);
            insert a;
            System.debug(' Account created');
            return a;
        } catch(Exception e){
            System.Debug('Account not created');
            return null;
        }
    } else {
        return null;
    }
     
        
    }    
}