• thinhtvu
  • NEWBIE
  • 0 Points
  • Member since 2012

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 6
    Questions
  • 6
    Replies

I'm trying to write a unit test class to cover the code in my controller extension, but I can't seem to get it to cover any of the code or even run properly. Could someone help me and let me know what's going on? I'm currently receiving this error message: 

 

System.DmlException : Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, CreateAP: execution of AfterInsert

However, I'm not trying to work on the CreateAP triggers I have set up, just the drfExtension class I made for my VF pages.

 

Here's my class: 

public class drfExtension {
 
    // Declare the class variables maintaining the state of the wizard.
    // When users enter data into wizard, input is stored in variables.
   
    public ApexPages.StandardController opportunityController;
    public Opportunity opp {get; set;}
 
    public ApexPages.StandardController accountController {get; set;}
    public Account account {get; set;}
    
    public ApexPages.StandardSetController contactController {get; set;}
    public List<Contact> contact {get; set;}

    String warning = 'Your request has been denied because you either do not have a Vendor account ' +
        'associated with the opportunity, or your opportunity does not have any contact relationships. ' +
        'Please go back and edit your opportunity to include at least one contact and one ' +
        'vendor relationship before continuing.'; 

    // Creates the controller for the extension.
       
    public drfExtension(ApexPages.StandardController std)
    {
        opportunityController = std;      
        opp = [SELECT AccountId, Name, Lease_Number__c, OwnerId, Billing_Street__c, Billing_City__c,
            Billing_State__c, Billing_Zip_Code__c, Equipment_Street__c, Equipment_City__c, 
            Equipment_State__c, Equipment_Zip_Code__c, Equipment_Costs__c, Bumped_Rate__c, Buy_Rate__c,
            Monthly_Payment__c, Points_to_PCC__c, Term__c, Commission_to_PCC__c, End_of_Term_Options__c,
            Advanced_Payments__c, Funding_Source_Doc_Fee__c, PCC_Doc_Fee__c, Inspection_Fee__c, Point_s_to_Close__c, 
            Total_of_All_Fees__c, Amount, Prefund_Signing__c, Prefund_Delivery__c, Prefund_Complete__c,
            Customer_Payment_s__c, Reimburse_to_Customer__c, Proof_of_Payment__c, Pass_Through_Service_Type__c,
            Pass_Through_Amount__c, Notes__c, Vendor__c, Vendor_Contact__c, Invoice_Contact__c 
            from Opportunity WHERE Id = :std.getId()];
            
        try {    
            account = [SELECT Id, Name, Phone, Fax, BillingStreet, BillingCity, BillingState,
                BillingPostalCode FROM Account Where Id = :opp.Vendor__c];
            contact = [SELECT Id, FirstName, LastName, MailingStreet, MailingCity, MailingState,
                MailingPostalCode, HomePhone, MobilePhone, Title from Contact where AccountId = :opp.AccountId];
        } catch (QueryException e) {
            e.setMessage(warning);
            e.getMessage();
        } 
        
        try{             
            accountController = new ApexPages.StandardController(account);
            contactController = new ApexPages.StandardSetController(contact);
        } catch (NullPointerException n) {
            n.setMessage(warning);
            n.getMessage();
        }

    }
    
    // Methods to return one of the three class variables.
    
    public Account getAccount(){
        return account;
    }
    
    public List<Contact> getContact(){
        return contact;
    }
    
    // Methods that manage the navigation of the wizard.

    public PageReference goToStep1() {
        return Page.drfStep1;
    }

    public PageReference goToStep2() {
        return Page.drfStep2;
    }
    
    public PageReference goToStep3() {
        return Page.drfStep3;
    }
 
    // Methods to alter the state of each object's data.
    
    public PageReference save()
    {
        try {    
            update opp;

            opportunityController.save();
            accountController.save();
            contactController.save();
        } catch (QueryException e) {
            e.setMessage(warning);
            e.getMessage();
        } catch (NullPointerException n) {
            n.setMessage(warning);
            n.getMessage();
        }          
        return null; 
    }
    
        public PageReference cancel()
    {
        try {    
            opportunityController.cancel();
            accountController.cancel();
            contactController.cancel();
        } catch (QueryException e) {
            e.setMessage(warning);
            e.getMessage();
        } catch (NullPointerException n) {
            n.setMessage(warning);
            n.getMessage();
        }            
        return null;
    }
    
