+ Start a Discussion
Pavel BandarenkaPavel Bandarenka 
Controller:public class AppointmentsViewController {


    public List<Doctor__c> doctorList {get;set;}
    public List<SelectOption> doctorSelectOptionList{get;set;}
    public List<Appointment__c> apointmentList{get;set;}
    public String doctorId {get;set;}
    public List<Patient__c> patientList{get;set;}
    public List<SelectOption> patientSelectOptionList{get;set;}
    public Integer noOfRecords{get; set;}
    public Integer size{get;set;}
    
    public AppointmentsViewController() {
       doctorList = [
           SELECT Id, Name, Working_Hours_Start__c, Working_Hours_End__c
           FROM Doctor__c
           ORDER BY Name ASC
       ];
        
        patientList = [
            SELECT Id, Name
            FROM Patient__c
        ];
        
        patientSelectOptionList = new List<SelectOption>();
        
        for(Patient__c item :patientList)
        {
            patientSelectOptionList.add(new SelectOption(item.Id, item.Name));
        }
        doctorId = doctorList.isEmpty() == FALSE ? doctorList[0].Id : NULL;
        
       doctorSelectOptionList = new List<SelectOption>();
        
        for(Doctor__c item :doctorList) {
            doctorSelectOptionList.add(new SelectOption(item.Id, item.Name));
        }
        getAppointments();
       
        
    }
    
    public void getAppointments () {
        apointmentList = [
            SELECT Id, Name, Doctor__c, Patient__c, Appointment_Date__c, Duration_in_minutes__c
            FROM Appointment__c
            WHERE Doctor__r.Id = :doctorId
        ];
    }



    public List<Appointment__c> Appointment { get{

        return (List<Appointment__c>)setCon.getRecords();

    } set; }



    public ApexPages.StandardSetController setCon {

        get{

            if(setCon == null){

                size = 20;

                List<Appointment__c> Appointment = [
                    SELECT Id, Name, Doctor__c, Patient__c, Appointment_Date__c, Duration_in_minutes__c
                    FROM Appointment__c];

                setCon = new ApexPages.StandardSetController(Appointment);

                setCon.setPageSize(size);

                noOfRecords = setCon.getResultSize();

            }

            return setCon;

        }set;

    }






}




Test:
@isTest
private class AppointmentsViewControllerTest {
    
