You need to sign in to do that
Don't have an account?
Nitesh Trivedi
i am getting this error- Constructor not defined: [QuoteTermEditorController].<Constructor>()
controller
public QuoteTermEditorController(ApexPages.StandardSetController acon) {
this.acon = acon;
recordId = ApexPages.currentPage().getParameters().get('id');
//system.debug(recordId);
revertMap = new Map<Id,Quote_term__c>();
}
public List<Quote_term__c> getRecords(){
if(recordId!=null){
List<Quote_term__c> termExtract = [select id,name,print_order__c,Active__c,type__c,Standard_Term__c,body__c,Quote_del__r.name,(select id,type__c,name,Standard_Term__c,body__c,Locked__c from Quote_Terms1__r where Quote_del__c=:recordId and Active__c=true) from Quote_term__c where (Type__c='Standard' or Type__c='Custom') order by print_order__c asc];
termList = new List<Quote_term__c>();
for(Quote_term__c term:termExtract){
if(term.Quote_terms1__r.size()>0 ){
termList.add(term.Quote_terms1__r);
for(Quote_term__c q:term.Quote_terms1__r){
revertMap.put(q.id,term);
}
}
else if(term.Active__c == true){
termList.add(term);
}
}
}
PrevData = new List<Quote_term__c>(termList);
return termList;
}
public pagereference revert(){
revertid = ApexPages.currentPage().getParameters().get('revertId');
system.debug(revertid);
update new Quote_term__c(id=revertid,Active__c=false);
for(Quote_term__c q:termList){
if(q.id==revertid){
termList[termList.indexOf(q)] = revertMap.get(revertid);
}
}
return null;
}
public pagereference save(){
String standrdId = ApexPages.currentPage().getParameters().get('savedDataId');
String body = ApexPages.currentPage().getParameters().get('changedTerm');
String type = ApexPages.currentPage().getParameters().get('recordType');
update termList;
for(Quote_term__c quoTerm:termList){
// update quoTerm;
system.debug(quoTerm + 'out');
if(!PrevData.contains(quoTerm)){
system.debug(quoTerm);
}
}
if(type=='Custom'){
Quote_term__c Custom = new Quote_term__c(id=standrdId,body__c=body);
update Custom;
//system.debug(termList);
// update termList;
}
system.debug(type);
system.debug(standrdId);
system.debug(body);
return null;
}
public pagereference cancel(){
return null;
}
public List<SelectOption> getTemplateOptions() {
List<SelectOption> countryOptions = new List<SelectOption>();
countryOptions.add(new SelectOption('','-None-'));
for(Quote_Template__c QtTem : [Select id,name from Quote_Template__c]){
countryOptions.add(new SelectOption(QtTem.name,QtTem.name));
}
return countryOptions;
}
}
Test Class
@isTest
public class QuoteTermEditorControllertest {
@isTest
public static void test(){
Account act =new Account();
act.Name = 'test';
act.BillingCity='xyz';
act.BillingCountry = 'xyz';
act.BillingPostalCode = '2346';
act.BillingState = 'xyz';
act.BillingStreet = 'xyz';
act.ShippingCity = 'xyz';
act.ShippingCountry = 'xyz';
act.ShippingPostalCode = '2346';
act.ShippingState = 'xyz';
act.ShippingStreet = 'xyz';
insert act;
Opportunity opp = new opportunity();
opp.Name='test';
opp.CloseDate=date.today().addMonths(2);
opp.StageName='IsWon';
opp.AccountId=act.Id;
insert opp;
Quote q = new Quote();
q.name = 'Quote-' + opp.name;
q.opportunityId = opp.id;
q.Account__c = opp.AccountId;
insert q;
Quote_term__c quoterm = new Quote_term__c();
quoterm.Quote_del__c = q.Id;
quoterm.Name = 'test';
quoterm.Print_Order__c = 23;
insert quoterm;
PageReference pageRef = Page.QuoteTermEditor;
pageRef.getparameters().put('recordId', quoterm.id);
Test.setCurrentPage(pageRef);
Apexpages.StandardController sc = new Apexpages.StandardController(quoterm);
//ApexPages.currentPage().getParameters().put('id', quoterm.id);
QuoteTermEditorController ext = new QuoteTermEditorController();
ext.revert();
ext.cancel();
ext.save();
}
}
public QuoteTermEditorController(ApexPages.StandardSetController acon) {
this.acon = acon;
recordId = ApexPages.currentPage().getParameters().get('id');
//system.debug(recordId);
revertMap = new Map<Id,Quote_term__c>();
}
public List<Quote_term__c> getRecords(){
if(recordId!=null){
List<Quote_term__c> termExtract = [select id,name,print_order__c,Active__c,type__c,Standard_Term__c,body__c,Quote_del__r.name,(select id,type__c,name,Standard_Term__c,body__c,Locked__c from Quote_Terms1__r where Quote_del__c=:recordId and Active__c=true) from Quote_term__c where (Type__c='Standard' or Type__c='Custom') order by print_order__c asc];
termList = new List<Quote_term__c>();
for(Quote_term__c term:termExtract){
if(term.Quote_terms1__r.size()>0 ){
termList.add(term.Quote_terms1__r);
for(Quote_term__c q:term.Quote_terms1__r){
revertMap.put(q.id,term);
}
}
else if(term.Active__c == true){
termList.add(term);
}
}
}
PrevData = new List<Quote_term__c>(termList);
return termList;
}
public pagereference revert(){
revertid = ApexPages.currentPage().getParameters().get('revertId');
system.debug(revertid);
update new Quote_term__c(id=revertid,Active__c=false);
for(Quote_term__c q:termList){
if(q.id==revertid){
termList[termList.indexOf(q)] = revertMap.get(revertid);
}
}
return null;
}
public pagereference save(){
String standrdId = ApexPages.currentPage().getParameters().get('savedDataId');
String body = ApexPages.currentPage().getParameters().get('changedTerm');
String type = ApexPages.currentPage().getParameters().get('recordType');
update termList;
for(Quote_term__c quoTerm:termList){
// update quoTerm;
system.debug(quoTerm + 'out');
if(!PrevData.contains(quoTerm)){
system.debug(quoTerm);
}
}
if(type=='Custom'){
Quote_term__c Custom = new Quote_term__c(id=standrdId,body__c=body);
update Custom;
//system.debug(termList);
// update termList;
}
system.debug(type);
system.debug(standrdId);
system.debug(body);
return null;
}
public pagereference cancel(){
return null;
}
public List<SelectOption> getTemplateOptions() {
List<SelectOption> countryOptions = new List<SelectOption>();
countryOptions.add(new SelectOption('','-None-'));
for(Quote_Template__c QtTem : [Select id,name from Quote_Template__c]){
countryOptions.add(new SelectOption(QtTem.name,QtTem.name));
}
return countryOptions;
}
}
Test Class
@isTest
public class QuoteTermEditorControllertest {
@isTest
public static void test(){
Account act =new Account();
act.Name = 'test';
act.BillingCity='xyz';
act.BillingCountry = 'xyz';
act.BillingPostalCode = '2346';
act.BillingState = 'xyz';
act.BillingStreet = 'xyz';
act.ShippingCity = 'xyz';
act.ShippingCountry = 'xyz';
act.ShippingPostalCode = '2346';
act.ShippingState = 'xyz';
act.ShippingStreet = 'xyz';
insert act;
Opportunity opp = new opportunity();
opp.Name='test';
opp.CloseDate=date.today().addMonths(2);
opp.StageName='IsWon';
opp.AccountId=act.Id;
insert opp;
Quote q = new Quote();
q.name = 'Quote-' + opp.name;
q.opportunityId = opp.id;
q.Account__c = opp.AccountId;
insert q;
Quote_term__c quoterm = new Quote_term__c();
quoterm.Quote_del__c = q.Id;
quoterm.Name = 'test';
quoterm.Print_Order__c = 23;
insert quoterm;
PageReference pageRef = Page.QuoteTermEditor;
pageRef.getparameters().put('recordId', quoterm.id);
Test.setCurrentPage(pageRef);
Apexpages.StandardController sc = new Apexpages.StandardController(quoterm);
//ApexPages.currentPage().getParameters().put('id', quoterm.id);
QuoteTermEditorController ext = new QuoteTermEditorController();
ext.revert();
ext.cancel();
ext.save();
}
}
Greetings!
Can you please try by changing the way of defining the constructor in the test class as mentioned in the below thread:
https://developer.salesforce.com/forums/?id=906F00000008xsOIAQ
Kindly mark it as best answer if it helps so that it can help others in the future.
Warm Regards,
Shirisha Pathuri