    public PageReference finish()
    {
        PageReference opptyPage = new PageReference('/' + opp.id);
        opptyPage.setRedirect(true);
        return opptyPage;
    }
    
}

Here's my extension:

/**
 * This class contains unit tests for validating the behavior of Apex classes
 * and triggers.
 *
 * Unit tests are class methods that verify whether a particular piece
 * of code is working properly. Unit test methods take no arguments,
 * commit no data to the database, and are flagged with the testMethod
 * keyword in the method definition.
 *
 * All test methods in an organization are executed whenever Apex code is deployed
 * to a production organization to confirm correctness, ensure code
 * coverage, and prevent regressions. All Apex classes are
 * required to have at least 75% code coverage in order to be deployed
 * to a production organization. In addition, all triggers must have some code coverage.
 * 
 * The @isTest class annotation indicates this class only contains test
 * methods. Classes defined with the @isTest annotation do not count against
 * the organization size limit for all Apex scripts.
 *
 * See the Apex Language Reference for more information about Testing and Code Coverage.
 */
@isTest
private class testDrfExtension {

    static testMethod void drfExtensionTest() {
    	
    	Account a = new Account();
    	a.Name = 'ABC Organization';
		a.Phone = '(404) 212-1241';
		a.Fax = '(404) 122-5512';
		a.BillingStreet = '125 Asgard St';
		a.BillingCity = 'Atlanta';
		a.BillingState = 'Georgia';
		a.BillingPostalCode = '30312';
		
		insert a;
		
		Opportunity o = new Opportunity();
		o.AccountId = a.Id; 
		o.Name = 'XYZ Organization';
		o.Lease_Number__c = '12345';
		o.OwnerId = '005d0000000ji9m';
		o.StageName = 'Closed Won';
		o.ForecastCategoryName = 'Pipeline';
		o.Billing_Street__c = a.BillingStreet;
		o.Billing_City__c = a.BillingCity;
        o.Billing_State__c = a.BillingState;
        o.Billing_Zip_Code__c = a.BillingPostalCode;
        o.Equipment_Street__c = a.BillingStreet;
        o.Equipment_City__c = a.BillingCity;
        o.Equipment_State__c = a.BillingState;
        o.Equipment_Zip_Code__c =  a.BillingPostalCode;
        o.Equipment_Costs__c = null;
        o.Buy_Rate__c = null;
        o.Monthly_Payment__c = null;
        o.Points_to_PCC__c = null;
        o.Term__c = null;
        o.Commission_to_PCC__c = null;
        o.End_of_Term_Options__c = null;
        o.Advanced_Payments__c = null;
        o.Funding_Source_Doc_Fee__c = null;
        o.PCC_Doc_Fee__c = null;
        o.Inspection_Fee__c = null;
        o.Point_s_to_Close__c = null;
        o.Total_of_All_Fees__c = null;
        o.Amount = null;
        o.Prefund_Signing__c = null;
        o.Prefund_Delivery__c = null;
        o.Prefund_Complete__c = null;
        o.Customer_Payment_s__c = null;
        o.Reimburse_to_Customer__c = true;
        o.Proof_of_Payment__c = true;
        o.Pass_Through_Service_Type__c = null;
        o.Pass_Through_Amount__c = null;
        o.Notes__c = null;
        o.Vendor__c = null;
        o.Vendor_Contact__c = null;
        o.Invoice_Contact__c = null;
        
        insert o;
		
    	Contact c = new Contact();
    	c.FirstName = 'Thinh';
    	c.LastName = 'Vu';
    	
    	insert c;
		
		PageReference pageRef = Page.drfStep1;
    	Test.setCurrentPage(pageRef);
    	
    	ApexPages.StandardController std = new ApexPages.StandardController(o);
    	drfExtension controller = new drfExtension(std);
    	
    	System.assertEquals(a, controller.getAccount());
    }
}

 

I used Visual Flow Designer to create a wizard for my Sales team, but because of the limitations of the flow designer, you can't customize the number of columns you want per screen. Is there any way I can accomplish this with CSS?

I have a VisualForce page with a pageBlockTable element that lists a set of contacts that relate to an Opportunity, however, when I hit save on the page, none of my fields are actually saved within the object. Could someone help me?

 

Here's the VF page:

 