    @isTest static void AppointmentsViewControllerTest1() {
        
        Doctor__c doctor = new Doctor__c(
        );
        
        insert doctor;
        
        AppointmentsViewController controller = new AppointmentsViewController();
        
        Appointment__c Appointment = new Appointment__c(
        );
        insert Appointment;
        
            ApexPages.standardSetController sc = new ApexPages.standardSetController(doctor

        
        
     // ApexPages.StandardSetController standardSetController = new ApexPages.StandardSetController(doctor);
        
    }
    
       
    

}
Best Answer chosen by Pavel Bandarenka
Maharajan CMaharajan C
Hi Pavel,

Sorry for the late reply.

Please use the belpw updated code:

t.setCon.getRecords(); ==> needs to be added
 
@isTest
public class AppointmentsViewControllerTest {
    @isTest static void AppointmentsViewControllerTest1() {
        Doctor__c doc = new Doctor__c(Name = 'pavel');
        insert doc;
        Patient__c pat = new Patient__c(Name = 'Test');
        insert pat;
        Appointment__c app = new Appointment__c(Doctor__c = doc.Id, Patient__c = pat.Id);
        insert app;
        
        ApexPages.StandardSetController stdSetController = new ApexPages.StandardSetController(Database.getQueryLocator([SELECT Id, OwnerId FROM Appointment__c LIMIT 5]));
        stdSetController.setSelected([SELECT Id, OwnerId FROM Appointment__c LIMIT 5]);
        
        Test.startTest();
        AppointmentsViewController t = new AppointmentsViewController();
        t.setCon.getRecords();
        Test.stopTest();
     }
}

Thanks,
Maharajan.C
Alex OlingerAlex Olinger 
Using the following call and JSON data I have been trying to Create a new opportunity attached to an account. Headers/Call are correct as I've been able to create Leads/Accounts. Something with the JSON is wrong but i'm not sure what it is. 

/services/data/v53.0/sobjects/Opportunity

data={
'Name': "Test opportunity",
'Accountid': "XXXXXXXXXXXXX",
'closedate': "1/12/2021",
'stagename':"Needs Analysis",
'Probability': "10"
}
Best Answer chosen by Alex Olinger
Abdul KhatriAbdul Khatri
Use the following, made the following changes
  • Changes single quote to double quote
  • Change the date format
  • Give the real AccountId.
 
data = {
"Name": "Test opportunity",
"Accountid": "XXXXXXXXXXXXX",
"closedate": "2021-13-12",
"stagename":"Needs Analysis",
"Probability": "10"
}

 
virendar singh 1virendar singh 1 
Hi, 

I am new to salesforce development.
How to write helper class for below apex trigger.
the handler class should have same logic. 

trigger DefaultEntitlement on Case (Before Insert, Before Update) { Set<Id> contactIds = new Set<Id>();
Set<Id> acctIds = new Set<Id>();
for (Case c : Trigger.new) {
  contactIds.add(c.ContactId);
  acctIds.add(c.AccountId);
}
List <EntitlementContact> entlContacts =
[Select e.EntitlementId,e.ContactId,e.Entitlement.AssetId
From EntitlementContact e
Where e.ContactId in :contactIds
And e.Entitlement.EndDate >= Today
And e.Entitlement.StartDate <= Today];
if(entlContacts.isEmpty()==false){
for(Case c : Trigger.new){
if(c.EntitlementId == null && c.ContactId != null){
for(EntitlementContact ec:entlContacts){
if(ec.ContactId==c.ContactId){
c.EntitlementId = ec.EntitlementId;
if(c.AssetId==null && ec.Entitlement.AssetId!=null) c.AssetId=ec.Entitlement.AssetId;
break;
        }
   }
 }
}
} else{
List <Entitlement> entls = [Select e.StartDate, e.Id, e.EndDate,
e.AccountId, e.AssetId
From Entitlement e
Where e.AccountId in :acctIds And e.EndDate >= Today
And e.StartDate <= Today];
if(entls.isEmpty()==false){
for(Case c : Trigger.new){
if(c.EntitlementId == null && c.AccountId != null){
for(Entitlement e:entls){
if(e.AccountId==c.AccountId){
c.EntitlementId = e.Id;
if(c.AssetId==null && e.AssetId!=null)
c.AssetId=e.AssetId; break;
         }
     }
   }
}
}
}
}
Best Answer chosen by virendar singh 1
Suraj Tripathi 47Suraj Tripathi 47

Hi Virendar

TRIGGER 

  trigger DefaultEntitlement on Case (Before Insert, Before Update)

    Switch on Trigger.operationType {

        when BEFORE_INSERT {

            DefaultEntitlementHelper.HelperMethod(TRIGGER.NEW);

        }

        WHEN BEFORE_UPDATE {

            DefaultEntitlementHelper.HelperMethod(TRIGGER.NEW);

        }

    }

}
 

HELPER CLASS 

public class DefaultEntitlementHelper {

    public static void HelperMethod(List<Case> Caselist) {

        Set<Id> contactIds = new Set<Id>();

 Set<Id> acctIds = new Set<Id>();

 for (Case c : Caselist) {

     contactIds.add(c.ContactId);

     acctIds.add(c.AccountId);

 }

 List <EntitlementContact> entlContacts =

     [Select e.EntitlementId,e.ContactId,e.Entitlement.AssetId

      From EntitlementContact e

      Where e.ContactId in :contactIds

      And e.Entitlement.EndDate >= Today

      And e.Entitlement.StartDate <= Today];

 if(entlContacts.isEmpty()==false){

     for(Case c : Caselist){

         if(c.EntitlementId == null && c.ContactId != null){

             for(EntitlementContact ec:entlContacts){

                 if(ec.ContactId==c.ContactId){

                     c.EntitlementId = ec.EntitlementId;

                     if(c.AssetId==null && ec.Entitlement.AssetId!=null) c.AssetId=ec.Entitlement.AssetId;

                     break;

                 }

             }

         }

     }

 }else{

     List <Entitlement> entls = [Select e.StartDate, e.Id, e.EndDate,

                                 e.AccountId, e.AssetId

                                 From Entitlement e

                                 Where e.AccountId in :acctIds And e.EndDate >= Today

                                 And e.StartDate <= Today];

     if(entls.isEmpty()==false){

         for(Case c : Caselist){

             if(c.EntitlementId == null && c.AccountId != null){

                 for(Entitlement e:entls){

                     if(e.AccountId==c.AccountId){

                         c.EntitlementId = e.Id;

                         if(c.AssetId==null && e.AssetId!=null)

                             c.AssetId=e.AssetId; break;

                     }

                 }

             }

         }

     }

 }
}

}
Hope this helps, If you find your solution please mark it as the best answer.

