• Atul Singh 87
  • NEWBIE
  • 0 Points
  • Member since 2018

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 2
    Replies
Hi All how do i write test class for this? I am getting error : "System.NullPointerException: Attempt to de-reference a null object" 
Code: 

public Boolean isExistingOktaUser(String UserEmail){
        Boolean isExistingUser=false;
        Boolean goAhead = true;
        userLoginAddress = '';
        if(ACN_Utilities.CheckNullOrEmpty(UserEmail)){
            goAhead = false;
        }
     
    @AuraEnabled
    public static String getCanonicalLink(String articleId) {
        String urlName = null ; 
        try{
            if(String.isNotBlank(articleId)) {
                List<Knowledge__kav> lstCurrentArticle = [SELECT id , Custom_Canonical_URL__c ,UrlName , Page_Index__c,
                                                          Custom_Canonical_URL__r.UrlName
                                                          FROM Knowledge__kav WHERE Id =: articleId
                                                          LIMIT 1];
                String domainURL = Site.getBaseCustomUrl()+Site.getPathPrefix()+ARTICLE_PATH; 
                System.debug('Value of page index '+lstCurrentArticle[0].Page_Index__c);
                //if record found and record says its page is index (TRUE denotes NO INDEX here)
                if(!lstCurrentArticle.isEmpty() && ! lstCurrentArticle[0].Page_Index__c) {
                    
                    if(String.isNotBlank(lstCurrentArticle[0].Custom_Canonical_URL__c)) {
                        List<Knowledge__kav> lstParentArticle = [SELECT id , UrlName
                                                                 FROM Knowledge__kav WHERE Id =: lstCurrentArticle[0].Custom_Canonical_URL__c
                                                                 LIMIT 1];
                        if(!lstParentArticle.isEmpty()){
                            System.debug('Parent Url Name == '+lstCurrentArticle[0].Custom_Canonical_URL__r.UrlName);
                            urlName = domainURL+lstParentArticle[0].UrlName ;     
                        }
                        
                    }
                    else {
                        urlName = domainURL+lstCurrentArticle[0].UrlName ; 
                    }
                }
            }
        }
        catch(Exception objExp) {
            ApplicationLogger.addLog('requestName', objExp); 
        }
        
        return urlName ; 
    }
Hi All how do i write test class for this? I am getting error : "System.NullPointerException: Attempt to de-reference a null object" 
Code: 

public Boolean isExistingOktaUser(String UserEmail){
        Boolean isExistingUser=false;
        Boolean goAhead = true;
        userLoginAddress = '';
        if(ACN_Utilities.CheckNullOrEmpty(UserEmail)){
            goAhead = false;
        }
     
User-added image

i want display lightning:helpText along with lable of lighting:input field.
<aura:component>
    <lightning:helptext content="Your Name will be your login name" />
	<lightning:input label="Name" name="myname" required="true"/>
</aura:component>



Thanks in advance