<apex:page extensions="drfExtension" standardController="Opportunity" showheader="false">
    <apex:composition template="patriotHeader">
    <apex:define name="header">
        
        <div class="page-title">
            Document Request Form
        </div>      
               
    <apex:form id="drfStep2">
        <apex:pageBlock title="Step 2">
            <apex:pageBlockSection title="CUSTOMER INFORMATION: " collapsible="false">     
                <apex:pageBlockTable value="{!account.Contacts}" var="c">
                    <apex:column value="{!c.FirstName}"/>
                    <apex:column value="{!c.LastName}"/> 
                    <apex:column value="{!c.MailingStreet}"/>
                    <apex:column value="{!c.MailingCity}"/>
                    <apex:column value="{!c.MailingState}"/>
                    <apex:column value="{!c.MailingPostalCode}"/>
                    <apex:column value="{!c.Phone}"/> 
                    <apex:column value="{!c.MobilePhone}"/> 
                    <apex:column value="{!c.Title}"/>  
                </apex:pageBlockTable>
            <apex:inlineEditSupport event="ondblClick"  showOnEdit="saveButton,cancelButton"/> 
            </apex:pageBlockSection>
            <apex:pageBlockButtons location="top" style="text-align:right"> 
                <apex:commandButton value="Save" action="{!save}" id="saveButton" style=""/>
                <apex:commandButton value="Cancel" action="{!cancel}" id="cancelButton" />
            </apex:pageBlockButtons>
            <apex:pageBlockButtons location="bottom" style="text-align:right">
                <apex:CommandButton value="Previous" action="{!goToStep1}"/>
                <apex:commandButton value="Next" action="{!goToStep3}"/>
            </apex:pageBlockButtons>
        </apex:pageBlock>
    </apex:form>
    </apex:define>
    </apex:composition>
</apex:page>

 And here's the Apex code:

public class drfExtension {

    // Declare the class variables maintaining the state of the wizard.
    // When users enter data into wizard, input is stored in variables.
    
    public Opportunity opp {get; set;}

    public ApexPages.StandardController accountController {get; set;}
    public Account account {get; set;}
    
    public ApexPages.StandardSetController contactController {
        get {
            if(contactController == null) {
                contactController = new ApexPages.StandardSetController(Database.getQueryLocator(
                    [SELECT Id, FirstName, LastName, MailingStreet, MailingCity, MailingState,
                    MailingPostalCode, Phone, MobilePhone, Title from Contact 
                    WHERE AccountId = :opp.AccountId]));
            }
            return contactController;
        }
        set;
    }
    public List<Contact> contact {get; set;}

    // Creates the controller for the extension.
        
    public ApexPages.StandardController opportunityController;
    public drfExtension(ApexPages.StandardController std)
    {
        opportunityController = std;       
        
        opp = [SELECT AccountId from Opportunity WHERE Id = :std.getId()];
        account = [SELECT Id, Name, Phone, Fax, BillingStreet, BillingCity, BillingState,
            BillingPostalCode FROM Account Where Id = :opp.AccountId];
        contact = [SELECT Id, FirstName, LastName, MailingStreet, MailingCity, MailingState,
            MailingPostalCode, Phone, MobilePhone, Title from Contact where AccountId = :opp.AccountId];
            
        accountController = new ApexPages.StandardController(account);
        contactController = new ApexPages.StandardSetController(contact);
    }
    
    // Methods to return one of the three class variables.
    
    public Account getAccount(){
        return account;
    }
    
    public List<Contact> getContact(){
        return (List<Contact>) contactController.getRecords();
    }

    // Methods that manage the navigation of the wizard.

    public PageReference goToStep1() {
        Pagereference pg1=new pagereference('/apex/drfStep1?oppid='+opp.id);
        return pg1;
    }


    public PageReference goToStep2() {
        Pagereference pg2=new pagereference('/apex/drfStep2?oppid='+opp.id);
        return pg2;
    }
    
    public PageReference goToStep3() {
        Pagereference pg3=new pagereference('/apex/drfStep3?oppid='+opp.id);
        return pg3;
    }
    
    public PageReference goToStep4() {
        
        Pagereference pg4=new pagereference('/apex/drfStep4?oppid='+opp.id);
        return pg4;
    }
 
    // Methods to alter the state of each object's data.
    
    public PageReference save()
    {
        opportunityController.save();
        accountController.save();
        contactController.save();
        return null;
    }
    