Thanks
Best Answer chosen by johnMark23
johnMark23johnMark23

Hi JohnMark ,

  According to me ,if system limit is over then you are not able to deploy your code in org or do not do any specific changes on it.

And also you can't perform any changes during code because it give error like system limit is over.
 
 If you find your Solution then mark this as the best answer.

 

  Thank you!


  Regards,
  Suraj Tripathi 

sumit dsumit d 
Hi All,
I am updating a user record by changing role of user, while changing role of user I ma getting Error:- The value of a parameter contains a character that is not allowed or the value exceeds the maximum allowed length. Remove the character from the parameter value or reduce the value length and resubmit.
  this error is only coming while i am changing only role, if i change anything else in user record, It gets saved but while updating role its giving me this error. I have tried inactive trigger/Flow etc on user record but i am still getting this error.
Can anyone help me with this?
Thanks in advance
Best Answer chosen by sumit d
sumit dsumit d
It was Due to Flow on user object.
Shubhashesh MisraShubhashesh Misra 
<apex:page showHeader="false" sidebar="false" renderAs="pdf" applyBodyTag="false"  standardStylesheets="false">
    <head>
        <style>  
        </style>
    </head>
    <apex:form >
        <body data-new-gr-c-s-loaded="14.991.0" spellcheck="false">
            <p style="text-align: center;"><strong>Test Pdf </strong><br /><strong>INFORMATION </strong></p>
            <div style="{!IF((1==1), 'display:block', 'display:none')}">
                <p>TO:&nbsp; <strong>Moblee, LLC</strong><br /><strong>&nbsp; &nbsp; &nbsp; &nbsp; There is </strong><br /><strong>&nbsp; &nbsp; &nbsp; &nbsp; Mount BSR</strong></p>
            </div>
            
            <div style="{!IF((1==2), 'display:block', 'display:none')}">
                <p>TO:&nbsp; <strong>Task, LLC</strong><br /><strong>&nbsp; &nbsp; &nbsp; &nbsp; PO 538643254</strong><br /><strong>&nbsp; &nbsp; &nbsp; &nbsp; hostel</strong></p>
            </div>
            
            <p>RE:<span style="white-space:pre;">&nbsp; &nbsp;&nbsp;</span>Patient Name: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;</p>
            <p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Date of Birth: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Number: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</p>
            <p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;I authorize and request the disclosure of all protected information for the purpose of review and evaluation in connection with a legal claim. I expressly request that the designated record custodian or agent of the covered  under entity identified above disclose full and complete protected medical information including the following:</p>
            
            <p>I love the feel of wood curls flying off the lathe as I begin to shape the log in front of me. The sound of scraping changes based on the wetness of the wood, the speed at which the lathe is turning, and the type of cut I am making. The smell and feel of wet wood being turned are unique. The water is sprayed out as I cut through the different layers of wood. A log can turn into anything one's imagination can think of with the right set of hands-on tools. I have those hands and imagination. I use all of my senses and intuition to create a beautiful object. That is why I enjoy turning wood.</p>
            <p>Twenty-five stars were neatly placed on the piece of paper. There was room for five more stars but they would be difficult ones to earn. It had taken years to earn the first twenty-five, and they were considered the "easy" ones.</p>
            <p>______________________________________________________________________________<br />Name</p>
            <p>______________________________________________________________________________<br />Law </p>
            <p>______________________________________________________________________________<br />Street Address<br /></p>
            <p>The alarm went off at exactly 6:00 AM as it had every morning for the past five years. Barbara began her morning and was ready to eat breakfast by 7:00 AM. The day appeared to be as normal as any other, but that was about to change. In fact, it was going to change at exactly 7:23 AM.</p>
            <ul>
                <li>I have a right to revoke .</li>
                <li>The information released in response </li>
                <li>My treatment in payment for my treatment.</li>
            </ul>
            <p>Then came the night of the first falling star. It was seen early in the morning, rushing over Winchester eastward, a line of flame high in the atmosphere. Hundreds must have seen it and taken it for an ordinary falling star. It seemed that it fell to earth about one hundred miles east of him.</p>
            <p>Signature of Patient / Legally Authorized Representative<span style="white-space:pre;">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;</span>Date</p>
            <p>Signature<span style="white-space:pre;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; &nbsp;</span>Date</p>
        </body>
    </apex:form>
