You need to sign in to do that
Don't have an account?
HarishGoudd Buura
Constructor not defined: [SalesTask].<Constructor>(System.PageReference) For Custom Controller
Hello,
My Business class
public with sharing class SalesTask {
public PageReference clientApproved() {
//Update the current task to close
pmt.Status__c = 'Completed';
pmt.Type_of_layout__c = 'Support';
pmt.Proposal_Status__c = 'Client Approved';
update pmt;
PageReference cancel= new PageReference(System.currentPageReference().getParameters().get('retURL'));
cancel.setRedirect(true);
return cancel;
}
public SalesTask(){
this.pmt = new PMO_Task__c();
List<PMO_Task__c> pmtList = new List<PMO_Task__c>();
pmtList = [SELECT Subject__c,AssigedDate__c,AssignedBy__c,MyComments__c,Status__c,Opportunity__c,Type_of_layout__c FROM PMO_Task__c WHERE id = :System.currentPageReference().getParameters().get('id') ];
pmt = pmtList.get(0);
}
test class i written
@isTest
public class PMOSalesTaskTest{
private static testmethod void pmoSalesTaskTest() {
PageReference pg = Page.pmotrackertasks;
Test.setCurrentPage(pg);
pg.getParameters().put('Status__c', 'Completed');
pg.getParameters().put('Type_of_layout__c', 'Support');
pg.getParameters().put('Proposal_Status__c', 'Client Approved');
PMOSalesTask pmo = new PMOSalesTask(pg);
System.assert(pmo.reviewed() == null);
pmo.reject();
}
}
Kindly help me to achive the code coverage, I'm not able to intialize the cunstructor facing error Constructor not defined.
If call method with parameter in constuctor i'm facing error System.ListException: List index out of bounds: 0
Please help me
My Business class
public with sharing class SalesTask {
public PageReference clientApproved() {
//Update the current task to close
pmt.Status__c = 'Completed';
pmt.Type_of_layout__c = 'Support';
pmt.Proposal_Status__c = 'Client Approved';
update pmt;
PageReference cancel= new PageReference(System.currentPageReference().getParameters().get('retURL'));
cancel.setRedirect(true);
return cancel;
}
public SalesTask(){
this.pmt = new PMO_Task__c();
List<PMO_Task__c> pmtList = new List<PMO_Task__c>();
pmtList = [SELECT Subject__c,AssigedDate__c,AssignedBy__c,MyComments__c,Status__c,Opportunity__c,Type_of_layout__c FROM PMO_Task__c WHERE id = :System.currentPageReference().getParameters().get('id') ];
pmt = pmtList.get(0);
}
test class i written
@isTest
public class PMOSalesTaskTest{
private static testmethod void pmoSalesTaskTest() {
PageReference pg = Page.pmotrackertasks;
Test.setCurrentPage(pg);
pg.getParameters().put('Status__c', 'Completed');
pg.getParameters().put('Type_of_layout__c', 'Support');
pg.getParameters().put('Proposal_Status__c', 'Client Approved');
PMOSalesTask pmo = new PMOSalesTask(pg);
System.assert(pmo.reviewed() == null);
pmo.reject();
}
}
Kindly help me to achive the code coverage, I'm not able to intialize the cunstructor facing error Constructor not defined.
If call method with parameter in constuctor i'm facing error System.ListException: List index out of bounds: 0
Please help me
Create a test class with below code..
PMO_Task__c obj = new PMO_Task__c (name='test');
insert obj;
ApexPages.currentPage().getParameters().put('id',obj.Id );
SalesTask objSalesTask = new SalesTask ();
objSalesTask .clientApproved ();
1. First insert the PMO_Task__c record by provide all required fields...
2. then set the page id as PMO id..
3. then create a insetane of your class ..
4. then call the clientApproved method from the instance..
Please check with this and let me know if it solves your issue..
P.S. If my answer helps you to solve your problem please mark it as best answer. It will help other to find best answer.
Thanks,
Sandeep
Salesforce Certified Developer