        public PageReference cancel()
    {
        opportunityController.cancel();
        accountController.cancel();
        contactController.cancel();
        return null;
    }
    
}

 

I'm creating a document request form wizard for my organization through Visualforce, and I have a couple of things I want to do with the url parameters.

 

1. How do I automatically get the Opportunity Id parameter value to get passed to Step 1 of the wizard when I'm in an opportunity and I click on a custom button for the wizard?

 

2. How do I pass the Opportunity Id parameter between pages. 

 

For example, the wizard has 4 pages and starts on Step 1 with an Id parameter in it's url (http://...force.com/apex/...?id=_____); what I want to be able to do is pass the same parameter value onto the next few pages when I click the "Next" command button, and also be able to traverse the function when I click the "Previous" command button. 

 

3. Lastly, one of the pages, Step 2, uses the Contact standardController rather than the Opportunity standardController, and therefore takes in a different Id parameter value. How can I get the ContactId parameter value from the linked Opportunity?

Hello,

 

I'm trying to create an Apex controller extension that allows me to use more than one Standard controller in a VF page. Right now, I'm creating a Document Request Form for my organization, but one of the steps requires me to retrieve fields from Contacts, Opportunities, and Accounts. I was wondering if there was a way to write an extension to incorporate the functions of these standard controllers into one controller?

 

I tried doing this, while still using the Opportunity standard controller in my VF page, and this class as an extension, but it didn't work the way I thought it would:

 

    private final Opportunity opp;
    private final Contact cont;
    
    public ApexPages.StandardController stdCtrl;
    public drfExtension(ApexPages.StandardController std)
    {
        stdCtrl = std;
        
        this.opp = (Opportunity)std.getRecord();
        this.cont = (Contact)std.getRecord();
    }

 

I have a wizard that i want to only enable when my sales team clicks on "New" in the Accounts tab, but I'm not quite sure if Salesforce can do that. I've been looking for a setting to help me enable that action, but can't find it. 

 

Also, if it's not possible, how would I be able to accomplish the same action with a Salesforce trigger or Apex class? Or perhaps even instead of triggering the wizard on click of the "New" button, how could I be able to add a custom button to the new accounts entry page?

I'm trying to write a unit test class to cover the code in my controller extension, but I can't seem to get it to cover any of the code or even run properly. Could someone help me and let me know what's going on? I'm currently receiving this error message: 

 

System.DmlException : Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, CreateAP: execution of AfterInsert

However, I'm not trying to work on the CreateAP triggers I have set up, just the drfExtension class I made for my VF pages.

 

Here's my class: 

public class drfExtension {
 
    // Declare the class variables maintaining the state of the wizard.
    // When users enter data into wizard, input is stored in variables.
   
    public ApexPages.StandardController opportunityController;
    public Opportunity opp {get; set;}
 
    public ApexPages.StandardController accountController {get; set;}
    public Account account {get; set;}
    
    public ApexPages.StandardSetController contactController {get; set;}
    public List<Contact> contact {get; set;}

    String warning = 'Your request has been denied because you either do not have a Vendor account ' +
        'associated with the opportunity, or your opportunity does not have any contact relationships. ' +
        'Please go back and edit your opportunity to include at least one contact and one ' +
        'vendor relationship before continuing.'; 

    // Creates the controller for the extension.
       
    public drfExtension(ApexPages.StandardController std)
    {
        opportunityController = std;      
        opp = [SELECT AccountId, Name, Lease_Number__c, OwnerId, Billing_Street__c, Billing_City__c,
            Billing_State__c, Billing_Zip_Code__c, Equipment_Street__c, Equipment_City__c, 
            Equipment_State__c, Equipment_Zip_Code__c, Equipment_Costs__c, Bumped_Rate__c, Buy_Rate__c,
            Monthly_Payment__c, Points_to_PCC__c, Term__c, Commission_to_PCC__c, End_of_Term_Options__c,
            Advanced_Payments__c, Funding_Source_Doc_Fee__c, PCC_Doc_Fee__c, Inspection_Fee__c, Point_s_to_Close__c, 
            Total_of_All_Fees__c, Amount, Prefund_Signing__c, Prefund_Delivery__c, Prefund_Complete__c,
            Customer_Payment_s__c, Reimburse_to_Customer__c, Proof_of_Payment__c, Pass_Through_Service_Type__c,
            Pass_Through_Amount__c, Notes__c, Vendor__c, Vendor_Contact__c, Invoice_Contact__c 
            from Opportunity WHERE Id = :std.getId()];
            
        try {    
            account = [SELECT Id, Name, Phone, Fax, BillingStreet, BillingCity, BillingState,
                BillingPostalCode FROM Account Where Id = :opp.Vendor__c];
            contact = [SELECT Id, FirstName, LastName, MailingStreet, MailingCity, MailingState,
                MailingPostalCode, HomePhone, MobilePhone, Title from Contact where AccountId = :opp.AccountId];
        } catch (QueryException e) {
            e.setMessage(warning);
            e.getMessage();
        } 
        
        try{             
            accountController = new ApexPages.StandardController(account);
            contactController = new ApexPages.StandardSetController(contact);
        } catch (NullPointerException n) {
            n.setMessage(warning);
            n.getMessage();
        }

    }
    