</apex:page>Here is Pdf
Best Answer chosen by Shubhashesh Misra
Suraj Tripathi 47Suraj Tripathi 47
Hi Shubhasheesh Mishra,

Add border for page in style tag
Here is code:

<style> 
@page {
size:A4 portrait;
border: 2px solid black;    
}
</style> 

Here is a pdf with the border:

Pdf with border

I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.

Thanks and Regards,
Suraj Tripathi
SrinivasSrinivas 

How to add try catch for error handling for the below code

 

global class updatePolicyStatusSchedule implements Schedulable {
    global void execute(SchedulableContext ctx) {
        updatePolicyStatus();
    }
    
    public void updatePolicyStatus() {
        List<Policy__c> expiredInForcePolicies = [SELECT Id, Status__c, Policy_End_Date__c, Policy_Effective_Date__c
                                                  FROM Policy__c
                                                  WHERE (Policy_End_Date__c <= TODAY AND Status__c != 'Expired' AND Status__c != 'Terminated')
                                                  OR (Policy_Effective_Date__c <= TODAY AND Policy_End_Date__c > TODAY AND Status__c NOT IN ('In Force','In-Force - Non-Renewing'))];

        List<Policy__c> updateExpiredInForcePolicies = new List<Policy__c>();
        

        for(Policy__c policy : expiredInForcePolicies){
            if((policy.Policy_End_Date__c<=System.today() && policy.Status__c!='Expired' && policy.Status__c!='Terminated') && !(policy.Policy_Effective_Date__c <= System.today() && policy.Policy_End_Date__c > System.today() && (policy.Status__c!='In Force' || policy.Status__c!='In-Force - Non-Renewing'))){
                policy.Status__c = 'Expired';
            }

            if(!(policy.Policy_End_Date__c<=System.today() && policy.Status__c!='Expired' && policy.Status__c!='Terminated') && (policy.Policy_Effective_Date__c <= System.today() && policy.Policy_End_Date__c > System.today() && (policy.Status__c!='In Force' || policy.Status__c!='In-Force - Non-Renewing'))){
                policy.Status__c = 'In Force';
            }
            
            updateExpiredInForcePolicies.add(policy);
        }
    if(!updateExpiredInForcePolicies.isEmpty()){
            Database.update(updateExpiredInForcePolicies);  
        }
    }
}


Thanks In advance

