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
uHaveOptionsuHaveOptions 

71% 2 lines left to pass test class.

Got this APEX and need to 2 more line to pass.  Kinda blanking out.  Can you help what should I pass?
 
public Account lender {get; set;}
    public Account_Update__c accountUpdate {get; set;}
    
    private String accountId;
    
    public AccountFormController() {
        accountId = ApexPages.currentPage().getParameters().get('id');
        
        if(String.isBlank(accountId)) {
            ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, 'Could not find account id in the parameter.'));
            return;
        }
        
        accountUpdate = new Account_Update__c();
        getAccount();
    }
    
    public void save() {
        try {
            if(accountUpdate.Account__c == null) {
                accountUpdate.Account__c = accountId;
            }
            upsert accountUpdate;
            PageReference pr = new PageReference('http://www.barringtoncapcorp.com');
            pr.setRedirect(true);
        } catch(Exception e) {
            System.debug('------------- ERROR: ' + e.getStackTraceString());
            System.debug('------------- ERROR: ' + e.getMessage());
            ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, 'There was a problem while saving the account information.'));
            return;
        }
    }
    
    private void getAccount() {
        try {
            lender = [
                select
                    Id,
                    Name,

                from Account
                where Id = :accountId
            ];
        
            if(lender == null) {
                ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, 'Could not find the account with the given id.'));
                return;
            }
                      
            
        } catch(Exception e) {
            System.debug('------------- ERROR: ' + e.getStackTraceString());
            ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, 'There was a problem while getting the account information.' + e.getStackTraceString()));
            return;
        }
    }
    
    public String getOptions()
{
//  List<SelectOption> options = new List<SelectOption>();
String listOptions='DEFAULT+';
   Schema.DescribeFieldResult fieldResult =
        Account.Primary_Focus__c.getDescribe();
   List<Schema.PicklistEntry> ple = fieldResult.getPicklistValues();

   for( Schema.PicklistEntry f : ple)
   {/*
      if(f.isDefaultValue()){
        String selectedCountry = f.getValue();break;
      */
      listOptions+=f;
      
     // }
   }       
   return listOptions;
}
}


TEst Class
@isTest
private class AccountFormControllerTest {

    private static testMethod void test() {
        Account lender = new Account();
        lender.Name = 'Test Account';
        insert lender;
        
        ApexPages.currentPage().getParameters().put('id', lender.Id);
        AccountFormController controller = new AccountFormController();
        controller.accountUpdate.Equity_Debt__c = 'Debt';
        controller.save();
    }
    
    private static testMethod void test2() {
        ApexPages.currentPage().getParameters().put('id', 'some id');
        AccountFormController controller = new AccountFormController();
        controller.save();
        
        AccountFormController controller2 = new AccountFormController();
        controller2.save();
        
        ApexPages.currentPage().getParameters().put('id', '');
        AccountFormController controller3 = new AccountFormController();
          
    }
    
    private static testMethod void test3() {
        ApexPages.currentPage().getParameters().put('id', 'some id');
        AccountFormController controller = new AccountFormController();
        controller.save();
        
        AccountFormController controller2 = new AccountFormController();
        controller2.save();
        
        ApexPages.currentPage().getParameters().put('id', '');
        AccountFormController controller3 = new AccountFormController();
          
    }
    
}

I'm currently getting an error when I try to pass     public String getOptions()  or  String listOptions='DEFAULT+';
 
Best Answer chosen by uHaveOptions
v varaprasadv varaprasad
Hi John,

Add following line in first method check once.
string options = controller.getOptions();

Hope this helps you!

Thanks
Varaprasad
For Support: varaprasad4sfdc@gmail.com  

All Answers

v varaprasadv varaprasad
Hi John,

Add following line in first method check once.
string options = controller.getOptions();

Hope this helps you!

Thanks
Varaprasad
For Support: varaprasad4sfdc@gmail.com  
This was selected as the best answer
uHaveOptionsuHaveOptions
^ Yup.  I was able to add this before and it worked. i trully appreciate it.