You need to sign in to do that
Don't have an account?
Staci
Constructor not defined: [ApexPages.StandardController].<Constructor>
Its been a long time since I've had to write a test class and I'm a little rusty. I'm getting this error
Compile Error: Constructor not defined: [ApexPages.StandardController].<Constructor>(List<Subscription_Assets__c>) at line 32 column 37
on this line: ApexPages.StandardController con2 = new ApexPages.StandardController(newasset);
I've also tried changing newasset to newsub and still get the same error.
Any help would be greatly appreciated
Compile Error: Constructor not defined: [ApexPages.StandardController].<Constructor>(List<Subscription_Assets__c>) at line 32 column 37
on this line: ApexPages.StandardController con2 = new ApexPages.StandardController(newasset);
I've also tried changing newasset to newsub and still get the same error.
Any help would be greatly appreciated
@isTest private class MultiAdTest{ static testMethod void MultiAdTest(){ } static testMethod void MultiAdTest_test() { Account testAccount = new Account(Name = 'Test Account'); insert testAccount; Support_Subscription__c sub = new Support_Subscription__c( Dealer_Name__c = testAccount.Id, Subscription_Start_Date__c = Date.today(), of_Months__c = 12, Date_Received__c = Date.today(), Date_Received_Executed__c = Date.today(), Subscription_Status__c = 'Active', Dealer_Sales_Person__c = 'Mike Gray', Software_End_User_Agreement_Version_Date__c = Date.today()); insert sub; //create an asset Record List<Subscription_Assets__c> newasset = new List<Subscription_Assets__c>(); Subscription_Assets__c asset = new Subscription_Assets__c(Support_Subscription__c = sub.Id); insert asset; newasset.add(asset); Test.startTest(); ApexPages.StandardController con2 = new ApexPages.StandardController(newasset); MultiAd controller = new MultiAd(con2); controller.addlic(); PageReference testPage = Page.LicenseSummaryHomePage; Test.setCurrentPage(testPage); Test.stopTest(); } }
/* Class/Method Name: MultiAd Description: Created Subscription Assets related to Support Subscription Author/Date: Staci Gilmore 5/27/2020 */ public with sharing class MultiAd { private final Subscription_Assets__c ln; Public string ss; public List<AccountWrapper> wrappers{get;set;} private Integer nextIdent=0; public MultiAd(ApexPages.StandardController controller) { ss = ApexPages.CurrentPage().getparameters().get('id'); wrappers=new List<AccountWrapper>(); for(Integer idx=0; idx<1; idx++) { wrappers.add(new AccountWrapper(nextIdent++)); } } public List<Subscription_Assets__c> addlic {get; set;} public PageReference Save() { List<Subscription_Assets__c> addlic=new List<Subscription_Assets__c>(); Support_Subscription__c ssid = [select id, Name, RecordTypeID from Support_Subscription__c where id=:ss]; for(AccountWrapper wrap:wrappers) { Subscription_Assets__c lic =wrap.asset; lic.Support_Subscription__c = ssid.id; lic.Support_Subscription_Record_Type__c = ssid.recordTypeID; addlic.add(lic); } insert addlic; PageReference pageRef = new PageReference(ApexPages.currentPage().getUrl()); pageRef.setRedirect(true); return pageRef; } public class AccountWrapper { public Subscription_Assets__c asset{get; private set;} public Integer ident{get; private set;} public AccountWrapper(Integer inIdent) { ident=inIdent; asset=new Subscription_Assets__c(); } } }
Greetings!
Please go through the below document for the sample scenario related to the error that you are getting:
https://salesforce.stackexchange.com/questions/55346/constructor-not-defined-error
Kindly mark it as best answer if it helps so that it can help others in the future.
Warm Regards,
Shirisha Pathuri