• Arthur Lawrence
  • NEWBIE
  • 0 Points
  • Member since 2018

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 1
    Likes Given
  • 0
    Questions
  • 1
    Replies
<apex:page id="Page" showHeader="false" controller="MyCustomVFPage_CTR" action="{!InitPage}" cache="false">
    <apex:form >
        Thank you for your response.
    </apex:form>
</apex:page>
^ Visualforce page. When someone clicks a link in an alert email I sent them it directs them here, and appends a value in the url based on what link in the alert they click: accepted or rejected. 
 
public class MyCustomVFPage_CTR {
    public String ObjectId {get;set;}
    public String ResponseCode {get;set;}
    public MyCustomVFPage_CTR () {
        ObjectId = ApexPages.currentPage().getParameters().get('ObjectId');
        ResponseCode = ApexPages.currentPage().getParameters().get('ResponseCode');
    }
    public PageReference InitPage() {
        List<Lead> CustomerIssues = [SELECT Id, Status FROM Lead WHERE Id=:ObjectId LIMIT 1];
        if(!CustomerIssues.IsEmpty()){
            CustomerIssues[0].Status = ResponseCode;
            UPDATE CustomerIssues;
        }
        Return null;
    }
}
^ class takes the value that's passed from the url, and updates the related record.

I don't know how to get code coverage for that class. Do I need to write something to test going to a visualforce page?





 
<apex:page id="Page" showHeader="false" controller="MyCustomVFPage_CTR" action="{!InitPage}" cache="false">
    <apex:form >
        Thank you for your response.
    </apex:form>
</apex:page>
^ Visualforce page. When someone clicks a link in an alert email I sent them it directs them here, and appends a value in the url based on what link in the alert they click: accepted or rejected. 
 
public class MyCustomVFPage_CTR {
    public String ObjectId {get;set;}
    public String ResponseCode {get;set;}
    public MyCustomVFPage_CTR () {
        ObjectId = ApexPages.currentPage().getParameters().get('ObjectId');
        ResponseCode = ApexPages.currentPage().getParameters().get('ResponseCode');
    }
    public PageReference InitPage() {
        List<Lead> CustomerIssues = [SELECT Id, Status FROM Lead WHERE Id=:ObjectId LIMIT 1];
        if(!CustomerIssues.IsEmpty()){
            CustomerIssues[0].Status = ResponseCode;
            UPDATE CustomerIssues;
        }
        Return null;
    }
}
^ class takes the value that's passed from the url, and updates the related record.

I don't know how to get code coverage for that class. Do I need to write something to test going to a visualforce page?