Best Answer chosen by Srinivas
CharuDuttCharuDutt
Hii Srinivas
Try Below  Code
global class updatePolicyStatusSchedule implements Schedulable {
    global void execute(SchedulableContext ctx) {
        updatePolicyStatus();
    }
    
    public void updatePolicyStatus() {
        List<Policy__c> expiredInForcePolicies = [SELECT Id, Status__c, Policy_End_Date__c, Policy_Effective_Date__c
                                                  FROM Policy__c
                                                  WHERE (Policy_End_Date__c <= TODAY AND Status__c != 'Expired' AND Status__c != 'Terminated')
                                                  OR (Policy_Effective_Date__c <= TODAY AND Policy_End_Date__c > TODAY AND Status__c NOT IN ('In Force','In-Force - Non-Renewing'))];

        List<Policy__c> updateExpiredInForcePolicies = new List<Policy__c>();
        

        for(Policy__c policy : expiredInForcePolicies){
            if((policy.Policy_End_Date__c<=System.today() && policy.Status__c!='Expired' && policy.Status__c!='Terminated') && !(policy.Policy_Effective_Date__c <= System.today() && policy.Policy_End_Date__c > System.today() && (policy.Status__c!='In Force' || policy.Status__c!='In-Force - Non-Renewing'))){
                policy.Status__c = 'Expired';
            }

            if(!(policy.Policy_End_Date__c<=System.today() && policy.Status__c!='Expired' && policy.Status__c!='Terminated') && (policy.Policy_Effective_Date__c <= System.today() && policy.Policy_End_Date__c > System.today() && (policy.Status__c!='In Force' || policy.Status__c!='In-Force - Non-Renewing'))){
                policy.Status__c = 'In Force';
            }
            
            updateExpiredInForcePolicies.add(policy);
        }
    if(!updateExpiredInForcePolicies.isEmpty()){
	try {
 
            Database.update(updateExpiredInForcePolicies);  
		} catch(DmlException e) {
			System.debug('The following exception has occurred: ' + e.getMessage());
		}
	
        }
    }
}
Please Mark It As Best Answer If It Helps
Thank You! 
Hitesh KhannaHitesh Khanna 
"User cannot change status to invoicing if previous status was Pharma Payment, Member Payout, Payment Processing, or Complete".......(these are the picklist values) .


I tried this..but its not working.


IF(ISPICKVAL(Status__c,'Invoicing'), 
    ISPICKVAL(Status__c, 'Pharma Payment') ||
    ISPICKVAL(Status__c, 'Member Payout') ||
    ISPICKVAL(Status__c, 'Payment Processing') ||
    ISPICKVAL(Status__c, 'Complete')
 ,
false )



