You need to sign in to do that
Don't have an account?
sfg1
code coverage for constructor
In my class i have below constructor, i am not able to cover code coverage.can some pls guide me, thanks.
Constructor: takes an Opporutnity action, color index and associate file
*/
public OpportunityAction(Opportunity_Action__c oppAction, Integer colorIndex, Files__c file) {
this.oppAction = oppAction;
this.oppPlan = oppAction.Opportunity_Plan__r;
this.colorIndex = colorIndex;
this.associatedFile = file;
planHeader = false;
}
Constructor: takes an Opporutnity action, color index and associate file
*/
public OpportunityAction(Opportunity_Action__c oppAction, Integer colorIndex, Files__c file) {
this.oppAction = oppAction;
this.oppPlan = oppAction.Opportunity_Plan__r;
this.colorIndex = colorIndex;
this.associatedFile = file;
planHeader = false;
}
Let us know if it helps.
Main class:
/**
Inner class for wrapping opp actions with relevant information
also assists in displaying of data (colorIndex, etc)
*/
public Class OpportunityAction {
public Opportunity_Action__c oppAction {get;set;}
public Opportunity_Plan__c oppPlan {get;set;}
public Boolean checked {get;set;}
public Boolean planHeader {get;set;}
public Integer colorIndex {get;set;}
public Files__c associatedFile {get;set;}
public static List<String> planColors = new List<String> {'DarkSlateBlue', 'Orange', 'SteelBlue', 'Sienna','DarkSeaGreen','Indigo','LightSeaGreen','DarkGreen','Navy', 'Chocolate', 'DarkCyan', 'CadetBlue', 'Crimson', 'DarkGoldenRod', 'FireBrick', 'ForestGreen'};
public String title {
get {
if (title == null && oppAction != null) {
title = oppAction.Name;
}
return title;
}
set;
}
public String actionId {
get {
if (oppAction != null && oppAction.ID != null) {
return oppAction.ID;
} else {
return '0';
}
}
}
/**
Constructor: takes an Opporutnity action and color index
*/
public OpportunityAction(Opportunity_Action__c oppAction, Integer colorIndex) {
this.oppAction = oppAction;
this.colorIndex = colorIndex;
this.oppPlan = oppAction.Opportunity_Plan__r;
planHeader = false;
}
/**
Constructor: takes an Opporutnity action, color index and associate file
*/
public OpportunityAction(Opportunity_Action__c oppAction, Integer colorIndex, Files__c file) {
this.oppAction = oppAction;
this.oppPlan = oppAction.Opportunity_Plan__r;
this.colorIndex = colorIndex;
this.associatedFile = file;
planHeader = false;
}
/**
Constructor: takes an Opporutnity Plan and color index
*/
public OpportunityAction(Opportunity_Plan__c oppPlan, Integer colorIndex) {
this.oppPlan = oppPlan;
this.title = oppPlan.Plan_Template__r.name;
this.colorIndex = colorIndex;
oppAction = new Opportunity_Action__c(Name = title, Status__c = oppPlan.Status__c);
planHeader = true;
}
public String statusColor {
get {
if (oppAction != null) {
if (oppAction.Status__c =='Pending') {
return 'gray';
} else if (oppAction.Status_Category__c == 'Overdue' ) {
return 'red';
} else {
return 'black';
}
}
return 'black';
}
}
public String planColor {
get {
if (colorIndex != null) {
return OpportunityAction.planColors[colorIndex];
} else {
return '';
}
}
}
public String editAction {
get {
PageReference ref = Page.OpportunityActionEdit;
ref.getParameters().put('ID', oppAction.ID);
if (oppPlan.Amendment__c != null) {
ref.getParameters().put('saveURL','/' + oppPlan.Amendment__c);
ref.getParameters().put('retURL','/' + oppPlan.Amendment__c);
} else {
ref.getParameters().put('saveURL','/' + oppPlan.Opportunity__c);
ref.getParameters().put('retURL','/' + oppPlan.Opportunity__c);
}
return ref.getUrl();
}
private set;
}
public String closeAction {
get {
PageReference ref = Page.OpportunityActionEdit;
ref.getParameters().put('ID', oppAction.ID);
ref.getParameters().put('st', 'Complete');
if (oppPlan.Amendment__c != null) {
ref.getParameters().put('saveURL','/' + oppPlan.Amendment__c);
ref.getParameters().put('retURL','/' + oppPlan.Amendment__c);
} else {
ref.getParameters().put('saveURL','/' + oppPlan.Opportunity__c);
ref.getParameters().put('retURL','/' + oppPlan.Opportunity__c);
}
return ref.getUrl();
}
private set;
}
public String editPlan {
get {
PageReference ref = Page.OpportunityPlanEdit;
ref.getParameters().put('ID', oppPlan.ID);
if (oppPlan.Amendment__c != null) {
ref.getParameters().put('saveURL','/' + oppPlan.Amendment__c);
ref.getParameters().put('retURL','/' + oppPlan.Amendment__c);
} else {
ref.getParameters().put('saveURL','/' + oppPlan.Opportunity__c);
ref.getParameters().put('retURL','/' + oppPlan.Opportunity__c);
}
return ref.getUrl();
}
private set;
}
public String viewAction {
get {
PageReference ref = new ApexPages.StandardController(oppAction).view();
ref.getParameters().put('ID', oppAction.ID);
if (oppPlan.Amendment__c != null) {
ref.getParameters().put('saveURL','/' + oppPlan.Amendment__c);
ref.getParameters().put('retURL','/' + oppPlan.Amendment__c);
} else {
ref.getParameters().put('saveURL','/' + oppPlan.Opportunity__c);
ref.getParameters().put('retURL','/' + oppPlan.Opportunity__c);
}
return ref.getUrl();
}
private set;
}
/**
*@description returns true if the action should show by default. Canceled and Cancel Rework actions are hidden by default
* to alter this behavior, modify the Hide__c formula field on the Opportunity Action object
*/
public Boolean show {
get {
Boolean hideAction = oppAction.Hide__c;
if (hideAction == true) {
return false;
} else {
return true;
}
}
}
}
Let me know if it helps