• GregNYC
  • NEWBIE
  • 0 Points
  • Member since 2009

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

Hello,


I'm new to Apex development, and while my class and visualforce page are working nicely, I'm a bit at a loss for getting Test Coverage working.

 

My class:

 

 

public class FlowReference {

      private final Program__c program;

      public FlowReference() {
            program = [select id, name, Product_Summary__c, Position1_Item__r.Name, Position2_Item__r.Name, Position1_Item__r.FAQ__c, Position2_Item__r.FAQ__c, Customer_Service_Info__c from Program__c where id =
                       :ApexPages.currentPage().getParameters().get('id')];
      }

      public Program__c getProgram() {
            return program;
      }
      
      //TEST COVERAGE
      public static testMethod void testFlowReference() {
          //Create program
          Program__c p = new Program__c(name='Test Program');
          insert p;
      
      p.CampaignID__c = '123';
      update p;
      
      FlowReference class1 = new FlowReference();
      class1.name = p.CampaignID__c; // I know this is wrong!!
      
      Program__c updatedProgram = [SELECT CampaignID__c FROM Program__C WHERE Id = :p.Id];
      System.assertEquals('123', updatedProgram.CampaignID__c);
      
      }
}

 I know things go bad around class1.name = p.CampaignID__c...

 

Any help is appreciated!

Thanks.

 

Hi I have following piece of code,

 

startUrl = '/home?a=' + value1 + '~b=' + value2;
PageReference page = Site.login(username, password, startUrl);

String temp = page.getParameters().get('retURL');
temp = temp.replaceAll('~', '&');
page.getParameters().put('retURL', temp);

return page;

 

Here the returnURL shows the correct url but after the actual redirect it just redirects to the page with the 1st parameter, so i get

 

'/home?a=' + value1

 

which is wrong....