Response will be appreciated.


 
Best Answer chosen by Hitesh Khanna
CharuDuttCharuDutt
Hii Hitesh
Try Below Validation Rule
AND(ISPICKVAL(Status__c,'Invoicing') ,
OR( 
NOT(ISPICKVAL(PRIORVALUE(Status__c),'Pharma Payment')), 
NOT(ISPICKVAL(PRIORVALUE(Status__c),''Member Payout')),
NOT(ISPICKVAL(PRIORVALUE(Status__c),'Payment Processing')),
NOT(ISPICKVAL(PRIORVALUE(Status__c),'Complete'))))
Please Mark It As Best Answer If It Helps
Thank You! 
Best Answer chosen by Raghav T
CharuDuttCharuDutt
Hii Raghav
Try  Below Trigger
trigger SumAmountOpp on Opportunity (After Insert,After Update,After Delete) {
 List<Account> accList=new List<Account>();

    Set<Id> setAccIds = new Set<Id>();
    if(Trigger.isInsert){
         if(trigger.isAfter){
        for(Opportunity con : Trigger.new){
            if(con.AccountId != null && && Con.StageName != 'Closed Won' && con.StageName != 'Closed Lost' && con.StageName != 'Cancelled'){
            setAccIds.add(con.AccountId);
            	}
			}
		}
    } 
    system.debug('setAccIds ==> '+setAccIds);
    if(Trigger.isUpdate){
         if(trigger.isAfter){
        for(Opportunity con : Trigger.new){ 
            if(con.AccountId!=Trigger.oldMap.get(con.Id).AccountId && Con.StageName != 'Closed Won' && con.StageName != 'Closed Lost' && con.StageName != 'Cancelled'){
               	setAccIds.add(con.AccountId);
                setAccIds.add(Trigger.oldMap.get(con.Id).AccountId);
            	}
            
			}        
        }
    }
    if(Trigger.isDelete){
        if(trigger.isAfter){
        for(Opportunity con : Trigger.old) { 
            if(con.AccountId != null && con.StageName != 'Closed Won' && con.StageName != 'Closed Lost' && con.StageName != 'Cancelled'){
            setAccIds.add(con.AccountId);
            	}
        	}
        }
    }    
    for(Account acc :[Select id,Total_opp__c ,(Select id,Name,Amount from Opportunities where StageName != 'Closed Won' AND StageName != 'Closed Lost' AND StageName != 'Cancelled') from Account where Id in : setAccIds]){
			
        acc.Total_opp__c = acc.Opportunities.size();
        acclist.add(acc);
        
    }
    if(acclist.size()>0){
        update accList;     
    }
    
}
Please Mark It As Best Answer If It Helps
Thank You! 
Maok kinesleMaok kinesle 
Original code:
global class LightningForgotPasswordController {

    public LightningForgotPasswordController() {

    }

    @AuraEnabled
    public static String forgotPassword(String username, String checkEmailUrl) {
        try {
            Site.forgotPassword(username);
            ApexPages.PageReference checkEmailRef = new PageReference(checkEmailUrl);
            if(!Site.isValidUsername(username)) {
                return Label.Site.invalid_email;
            }
            aura.redirect(checkEmailRef);
            return null;
        }
        catch (Exception ex) {
            return ex.getMessage();
        }
    }

    @AuraEnabled
    global static String setExperienceId(String expId) {    
        // Return null if there is no error, else it will return the error message 
        try {
            if (expId != null) {
                Site.setExperienceId(expId);               
            }
            return null; 
        } catch (Exception ex) {
            return ex.getMessage();            
        }        
    } 
}

Test class:
@IsTest(SeeAllData = true)
public with sharing class LightningForgotPasswordControllerTest {

 /* Verifies that ForgotPasswordController handles invalid usernames appropriately */
 @IsTest
 static void testLightningForgotPasswordControllerInvalidUserName() {
  System.assertEquals(LightningForgotPasswordController.forgotPassword('fakeUser', 'http://a.com'), Label.Site.invalid_email);
  System.assertEquals(LightningForgotPasswordController.forgotPassword(null, 'http://a.com'), Label.Site.invalid_email);
  System.assertEquals(LightningForgotPasswordController.forgotPassword('a', '/home/home.jsp'), Label.Site.invalid_email);
 }

 /* Verifies that null checkEmailRef url throws proper exception. */
 @IsTest
 static void testLightningForgotPasswordControllerWithNullCheckEmailRef() {
  System.assertEquals(LightningForgotPasswordController.forgotPassword('a', null), 'Argument 1 cannot be null');
  System.assertEquals(LightningForgotPasswordController.forgotPassword('a@salesforce.com', null), 'Argument 1 cannot be null');
 }

 /* Verifies that LightningForgotPasswordController object is instantiated correctly. */
 @IsTest
 static void LightningForgotPasswordControllerInstantiation() {
  LightningForgotPasswordController controller = new LightningForgotPasswordController();
  System.assertNotEquals(controller, null);
 }
}
Best Answer chosen by Maok kinesle
CharuDuttCharuDutt
Hii Moak
Try Below Test Class 88% Coverage
@IsTest(SeeAllData = true)
public with sharing class LightningForgotPasswordControllerTest {

 /* Verifies that ForgotPasswordController handles invalid usernames appropriately */
 @IsTest
 static void testLightningForgotPasswordControllerInvalidUserName() {
  System.assertEquals(LightningForgotPasswordController.forgotPassword('fakeUser', 'http://a.com'), Label.Site.invalid_email);
  System.assertEquals(LightningForgotPasswordController.forgotPassword(null, 'http://a.com'), Label.Site.invalid_email);
  System.assertEquals(LightningForgotPasswordController.forgotPassword('a', '/home/home.jsp'), Label.Site.invalid_email);
     
     
   LightningForgotPasswordController.setExperienceId('FakeString');
 }

 /* Verifies that null checkEmailRef url throws proper exception. */
 @IsTest
 static void testLightningForgotPasswordControllerWithNullCheckEmailRef() {
  System.assertEquals(LightningForgotPasswordController.forgotPassword('a', null), 'Argument 1 cannot be null');
  System.assertEquals(LightningForgotPasswordController.forgotPassword('a@salesforce.com', null), 'Argument 1 cannot be null');
      LightningForgotPasswordController.setExperienceId(null);
 }

 /* Verifies that LightningForgotPasswordController object is instantiated correctly. */
 @IsTest
 static void LightningForgotPasswordControllerInstantiation() {
  LightningForgotPasswordController controller = new LightningForgotPasswordController();
  System.assertNotEquals(controller, null);
 }
}
Please Mark It As Best Answer If It Helps
Thank You!