    // Methods to return one of the three class variables.
    
    public Account getAccount(){
        return account;
    }
    
    public List<Contact> getContact(){
        return contact;
    }
    
    // Methods that manage the navigation of the wizard.

    public PageReference goToStep1() {
        return Page.drfStep1;
    }

    public PageReference goToStep2() {
        return Page.drfStep2;
    }
    
    public PageReference goToStep3() {
        return Page.drfStep3;
    }
 
    // Methods to alter the state of each object's data.
    
    public PageReference save()
    {
        try {    
            update opp;

            opportunityController.save();
            accountController.save();
            contactController.save();
        } catch (QueryException e) {
            e.setMessage(warning);
            e.getMessage();
        } catch (NullPointerException n) {
            n.setMessage(warning);
            n.getMessage();
        }          
        return null; 
    }
    
        public PageReference cancel()
    {
        try {    
            opportunityController.cancel();
            accountController.cancel();
            contactController.cancel();
        } catch (QueryException e) {
            e.setMessage(warning);
            e.getMessage();
        } catch (NullPointerException n) {
            n.setMessage(warning);
            n.getMessage();
        }            
        return null;
    }
    
    public PageReference finish()
    {
        PageReference opptyPage = new PageReference('/' + opp.id);
        opptyPage.setRedirect(true);
        return opptyPage;
    }
    
}

Here's my extension:

/**
 * This class contains unit tests for validating the behavior of Apex classes
 * and triggers.
 *
 * Unit tests are class methods that verify whether a particular piece
 * of code is working properly. Unit test methods take no arguments,
 * commit no data to the database, and are flagged with the testMethod
 * keyword in the method definition.
 *
 * All test methods in an organization are executed whenever Apex code is deployed
 * to a production organization to confirm correctness, ensure code
 * coverage, and prevent regressions. All Apex classes are
 * required to have at least 75% code coverage in order to be deployed
 * to a production organization. In addition, all triggers must have some code coverage.
 * 
 * The @isTest class annotation indicates this class only contains test
 * methods. Classes defined with the @isTest annotation do not count against
 * the organization size limit for all Apex scripts.
 *
 * See the Apex Language Reference for more information about Testing and Code Coverage.
 */
@isTest
private class testDrfExtension {

    static testMethod void drfExtensionTest() {
    	
    	Account a = new Account();
    	a.Name = 'ABC Organization';
		a.Phone = '(404) 212-1241';
		a.Fax = '(404) 122-5512';
		a.BillingStreet = '125 Asgard St';
		a.BillingCity = 'Atlanta';
		a.BillingState = 'Georgia';
		a.BillingPostalCode = '30312';
		
		insert a;
		
		Opportunity o = new Opportunity();
		o.AccountId = a.Id; 
		o.Name = 'XYZ Organization';
		o.Lease_Number__c = '12345';
		o.OwnerId = '005d0000000ji9m';
		o.StageName = 'Closed Won';
		o.ForecastCategoryName = 'Pipeline';
		o.Billing_Street__c = a.BillingStreet;
		o.Billing_City__c = a.BillingCity;
        o.Billing_State__c = a.BillingState;
        o.Billing_Zip_Code__c = a.BillingPostalCode;
        o.Equipment_Street__c = a.BillingStreet;
        o.Equipment_City__c = a.BillingCity;
        o.Equipment_State__c = a.BillingState;
        o.Equipment_Zip_Code__c =  a.BillingPostalCode;
        o.Equipment_Costs__c = null;
        o.Buy_Rate__c = null;
        o.Monthly_Payment__c = null;
        o.Points_to_PCC__c = null;
        o.Term__c = null;
        o.Commission_to_PCC__c = null;
        o.End_of_Term_Options__c = null;
        o.Advanced_Payments__c = null;
        o.Funding_Source_Doc_Fee__c = null;
        o.PCC_Doc_Fee__c = null;
        o.Inspection_Fee__c = null;
        o.Point_s_to_Close__c = null;
        o.Total_of_All_Fees__c = null;
        o.Amount = null;
        o.Prefund_Signing__c = null;
        o.Prefund_Delivery__c = null;
        o.Prefund_Complete__c = null;
        o.Customer_Payment_s__c = null;
        o.Reimburse_to_Customer__c = true;
        o.Proof_of_Payment__c = true;
        o.Pass_Through_Service_Type__c = null;
        o.Pass_Through_Amount__c = null;
        o.Notes__c = null;
        o.Vendor__c = null;
        o.Vendor_Contact__c = null;
        o.Invoice_Contact__c = null;
        
        insert o;
		
    	Contact c = new Contact();
    	c.FirstName = 'Thinh';
    	c.LastName = 'Vu';
    	
    	insert c;
		
		PageReference pageRef = Page.drfStep1;
    	Test.setCurrentPage(pageRef);
    	
    	ApexPages.StandardController std = new ApexPages.StandardController(o);
    	drfExtension controller = new drfExtension(std);
    	
    	System.assertEquals(a, controller.getAccount());
    }
}

 

I'm creating a document request form wizard for my organization through Visualforce, and I have a couple of things I want to do with the url parameters.

 

1. How do I automatically get the Opportunity Id parameter value to get passed to Step 1 of the wizard when I'm in an opportunity and I click on a custom button for the wizard?

 

2. How do I pass the Opportunity Id parameter between pages. 

 

For example, the wizard has 4 pages and starts on Step 1 with an Id parameter in it's url (http://...force.com/apex/...?id=_____); what I want to be able to do is pass the same parameter value onto the next few pages when I click the "Next" command button, and also be able to traverse the function when I click the "Previous" command button. 

 

3. Lastly, one of the pages, Step 2, uses the Contact standardController rather than the Opportunity standardController, and therefore takes in a different Id parameter value. How can I get the ContactId parameter value from the linked Opportunity?

Hello,

 

I'm trying to create an Apex controller extension that allows me to use more than one Standard controller in a VF page. Right now, I'm creating a Document Request Form for my organization, but one of the steps requires me to retrieve fields from Contacts, Opportunities, and Accounts. I was wondering if there was a way to write an extension to incorporate the functions of these standard controllers into one controller?

 

I tried doing this, while still using the Opportunity standard controller in my VF page, and this class as an extension, but it didn't work the way I thought it would:

 

    private final Opportunity opp;
    private final Contact cont;
    
    public ApexPages.StandardController stdCtrl;
    public drfExtension(ApexPages.StandardController std)
    {
        stdCtrl = std;
        
        this.opp = (Opportunity)std.getRecord();
        this.cont = (Contact)std.getRecord();
    }

 

I have a wizard that i want to only enable when my sales team clicks on "New" in the Accounts tab, but I'm not quite sure if Salesforce can do that. I've been looking for a setting to help me enable that action, but can't find it. 

 

Also, if it's not possible, how would I be able to accomplish the same action with a Salesforce trigger or Apex class? Or perhaps even instead of triggering the wizard on click of the "New" button, how could I be able to add a custom button to the new accounts entry page?

How do I unit test methods in my controller that return a page reference? In particular how do I test that the page returned is the one I expect?
 
Here is a simple method returning a page reference:
 
Code:
public PageReference policiesPage()
{
 return Page.newClaimWzrdPolicies;
}

 
I can't seem to test like this:
 
Code:
PageReference policiesPage = controller.policiesPage();

system.assert( policiesPage == Page.newClaimWzrdPolicies ); 

 
because I'm testing that two instances of an object are the same and I'm guessing they are not for some reason.
 
So how do I test I'm getting the correct page back? I have other methods that can return one of a number of pages depending on certain conditions so I need to test all conditions and all returned pages.
 
Has anyone done this?